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

Side by Side Diff: tools/telemetry/telemetry/core/platform/power_monitor/monsoon_power_monitor_unittest.py

Issue 321773002: [PowerProfiler] Make sure correct version of pySerial is imported with monsoon profiler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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 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)
OLDNEW
« no previous file with comments | « no previous file | tools/telemetry/telemetry/core/platform/profiler/monsoon.py » ('j') | tools/telemetry/telemetry/core/util.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698