1# Copyright (c) 2014 The Chromium OS 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 time 6from autotest_lib.server import autotest, test 7 8LINE_STATUS_WAIT_TIME = 5 9 10 11class power_RPMTest(test.test): 12 """Test RPM functionality.""" 13 version = 1 14 15 16 def initialize(self, host, verify=True): 17 """ 18 @param host: The host to run the test on 19 @param verify: True to test both on and off for the AC power and to 20 check with the host whether it sees the same state 21 """ 22 self._host = host 23 self._host_at = autotest.Autotest(host) 24 self._verify = verify 25 26 27 def _set_power(self, power_on): 28 if power_on: 29 self._host.power_on() 30 else: 31 self._host.power_off() 32 33 if self._verify: 34 time.sleep(LINE_STATUS_WAIT_TIME) 35 self._host_at.run_test('power_CheckAC', power_on=power_on) 36 37 38 def run_once(self, power_sequence=[True]): 39 """Run the test.i 40 41 @param power_sequence: Sequence of values to set the power state to in 42 order 43 """ 44 45 for val in power_sequence: 46 self._set_power(val) 47