Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 json | 5 import json |
| 6 import unittest | 6 import unittest |
| 7 | 7 |
| 8 from telemetry.core import util | |
| 8 from telemetry.core.platform.power_monitor import monsoon_power_monitor | 9 from telemetry.core.platform.power_monitor import monsoon_power_monitor |
| 9 | 10 |
| 10 | 11 |
| 11 class MonsoonPowerMonitorTest(unittest.TestCase): | 12 class MonsoonPowerMonitorTest(unittest.TestCase): |
| 12 def testEnergyComsumption(self): | 13 def testEnergyComsumption(self): |
| 13 data = { | 14 data = { |
| 14 'duration_s': 3600.0, | 15 'duration_s': 3600.0, |
| 15 'samples': [(1.0,1.0), (2.0,2.0), (3.0,3.0), (4.0,4.0)] | 16 'samples': [(1.0,1.0), (2.0,2.0), (3.0,3.0), (4.0,4.0)] |
| 16 } | 17 } |
| 17 results = monsoon_power_monitor.MonsoonPowerMonitor.ParseSamplingOutput( | 18 results = monsoon_power_monitor.MonsoonPowerMonitor.ParseSamplingOutput( |
| 18 json.dumps(data)) | 19 json.dumps(data)) |
| 19 self.assertEqual(results['power_samples_mw'], [1000, 4000, 9000, 16000]) | 20 self.assertEqual(results['power_samples_mw'], [1000, 4000, 9000, 16000]) |
| 20 self.assertEqual(results['energy_consumption_mwh'], 7500) | 21 self.assertEqual(results['energy_consumption_mwh'], 7500) |
| 22 | |
| 23 def testPySerialVersionNumber(self): | |
|
tonyg
2014/06/09 16:13:34
I think a better test would be to just import mons
| |
| 24 util.AddDirToPythonPath(util.GetTelemetryDir(), 'third_party', 'pyserial') | |
| 25 import serial | |
| 26 try: | |
| 27 import serial.tools | |
| 28 import serial.tools.list_ports | |
| 29 self.assertTrue(True) | |
| 30 except ImportError: | |
| 31 self.assertTrue(True) | |
| 32 | |
| 33 util.InsertDirInPythonPath( | |
| 34 0, util.GetTelemetryDir(), 'third_party', 'pyserial') | |
| 35 import serial | |
| 36 self.assertEqual(serial.VERSION, '2.7') | |
| 37 try: | |
| 38 import serial.tools | |
| 39 import serial.tools.list_ports | |
| 40 self.assertTrue(True) | |
| 41 except ImportError: | |
| 42 self.assertTrue(False) | |
| OLD | NEW |