OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 import benchmark | 5 from telemetry import benchmark |
6 from telemetry.testing import tab_test_case | 6 from telemetry.testing import tab_test_case |
7 from telemetry.timeline import trace_data | 7 from telemetry.timeline import trace_data |
8 from telemetry.timeline import tracing_config | 8 from telemetry.timeline import tracing_config |
9 | 9 |
10 def GetSyncEvents(trace_part): | 10 def GetSyncEvents(trace_part): |
11 return [x for x in trace_part if x['ph'] == 'c'] | 11 return [x for x in trace_part if x['ph'] == 'c'] |
12 | 12 |
13 class ClockDomainTest(tab_test_case.TabTestCase): | 13 class ClockDomainTest(tab_test_case.TabTestCase): |
14 | 14 |
15 # Don't run this test on Android; it's not supposed to work on Android | 15 # Don't run this test on Android; it's not supposed to work on Android |
16 # (since when doing Android tracing there are two different devices, | 16 # (since when doing Android tracing there are two different devices, |
17 # so the clock domains will be different) | 17 # so the clock domains will be different) |
18 @benchmark.Disabled('android') | 18 # TODO(rnephew): Revert change from android to all once |
| 19 # https://codereview.chromium.org/2741533003/ lands. |
| 20 @benchmark.Disabled('all') |
19 def testTelemetryUsesChromeClockDomain(self): | 21 def testTelemetryUsesChromeClockDomain(self): |
20 | 22 |
21 tracing_controller = self._browser.platform.tracing_controller | 23 tracing_controller = self._browser.platform.tracing_controller |
22 options = tracing_config.TracingConfig() | 24 options = tracing_config.TracingConfig() |
23 options.enable_chrome_trace = True | 25 options.enable_chrome_trace = True |
24 tracing_controller.StartTracing(options) | 26 tracing_controller.StartTracing(options) |
25 | 27 |
26 full_trace = tracing_controller.StopTracing() | 28 full_trace = tracing_controller.StopTracing() |
27 chrome_sync = GetSyncEvents( | 29 chrome_sync = GetSyncEvents( |
28 full_trace.GetTraceFor(trace_data.CHROME_TRACE_PART)['traceEvents']) | 30 full_trace.GetTraceFor(trace_data.CHROME_TRACE_PART)['traceEvents']) |
29 telemetry_sync = GetSyncEvents( | 31 telemetry_sync = GetSyncEvents( |
30 full_trace.GetTraceFor(trace_data.TELEMETRY_PART)['traceEvents']) | 32 full_trace.GetTraceFor(trace_data.TELEMETRY_PART)['traceEvents']) |
31 | 33 |
32 assert len(chrome_sync) == 1 | 34 assert len(chrome_sync) == 1 |
33 assert len(telemetry_sync) == 1 | 35 assert len(telemetry_sync) == 1 |
34 | 36 |
35 # If Telemetry and Chrome are in the same clock domain, the Chrome sync | 37 # If Telemetry and Chrome are in the same clock domain, the Chrome sync |
36 # timestamp should be between Telemetry's sync start and end timestamps. | 38 # timestamp should be between Telemetry's sync start and end timestamps. |
37 ts_telemetry_start = telemetry_sync[0]['args']['issue_ts'] | 39 ts_telemetry_start = telemetry_sync[0]['args']['issue_ts'] |
38 ts_chrome = chrome_sync[0]['ts'] | 40 ts_chrome = chrome_sync[0]['ts'] |
39 ts_telemetry_end = telemetry_sync[0]['ts'] | 41 ts_telemetry_end = telemetry_sync[0]['ts'] |
40 assert ts_chrome > ts_telemetry_start | 42 assert ts_chrome > ts_telemetry_start |
41 assert ts_telemetry_end > ts_chrome | 43 assert ts_telemetry_end > ts_chrome |
OLD | NEW |