Home | History | Annotate | Download | only in profile_chrome
      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 json
      6 
      7 from profile_chrome import perf_tracing_agent
      8 from profile_chrome import ui
      9 from systrace import decorators
     10 from systrace.tracing_agents import agents_unittest
     11 
     12 
     13 class PerfProfilerAgentTest(agents_unittest.BaseAgentTest):
     14   @decorators.ClientOnlyTest
     15   def testGetCategories(self):
     16     if not perf_tracing_agent.PerfProfilerAgent.IsSupported():
     17       return
     18     categories = \
     19         perf_tracing_agent.PerfProfilerAgent.GetCategories(self.device)
     20     assert 'cycles' in ' '.join(categories)
     21 
     22   # TODO(washingtonp): Try enabling this test for the SimpleperfProfilerAgent,
     23   # which will be added later.
     24   @decorators.Disabled
     25   def testTracing(self):
     26     if not perf_tracing_agent.PerfProfilerAgent.IsSupported():
     27       return
     28     ui.EnableTestMode()
     29     categories = 'cycles'
     30     agent = perf_tracing_agent.PerfProfilerAgent(self.device)
     31 
     32     try:
     33       agent.StartAgentTracing(perf_tracing_agent.PerfConfig(categories,
     34                                                             self.device))
     35     finally:
     36       agent.StopAgentTracing()
     37 
     38     result = agent.GetResults()
     39     json.loads(result.raw_data)
     40