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.platform import factory
12 class PlatformBackendTest(unittest.TestCase):
13 def testPowerMonitoringSync(self):
14 # Tests that the act of monitoring power doesn't blow up.
15 backend = factory.GetPlatformBackendForCurrentOS()
16 if not backend.CanMonitorPower():
17 logging.warning('Test not supported on this platform.')
20 browser_mock = lambda: None
21 # Android needs to access the package of the monitored app.
22 if backend.GetOSName() == 'android':
23 # pylint: disable=W0212
24 browser_mock._browser_backend = lambda: None
25 # Monitor the launcher, which is always present.
26 browser_mock._browser_backend.package = 'com.android.launcher'
28 backend.StartMonitoringPower(browser_mock)
30 output = backend.StopMonitoringPower()
31 self.assertTrue(output.has_key('power_samples_mw'))
32 self.assertTrue(output.has_key('identifier'))