| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 from telemetry.internal.results import page_test_results | 5 from telemetry.internal.results import page_test_results |
| 6 from telemetry.page import page as page_module | 6 from telemetry.page import page as page_module |
| 7 from telemetry.testing import options_for_unittests | 7 from telemetry.testing import options_for_unittests |
| 8 from telemetry.testing import page_test_test_case | 8 from telemetry.testing import page_test_test_case |
| 9 from telemetry.util import wpr_modes | 9 from telemetry.util import wpr_modes |
| 10 | 10 |
| 11 from measurements import v8_detached_context_age_in_gc | 11 from measurements import v8_detached_context_age_in_gc |
| 12 | 12 |
| 13 | 13 |
| 14 class FakePage(page_module.Page): | 14 class FakePage(page_module.Page): |
| 15 | 15 |
| 16 def __init__(self, url): | 16 def __init__(self, url): |
| 17 super(FakePage, self).__init__(url=url) | 17 super(FakePage, self).__init__(url=url, name=url) |
| 18 | 18 |
| 19 @property | 19 @property |
| 20 def is_file(self): | 20 def is_file(self): |
| 21 return self._url.startswith('file://') | 21 return self._url.startswith('file://') |
| 22 | 22 |
| 23 | 23 |
| 24 class FakeTab(object): | 24 class FakeTab(object): |
| 25 | 25 |
| 26 def __init__(self, histograms): | 26 def __init__(self, histograms): |
| 27 self.histograms = histograms | 27 self.histograms = histograms |
| (...skipping 23 matching lines...) Expand all Loading... |
| 51 | 51 |
| 52 | 52 |
| 53 def _ActualValues(results): | 53 def _ActualValues(results): |
| 54 return dict((v.name, v) for v in results.all_page_specific_values) | 54 return dict((v.name, v) for v in results.all_page_specific_values) |
| 55 | 55 |
| 56 | 56 |
| 57 class SimplePage(page_module.Page): | 57 class SimplePage(page_module.Page): |
| 58 | 58 |
| 59 def __init__(self, page_set): | 59 def __init__(self, page_set): |
| 60 super(SimplePage, self).__init__( | 60 super(SimplePage, self).__init__( |
| 61 'file://host.html', page_set, page_set.base_dir) | 61 'file://host.html', page_set, page_set.base_dir, name='host.html') |
| 62 | 62 |
| 63 def RunPageInteractions(self, action_runner): | 63 def RunPageInteractions(self, action_runner): |
| 64 # Reload the page to detach the previous context. | 64 # Reload the page to detach the previous context. |
| 65 action_runner.ReloadPage() | 65 action_runner.ReloadPage() |
| 66 | 66 |
| 67 | 67 |
| 68 class V8DetachedContextAgeInGCTests(page_test_test_case.PageTestTestCase): | 68 class V8DetachedContextAgeInGCTests(page_test_test_case.PageTestTestCase): |
| 69 | 69 |
| 70 def setUp(self): | 70 def setUp(self): |
| 71 self._options = options_for_unittests.GetCopy() | 71 self._options = options_for_unittests.GetCopy() |
| (...skipping 24 matching lines...) Expand all Loading... |
| 96 def testWithSimplePage(self): | 96 def testWithSimplePage(self): |
| 97 page_set = self.CreateEmptyPageSet() | 97 page_set = self.CreateEmptyPageSet() |
| 98 page = SimplePage(page_set) | 98 page = SimplePage(page_set) |
| 99 page_set.AddStory(page) | 99 page_set.AddStory(page) |
| 100 metric = v8_detached_context_age_in_gc.V8DetachedContextAgeInGC() | 100 metric = v8_detached_context_age_in_gc.V8DetachedContextAgeInGC() |
| 101 results = self.RunMeasurement(metric, page_set, options=self._options) | 101 results = self.RunMeasurement(metric, page_set, options=self._options) |
| 102 self.assertEquals(0, len(results.failures), msg=str(results.failures)) | 102 self.assertEquals(0, len(results.failures), msg=str(results.failures)) |
| 103 actual = _ActualValues(results)['V8_DetachedContextAgeInGC'] | 103 actual = _ActualValues(results)['V8_DetachedContextAgeInGC'] |
| 104 self.assertLessEqual(0, actual.value) | 104 self.assertLessEqual(0, actual.value) |
| 105 self.assertEqual('garbage_collections', actual.units) | 105 self.assertEqual('garbage_collections', actual.units) |
| OLD | NEW |