| 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 from measurements import smoothness | 4 from measurements import smoothness |
| 5 from telemetry.core import wpr_modes | 5 from telemetry.core import wpr_modes |
| 6 from telemetry.page import page | 6 from telemetry.page import page |
| 7 from telemetry.page import page_measurement_unittest_base | 7 from telemetry.page import page_measurement_unittest_base |
| 8 from telemetry.unittest import options_for_unittests | 8 from telemetry.unittest import options_for_unittests |
| 9 | 9 |
| 10 class FakePlatform(object): | 10 class FakePlatform(object): |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 class SmoothnessUnitTest( | 31 class SmoothnessUnitTest( |
| 32 page_measurement_unittest_base.PageMeasurementUnitTestBase): | 32 page_measurement_unittest_base.PageMeasurementUnitTestBase): |
| 33 """Smoke test for smoothness measurement | 33 """Smoke test for smoothness measurement |
| 34 | 34 |
| 35 Runs smoothness measurement on a simple page and verifies | 35 Runs smoothness measurement on a simple page and verifies |
| 36 that all metrics were added to the results. The test is purely functional, | 36 that all metrics were added to the results. The test is purely functional, |
| 37 i.e. it only checks if the metrics are present and non-zero. | 37 i.e. it only checks if the metrics are present and non-zero. |
| 38 """ | 38 """ |
| 39 def testSyntheticDelayConfiguration(self): | 39 def testSyntheticDelayConfiguration(self): |
| 40 attributes = { | 40 test_page = page.Page('http://dummy', None) |
| 41 'synthetic_delays': { | 41 test_page.synthetic_delays = { |
| 42 'cc.BeginMainFrame': { 'target_duration': 0.012 }, | 42 'cc.BeginMainFrame': { 'target_duration': 0.012 }, |
| 43 'cc.DrawAndSwap': { 'target_duration': 0.012, 'mode': 'alternating' }, | 43 'cc.DrawAndSwap': { 'target_duration': 0.012, 'mode': 'alternating' }, |
| 44 'gpu.SwapBuffers': { 'target_duration': 0.012 } | 44 'gpu.SwapBuffers': { 'target_duration': 0.012 } |
| 45 } | |
| 46 } | 45 } |
| 47 test_page = page.Page('http://dummy', None, attributes=attributes) | |
| 48 | 46 |
| 49 tab = FakeTab() | 47 tab = FakeTab() |
| 50 measurement = smoothness.Smoothness() | 48 measurement = smoothness.Smoothness() |
| 51 measurement.WillRunActions(test_page, tab) | 49 measurement.WillRunActions(test_page, tab) |
| 52 | 50 |
| 53 expected_category_filter = [ | 51 expected_category_filter = [ |
| 54 'DELAY(cc.BeginMainFrame;0.012000;static)', | 52 'DELAY(cc.BeginMainFrame;0.012000;static)', |
| 55 'DELAY(cc.DrawAndSwap;0.012000;alternating)', | 53 'DELAY(cc.DrawAndSwap;0.012000;alternating)', |
| 56 'DELAY(gpu.SwapBuffers;0.012000;static)', | 54 'DELAY(gpu.SwapBuffers;0.012000;static)', |
| 57 'benchmark', | 55 'benchmark', |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 self.assertEquals(len(mean_mouse_wheel_latency), 1) | 90 self.assertEquals(len(mean_mouse_wheel_latency), 1) |
| 93 self.assertGreater( | 91 self.assertGreater( |
| 94 mean_mouse_wheel_latency[0].GetRepresentativeNumber(), 0) | 92 mean_mouse_wheel_latency[0].GetRepresentativeNumber(), 0) |
| 95 | 93 |
| 96 mean_touch_scroll_latency = results.FindAllPageSpecificValuesNamed( | 94 mean_touch_scroll_latency = results.FindAllPageSpecificValuesNamed( |
| 97 'mean_touch_scroll_latency') | 95 'mean_touch_scroll_latency') |
| 98 if mean_touch_scroll_latency: | 96 if mean_touch_scroll_latency: |
| 99 self.assertEquals(len(mean_touch_scroll_latency), 1) | 97 self.assertEquals(len(mean_touch_scroll_latency), 1) |
| 100 self.assertGreater( | 98 self.assertGreater( |
| 101 mean_touch_scroll_latency[0].GetRepresentativeNumber(), 0) | 99 mean_touch_scroll_latency[0].GetRepresentativeNumber(), 0) |
| OLD | NEW |