Beispiel #1
0
    def setup_workload_apk(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,
                    package=getattr(self, 'package', None)),
            version=getattr(self, 'version', None),
            variant_name=getattr(self, 'variant_name', None),
            strict=False)

        # Get target abi
        target_abi = self.device.get_installed_package_abi(self.package)
        if target_abi:
            self.logger.debug(
                "Found apk with primary abi '{}' on target device".format(
                    target_abi))

        # Get host version, primary abi is first, and then try to find supported.
        for abi in self.device.supported_abi:
            self.apk_file = context.resolver.get(
                ApkFile(self, abi, package=getattr(self, 'package', None)),
                version=getattr(self, 'version', None),
                variant_name=getattr(self, 'variant_name', None),
                strict=False)

            # Stop if apk found, or if exact_abi is set only look for primary abi.
            if self.apk_file or self.exact_abi:
                break

        host_version = self.check_host_version()
        self.verify_apk_version(target_version, target_abi, host_version)

        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)
Beispiel #2
0
 def init_resources(self, context):
     self.uiauto_params['tolerance'] = self.tolerance
     self.uiauto_params['sampling_interval'] = self.sampling_interval
     if self.video_name and self.video_name != "":
         self.uiauto_params['video_name'] = self.video_name
     else:
         self.uiauto_params['video_name'] = "abkk sathe {}".format(
             self.resolution)
     self.apk_file = context.resolver.get(ApkFile(self))
     self.uiauto_file = context.resolver.get(ApkFile(self, uiauto=True))
     self.device_uiauto_file = self.device.path.join(
         self.device.working_directory, os.path.basename(self.uiauto_file))
     if not self.uiauto_package:
         self.uiauto_package = os.path.splitext(
             os.path.basename(self.uiauto_file))[0]
Beispiel #3
0
    def init_resources(self, context):
        self.uiauto_file = context.resolver.get(ApkFile(self, uiauto=True))
        if not self.uiauto_file:
            raise ResourceError('No UI automation APK file found for workload {}.'.format(self.name))

        if not self.uiauto_package:
            self.uiauto_package = os.path.splitext(os.path.basename(self.uiauto_file))[0]
Beispiel #4
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()