Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: tracing/tracing/value/histogram_unittest.py

Issue 2982283002: Delete TelemetryInfo, MergedTelemetryInfo diagnostics. (Closed)
Patch Set: rebase Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2017 The Chromium Authors. All rights reserved. 1 # Copyright 2017 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import json 5 import json
6 import math 6 import math
7 import time 7 import time
8 import unittest 8 import unittest
9 9
10 from tracing.value import histogram 10 from tracing.value import histogram
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 clone.tags_to_story_names.get('press'), 628 clone.tags_to_story_names.get('press'),
629 set(['story0', 'story1', 'story3', 'story4'])) 629 set(['story0', 'story1', 'story3', 'story4']))
630 self.assertSetEqual( 630 self.assertSetEqual(
631 clone.tags_to_story_names.get('desktop'), 631 clone.tags_to_story_names.get('desktop'),
632 set(['story0', 'story1', 'story2'])) 632 set(['story0', 'story1', 'story2']))
633 self.assertSetEqual( 633 self.assertSetEqual(
634 clone.tags_to_story_names.get('android'), 634 clone.tags_to_story_names.get('android'),
635 set(['story3', 'story4', 'story5'])) 635 set(['story3', 'story4', 'story5']))
636 636
637 637
638 class TelemetryInfoUnittest(unittest.TestCase):
639 def testRoundtrip(self):
640 info = histogram.TelemetryInfo()
641 info.AddInfo({
642 'benchmarkName': 'foo',
643 'benchmarkStartMs': 42,
644 'label': 'lbl',
645 'storyDisplayName': 'story',
646 'storyGroupingKeys': {'a': 'b'},
647 'storysetRepeatCounter': 1,
648 'legacyTIRLabel': 'tir',
649 })
650 d = info.AsDict()
651 clone = diagnostic.Diagnostic.FromDict(d)
652 self.assertEqual(ToJSON(d), ToJSON(clone.AsDict()))
653 self.assertEqual(clone.benchmark_name, 'foo')
654 self.assertEqual(clone.benchmark_start, 42)
655 self.assertEqual(clone.label, 'lbl')
656 self.assertEqual(clone.story_display_name, 'story')
657 self.assertEqual(clone.story_grouping_keys['a'], 'b')
658 self.assertEqual(clone.storyset_repeat_counter, 1)
659 self.assertEqual(clone.legacy_tir_label, 'tir')
660
661 def testEquality(self):
662 info0 = histogram.TelemetryInfo()
663 info0.AddInfo({
664 'benchmarkName': 'foo',
665 'benchmarkStartMs': 42,
666 'label': 'lbl',
667 'storyDisplayName': 'story',
668 'storyGroupingKeys': {'a': 'b'},
669 'storysetRepeatCounter': 1,
670 'legacyTIRLabel': 'tir',
671 })
672 info0.guid = 'abc'
673 info1 = histogram.TelemetryInfo()
674 info1.AddInfo({
675 'benchmarkName': 'foo',
676 'benchmarkStartMs': 42,
677 'label': 'lbl',
678 'storyDisplayName': 'story',
679 'storyGroupingKeys': {'a': 'b'},
680 'storysetRepeatCounter': 1,
681 'legacyTIRLabel': 'tir',
682 })
683 info1.guid = 'def'
684 self.assertEqual(info0, info1)
685
686 def testInequality(self):
687 info0 = histogram.TelemetryInfo()
688 info0.AddInfo({
689 'benchmarkName': 'foo',
690 'benchmarkStartMs': 42,
691 'label': 'lbl',
692 'storyDisplayName': 'story',
693 'storyGroupingKeys': {'a': 'b'},
694 'storysetRepeatCounter': 1,
695 'legacyTIRLabel': 'tir',
696 })
697 info0.guid = 'abc'
698 info1 = histogram.TelemetryInfo()
699 info1.AddInfo({
700 'benchmarkName': 'baz',
701 'benchmarkStartMs': 42,
702 'label': 'lbl',
703 'storyDisplayName': 'story',
704 'storyGroupingKeys': {'a': 'b'},
705 'storysetRepeatCounter': 1,
706 'legacyTIRLabel': 'tir',
707 })
708 info1.guid = 'def'
709 self.assertNotEqual(info0, info1)
710
711
712 class RelatedEventSetUnittest(unittest.TestCase): 638 class RelatedEventSetUnittest(unittest.TestCase):
713 def testRoundtrip(self): 639 def testRoundtrip(self):
714 events = histogram.RelatedEventSet() 640 events = histogram.RelatedEventSet()
715 events.Add({ 641 events.Add({
716 'stableId': '0.0', 642 'stableId': '0.0',
717 'title': 'foo', 643 'title': 'foo',
718 'start': 0, 644 'start': 0,
719 'duration': 1, 645 'duration': 1,
720 }) 646 })
721 d = events.AsDict() 647 d = events.AsDict()
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 hist5.diagnostics['a'] = histogram.UnmergeableDiagnosticSet( 852 hist5.diagnostics['a'] = histogram.UnmergeableDiagnosticSet(
927 [events, generic2]) 853 [events, generic2])
928 hist.diagnostics.Merge(hist5.diagnostics, hist, hist5) 854 hist.diagnostics.Merge(hist5.diagnostics, hist, hist5)
929 self.assertIsInstance( 855 self.assertIsInstance(
930 hist.diagnostics['a'], histogram.UnmergeableDiagnosticSet) 856 hist.diagnostics['a'], histogram.UnmergeableDiagnosticSet)
931 diagnostics = list(hist.diagnostics['a']) 857 diagnostics = list(hist.diagnostics['a'])
932 self.assertIs(generic, diagnostics[0]) 858 self.assertIs(generic, diagnostics[0])
933 self.assertIs(related_map, diagnostics[1]) 859 self.assertIs(related_map, diagnostics[1])
934 self.assertIs(events, diagnostics[2]) 860 self.assertIs(events, diagnostics[2])
935 self.assertIs(generic2, diagnostics[3]) 861 self.assertIs(generic2, diagnostics[3])
OLDNEW
« no previous file with comments | « tracing/tracing/value/histogram_set_unittest.py ('k') | tracing/tracing/value/ui/collected_related_event_set_span_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698