Ejemplo n.º 1
0
 def setUp(self):
     print "[Setup]:%s" % self.__class__.__name__
     super(CardviewRecentsTest, self).setUp()
     self.actor_apps = self.test_conf.get('actor_apps')
     self.calendar_path = get_resource_from_atifactory(
         self.config_file, "apps", "calendar")
     self.clock_path = get_resource_from_atifactory(self.config_file,
                                                    "apps", "clock")
     pkgmgr.apk_install(self.calendar_path)
     pkgmgr.apk_install(self.clock_path)
     self.systemui = SystemUiExtendImpl()
     self.photos = get_photo_implement()
     self.photos.rm_delete_photos()
     self.systemui.unlock_screen()
     self.d.screen.on()
     self.d.press.menu()
     self.mark_time = logcat.get_device_time_mark()
Ejemplo n.º 2
0
 def setUpClass(self):
     """
     install apk
     """
     super(PhotoGrid, self).setUpClass()
     self.photos = get_photo_implement()
     self.photos.rm_delete_photos()
     apk_path = get_resource_from_atifactory(
         'tests.tablet.artifactory.conf', 'content_photogrid', 'name')
     pkgmgr.apk_install(apk_path)
     self.photos.deploy_photo_content('Pictures', 'email')
Ejemplo n.º 3
0
 def setUp(self):
     super(VirtualDisplay, self).setUp()
     self._test_name = __name__
     print "[Setup]: %s" % self._test_name
     self.apk = get_resource_from_atifactory(CONFIG_FILE, SECTION, 'name')
     self.d = g_common_obj.get_device()
     self.apiDemoImpl = SampleApiDemoImpl()
     self.photoImpl = get_photo_implement()
     self.photoImpl.stop_photos_am()
     self.photoImpl.rm_delete_photos()
     self.photoImpl.refresh_sdcard()
Ejemplo n.º 4
0
    def _check_dependency(self):

        if not pkgmgr._package_installed(pkgName=PACKAGENAME):
            android_version = self.env.get_android_version()
            selection = {
                'L': 'apk_l',
                'M': 'apk_m',
                'N': 'apk_n',
                'O-MR0': 'apk_omr0',
                'O-MR1': 'apk_omr1'
            }
            try:
                file_path = get_resource_from_atifactory(
                    'tests.common.dEQP.conf', 'dEQP',
                    selection[android_version])
                pkgmgr.apk_install(file_path)
            except KeyError, e:
                print "DEQP app version not match with android os: %s" % str(e)
Ejemplo n.º 5
0
    def _install_apk(self):

        if not pkgmgr._package_installed(pkgName=PACKAGE_NAME):
            android_version = EnvironmentUtils().get_android_version()
            selection = {
                'L': 'apk_l',
                'M': 'apk_m',
                'N': 'apk_n',
                'O-MR0': 'apk_omr0',
                'O-MR1': 'apk_omr1'
            }
            try:
                file_path = get_resource_from_atifactory(
                    'tests.tablet.artifactory.conf', 'content_colormode',
                    selection[android_version])
                pkgmgr.apk_install(file_path)
            except KeyError, e:
                print "ColorMode app version not match with android os: %s" % str(
                    e)
Ejemplo n.º 6
0
    def test_shadow_sampleapkelevationbasic(self):
        """
        refer TC test_Shadow_SampleAPKElevationBasic
        """
        print "[RunTest]: %s" % self.__str__()
        # install apk if not exists in package list
        if self.basic_pkg_name not in pkgmgr.get_packages():
            apk_path = get_resource_from_atifactory(self.case_cfg,
                                                    'ElevationBasic', 'apk')
            pkgmgr.apk_install(apk_path)
        # launch app
        run_cmd = "am start -S -n %s/%s" % (self.basic_pkg_name,
                                            self.activity_name)
        g_common_obj.adb_cmd_capture_msg(run_cmd)
        sleep(2)
        # screen capture before operation
        sx, sy, ex, ey = self.d.info["displayWidth"] / 2, \
                         0, \
                         self.d.info["displayWidth"], \
                         self.d.info["displayHeight"]
        img_before = multi_display.get_screenshot_multidisplay_croped(
            0, sx, sy, ex, ey)

        # define operation type
        def long_tap_content():
            d = g_common_obj.get_device()
            d(resourceId="com.example.android.elevationbasic:id/floating_shape_2"
              ).long_click()

        # start test
        thread = threading.Timer(1.5, long_tap_content)
        thread.start()
        # screen capture after operation
        sleep(2)
        img_after = multi_display.get_screenshot_multidisplay_croped(
            0, sx, sy, ex, ey)
        assert compare_pic.compare_pic(
            img_before, img_after) > 4, "No diff after operation"
Ejemplo n.º 7
0
class dEQPImpl(object):
    def __init__(self):
        self._device = g_common_obj.get_device()
        self.tmp = tempfile.gettempdir()
        self.tmpdir = getTmpDir()
        self.inside_output = "/sdcard/TestResult.qpa"
        self.device = g_common_obj.get_test_device()
        self.env = EnvironmentUtils()
        self._mustpass_path = '/sdcard'
        self._mustpass_list = [
            'vk-master.txt', 'egl-master.txt', 'gles2-master.txt',
            'gles3-master.txt', 'gles31-master.txt'
        ]
        self._failure_log = os.path.join(
            g_common_obj.globalcontext.user_log_dir, 'deqp_failures.log')
        self._raw_deqp_result = os.path.join(
            g_common_obj.globalcontext.user_log_dir, 'deqp_test_result.log')
        self._extension_list = os.path.join(
            g_common_obj.globalcontext.user_log_dir, 'extension_list.log')

    def setup(self):
        g_common_obj.root_on_device()
        g_common_obj.remount_device()
        g_common_obj.adb_cmd_capture_msg("logcat -c")
        self._check_dependency()

    def run_case(self, case_name, check_extensions=False, extension_name=''):

        _inside_output = self.inside_output

        # Add inside function for further check extension tests.
        def _get_extension_list():
            inside_content = g_common_obj.adb_cmd_capture_msg('cat %s' %
                                                              _inside_output)
            return re.findall(r'\ +?<Text>(.+)</Text>', inside_content)

        # Start run deqp test.
        _results = {
            'Passed': 0,
            'Failed': 0,
            'Not supported': 0,
            'Warnings': 0
        }
        LOG.debug("Testcase: %s" % (case_name))
        setlog_cmd = "setprop log.tag.dEQP DEBUG"
        cmd = "am start -S -n com.drawelements.deqp/android.app.NativeActivity -e cmdLine \"" \
              "deqp --deqp-log-filename=%s --deqp-case=%s\"" % (self.inside_output, case_name)
        self.device.adb_cmd_capture_msg_ext(repr(setlog_cmd))
        self.device.adb_cmd_capture_msg_ext(repr(cmd))
        # failures = ['Fail', 'ResourceError', 'Crash', 'Timeout', 'InternalError']
        s_time = time.time()
        while time.time() - s_time < 900:
            cur_window = get_current_focus_window()
            time.sleep(2)
            if PACKAGENAME not in cur_window:
                LOG.debug("Test finished.")
                # Save deqp results to log.
                g_common_obj.adb_cmd_capture_msg('logcat -d -s dEQP > %s' %
                                                 self._raw_deqp_result)
                # Handle results.
                logs = Popen('cat %s' % self._raw_deqp_result,
                             shell=True,
                             stdout=PIPE,
                             stderr=PIPE).communicate()[0]
                for i in _results.keys():
                    chk_log = r"logcat -d -s dEQP | grep -oe '%s:\ \+[0-9]\+/[0-9]\+'" % i
                    try:
                        output = g_common_obj.adb_cmd_capture_msg(chk_log)
                        num = output.split(' ')[-1].split('/')[0]
                        _results[i] = int(num)
                    except ValueError as e:
                        raise Exception("Got error when running tests: %s" % e)

                assert sum(_results.values()) != 0, LOG.debug("Test not run.")

                LOG.debug("Raw summary: %s" % _results)
                if _results['Failed'] > 0:
                    raw_failures = re.findall(
                        r'Test case .(dEQP-.*[\d|\w]).+\n.+?dEQP +: +Fail.+?.',
                        logs)
                    head_name = raw_failures[0].split('.')[0].split(
                        '-')[-1].lower()
                    real_failures = []
                    for i in raw_failures:
                        _is_mustpass = "******" % (
                            self._mustpass_path, head_name, i)
                        chk = g_common_obj.adb_cmd_capture_msg(_is_mustpass)
                        if chk == '':
                            _results['Failed'] -= 1
                            _results['Not supported'] += 1
                        else:
                            real_failures.append(i)
                    if len(real_failures) > 0:
                        f = open(self._failure_log, 'w')
                        for i in real_failures:
                            f.write(i + '\n')
                        f.close()
                    LOG.debug("Final summary: %s" % _results)
                # Handle event for extension list check.
                if check_extensions:
                    ext_list = _get_extension_list()
                    f = open(self._extension_list,
                             'w')  # Save extension list to logfile.
                    for el in ext_list:
                        f.write(el + '\n')
                    f.close()
                    LOG.info("Extension list saved in: %s" %
                             self._extension_list)
                    assert extension_name in ext_list, "%s is not in this test." % extension_name
                    LOG.info("%s is found in this test." % extension_name)
                    return True
                else:
                    if _results['Failed'] == 0:
                        LOG.info("All tests passed.")
                        return True
                    else:
                        raise Exception(
                            "dEQP test failed, details refer to log file: %s" %
                            self._failure_log)
            else:
                time.sleep(3)
        raise Exception("Test timeout.")

    def _check_dependency(self):

        if not pkgmgr._package_installed(pkgName=PACKAGENAME):
            android_version = self.env.get_android_version()
            selection = {
                'L': 'apk_l',
                'M': 'apk_m',
                'N': 'apk_n',
                'O-MR0': 'apk_omr0',
                'O-MR1': 'apk_omr1'
            }
            try:
                file_path = get_resource_from_atifactory(
                    'tests.common.dEQP.conf', 'dEQP',
                    selection[android_version])
                pkgmgr.apk_install(file_path)
            except KeyError, e:
                print "DEQP app version not match with android os: %s" % str(e)
            # Need to update above when new version is released.
        for i in self._mustpass_list:
            op = g_common_obj.adb_cmd_capture_msg('ls %s/%s' %
                                                  (self._mustpass_path, i))
            if 'No such file' in op:
                file_path = get_resource_from_atifactory(
                    'tests.common.dEQP.conf', 'dEQP',
                    i.split('-')[0] + '_mustpass')
                g_common_obj.push_file(file_path, self._mustpass_path + '/')