def _grab_screenshots(self):
     """Captures screenshots that are created by the UIAutomator tests."""
     for screenshot in arc.adb_shell('find /sdcard/*.png').splitlines():
         logging.debug('Screenshot is %s.', screenshot)
         arc.adb_cmd('pull %s %s' % (screenshot, self.resultsdir),
                     ignore_status=True)
         arc.adb_shell('rm -r %s' % screenshot, ignore_status=True)
    def _get_file(self, dest_path):
        """Gets recorded audio file from container.

        Copies the recorded file from container to Cros device.

        @dest_path: Destination path of the recorded file on Cros device.

        """
        arc.adb_cmd('pull %s %s' % (pipes.quote(self._MICROPHONE_RECORD_PATH),
                                    pipes.quote(dest_path)))
Example #3
0
 def arc_setup(self):
     super(graphics_Gralloc, self).arc_setup()
     # Get the executable from CrOS and copy it to Android container. Due to
     # weird permission issues inside the container, we first have to copy
     # the test to /sdcard/, then move it to a /data/ subdirectory we create.
     # The permissions on the exectuable have to be modified as well.
     arc.adb_root()
     cmd = os.path.join(self.srcdir, 'gralloctest')
     arc.adb_cmd('-e push %s %s' % (cmd, _SDCARD_EXEC))
     arc._android_shell('mkdir -p %s' % (_EXEC_DIRECTORY))
     arc._android_shell('mv %s %s' % (_SDCARD_EXEC, _ANDROID_EXEC))
     arc._android_shell('chmod o+rwx %s' % (_ANDROID_EXEC))
    def set_playback_file(self, file_path):
        """Copies file into container.

        @param file_path: Path to the file to play on Cros host.

        @returns: Path to the file in container.

        """
        file_name = os.path.basename(file_path)
        dest_path = os.path.join(self._PLAYMUSIC_FILE_FOLDER, file_name)

        # pipes.quote is deprecated in 2.7 (but still available).
        # It should be replaced by shlex.quote in python 3.3.
        arc.adb_cmd('push %s %s' % (pipes.quote(file_path),
                                    pipes.quote(dest_path)))

        self._files_pushed.append(dest_path)

        return dest_path
    def _copy_resources_to_dut(self):
        """Copy the apks & xml file needed for the UIAutomator tests."""
        if not os.path.exists(self._TMP_LOCATION):
            os.mkdir(self._TMP_LOCATION)
        for test_file in self._TEST_FILES:
            uri = self._TEST_FILES_LOCATION + test_file
            utils.run('wget -O %s %s' %
                      (os.path.join(self._TMP_LOCATION, test_file), uri))

        for test_file in os.listdir(self._TMP_LOCATION):
            if test_file == 'app-debug.apk':
                arc.adb_cmd('push %s /data/local/tmp/com.hcl.actframework' %
                            os.path.join(self._TMP_LOCATION, test_file))
                arc.adb_shell('pm install -t -r '
                              '"/data/local/tmp/com.hcl.actframework"')
            elif test_file == 'app-debug-androidTest.apk':
                arc.adb_cmd('push %s '
                            '/data/local/tmp/com.hcl.actframework.test' %
                            os.path.join(self._TMP_LOCATION, test_file))
                arc.adb_shell('pm install -t -r '
                              '"/data/local/tmp/com.hcl.actframework.test"')
            else:
                arc.adb_cmd('push %s /sdcard/' %
                            os.path.join(self._TMP_LOCATION, test_file))
        if self._touch_view_mode:
            arc.adb_shell('touch /sdcard/touchView.txt')
    def arc_setup(self):
        super(graphics_Gralloc, self).arc_setup()
        # Get the executable from CrOS and copy it to Android container. Due to
        # weird permission issues inside the container, we first have to copy
        # the test to /sdcard/, then move it to a /data/ subdirectory we create.
        # The permissions on the exectuable have to be modified as well.
        arc.adb_root()
        arc._android_shell('mkdir -p %s' % (_EXEC_DIR))
        for binary in _POSSIBLE_BINARIES:
            cros_path = os.path.join(_CROS_BIN_DIR, binary)
            cros_cmd = '%s %s' % (_TEST_COMMAND, cros_path)
            job = utils.run(cros_cmd, ignore_status=True)
            if job.exit_status:
                continue

            sdcard_path = os.path.join(_SDCARD_DIR, binary)
            arc.adb_cmd('-e push %s %s' % (cros_path, sdcard_path))

            exec_path = os.path.join(_EXEC_DIR, binary)
            arc._android_shell('mv %s %s' % (sdcard_path, exec_path))
            arc._android_shell('chmod o+rwx %s' % (exec_path))
            self._executables.append(exec_path)
 def cleanup(self):
     arc.adb_cmd('uninstall com.hcl.actframework')
     arc.adb_cmd('uninstall com.hcl.actframework.test')
     arc.adb_cmd('uninstall %s' % self._pkg_name)
     arc.adb_shell('rm -f /sdcard/autresources.xml > /dev/null')
     arc.adb_shell('rm -f /sdcard/touchView.txt > /dev/null',
                   ignore_status=True)
     utils.run('rm -rf %s' % self._TMP_LOCATION)
     super(cheets_AppCompatTest, self).cleanup()
    def prepare_playback(self, file_path, fullscreen=True):
        """Copies file into the container and starts the video player app.

        @param file_path: Path to the file to play on Cros host.
        @param fullscreen: Plays the video in fullscreen.

        """
        if not tag_exists(arc_resource_common.PlayVideoProps.READY_TAG_FILE):
            raise ArcPlayVideoResourceException(
                    'Play Video app is not ready yet.')
        file_name = os.path.basename(file_path)
        dest_path = os.path.join(self._PLAYVIDEO_FILE_FOLDER, file_name)

        # pipes.quote is deprecated in 2.7 (but still available).
        # It should be replaced by shlex.quote in python 3.3.
        arc.adb_cmd('push %s %s' % (pipes.quote(file_path),
                                    pipes.quote(dest_path)))

        # In case the permissions are cleared, set the permission again before
        # each start of the app.
        self._set_permission()
        self._start_app(dest_path)
        if fullscreen:
            self.set_fullscreen()
 def _clear_logcat_buffer(self):
     """Clear logcat buffer between runs."""
     arc.adb_cmd('logcat -c')
 def _increase_logcat_buffer(self):
     """Increase logcat buffer so all UIAutomator test entries appear."""
     arc.adb_cmd('logcat -G 16M')
 def _save_logcat(self, iteration):
     """Saves the logcat for the test run to the resultsdir."""
     self._logcat = 'logcat%d.txt' % iteration
     arc.adb_cmd('logcat -d > %s' %
                 os.path.join(self.resultsdir, self._logcat))
 def _capture_bugreport(self):
     """Captures a bugreport and saves into resultsdir."""
     arc.adb_cmd('bugreport > %s' %
                 os.path.join(self.resultsdir, 'bugreport.txt'))