def testDoubleStart(self): battery = pm_mock.MockBattery(None, voltage=5.0, fuelgauge=[5.e6, 3.e6]) backend = pm_mock.MockPlatformBackend() pm = android_fuelgauge_power_monitor.FuelGaugePowerMonitor(battery, backend) pm.StartMonitoringPower(None) with self.assertRaises(AssertionError): pm.StartMonitoringPower(None)
def testMonitorCycle(self): battery = pm_mock.MockBattery(None, voltage=5.0, fuelgauge=[5.e6, 3.e6]) backend = pm_mock.MockPlatformBackend() pm = android_fuelgauge_power_monitor.FuelGaugePowerMonitor(battery, backend) pm.StartMonitoringPower(None) results = pm.StopMonitoringPower() self.assertEqual(results['identifier'], 'fuel_gauge') self.assertAlmostEqual(results['fuel_gauge_energy_consumption_mwh'], 10)
def testDoubleStart(self): browser = pm_mock.MockBrowser(_PACKAGE) battery = pm_mock.MockBattery(_TYPICAL_POWER_DATA_MULTISAMPLE, voltage=5.0) backend = pm_mock.MockPlatformBackend() pm = android_dumpsys_power_monitor.DumpsysPowerMonitor( battery, backend) pm.StartMonitoringPower(browser) with self.assertRaises(AssertionError): pm.StartMonitoringPower(browser)
def testBatteryChargingState(self): browser = pm_mock.MockBrowser(_PACKAGE) battery = pm_mock.MockBattery(_TYPICAL_POWER_DATA_MULTISAMPLE, voltage=5.0) backend = pm_mock.MockPlatformBackend() pm = android_dumpsys_power_monitor.DumpsysPowerMonitor( battery, backend) self.assertEqual(battery.GetCharging(), True) pm.StartMonitoringPower(browser) self.assertEqual(battery.GetCharging(), False) pm.StopMonitoringPower() self.assertEqual(battery.GetCharging(), True)
def testMonitorCycle(self): browser = pm_mock.MockBrowser(_PACKAGE) battery = pm_mock.MockBattery(_TYPICAL_POWER_DATA_MULTISAMPLE, voltage=5.0) backend = pm_mock.MockPlatformBackend() pm = android_dumpsys_power_monitor.DumpsysPowerMonitor( battery, backend) pm.StartMonitoringPower(browser) result = pm.StopMonitoringPower() self.assertEqual(result['identifier'], 'dumpsys') self.assertEqual(result['power_samples_mw'], []) self.assertAlmostEqual(result['application_energy_consumption_mwh'], 250.0) self.assertAlmostEqual(result['energy_consumption_mwh'], 10000.0)