Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Unified Diff: systrace/profile_chrome/fake_agent_1.py

Issue 2295913002: Enable some profile_chrome unit tests on Trybots (Closed) Base URL: https://chromium.googlesource.com/external/github.com/catapult-project/catapult.git@master
Patch Set: Add Chris as owner of Systrace bin directory Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « systrace/profile_chrome/ddms_tracing_agent_unittest.py ('k') | systrace/profile_chrome/fake_agent_2.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()
« no previous file with comments | « systrace/profile_chrome/ddms_tracing_agent_unittest.py ('k') | systrace/profile_chrome/fake_agent_2.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698