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