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