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 3 # found in the LICENSE file. 4 5 import json 6 import unittest 7 8 from telemetry.core.platform.power_monitor import monsoon_power_monitor 9 10 11 class MonsoonPowerMonitorTest(unittest.TestCase): 12 def testEnergyComsumption(self): 13 data = { 14 'duration_s': 3600.0, 15 'samples': [(1.0,1.0), (2.0,2.0), (3.0,3.0), (4.0,4.0)] 16 } 17 results = monsoon_power_monitor.MonsoonPowerMonitor.ParseSamplingOutput( 18 json.dumps(data)) 19 self.assertEqual(results['power_samples_mw'], [1000, 4000, 9000, 16000]) 20 self.assertEqual(results['energy_consumption_mwh'], 7500) 21