OLD | NEW |
| (Empty) |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 | |
5 import unittest | |
6 | |
7 from metrics import smoothness | |
8 | |
9 from telemetry.page import page | |
10 | |
11 | |
12 class FakePlatform(object): | |
13 def IsRawDisplayFrameRateSupported(self): | |
14 return False | |
15 | |
16 | |
17 class FakeBrowser(object): | |
18 def __init__(self): | |
19 self.platform = FakePlatform() | |
20 self.category_filter = None | |
21 | |
22 def StartTracing(self, category_filter, _): | |
23 self.category_filter = category_filter | |
24 | |
25 | |
26 class FakeTab(object): | |
27 def __init__(self): | |
28 self.browser = FakeBrowser() | |
29 | |
30 def ExecuteJavaScript(self, js): | |
31 pass | |
32 | |
33 | |
34 class SmoothnessMetricUnitTest(unittest.TestCase): | |
35 def testSyntheticDelayConfiguration(self): | |
36 attributes = { | |
37 'synthetic_delays': { | |
38 'cc.BeginMainFrame': { 'target_duration': 0.012 }, | |
39 'cc.DrawAndSwap': { 'target_duration': 0.012, 'mode': 'alternating' }, | |
40 'gpu.SwapBuffers': { 'target_duration': 0.012 } | |
41 } | |
42 } | |
43 test_page = page.Page('http://dummy', None, attributes=attributes) | |
44 | |
45 tab = FakeTab() | |
46 smoothness_metric = smoothness.SmoothnessMetric() | |
47 smoothness_metric.Start(test_page, tab) | |
48 | |
49 expected_category_filter = [ | |
50 'DELAY(cc.BeginMainFrame;0.012000;static)', | |
51 'DELAY(cc.DrawAndSwap;0.012000;alternating)', | |
52 'DELAY(gpu.SwapBuffers;0.012000;static)', | |
53 'benchmark', | |
54 'webkit.console' | |
55 ] | |
56 self.assertEquals(expected_category_filter, | |
57 sorted(tab.browser.category_filter.split(','))) | |
OLD | NEW |