| Index: systrace/profile_chrome/fake_agent_1.py
|
| diff --git a/systrace/profile_chrome/profiler_unittest.py b/systrace/profile_chrome/fake_agent_1.py
|
| similarity index 51%
|
| copy from systrace/profile_chrome/profiler_unittest.py
|
| copy to systrace/profile_chrome/fake_agent_1.py
|
| index 9528db67ca10c273cbae48f752c80351f9ea1ba3..62889f4526fe83b9c6679df12fc74885d0e323c3 100644
|
| --- a/systrace/profile_chrome/profiler_unittest.py
|
| +++ b/systrace/profile_chrome/fake_agent_1.py
|
| @@ -1,15 +1,12 @@
|
| -# Copyright 2014 The Chromium Authors. All rights reserved.
|
| +# 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.
|
|
|
| -import os
|
| +import optparse
|
| import tempfile
|
| -import unittest
|
| -import zipfile
|
|
|
| -from profile_chrome import profiler
|
| -from profile_chrome import ui
|
| from systrace import trace_result
|
| +from systrace import tracing_agents
|
|
|
|
|
| class FakeAgent(object):
|
| @@ -54,41 +51,19 @@ class FakeAgent(object):
|
| return 'faketrace'
|
|
|
|
|
| -class ProfilerTest(unittest.TestCase):
|
| - def setUp(self):
|
| - ui.EnableTestMode()
|
| -
|
| - def testCaptureBasicProfile(self):
|
| - agent = FakeAgent()
|
| - result = profiler.CaptureProfile(None, [agent], 1)
|
| -
|
| - try:
|
| - self.assertTrue(agent.stopped)
|
| - self.assertTrue(os.path.exists(result))
|
| - self.assertTrue(result.endswith('.html'))
|
| - finally:
|
| - if os.path.exists(result):
|
| - os.remove(result)
|
| -
|
| - def testCaptureJsonProfile(self):
|
| - agent = FakeAgent()
|
| - result = profiler.CaptureProfile(None, [agent], 1, write_json=True)
|
| -
|
| - try:
|
| - self.assertFalse(result.endswith('.html'))
|
| - with open(result) as f:
|
| - self.assertEquals(f.read(), agent.contents)
|
| - finally:
|
| - if os.path.exists(result):
|
| - os.remove(result)
|
| -
|
| - def testCaptureMultipleProfiles(self):
|
| - agents = [FakeAgent('c1'), FakeAgent('c2')]
|
| - result = profiler.CaptureProfile(None, agents, 1, write_json=True)
|
| -
|
| - try:
|
| - self.assertTrue(result.endswith('.zip'))
|
| - self.assertTrue(zipfile.is_zipfile(result))
|
| - finally:
|
| - if os.path.exists(result):
|
| - os.remove(result)
|
| +class FakeConfig(tracing_agents.TracingConfig):
|
| + def __init__(self):
|
| + tracing_agents.TracingConfig.__init__(self)
|
| +
|
| +
|
| +# pylint: disable=unused-argument
|
| +def try_create_agent(config):
|
| + return FakeAgent()
|
| +
|
| +def add_options(parser):
|
| + options = optparse.OptionGroup(parser, 'Fake options.')
|
| + return options
|
| +
|
| +# pylint: disable=unused-argument
|
| +def get_config(options):
|
| + return FakeConfig()
|
|
|