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

Side by Side Diff: telemetry/telemetry/internal/platform/tracing_agent/battor_tracing_agent_unittest.py

Issue 2162963002: [polymer] Merge of master into polymer10-migration (Closed) Base URL: git@github.com:catapult-project/catapult.git@polymer10-migration
Patch Set: Merge polymer10-migration int polymer10-merge Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 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 unittest 5 import unittest
6 6
7 from battor import battor_error 7 from battor import battor_error
8 from battor import battor_wrapper 8 from battor import battor_wrapper
9 from devil.android import battery_utils 9 from devil.android import battery_utils
10 from telemetry.internal.platform.tracing_agent import battor_tracing_agent 10 from telemetry.internal.platform.tracing_agent import battor_tracing_agent
11 from telemetry.timeline import trace_data 11 from telemetry.timeline import trace_data
12 from telemetry.timeline import tracing_config 12 from telemetry.timeline import tracing_config
13 13
14 _BATTOR_RETURN = ['fake', 'battor', 'data'] 14 _BATTOR_RETURN = 'fake\nbattor\ndata'
15 15
16 16
17 class FakeBatteryUtils(object): 17 class FakeBatteryUtils(object):
18 def __init__(self, device): 18 def __init__(self, device):
19 self._device = device 19 self._device = device
20 self._charging_state = True 20 self._charging_state = True
21 21
22 def SetCharging(self, state): 22 def SetCharging(self, state):
23 self._charging_state = state 23 self._charging_state = state
24 24
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 self.android_agent.StopAgentTracing() 163 self.android_agent.StopAgentTracing()
164 self.assertTrue(self.android_agent._battor._stop_tracing_called) 164 self.assertTrue(self.android_agent._battor._stop_tracing_called)
165 165
166 def testCollectAgentTraceData(self): 166 def testCollectAgentTraceData(self):
167 builder = trace_data.TraceDataBuilder() 167 builder = trace_data.TraceDataBuilder()
168 self.android_agent.CollectAgentTraceData(builder) 168 self.android_agent.CollectAgentTraceData(builder)
169 self.assertTrue(self.android_agent._battor._collect_trace_data_called) 169 self.assertTrue(self.android_agent._battor._collect_trace_data_called)
170 builder = builder.AsData() 170 builder = builder.AsData()
171 self.assertTrue(builder.HasTraceFor(trace_data.BATTOR_TRACE_PART)) 171 self.assertTrue(builder.HasTraceFor(trace_data.BATTOR_TRACE_PART))
172 data_from_builder = builder.GetTraceFor(trace_data.BATTOR_TRACE_PART) 172 data_from_builder = builder.GetTraceFor(trace_data.BATTOR_TRACE_PART)
173 self.assertEqual('\n'.join(_BATTOR_RETURN), data_from_builder) 173 self.assertEqual(_BATTOR_RETURN, data_from_builder)
174 174
175 def testAndroidCharging(self): 175 def testAndroidCharging(self):
176 self.assertTrue(self.android_agent._battery.GetCharging()) 176 self.assertTrue(self.android_agent._battery.GetCharging())
177 self.assertTrue(self.android_agent.StartAgentTracing(self._config, 0)) 177 self.assertTrue(self.android_agent.StartAgentTracing(self._config, 0))
178 self.assertFalse(self.android_agent._battery.GetCharging()) 178 self.assertFalse(self.android_agent._battery.GetCharging())
179 self.android_agent.StopAgentTracing() 179 self.android_agent.StopAgentTracing()
180 self.assertTrue(self.android_agent._battery.GetCharging()) 180 self.assertTrue(self.android_agent._battery.GetCharging())
181 181
182 def testRecordClockSyncMarker(self): 182 def testRecordClockSyncMarker(self):
183 def callback_with_exception(a, b): 183 def callback_with_exception(a, b):
184 del a # unused 184 del a # unused
185 del b # unused 185 del b # unused
186 raise Exception 186 raise Exception
187 def callback_without_exception(a, b): 187 def callback_without_exception(a, b):
188 del a # unused 188 del a # unused
189 del b # unused 189 del b # unused
190 190
191 self.android_agent.RecordClockSyncMarker('123', callback_without_exception) 191 self.android_agent.RecordClockSyncMarker('123', callback_without_exception)
192 with self.assertRaises(Exception): 192 with self.assertRaises(Exception):
193 self.android_agent.RecordClockSyncMarker('abc', callback_with_exception) 193 self.android_agent.RecordClockSyncMarker('abc', callback_with_exception)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698