[Autotest] Updating ArcVideoCaptureAllowed

The old commands used to launch/check the camera app no longer work.
Updating to simply open with UI, and check if its launched via specific
buttons appearing/not

BUG=None
TEST=This

Change-Id: I92ea844da97f53559b901d3e70d2a3f15cd8b6aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/1963520
Reviewed-by: Ruben Zakarian <rzakarian@chromium.org>
Tested-by: Derek Beckett <dbeckett@chromium.org>
Commit-Queue: Derek Beckett <dbeckett@chromium.org>
diff --git a/client/cros/input_playback/keyboard_c b/client/cros/input_playback/keyboard_c
new file mode 100644
index 0000000..261e62f
--- /dev/null
+++ b/client/cros/input_playback/keyboard_c
@@ -0,0 +1,6 @@
+E: 1576091330.295165 0004 0004 46
+E: 1576091330.295165 0001 002e 1
+E: 1576091330.295165 0000 0000 0
+E: 1576091330.375388 0004 0004 46
+E: 1576091330.375388 0001 002e 0
+E: 1576091330.375388 0000 0000 0
diff --git a/client/cros/input_playback/keyboard_m b/client/cros/input_playback/keyboard_m
new file mode 100644
index 0000000..0335f97
--- /dev/null
+++ b/client/cros/input_playback/keyboard_m
@@ -0,0 +1,6 @@
+E: 1576091422.510474 0004 0004 50
+E: 1576091422.510474 0001 0032 1
+E: 1576091422.510474 0000 0000 0
+E: 1576091422.619556 0004 0004 50
+E: 1576091422.619556 0001 0032 0
+E: 1576091422.619556 0000 0000 0
diff --git a/client/site_tests/policy_ArcVideoCaptureAllowed/policy_ArcVideoCaptureAllowed.py b/client/site_tests/policy_ArcVideoCaptureAllowed/policy_ArcVideoCaptureAllowed.py
index 980785e..1020d97 100644
--- a/client/site_tests/policy_ArcVideoCaptureAllowed/policy_ArcVideoCaptureAllowed.py
+++ b/client/site_tests/policy_ArcVideoCaptureAllowed/policy_ArcVideoCaptureAllowed.py
@@ -3,11 +3,8 @@
 # found in the LICENSE file.
 import time
 
-from autotest_lib.client.common_lib import error
-from autotest_lib.client.common_lib import utils
-
-from autotest_lib.client.common_lib.cros import arc
 from autotest_lib.client.cros.enterprise import enterprise_policy_base
+from autotest_lib.client.cros.input_playback import keyboard
 
 
 class policy_ArcVideoCaptureAllowed(
@@ -27,42 +24,18 @@
 
     def _launch_Arc_Cam(self):
         """Grant the Camera location permission, and launch the Camera app."""
-        utils.poll_for_condition(
-            lambda: self.did_cam_app_respond(),
-            exception=error.TestFail('Camera APP did not respond.'),
-            timeout=25,
-            sleep_interval=5,
-            desc='Wait for Camera to respond.')
+        self.ui.click_and_wait_for_item_with_retries(
+            'Launcher',
+            '/Search your device, apps/',
+            isRegex_wait=True)
+        self.ui.doDefault_on_obj('/Search your device, apps/', isRegex=True)
+        for button in 'cam':
+            time.sleep(0.1)
+            self.keyboard.press_key(button)
+        self.ui.wait_for_ui_obj('/Camera/', isRegex=True)
+        self.ui.doDefault_on_obj('/Camera/', isRegex=True)
 
-    def _cam_closed(self):
-        """Check if the camera got closed after it opened."""
-        return arc.adb_shell("logcat -d | grep camera | grep Closing",
-                             ignore_status=True)
-
-    def _check_cam_status(self):
-        """Returns the specified section from loggcat."""
-        cam_device = arc.adb_shell("logcat -d | grep 'Camera device'",
-                                   ignore_status=True)
-        cam_disable = arc.adb_shell("logcat -d | grep 'disabled by policy'",
-                                    ignore_status=True)
-        return [cam_device, cam_disable]
-
-    def did_cam_app_respond(self):
-        """
-        Check if the Camera app has responded to the start command via
-        data in the logs being populated.
-
-        @return: True/False, if the Camera has responded to the start command.
-
-        """
-        arc.adb_shell('pm grant com.google.android.GoogleCameraArc android.permission.ACCESS_COARSE_LOCATION')
-        arc.adb_shell('am start -a android.media.action.IMAGE_CAPTURE')
-        cam_logs = self._check_cam_status()
-        if cam_logs[0] or cam_logs[1]:
-            return True
-        return False
-
-    def _test_Arc_cam_status(self, case):
+    def _test_Arc_cam_status(self, expected):
         """
         Test if the Arc Camera has been opened, or not.
 
@@ -70,24 +43,15 @@
 
         """
         #  Once the Camera is open, get the status from logcat.
-        cam_device_resp, disabled_resp = self._check_cam_status()
 
-        if case or case is None:
-            if 'opened successfully' not in cam_device_resp or disabled_resp:
-                raise error.TestFail(
-                    'Camera did not launch when it should have.')
+        if expected is False:
+            self.ui.did_obj_not_load('/Switch to take photo/',
+                                     isRegex=True,
+                                     timeout=10)
         else:
-            if ('opened successfully' in cam_device_resp or
-                'disabled by policy' not in disabled_resp):
-                # Sometimes due to timing the camera will still open, but then
-                # will quickly be closed. Check for this.
-                utils.poll_for_condition(
-                    lambda: self._cam_closed(),
-                    exception=error.TestFail(
-                        'Camera APP did not close or unstable.'),
-                    timeout=15,
-                    sleep_interval=3,
-                    desc='Wait for Camera to close.')
+            self.ui.wait_for_ui_obj('/Switch to take photo/',
+                                    isRegex=True,
+                                    timeout=10)
 
     def run_once(self, case):
         """
@@ -104,7 +68,8 @@
                         use_clouddpc_test=False)
 
         # Allow the ARC container time to apply the policy...
-        time.sleep(15)
+        self.keyboard = keyboard.Keyboard()
+        self.ui.start_ui_root(self.cr)
 
         self._launch_Arc_Cam()
         self._test_Arc_cam_status(case)