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
cases.

BUG=None
TEST=power_RPMTest

Change-Id: I2432cdb4c8700efe6849cabe52663e25b8b267cf
Reviewed-on: https://chromium-review.googlesource.com/492309
Commit-Ready: Hsinyu Chao <hychao@chromium.org>
Tested-by: Derek Basehore <dbasehore@chromium.org>
Reviewed-by: Dan Erat <derat@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
diff --git a/client/site_tests/power_CheckAC/power_CheckAC.py b/client/site_tests/power_CheckAC/power_CheckAC.py
index 895072c..439e81a 100755
--- a/client/site_tests/power_CheckAC/power_CheckAC.py
+++ b/client/site_tests/power_CheckAC/power_CheckAC.py
@@ -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/power_RPMTest.py b/server/site_tests/power_RPMTest/power_RPMTest.py
index 0b71eaf..2cc58f4 100755
--- a/server/site_tests/power_RPMTest/power_RPMTest.py
+++ b/server/site_tests/power_RPMTest/power_RPMTest.py
@@ -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
 
-LINE_STATUS_WAIT_TIME = 5
-
 
 class power_RPMTest(test.test):
     """Test RPM functionality."""
@@ -32,7 +29,6 @@
             self._host.power_off()
 
         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')