OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 import os | 4 import os |
5 import StringIO | 5 import StringIO |
6 import unittest | 6 import unittest |
7 | 7 |
8 from telemetry.page import html_page_measurement_results | 8 from telemetry.page import html_page_measurement_results |
9 from telemetry.page import page_set | 9 from telemetry.page import page_set |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 | 32 |
33 # Wrap string IO with a .name property so that it behaves more like a file. | 33 # Wrap string IO with a .name property so that it behaves more like a file. |
34 class StringIOFile(StringIO.StringIO): | 34 class StringIOFile(StringIO.StringIO): |
35 name = 'fake_output_file' | 35 name = 'fake_output_file' |
36 | 36 |
37 | 37 |
38 class HtmlPageMeasurementResultsTest(unittest.TestCase): | 38 class HtmlPageMeasurementResultsTest(unittest.TestCase): |
39 | 39 |
40 # TODO(tonyg): Remove this backfill when we can assume python 2.7 everywhere. | 40 # TODO(tonyg): Remove this backfill when we can assume python 2.7 everywhere. |
41 def assertIn(self, first, second, _=None): | 41 def assertIn(self, first, second, msg=None): |
42 self.assertTrue(first in second, | 42 self.assertTrue(first in second, |
43 msg="'%s' not found in '%s'" % (first, second)) | 43 msg="'%s' not found in '%s'" % (first, second)) |
44 | 44 |
45 def test_basic_summary(self): | 45 def test_basic_summary(self): |
46 test_page_set = _MakePageSet() | 46 test_page_set = _MakePageSet() |
47 output_file = StringIOFile() | 47 output_file = StringIOFile() |
48 | 48 |
49 # Run the first time and verify the results are written to the HTML file. | 49 # Run the first time and verify the results are written to the HTML file. |
50 results = DeterministicHtmlPageMeasurementResults( | 50 results = DeterministicHtmlPageMeasurementResults( |
51 output_file, 'test_name', False, False, 'browser_type') | 51 output_file, 'test_name', False, False, 'browser_type') |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 '"important": false' | 238 '"important": false' |
239 '}' | 239 '}' |
240 '}' | 240 '}' |
241 '}' | 241 '}' |
242 '}, ' | 242 '}, ' |
243 '"revision": "revision"' | 243 '"revision": "revision"' |
244 '}]' | 244 '}]' |
245 '</script>') | 245 '</script>') |
246 self.assertIn(expected, output_file.getvalue()) | 246 self.assertIn(expected, output_file.getvalue()) |
247 self.assertTrue(len(output_file.getvalue()) < last_output_len) | 247 self.assertTrue(len(output_file.getvalue()) < last_output_len) |
OLD | NEW |