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

Unified Diff: tools/telemetry/telemetry/block_page_benchmark_results_unittest.py

Issue 11779041: [telemetry] Add support for BenchmarkResults that vary from page to page (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nitfix Created 7 years, 11 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
Index: tools/telemetry/telemetry/block_page_benchmark_results_unittest.py
diff --git a/tools/telemetry/telemetry/block_page_benchmark_results_unittest.py b/tools/telemetry/telemetry/block_page_benchmark_results_unittest.py
new file mode 100644
index 0000000000000000000000000000000000000000..ba4c02e5a8a99392bcfe5ae163db9cc0d680b756
--- /dev/null
+++ b/tools/telemetry/telemetry/block_page_benchmark_results_unittest.py
@@ -0,0 +1,63 @@
+# Copyright (c) 2012 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 StringIO
+import os
+import unittest
+
+from telemetry import block_page_benchmark_results
+from telemetry.page_set import PageSet
+
+BlockPageBenchmarkResults = \
+ block_page_benchmark_results.BlockPageBenchmarkResults
+
+def _MakePageSet():
+ return PageSet.FromDict({
+ "description": "hello",
+ "archive_path": "foo.wpr",
+ "pages": [
+ {"url": "http://www.foo.com/"},
+ {"url": "http://www.bar.com/"}
+ ]
+ }, os.path.dirname(__file__))
+
+class NonPrintingBlockPageBenchmarkResults(BlockPageBenchmarkResults):
+ def __init__(self, *args):
+ super(NonPrintingBlockPageBenchmarkResults, self).__init__(*args)
+
+ def _PrintPerfResult(self, *args):
+ pass
+
+class BlockPageBenchmarkResultsTest(unittest.TestCase):
+ def setUp(self):
+ self._output = StringIO.StringIO()
+ self._page_set = _MakePageSet()
+
+ @property
+ def lines(self):
+ lines = StringIO.StringIO(self._output.getvalue()).readlines()
+ return [line.strip() for line in lines]
+
+ @property
+ def data(self):
+ return [line.split(': ', 1) for line in self.lines]
+
+ def test_with_output_after_every_page(self):
+ results = NonPrintingBlockPageBenchmarkResults(self._output)
+ results.WillMeasurePage(self._page_set[0])
+ results.Add('foo', 'seconds', 3)
+ results.DidMeasurePage()
+
+ results.WillMeasurePage(self._page_set[1])
+ results.Add('bar', 'seconds', 4)
+ results.DidMeasurePage()
+
+ expected = [
+ ['url', 'http://www.foo.com/'],
+ ['foo (seconds)', '3'],
+ [''],
+ ['url', 'http://www.bar.com/'],
+ ['bar (seconds)', '4'],
+ ['']
+ ]
+ self.assertEquals(self.data, expected)
« no previous file with comments | « tools/telemetry/telemetry/block_page_benchmark_results.py ('k') | tools/telemetry/telemetry/csv_page_benchmark_results.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698