예제 #1
0
 def __init__(self, device, _call_super=True, **kwargs):
     if _call_super:
         Workload.__init__(self, device, **kwargs)
     self.apk_file = None
     self.apk_version = None
     self.logcat_log = None
     self.exact_apk_version = None
예제 #2
0
    def setup(self, context):
        devpath = self.device.path
        if self.setup_required:
            self.revent_setup_file = context.resolver.get(ReventFile(self, 'setup'))
            if self.revent_setup_file:
                self.on_device_setup_revent = devpath.join(self.device.working_directory,
                                                 os.path.split(self.revent_setup_file)[-1])
                duration = ReventRecording(self.revent_setup_file).duration
                self.default_setup_timeout = ceil(duration) + 30
        if not self.idle_time:
            self.revent_run_file = context.resolver.get(ReventFile(self, 'run'))
            if self.revent_run_file:
                self.on_device_run_revent = devpath.join(self.device.working_directory,
                                                 os.path.split(self.revent_run_file)[-1])
                self.default_run_timeout = ceil(ReventRecording(self.revent_run_file).duration) + 30
        if self.teardown_required:
            self.revent_teardown_file = context.resolver.get(ReventFile(self, 'teardown'))
            if self.revent_teardown_file:
                self.on_device_teardown_revent = devpath.join(self.device.working_directory,
                                                 os.path.split(self.revent_teardown_file)[-1])
                duration = ReventRecording(self.revent_teardown_file).duration
                self.default_teardown_timeout = ceil(duration) + 30
        self._check_revent_files(context)

        Workload.setup(self, context)

        if self.revent_setup_file is not None:
            self.setup_timeout = self.setup_timeout or self.default_setup_timeout
            self.device.killall('revent')
            command = '{} replay {}'.format(self.on_device_revent_binary, self.on_device_setup_revent)
            self.device.execute(command, timeout=self.setup_timeout)
            self.logger.debug('Revent setup completed.')
 def __init__(self, device, _call_super=True, **kwargs):  # pylint: disable=W0613
     if _call_super:
         Workload.__init__(self, device, **kwargs)
     self.uiauto_file = None
     self.device_uiauto_file = None
     self.command = None
     self.uiauto_params = ParameterDict()
예제 #4
0
 def __init__(self, device, _call_super=True, **kwargs):
     if _call_super:
         Workload.__init__(self, device, **kwargs)
     self.apk_file = None
     self.apk_version = None
     self.logcat_log = None
     self.exact_apk_version = None
예제 #5
0
 def __init__(self, device, _call_super=True, **kwargs):  # pylint: disable=W0613
     if _call_super:
         Workload.__init__(self, device, **kwargs)
     self.uiauto_file = None
     self.device_uiauto_file = None
     self.command = None
     self.uiauto_params = {}
예제 #6
0
    def setup(self, context):
        Workload.setup(self, context)

        # Get target version
        target_version = self.device.get_installed_package_version(
            self.package)
        if target_version:
            target_version = LooseVersion(target_version)
            self.logger.debug(
                "Found version '{}' on target device".format(target_version))

        # Get host version
        self.apk_file = context.resolver.get(
            ApkFile(self, self.device.abi),
            version=getattr(self, 'version', None),
            check_abi=getattr(self, 'check_abi', False),
            variant_name=getattr(self, 'variant_name', None),
            strict=False)
        host_version = None
        if self.apk_file is not None:
            host_version = ApkInfo(self.apk_file).version_name
            if host_version:
                host_version = LooseVersion(host_version)
            self.logger.debug(
                "Found version '{}' on host".format(host_version))

        # Error if apk was not found anywhere
        if target_version is None and host_version is None:
            msg = "Could not find APK for '{}' on the host or target device"
            raise ResourceError(msg.format(self.name))

        if self.exact_apk_version is not None:
            if self.exact_apk_version != target_version and self.exact_apk_version != host_version:
                msg = "APK version '{}' not found on the host '{}' or target '{}'"
                raise ResourceError(
                    msg.format(self.exact_apk_version, host_version,
                               target_version))

        # Ensure the apk is setup on the device
        if self.force_install:
            self.force_install_apk(context, host_version)
        elif self.check_apk:
            self.prefer_host_apk(context, host_version, target_version)
        else:
            self.prefer_target_apk(context, host_version, target_version)

        self.reset(context)
        self.apk_version = self.device.get_installed_package_version(
            self.package)
        context.add_classifiers(apk_version=self.apk_version)

        if self.launch_main:
            self.launch_package(
            )  # launch default activity without intent data
        self.device.execute('am kill-all')  # kill all *background* activities
        self.device.clear_logcat()
예제 #7
0
 def setup(self, context):
     Workload.setup(self, context)
     method_string = '{}.{}#{}'.format(self.uiauto_package, self.uiauto_class, self.uiauto_method)
     params_dict = self.uiauto_params
     params_dict['workdir'] = self.device.working_directory
     params = ''
     for k, v in self.uiauto_params.iteritems():
         params += ' -e {} "{}"'.format(k, v)
     self.command = 'uiautomator runtest {}{} -c {}'.format(self.device_uiauto_file, params, method_string)
     self.device.push_file(self.uiauto_file, self.device_uiauto_file)
     self.device.killall('uiautomator')
 def setup(self, context):
     Workload.setup(self, context)
     method_string = '{}.{}#{}'.format(self.uiauto_package, self.uiauto_class, self.uiauto_method)
     params_dict = self.uiauto_params
     params_dict['workdir'] = self.device.working_directory
     params = ''
     for k, v in self.uiauto_params.iter_encoded_items():
         params += ' -e {} "{}"'.format(k, v)
     self.command = 'uiautomator runtest {}{} -c {}'.format(self.device_uiauto_file, params, method_string)
     self.device.push_file(self.uiauto_file, self.device_uiauto_file)
     self.device.killall('uiautomator')
예제 #9
0
 def __init__(self, device, _call_super=True, **kwargs):
     if _call_super:
         Workload.__init__(self, device, **kwargs)
     self.setup_timeout = kwargs.get('setup_timeout', None)
     self.run_timeout = kwargs.get('run_timeout', None)
     self.teardown_timeout = kwargs.get('teardown_timeout', None)
     self.revent_setup_file = None
     self.revent_run_file = None
     self.revent_teardown_file = None
     self.on_device_setup_revent = None
     self.on_device_run_revent = None
     self.on_device_teardown_revent = None
     self.statedefs_dir = None
예제 #10
0
 def __init__(self, device, _call_super=True, **kwargs):
     if _call_super:
         Workload.__init__(self, device, **kwargs)
     devpath = self.device.path
     self.on_device_revent_binary = devpath.join(self.device.binaries_directory, 'revent')
     self.setup_timeout = kwargs.get('setup_timeout', None)
     self.run_timeout = kwargs.get('run_timeout', None)
     self.revent_setup_file = None
     self.revent_run_file = None
     self.on_device_setup_revent = None
     self.on_device_run_revent = None
     self.statedefs_dir = None
     self.check_states = None
예제 #11
0
    def __init__(self, device, _call_super=True, **kwargs):
        if _call_super:
            Workload.__init__(self, device, **kwargs)
        devpath = self.device.path
        self.on_device_revent_binary = devpath.join(self.device.binaries_directory, 'revent')
        self.setup_timeout = kwargs.get('setup_timeout', None)
        self.run_timeout = kwargs.get('run_timeout', None)
        self.revent_setup_file = None
        self.revent_run_file = None
        self.on_device_setup_revent = None
        self.on_device_run_revent = None
        self.statedefs_dir = None

        if self.check_states:
            state_detector.check_match_state_dependencies()
예제 #12
0
    def setup(self, context):
        Workload.setup(self, context)

        # Get target version
        target_version = self.device.get_installed_package_version(self.package)
        if target_version:
            target_version = LooseVersion(target_version)
            self.logger.debug("Found version '{}' on target device".format(target_version))

        # Get host version
        self.apk_file = context.resolver.get(ApkFile(self, self.device.abi),
                                             version=getattr(self, 'version', None),
                                             check_abi=getattr(self, 'check_abi', False),
                                             variant_name=getattr(self, 'variant_name', None),
                                             strict=False)
        host_version = None
        if self.apk_file is not None:
            host_version = ApkInfo(self.apk_file).version_name
            if host_version:
                host_version = LooseVersion(host_version)
            self.logger.debug("Found version '{}' on host".format(host_version))

        # Error if apk was not found anywhere
        if target_version is None and host_version is None:
            msg = "Could not find APK for '{}' on the host or target device"
            raise ResourceError(msg.format(self.name))

        if self.exact_apk_version is not None:
            if self.exact_apk_version != target_version and self.exact_apk_version != host_version:
                msg = "APK version '{}' not found on the host '{}' or target '{}'"
                raise ResourceError(msg.format(self.exact_apk_version, host_version, target_version))

        # Ensure the apk is setup on the device
        if self.force_install:
            self.force_install_apk(context, host_version)
        elif self.check_apk:
            self.prefer_host_apk(context, host_version, target_version)
        else:
            self.prefer_target_apk(context, host_version, target_version)

        self.reset(context)
        self.apk_version = self.device.get_installed_package_version(self.package)
        context.add_classifiers(apk_version=self.apk_version)

        if self.launch_main:
            self.launch_package()  # launch default activity without intent data
        self.device.execute('am kill-all')  # kill all *background* activities
        self.device.clear_logcat()
예제 #13
0
    def setup(self, context):
        Workload.setup(self, context)
        params_dict = self.uiauto_params
        params_dict['workdir'] = self.device.working_directory
        params = ''
        for k, v in self.uiauto_params.iter_encoded_items():
            params += ' -e {} "{}"'.format(k, v)

        if self.device.package_is_installed(self.uiauto_package):
            self.device.uninstall(self.uiauto_package)
        self.device.install_apk(self.uiauto_file)

        instrumention_string = 'am instrument -w -r {}  -e class {}.{} {}/{}'
        self.command = instrumention_string.format(params, self.uiauto_package,
                                                   self.uiauto_class, self.uiauto_package,
                                                   self.uiauto_method)
        self.device.killall('uiautomator')
예제 #14
0
    def setup(self, context):
        Workload.setup(self, context)
        params_dict = self.uiauto_params
        params_dict['workdir'] = self.device.working_directory
        params = ''
        for k, v in self.uiauto_params.iter_encoded_items():
            params += ' -e {} "{}"'.format(k, v)

        if self.device.package_is_installed(self.uiauto_package):
            self.device.uninstall(self.uiauto_package)
        self.device.install_apk(self.uiauto_file)

        instrumention_string = 'am instrument -w -r {}  -e class {}.{} {}/{}'
        self.command = instrumention_string.format(params, self.uiauto_package,
                                                   self.uiauto_class, self.uiauto_package,
                                                   self.uiauto_method)
        self.device.killall('uiautomator')
예제 #15
0
    def setup(self, context):
        self.revent_setup_file = context.resolver.get(ReventFile(self, 'setup'))
        self.revent_run_file = context.resolver.get(ReventFile(self, 'run'))
        devpath = self.device.path
        self.on_device_setup_revent = devpath.join(self.device.working_directory,
                                                   os.path.split(self.revent_setup_file)[-1])
        self.on_device_run_revent = devpath.join(self.device.working_directory,
                                                 os.path.split(self.revent_run_file)[-1])
        self._check_revent_files(context)
        default_setup_timeout = ceil(ReventRecording(self.revent_setup_file).duration) + 30
        default_run_timeout = ceil(ReventRecording(self.revent_run_file).duration) + 30
        self.setup_timeout = self.setup_timeout or default_setup_timeout
        self.run_timeout = self.run_timeout or default_run_timeout

        Workload.setup(self, context)
        self.device.killall('revent')
        command = '{} replay {}'.format(self.on_device_revent_binary, self.on_device_setup_revent)
        self.device.execute(command, timeout=self.setup_timeout)
예제 #16
0
    def setup(self, context):
        self.revent_setup_file = context.resolver.get(ReventFile(self, 'setup'))
        self.revent_run_file = context.resolver.get(ReventFile(self, 'run'))
        devpath = self.device.path
        self.on_device_setup_revent = devpath.join(self.device.working_directory,
                                                   os.path.split(self.revent_setup_file)[-1])
        self.on_device_run_revent = devpath.join(self.device.working_directory,
                                                 os.path.split(self.revent_run_file)[-1])
        self._check_revent_files(context)
        default_setup_timeout = ceil(ReventRecording(self.revent_setup_file).duration) + 30
        default_run_timeout = ceil(ReventRecording(self.revent_run_file).duration) + 30
        self.setup_timeout = self.setup_timeout or default_setup_timeout
        self.run_timeout = self.run_timeout or default_run_timeout

        Workload.setup(self, context)
        self.device.killall('revent')
        command = '{} replay {}'.format(self.on_device_revent_binary, self.on_device_setup_revent)
        self.device.execute(command, timeout=self.setup_timeout)
예제 #17
0
 def setup(self, context):  # pylint: disable=too-many-branches
     Workload.setup(self, context)
     self.setup_workload_apk(context)
     self.launch_application()
     self.kill_background()
     self.device.clear_logcat()
예제 #18
0
 def setup(self, context):  # pylint: disable=too-many-branches
     Workload.setup(self, context)
     self.setup_workload_apk(context)
     self.launch_application()
     self.kill_background()
     self.device.clear_logcat()