| # Copyright 2016 The Chromium Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| from telemetry import benchmark |
| from telemetry.testing import tab_test_case |
| from telemetry.timeline import tracing_config |
| from tracing.trace_data import trace_data |
| |
| |
| def GetSyncEvents(trace_part): |
| return [x for x in trace_part if x['ph'] == 'c'] |
| |
| class ClockDomainTest(tab_test_case.TabTestCase): |
| |
| # Don't run this test on Android; it's not supposed to work on Android |
| # (since when doing Android tracing there are two different devices, |
| # so the clock domains will be different) |
| @benchmark.Disabled('android') |
| def testTelemetryUsesChromeClockDomain(self): |
| |
| tracing_controller = self._browser.platform.tracing_controller |
| options = tracing_config.TracingConfig() |
| options.enable_chrome_trace = True |
| tracing_controller.StartTracing(options) |
| |
| full_trace = tracing_controller.StopTracing() |
| chrome_sync = GetSyncEvents( |
| full_trace.GetTraceFor(trace_data.CHROME_TRACE_PART)['traceEvents']) |
| telemetry_sync = GetSyncEvents( |
| full_trace.GetTraceFor(trace_data.TELEMETRY_PART)['traceEvents']) |
| |
| assert len(chrome_sync) == 1 |
| assert len(telemetry_sync) == 1 |
| |
| # If Telemetry and Chrome are in the same clock domain, the Chrome sync |
| # timestamp should be between Telemetry's sync start and end timestamps. |
| ts_telemetry_start = telemetry_sync[0]['args']['issue_ts'] |
| ts_chrome = chrome_sync[0]['ts'] |
| ts_telemetry_end = telemetry_sync[0]['ts'] |
| assert ts_chrome > ts_telemetry_start |
| assert ts_telemetry_end > ts_chrome |