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

Unified Diff: systrace/profile_chrome/profiler_unittest.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/perf_tracing_agent_unittest.py ('k') | systrace/systrace/decorators.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: systrace/profile_chrome/profiler_unittest.py
diff --git a/systrace/profile_chrome/profiler_unittest.py b/systrace/profile_chrome/profiler_unittest.py
index 9528db67ca10c273cbae48f752c80351f9ea1ba3..cd7af956e93ff238c8d1d036cddf8bd41d008128 100644
--- a/systrace/profile_chrome/profiler_unittest.py
+++ b/systrace/profile_chrome/profiler_unittest.py
@@ -3,88 +3,52 @@
# found in the LICENSE file.
import os
-import tempfile
import unittest
import zipfile
from profile_chrome import profiler
from profile_chrome import ui
-from systrace import trace_result
-
-
-class FakeAgent(object):
- def __init__(self, contents='fake-contents'):
- self.contents = contents
- self.stopped = False
- self.filename = None
- self.config = None
- self.timeout = None
-
- def StartAgentTracing(self, config, timeout=None):
- self.config = config
- self.timeout = timeout
- 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('fakeData', 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 'faketrace'
+from profile_chrome import fake_agent_1
+from profile_chrome import fake_agent_2
+from systrace import decorators
+from systrace import tracing_controller
class ProfilerTest(unittest.TestCase):
def setUp(self):
ui.EnableTestMode()
+ self._tracing_options = tracing_controller.TracingControllerConfig(None,
+ None, None, None, None, None, None, None, None, None)
+ @decorators.ClientOnlyTest
def testCaptureBasicProfile(self):
- agent = FakeAgent()
- result = profiler.CaptureProfile(None, [agent], 1)
+ result = profiler.CaptureProfile(self._tracing_options, 1, [fake_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)
+ @decorators.ClientOnlyTest
def testCaptureJsonProfile(self):
- agent = FakeAgent()
- result = profiler.CaptureProfile(None, [agent], 1, write_json=True)
+ result = profiler.CaptureProfile(self._tracing_options, 1,
+ [fake_agent_2], write_json=True)
try:
self.assertFalse(result.endswith('.html'))
with open(result) as f:
- self.assertEquals(f.read(), agent.contents)
+ self.assertEquals(f.read(), 'fake-contents')
finally:
if os.path.exists(result):
os.remove(result)
+ @decorators.ClientOnlyTest
def testCaptureMultipleProfiles(self):
- agents = [FakeAgent('c1'), FakeAgent('c2')]
- result = profiler.CaptureProfile(None, agents, 1, write_json=True)
+ result = profiler.CaptureProfile(self._tracing_options, 1,
+ [fake_agent_1, fake_agent_2],
+ write_json=True)
try:
self.assertTrue(result.endswith('.zip'))
« no previous file with comments | « systrace/profile_chrome/perf_tracing_agent_unittest.py ('k') | systrace/systrace/decorators.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698