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
5import logging
6import time
7import unittest
8
9from telemetry import decorators
10from telemetry.core.platform import win_platform_backend
11from telemetry.core.platform.power_monitor import msr_power_monitor
12
13
14class MsrPowerMonitorTest(unittest.TestCase):
15  @decorators.Enabled('win')
16  def testMsrRuns(self):
17    platform_backend = win_platform_backend.WinPlatformBackend()
18    power_monitor = msr_power_monitor.MsrPowerMonitor(platform_backend)
19    if not power_monitor.CanMonitorPower():
20      logging.warning('Test not supported on this platform.')
21      return
22
23    power_monitor.StartMonitoringPower(None)
24    time.sleep(0.01)
25    statistics = power_monitor.StopMonitoringPower()
26
27    self.assertEqual(statistics['identifier'], 'msr')
28    self.assertIn('energy_consumption_mwh', statistics)
29    self.assertGreater(statistics['energy_consumption_mwh'], 0)
30