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 sys | 4 import sys |
5 | 5 |
6 from measurements import smoothness | 6 from measurements import smoothness |
7 from metrics import power | 7 from metrics import power |
8 from telemetry.core import exceptions | 8 from telemetry.core import exceptions |
9 from telemetry.core import wpr_modes | 9 from telemetry.core import wpr_modes |
10 from telemetry.page import page | 10 from telemetry.page import page |
11 from telemetry.page import page_measurement_unittest_base | |
12 from telemetry.page import page_test | 11 from telemetry.page import page_test |
| 12 from telemetry.testing import page_test_test_case |
13 from telemetry.unittest import options_for_unittests | 13 from telemetry.unittest import options_for_unittests |
14 | 14 |
15 class FakePlatform(object): | 15 class FakePlatform(object): |
16 def IsRawDisplayFrameRateSupported(self): | 16 def IsRawDisplayFrameRateSupported(self): |
17 return False | 17 return False |
18 def CanMonitorPower(self): | 18 def CanMonitorPower(self): |
19 return False | 19 return False |
20 | 20 |
21 | 21 |
22 class FakeBrowser(object): | 22 class FakeBrowser(object): |
(...skipping 15 matching lines...) Expand all Loading... |
38 action_runner.Wait(1) | 38 action_runner.Wait(1) |
39 | 39 |
40 | 40 |
41 class FakeTab(object): | 41 class FakeTab(object): |
42 def __init__(self): | 42 def __init__(self): |
43 self.browser = FakeBrowser() | 43 self.browser = FakeBrowser() |
44 | 44 |
45 def ExecuteJavaScript(self, js): | 45 def ExecuteJavaScript(self, js): |
46 pass | 46 pass |
47 | 47 |
48 class SmoothnessUnitTest( | 48 class SmoothnessUnitTest(page_test_test_case.PageTestTestCase): |
49 page_measurement_unittest_base.PageMeasurementUnitTestBase): | |
50 """Smoke test for smoothness measurement | 49 """Smoke test for smoothness measurement |
51 | 50 |
52 Runs smoothness measurement on a simple page and verifies | 51 Runs smoothness measurement on a simple page and verifies |
53 that all metrics were added to the results. The test is purely functional, | 52 that all metrics were added to the results. The test is purely functional, |
54 i.e. it only checks if the metrics are present and non-zero. | 53 i.e. it only checks if the metrics are present and non-zero. |
55 """ | 54 """ |
56 def testSyntheticDelayConfiguration(self): | 55 def testSyntheticDelayConfiguration(self): |
57 test_page = page.Page('http://dummy', None) | 56 test_page = page.Page('http://dummy', None) |
58 test_page.synthetic_delays = { | 57 test_page.synthetic_delays = { |
59 'cc.BeginMainFrame': { 'target_duration': 0.012 }, | 58 'cc.BeginMainFrame': { 'target_duration': 0.012 }, |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 self.fake_power = self._power_metric = FakePowerMetric(browser) | 162 self.fake_power = self._power_metric = FakePowerMetric(browser) |
164 | 163 |
165 measurement = BuggyMeasurement() | 164 measurement = BuggyMeasurement() |
166 try: | 165 try: |
167 self.RunMeasurement(measurement, ps) | 166 self.RunMeasurement(measurement, ps) |
168 except page_test.TestNotSupportedOnPlatformFailure: | 167 except page_test.TestNotSupportedOnPlatformFailure: |
169 pass | 168 pass |
170 | 169 |
171 self.assertTrue(measurement.fake_power.start_called) | 170 self.assertTrue(measurement.fake_power.start_called) |
172 self.assertTrue(measurement.fake_power.stop_called) | 171 self.assertTrue(measurement.fake_power.stop_called) |
OLD | NEW |