| Index: tools/telemetry/telemetry/core/platform/power_monitor/cros_power_monitor_unittest.py
|
| diff --git a/tools/telemetry/telemetry/core/platform/power_monitor/cros_power_monitor_unittest.py b/tools/telemetry/telemetry/core/platform/power_monitor/cros_power_monitor_unittest.py
|
| index c012bbc4f4ba9cd53863f1ad67f29ff682a294fc..1310403250b645908700abf27bc8227fea64b269 100644
|
| --- a/tools/telemetry/telemetry/core/platform/power_monitor/cros_power_monitor_unittest.py
|
| +++ b/tools/telemetry/telemetry/core/platform/power_monitor/cros_power_monitor_unittest.py
|
| @@ -8,93 +8,40 @@ from telemetry.core.platform.power_monitor import cros_power_monitor
|
|
|
|
|
| class CrosPowerMonitorMonitorTest(unittest.TestCase):
|
| - initial_power = ('''Device: Line Power
|
| - path: /sys/class/power_supply/AC
|
| - online: no
|
| - type: Mains
|
| - enum type: Disconnected
|
| - model name:
|
| - voltage (V): 0
|
| - current (A): 0
|
| -Device: Battery
|
| - path: /sys/class/power_supply/BAT0
|
| - vendor: SANYO
|
| - model name: AP13J3K
|
| - serial number: 0061
|
| - state: Discharging
|
| - voltage (V): 11.816
|
| - energy (Wh): 31.8262
|
| - energy rate (W): 12.7849
|
| - current (A): 1.082
|
| - charge (Ah): 2.829
|
| - full charge (Ah): 4.03
|
| - full charge design (Ah): 4.03
|
| - percentage: 70.1985
|
| - display percentage: 73.9874
|
| - technology: Li-ion''')
|
| - final_power = ('''Device: Line Power
|
| - path: /sys/class/power_supply/AC
|
| - online: yes
|
| - type: Mains
|
| - enum type: Disconnected
|
| - model name:
|
| - voltage (V): 0
|
| - current (A): 0
|
| -Device: Battery
|
| - path: /sys/class/power_supply/BAT0
|
| - vendor: SANYO
|
| - model name: AP13J3K
|
| - serial number: 0061
|
| - state: Discharging
|
| - voltage (V): 12.238
|
| - energy (Wh): 31.8262
|
| - energy rate (W): 12.7993
|
| - current (A): 1.082
|
| - charge (Ah): 2.827
|
| - full charge (Ah): 4.03
|
| - full charge design (Ah): 4.03
|
| - percentage: 70.1985
|
| - display percentage: 73.9874
|
| - technology: Li-ion''')
|
| - expected_parsing_power = {
|
| - 'Line Power': {
|
| - 'path': '/sys/class/power_supply/AC',
|
| - 'online': 'no',
|
| - 'type': 'Mains',
|
| - 'enum type': 'Disconnected',
|
| - 'voltage': '0',
|
| - 'current': '0'
|
| - },
|
| - 'Battery': {
|
| - 'path': '/sys/class/power_supply/BAT0',
|
| - 'vendor': 'SANYO',
|
| - 'model name': 'AP13J3K',
|
| - 'serial number': '0061',
|
| - 'state': 'Discharging',
|
| - 'voltage': '11.816',
|
| - 'energy': '31.8262',
|
| - 'energy rate': '12.7849',
|
| - 'current': '1.082',
|
| - 'charge': '2.829',
|
| - 'full charge': '4.03',
|
| - 'full charge design': '4.03',
|
| - 'percentage': '70.1985',
|
| - 'display percentage': '73.9874',
|
| - 'technology': 'Li-ion'
|
| - }
|
| - }
|
| + initial_power = ('''line_power_connected 0
|
| +battery_present 1
|
| +battery_percent 70.20
|
| +battery_charge 2.83
|
| +battery_charge_full 4.03
|
| +battery_charge_full_design 4.03
|
| +battery_current 1.08
|
| +battery_energy 31.83
|
| +battery_energy_rate 12.78
|
| +battery_voltage 11.82
|
| +battery_discharging 1''')
|
| + final_power = ('''line_power_connected 0
|
| +battery_present 1
|
| +battery_percent 70.20
|
| +battery_charge 2.83
|
| +battery_charge_full 4.03
|
| +battery_charge_full_design 4.03
|
| +battery_current 1.08
|
| +battery_energy 31.83
|
| +battery_energy_rate 12.80
|
| +battery_voltage 12.24
|
| +battery_discharging 1''')
|
| expected_power = {
|
| - 'energy_consumption_mwh': 2558.42,
|
| - 'power_samples_mw': [12784.9, 12799.3],
|
| + 'energy_consumption_mwh': 2558.0,
|
| + 'power_samples_mw': [12780.0, 12800.0],
|
| 'component_utilization': {
|
| 'battery': {
|
| 'charge_full': 4.03,
|
| 'charge_full_design': 4.03,
|
| - 'charge_now': 2.827,
|
| - 'current_now': 1.082,
|
| - 'energy': 31.8262,
|
| - 'energy_rate': 12.7993,
|
| - 'voltage_now': 12.238
|
| + 'charge_now': 2.83,
|
| + 'current_now': 1.08,
|
| + 'energy': 31.83,
|
| + 'energy_rate': 12.80,
|
| + 'voltage_now': 12.24
|
| }
|
| }
|
| }
|
| @@ -178,11 +125,6 @@ Device: Battery
|
| }
|
| }
|
| }
|
| - def testParsePowerSupplyInfo(self):
|
| - result = cros_power_monitor.CrosPowerMonitor.ParsePowerSupplyInfo(
|
| - self.initial_power)
|
| - self.assertDictEqual(result, self.expected_parsing_power)
|
| -
|
| def testParsePower(self):
|
| results = cros_power_monitor.CrosPowerMonitor.ParsePower(
|
| self.initial_power, self.final_power, 0.2)
|
| @@ -237,9 +179,9 @@ Device: Battery
|
|
|
| def testCanMonitorPower(self):
|
| # TODO(tmandel): Add a test here where the device cannot monitor power.
|
| - initial_status = cros_power_monitor.CrosPowerMonitor.ParsePowerSupplyInfo(
|
| + initial_status = cros_power_monitor.CrosPowerMonitor.ParsePowerStatus(
|
| self.initial_power)
|
| - final_status = cros_power_monitor.CrosPowerMonitor.ParsePowerSupplyInfo(
|
| + final_status = cros_power_monitor.CrosPowerMonitor.ParsePowerStatus(
|
| self.final_power)
|
| self.assertTrue(cros_power_monitor.CrosPowerMonitor.IsOnBatteryPower(
|
| initial_status, 'peppy'))
|
|
|