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 5import unittest 6 7from telemetry.core.platform.power_monitor import android_ds2784_power_monitor 8 9 10class DS2784PowerMonitorMonitorTest(unittest.TestCase): 11 def testEnergyComsumption(self): 12 13 data = ('0000 1000 -10 12\n' 14 '1800 1000 -10 11\n' 15 '3600 1000 -10 09\n' 16 '5400 0000 -20 08\n' 17 '7200 0000 -20 11\n' 18 '9000 0000 -20 11\n') 19 results = ( 20 android_ds2784_power_monitor.DS2784PowerMonitor.ParseSamplingOutput( 21 data)) 22 self.assertEqual(results['power_samples_mw'], [1.2e-07, 1.1e-07, 9e-08, 23 1.6e-07, 2.2e-07, 2.2e-07]) 24 self.assertEqual(results['energy_consumption_mwh'], 2.1e-07) 25