1# Lint as: python2, python3
2# Copyright 2017 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5import logging
6from autotest_lib.server import autotest
7from autotest_lib.server import test
8from autotest_lib.client.common_lib import error
9
10
11class graphics_PowerConsumption(test.test):
12    version = 1
13
14    def run_once(self, host, client_test):
15        """Runs client test with battery actively discharging."""
16        if not host.has_power():
17            raise error.TestError("This test requires RPM support.")
18
19        try:
20            logging.debug("Powering off client machine before running %s test.",
21                          client_test)
22            host.power_off()
23            client = autotest.Autotest(host)
24            client.run_test(client_test, power_test=True)
25        finally:
26            host.power_on()
27