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

Unified Diff: systrace/profile_chrome/fake_agent_2.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/fake_agent_1.py ('k') | systrace/profile_chrome/perf_tracing_agent_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: systrace/profile_chrome/fake_agent_2.py
diff --git a/systrace/profile_chrome/fake_agent_2.py b/systrace/profile_chrome/fake_agent_2.py
new file mode 100644
index 0000000000000000000000000000000000000000..477b6c750910601a4c7c756a562ec5c2c6f259a0
--- /dev/null
+++ b/systrace/profile_chrome/fake_agent_2.py
@@ -0,0 +1,68 @@
+# 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 optparse
+import tempfile
+
+from systrace import trace_result
+from systrace import tracing_agents
+
+
+class FakeAgent2(object):
+ def __init__(self, contents='fake-contents'):
+ self.contents = contents
+ self.stopped = False
+ self.config = None
+ self.filename = None
+
+ # pylint: disable=unused-argument
+ def StartAgentTracing(self, config, timeout=None):
+ self.config = config
+ return True
+
+ # pylint: disable=unused-argument
+ def StopAgentTracing(self, timeout=None):
+ self.stopped = True
+ return True
+
+ # pylint: disable=unused-argument
+ def GetResults(self, timeout=None):
+ trace_data = open(self._PullTrace()).read()
+ return trace_result.TraceResult('fakeDataTwo', trace_data)
+
+ def _PullTrace(self):
+ with tempfile.NamedTemporaryFile(delete=False) as f:
+ self.filename = f.name
+ f.write(self.contents)
+ return f.name
+
+ # pylint: disable=no-self-use
+ def SupportsExplicitClockSync(self):
+ return False
+
+ # pylint: disable=unused-argument, no-self-use
+ def RecordClockSyncMarker(self, sync_id, did_record_sync_marker_callback):
+ print ('Clock sync marker cannot be recorded since explicit clock sync '
+ 'is not supported.')
+
+ def __repr__(self):
+ return 'faketracetwo'
+
+
+class FakeConfig(tracing_agents.TracingConfig):
+ def __init__(self):
+ tracing_agents.TracingConfig.__init__(self)
+
+
+# pylint: disable=unused-argument
+def try_create_agent(config):
+ return FakeAgent2()
+
+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/fake_agent_1.py ('k') | systrace/profile_chrome/perf_tracing_agent_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698