| 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 sys | 5 import sys |
| 6 import unittest | 6 import unittest |
| 7 | 7 |
| 8 from telemetry.page import page_test_results | 8 from telemetry.page import page_test_results |
| 9 from telemetry.page import page_set | 9 from telemetry.page import page_set |
| 10 | 10 |
| 11 class NonPrintingPageTestResults( | 11 class NonPrintingPageTestResults( |
| 12 page_test_results.PageTestResults): | 12 page_test_results.PageTestResults): |
| 13 def __init__(self): | 13 def __init__(self): |
| 14 super(NonPrintingPageTestResults, self).__init__() | 14 super(NonPrintingPageTestResults, self).__init__() |
| 15 | 15 |
| 16 def _PrintPerfResult(self, *args): | 16 def _PrintPerfResult(self, *args): |
| 17 pass | 17 pass |
| 18 | 18 |
| 19 class PageTestResultsTest(unittest.TestCase): | 19 class PageTestResultsTest(unittest.TestCase): |
| 20 def setUp(self): | 20 def setUp(self): |
| 21 self.page_set = page_set.PageSet.FromDict({ | 21 self.page_set = page_set.PageSet(file_path=os.path.dirname(__file__)) |
| 22 "description": "hello", | 22 self.page_set.AddPageWithDefaultRunNavigate("http://www.bar.com/") |
| 23 "archive_path": "foo.wpr", | 23 self.page_set.AddPageWithDefaultRunNavigate("http://www.baz.com/") |
| 24 "pages": [ | 24 self.page_set.AddPageWithDefaultRunNavigate("http://www.foo.com/") |
| 25 {"url": "http://www.bar.com/"}, | |
| 26 {"url": "http://www.baz.com/"}, | |
| 27 {"url": "http://www.foo.com/"} | |
| 28 ] | |
| 29 }, os.path.dirname(__file__)) | |
| 30 | 25 |
| 31 @property | 26 @property |
| 32 def pages(self): | 27 def pages(self): |
| 33 return self.page_set.pages | 28 return self.page_set.pages |
| 34 | 29 |
| 35 def CreateException(self): | 30 def CreateException(self): |
| 36 try: | 31 try: |
| 37 raise Exception('Intentional exception') | 32 raise Exception('Intentional exception') |
| 38 except Exception: | 33 except Exception: |
| 39 return sys.exc_info() | 34 return sys.exc_info() |
| (...skipping 18 matching lines...) Expand all Loading... |
| 58 | 53 |
| 59 def test_errors_and_failures(self): | 54 def test_errors_and_failures(self): |
| 60 results = NonPrintingPageTestResults() | 55 results = NonPrintingPageTestResults() |
| 61 results.AddError(self.pages[0], self.CreateException()) | 56 results.AddError(self.pages[0], self.CreateException()) |
| 62 results.AddError(self.pages[1], self.CreateException()) | 57 results.AddError(self.pages[1], self.CreateException()) |
| 63 results.AddSuccess(self.pages[2]) | 58 results.AddSuccess(self.pages[2]) |
| 64 self.assertEquals(results.pages_that_had_errors_or_failures, | 59 self.assertEquals(results.pages_that_had_errors_or_failures, |
| 65 set([self.pages[0], self.pages[1]])) | 60 set([self.pages[0], self.pages[1]])) |
| 66 self.assertEquals(results.successes, | 61 self.assertEquals(results.successes, |
| 67 [self.pages[2].display_name]) | 62 [self.pages[2].display_name]) |
| OLD | NEW |