OLD | NEW |
| (Empty) |
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 logging | |
6 import time | |
7 import unittest | |
8 | |
9 from telemetry.core import platform as platform_module | |
10 from telemetry import decorators | |
11 | |
12 | |
13 class PlatformBackendTest(unittest.TestCase): | |
14 @decorators.Disabled('mac', # crbug.com/440666 | |
15 'vista', # crbug.com/479337 | |
16 'chromeos') # crbug.com/483212 | |
17 def testPowerMonitoringSync(self): | |
18 # Tests that the act of monitoring power doesn't blow up. | |
19 platform = platform_module.GetHostPlatform() | |
20 can_monitor_power = platform.CanMonitorPower() | |
21 self.assertIsInstance(can_monitor_power, bool) | |
22 if not can_monitor_power: | |
23 logging.warning('Test not supported on this platform.') | |
24 return | |
25 | |
26 browser_mock = lambda: None | |
27 # Android needs to access the package of the monitored app. | |
28 if platform.GetOSName() == 'android': | |
29 # pylint: disable=protected-access | |
30 browser_mock._browser_backend = lambda: None | |
31 # Monitor the launcher, which is always present. | |
32 browser_mock._browser_backend.package = 'com.android.launcher' | |
33 | |
34 platform.StartMonitoringPower(browser_mock) | |
35 time.sleep(0.001) | |
36 output = platform.StopMonitoringPower() | |
37 self.assertTrue(output.has_key('energy_consumption_mwh')) | |
38 self.assertTrue(output.has_key('identifier')) | |
OLD | NEW |