autotest: disable video power tests if AC state is unexpected

BUG=chromium:723968
TEST=video_PlaybackPerf and video_WebRtcPerf

Change-Id: Idcdec044039fbc6751bc9ae8fc6857521b2cf3aa
Reviewed-on: https://chromium-review.googlesource.com/523484
Commit-Ready: Kuang-che Wu <kcwu@chromium.org>
Tested-by: Kuang-che Wu <kcwu@chromium.org>
Reviewed-by: Pin-chih Lin <johnylin@chromium.org>
diff --git a/client/site_tests/video_PlaybackPerf/video_PlaybackPerf.py b/client/site_tests/video_PlaybackPerf/video_PlaybackPerf.py
index 71d3288..48e29b6 100644
--- a/client/site_tests/video_PlaybackPerf/video_PlaybackPerf.py
+++ b/client/site_tests/video_PlaybackPerf/video_PlaybackPerf.py
@@ -202,8 +202,14 @@
         self._service_stopper.stop_services()
 
         self._power_status = power_status.get_status()
-        # Verify that we are running on battery and the battery is sufficiently
-        # charged.
+        # We expect the DUT is powered by battery now. But this is not always
+        # true due to other bugs. Disable this test temporarily as workaround.
+        # TODO(kcwu): remove this workaround after AC control is stable
+        #             crbug.com/723968
+        if self._power_status.on_ac():
+            logging.warning('Still powered by AC. Skip this test')
+            return {}
+        # Verify that the battery is sufficiently charged.
         self._power_status.assert_battery_state(BATTERY_INITIAL_CHARGED_MIN)
 
         measurements = [power_status.SystemPower(
@@ -290,10 +296,11 @@
                     description= 'hw_' + description, value=result_with_hw,
                     units=units, higher_is_better=False)
 
-        result_without_hw = keyvals[PLAYBACK_WITHOUT_HW_ACCELERATION]
-        self.output_perf_value(
-                description= 'sw_' + description, value=result_without_hw,
-                units=units, higher_is_better=False)
+        result_without_hw = keyvals.get(PLAYBACK_WITHOUT_HW_ACCELERATION)
+        if result_without_hw is not None:
+            self.output_perf_value(
+                    description= 'sw_' + description, value=result_without_hw,
+                    units=units, higher_is_better=False)
 
 
     def cleanup(self):
diff --git a/client/site_tests/video_WebRtcPerf/video_WebRtcPerf.py b/client/site_tests/video_WebRtcPerf/video_WebRtcPerf.py
index 2f4f913..d308122 100644
--- a/client/site_tests/video_WebRtcPerf/video_WebRtcPerf.py
+++ b/client/site_tests/video_WebRtcPerf/video_WebRtcPerf.py
@@ -287,9 +287,15 @@
                 service_stopper.ServiceStopper.POWER_DRAW_SERVICES)
         self._service_stopper.stop_services()
 
-        # Verify that we are running on battery and the battery is sufficiently
-        # charged.
         current_power_status = power_status.get_status()
+        # We expect the DUT is powered by battery now. But this is not always
+        # true due to other bugs. Disable this test temporarily as workaround.
+        # TODO(kcwu): remove this workaround after AC control is stable
+        #             crbug.com/723968
+        if current_power_status.on_ac():
+            logging.warning('Still powered by AC. Skip this test')
+            return {}
+        # Verify that the battery is sufficiently charged.
         current_power_status.assert_battery_state(BATTERY_INITIAL_CHARGED_MIN)
 
         measurements = [power_status.SystemPower(