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

Side by Side Diff: telemetry/telemetry/core/tracing_controller_unittest.py

Issue 2236493003: [catapult android trybot] Make Telemetry tests run on Android (Closed) Base URL: git@github.com:catapult-project/catapult.git@master
Patch Set: Add stack traces and more logging Created 4 years 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 unified diff | Download patch
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import time 5 import time
6 6
7 from battor import battor_wrapper 7 from battor import battor_wrapper
8 from telemetry import decorators 8 from telemetry import decorators
9 from telemetry.core import platform as platform_module 9 from telemetry.core import platform as platform_module
10 from telemetry.testing import browser_test_case 10 from telemetry.testing import browser_test_case
11 from telemetry.testing import tab_test_case 11 from telemetry.testing import tab_test_case
12 from telemetry.timeline import model as model_module 12 from telemetry.timeline import model as model_module
13 from telemetry.timeline import tracing_config 13 from telemetry.timeline import tracing_config
14 from telemetry.timeline import trace_data as trace_data_module 14 from telemetry.timeline import trace_data as trace_data_module
15 15
16 16
17 class TracingControllerTest(tab_test_case.TabTestCase): 17 class TracingControllerTest(tab_test_case.TabTestCase):
18 18
19 # https://github.com/catapult-project/catapult/issues/3099 (Android)
19 @decorators.Isolated 20 @decorators.Isolated
21 @decorators.Disabled('android')
20 def testExceptionRaisedInStopTracing(self): 22 def testExceptionRaisedInStopTracing(self):
21 tracing_controller = self._tab.browser.platform.tracing_controller 23 tracing_controller = self._tab.browser.platform.tracing_controller
22 config = tracing_config.TracingConfig() 24 config = tracing_config.TracingConfig()
23 config.enable_chrome_trace = True 25 config.enable_chrome_trace = True
24 tracing_controller.StartTracing(config) 26 tracing_controller.StartTracing(config)
25 27
26 self.Navigate('blank.html') 28 self.Navigate('blank.html')
27 29
28 def _FakeStopChromeTracing(*args): 30 def _FakeStopChromeTracing(*args):
29 del args # Unused 31 del args # Unused
30 raise Exception('Intentional Tracing Exception') 32 raise Exception('Intentional Tracing Exception')
31 33
32 self._tab._inspector_backend._devtools_client.StopChromeTracing = ( 34 self._tab._inspector_backend._devtools_client.StopChromeTracing = (
33 _FakeStopChromeTracing) 35 _FakeStopChromeTracing)
34 with self.assertRaisesRegexp(Exception, 'Intentional Tracing Exception'): 36 with self.assertRaisesRegexp(Exception, 'Intentional Tracing Exception'):
35 tracing_controller.StopTracing() 37 tracing_controller.StopTracing()
36 38
37 # Tracing is stopped even if there is exception. 39 # Tracing is stopped even if there is exception.
38 self.assertFalse(tracing_controller.is_tracing_running) 40 self.assertFalse(tracing_controller.is_tracing_running)
39 41
40 42
43 # https://github.com/catapult-project/catapult/issues/3099 (Android)
41 @decorators.Isolated 44 @decorators.Isolated
45 @decorators.Disabled('android')
42 def testGotTrace(self): 46 def testGotTrace(self):
43 tracing_controller = self._browser.platform.tracing_controller 47 tracing_controller = self._browser.platform.tracing_controller
44 config = tracing_config.TracingConfig() 48 config = tracing_config.TracingConfig()
45 config.enable_chrome_trace = True 49 config.enable_chrome_trace = True
46 tracing_controller.StartTracing(config) 50 tracing_controller.StartTracing(config)
47 51
48 trace_data = tracing_controller.StopTracing() 52 trace_data = tracing_controller.StopTracing()
49 # Test that trace data is parsable 53 # Test that trace data is parsable
50 model = model_module.TimelineModel(trace_data) 54 model = model_module.TimelineModel(trace_data)
51 assert len(model.processes) > 0 55 assert len(model.processes) > 0
52 56
57 # https://github.com/catapult-project/catapult/issues/3099 (Android)
53 @decorators.Isolated 58 @decorators.Isolated
59 @decorators.Disabled('android')
54 def testStartAndStopTraceMultipleTimes(self): 60 def testStartAndStopTraceMultipleTimes(self):
55 tracing_controller = self._browser.platform.tracing_controller 61 tracing_controller = self._browser.platform.tracing_controller
56 config = tracing_config.TracingConfig() 62 config = tracing_config.TracingConfig()
57 config.enable_chrome_trace = True 63 config.enable_chrome_trace = True
58 tracing_controller.StartTracing(config) 64 tracing_controller.StartTracing(config)
59 self.assertFalse(tracing_controller.StartTracing(config)) 65 self.assertFalse(tracing_controller.StartTracing(config))
60 66
61 trace_data = tracing_controller.StopTracing() 67 trace_data = tracing_controller.StopTracing()
62 # Test that trace data is parsable 68 # Test that trace data is parsable
63 model_module.TimelineModel(trace_data) 69 model_module.TimelineModel(trace_data)
64 self.assertFalse(tracing_controller.is_tracing_running) 70 self.assertFalse(tracing_controller.is_tracing_running)
65 # Calling stop again will raise exception 71 # Calling stop again will raise exception
66 self.assertRaises(Exception, tracing_controller.StopTracing) 72 self.assertRaises(Exception, tracing_controller.StopTracing)
67 73
74 # https://github.com/catapult-project/catapult/issues/3099 (Android)
68 @decorators.Isolated 75 @decorators.Isolated
76 @decorators.Disabled('android')
69 def testFlushTracing(self): 77 def testFlushTracing(self):
70 SUBTRACE_COUNT = 5 78 SUBTRACE_COUNT = 5
71 79
72 tab = self._browser.tabs[0] 80 tab = self._browser.tabs[0]
73 def InjectMarker(index): 81 def InjectMarker(index):
74 marker = 'test-marker-%d' % index 82 marker = 'test-marker-%d' % index
75 # TODO(catapult:#3028): Fix interpolation of JavaScript values. 83 # TODO(catapult:#3028): Fix interpolation of JavaScript values.
76 tab.EvaluateJavaScript('console.time("%s");' % marker) 84 tab.EvaluateJavaScript('console.time("%s");' % marker)
77 # TODO(catapult:#3028): Fix interpolation of JavaScript values. 85 # TODO(catapult:#3028): Fix interpolation of JavaScript values.
78 tab.EvaluateJavaScript('console.timeEnd("%s");' % marker) 86 tab.EvaluateJavaScript('console.timeEnd("%s");' % marker)
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 self.assertFalse(platform.tracing_controller.is_tracing_running) 153 self.assertFalse(platform.tracing_controller.is_tracing_running)
146 # Calling stop tracing again will raise exception 154 # Calling stop tracing again will raise exception
147 self.assertRaises(Exception, platform.tracing_controller.StopTracing) 155 self.assertRaises(Exception, platform.tracing_controller.StopTracing)
148 finally: 156 finally:
149 if platform.tracing_controller.is_tracing_running: 157 if platform.tracing_controller.is_tracing_running:
150 platform.tracing_controller.StopTracing() 158 platform.tracing_controller.StopTracing()
151 if self._browser: 159 if self._browser:
152 self._browser.Close() 160 self._browser.Close()
153 self._browser = None 161 self._browser = None
154 162
155 @decorators.Enabled('android') 163 # https://github.com/catapult-project/catapult/issues/3099 (Android)
164 @decorators.Disabled('all')
156 @decorators.Isolated 165 @decorators.Isolated
157 def testStartupTracingOnAndroid(self): 166 def testStartupTracingOnAndroid(self):
158 self._StartupTracing(self._browser.platform) 167 self._StartupTracing(self._browser.platform)
159 168
160 @decorators.Enabled('chromeos') 169 @decorators.Enabled('chromeos')
161 @decorators.Isolated 170 @decorators.Isolated
162 def testStartupTracingOnCrOS(self): 171 def testStartupTracingOnCrOS(self):
163 self._StartupTracing(self._browser.platform) 172 self._StartupTracing(self._browser.platform)
164 173
165 @decorators.Enabled('linux', 'mac', 'win') 174 @decorators.Enabled('linux', 'mac', 'win')
(...skipping 13 matching lines...) Expand all
179 tracing_controller = self._browser.platform.tracing_controller 188 tracing_controller = self._browser.platform.tracing_controller
180 config = tracing_config.TracingConfig() 189 config = tracing_config.TracingConfig()
181 config.enable_battor_trace = True 190 config.enable_battor_trace = True
182 tracing_controller.StartTracing(config) 191 tracing_controller.StartTracing(config)
183 # We wait 1s before starting and stopping tracing to avoid crbug.com/602266, 192 # We wait 1s before starting and stopping tracing to avoid crbug.com/602266,
184 # which would cause a crash otherwise. 193 # which would cause a crash otherwise.
185 time.sleep(1) 194 time.sleep(1)
186 trace_data = tracing_controller.StopTracing() 195 trace_data = tracing_controller.StopTracing()
187 self.assertTrue( 196 self.assertTrue(
188 trace_data.HasTraceFor(trace_data_module.BATTOR_TRACE_PART)) 197 trace_data.HasTraceFor(trace_data_module.BATTOR_TRACE_PART))
OLDNEW
« no previous file with comments | « telemetry/telemetry/core/platform_unittest.py ('k') | telemetry/telemetry/internal/actions/action_runner_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698