autotest: Move delay from power_RPMTest to power_CheckAC

This moves the delay to let the AC status settle into power_CheckAC.
This allows a polling loop to be used to make the test faster. The
max time is double (10 seconds) what the standard wait time was
before, but the AC status should change well before that in most


Change-Id: I2432cdb4c8700efe6849cabe52663e25b8b267cf
Commit-Ready: Hsinyu Chao <>
Tested-by: Derek Basehore <>
Reviewed-by: Dan Erat <>
Reviewed-by: Todd Broch <>
diff --git a/client/site_tests/power_CheckAC/ b/client/site_tests/power_CheckAC/
index 895072c..439e81a 100755
--- a/client/site_tests/power_CheckAC/
+++ b/client/site_tests/power_CheckAC/
@@ -3,7 +3,7 @@
 # found in the LICENSE file.
 from autotest_lib.client.bin import test
-from autotest_lib.client.common_lib import error
+from autotest_lib.client.common_lib import error, utils
 from autotest_lib.client.cros import power_status
 class power_CheckAC(test.test):
@@ -16,8 +16,6 @@
     def run_once(self, power_on=True):
-        status = power_status.get_status()
-        if power_on and not status.on_ac():
-            raise error.TestError('AC line status is not on but should be')
-        elif not power_on and status.on_ac():
-            raise error.TestError('AC line status is on but should not be')
+        utils.poll_for_condition(
+            lambda: power_status.get_status().on_ac() == power_on,
+            timeout=10, exception=error.TestError('AC power not %d' % power_on))
diff --git a/server/site_tests/power_RPMTest/ b/server/site_tests/power_RPMTest/
index 0b71eaf..2cc58f4 100755
--- a/server/site_tests/power_RPMTest/
+++ b/server/site_tests/power_RPMTest/
@@ -2,12 +2,9 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
-import time
 from autotest_lib.client.common_lib import error
 from autotest_lib.server import autotest, test
 class power_RPMTest(test.test):
     """Test RPM functionality."""
@@ -32,7 +29,6 @@
         if self._verify:
-            time.sleep(LINE_STATUS_WAIT_TIME)
             if not self._host_at.run_test('power_CheckAC', power_on=power_on):
                 raise error.TestError('power_CheckAC failed')