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

Unified Diff: tracing/tracing/value/add_shared_diagnostics_unittest.py

Issue 3000643002: [Tracing] Add add_shared_diagnostics.AddValueDiagnostics (Closed)
Patch Set: fix test 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tracing/tracing/value/add_shared_diagnostics.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tracing/tracing/value/add_shared_diagnostics_unittest.py
diff --git a/tracing/tracing/value/add_shared_diagnostics_unittest.py b/tracing/tracing/value/add_shared_diagnostics_unittest.py
new file mode 100644
index 0000000000000000000000000000000000000000..7f7f7b83f38f22f42458ee30ad161d884c6b7a25
--- /dev/null
+++ b/tracing/tracing/value/add_shared_diagnostics_unittest.py
@@ -0,0 +1,57 @@
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import json
+import tempfile
+import unittest
+
+from tracing.value import add_shared_diagnostics
+from tracing.value import histogram
+from tracing.value import histogram_set
+
+
+class AddSharedDiagnosticTest(unittest.TestCase):
+ def testAddSharedDiagnostics(self):
+ hf = tempfile.NamedTemporaryFile(delete=False)
+ h = histogram.Histogram('foo', 'count')
+ hs = histogram_set.HistogramSet([h])
+ json.dump(hs.AsDicts(), hf)
+ hf.close()
+
+ df = tempfile.NamedTemporaryFile(delete=False)
+ d = histogram.GenericSet(['bar'])
+ json.dump(d.AsDict(), df)
+ df.close()
+
+ df2 = tempfile.NamedTemporaryFile(delete=False)
+ d2 = histogram.GenericSet(['baz'])
+ json.dump(d2.AsDict(), df2)
+ df2.close()
+
+ new_hs_data = add_shared_diagnostics.AddSharedDiagnostics(
+ hf.name, {'foo': df.name, 'qux': df2.name})
+ new_hs = histogram_set.HistogramSet()
+ new_hs.ImportDicts(json.loads(new_hs_data))
+ new_hs.ResolveRelatedHistograms()
+ new_h = new_hs.GetFirstHistogram()
+
+ self.assertEqual(new_h.diagnostics['foo'], d)
+ self.assertEqual(new_h.diagnostics['qux'], d2)
+
+ def testAddValueDiagnostics(self):
+ hf = tempfile.NamedTemporaryFile(delete=False)
+ h = histogram.Histogram('foo', 'count')
+ hs = histogram_set.HistogramSet([h])
+ json.dump(hs.AsDicts(), hf)
+ hf.close()
+
+ new_hs_data = add_shared_diagnostics.AddValueDiagnostic(
+ hf.name, {'foo': 'bar', 'baz': 'qux'})
+ new_hs = histogram_set.HistogramSet()
+ new_hs.ImportDicts(json.loads(new_hs_data))
+ new_hs.ResolveRelatedHistograms()
+ new_h = new_hs.GetFirstHistogram()
+
+ self.assertEqual(new_h.diagnostics['foo'], histogram.GenericSet(['bar']))
+ self.assertEqual(new_h.diagnostics['baz'], histogram.GenericSet(['qux']))
« no previous file with comments | « tracing/tracing/value/add_shared_diagnostics.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698