OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright 2016 The Chromium Authors. All rights reserved. | 3 # Copyright 2016 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 from collections import namedtuple | 7 from collections import namedtuple |
8 import unittest | 8 import unittest |
9 import logging | 9 import logging |
10 | 10 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 if self._StopTracing_error: | 72 if self._StopTracing_error: |
73 raise RuntimeError('Simulated error in StopTracing') | 73 raise RuntimeError('Simulated error in StopTracing') |
74 self._running = False | 74 self._running = False |
75 self._tracing = False | 75 self._tracing = False |
76 self._output = True | 76 self._output = True |
77 | 77 |
78 def CollectTraceData(self): | 78 def CollectTraceData(self): |
79 assert self._output | 79 assert self._output |
80 if self._CollectTraceData_error: | 80 if self._CollectTraceData_error: |
81 raise RuntimeError('Simulated error in CollectTraceData') | 81 raise RuntimeError('Simulated error in CollectTraceData') |
82 return ['traceout1', 'traceout2'] | 82 return 'traceout1\ntraceout2' |
83 | 83 |
84 class MockBatteryUtils(object): | 84 class MockBatteryUtils(object): |
85 def __init__(self, _): | 85 def __init__(self, _): |
86 self._is_charging = True | 86 self._is_charging = True |
87 | 87 |
88 def GetCharging(self): | 88 def GetCharging(self): |
89 return self._is_charging | 89 return self._is_charging |
90 | 90 |
91 def SetCharging(self, value): | 91 def SetCharging(self, value): |
92 self._is_charging = value | 92 self._is_charging = value |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 StopTracing_error=False, CollectTraceData_error=False) | 137 StopTracing_error=False, CollectTraceData_error=False) |
138 agent = battor_trace_agent.BattorTraceAgent() | 138 agent = battor_trace_agent.BattorTraceAgent() |
139 agent.StartAgentTracing(OPTIONS, CATEGORIES) | 139 agent.StartAgentTracing(OPTIONS, CATEGORIES) |
140 agent.StopAgentTracing() | 140 agent.StopAgentTracing() |
141 x = agent.GetResults() | 141 x = agent.GetResults() |
142 self.assertEqual(x.raw_data, 'traceout1\ntraceout2') | 142 self.assertEqual(x.raw_data, 'traceout1\ntraceout2') |
143 | 143 |
144 if __name__ == "__main__": | 144 if __name__ == "__main__": |
145 logging.getLogger().setLevel(logging.DEBUG) | 145 logging.getLogger().setLevel(logging.DEBUG) |
146 unittest.main(verbosity=2) | 146 unittest.main(verbosity=2) |
OLD | NEW |