示例#1
0
    def run_test(self, names, timeout=1800):
        """run test"""
        self.home.go_category_testlist()
        self.testlist.clean_chooses()

        for each in names.split(','):
            print "[Debug] test: %s" % (each)
            if self.testlist.search_item_checkbox(each).exists:
                self.testlist.search_item_checkbox(each).click()
        checked_count = self.device(className="android.widget.CheckBox",
                                    checked=True).count
        assert checked_count == len(names.split(',')),\
            "[FAILURE] Failed Choose Test item"

        self.testlist.btn_start.click()
        _, current_activity = common.get_current_focus_window()
        assert current_activity == self.TEST_ACTIVITY,\
            "[FAILURE] Tests failed to start"

        print "[Debug] start test: %s" % (names)
        start_time = time.time()
        is_completed = False
        while time.time() - start_time < timeout:
            _, current_activity = common.get_current_focus_window()
            if current_activity == self.MAIN_ACTIVITY:
                is_completed = True
                break
            time.sleep(10)
        assert is_completed,\
            "[FAILURE] Test time out: %s" % (timeout)
示例#2
0
    def run_test(self, names, timeout=1800):
        """run test"""

        for each in names.split(','):
            print "[Debug] test: %s" % (each)
            if self.device(resourceId="com.glbenchmark.glbenchmark27:id/main_testSelectListView")\
                    .scroll.vert.to(text=each):
                self.device(text=each).right(
                    className="android.widget.CheckBox").click.wait()
        checked_count = self.device(className="android.widget.CheckBox",
                                    checked=True).count
        assert checked_count == len(names.split(',')),\
            "[FAILURE] Failed Choose Test item"
        self.device(text='Start').click.wait()
        _, current_activity = get_current_focus_window()
        assert current_activity == self.TEST_ACTIVITY,\
            "[FAILURE] Tests failed to start"

        print "[Debug] start test: %s" % (names)
        start_time = time.time()
        is_completed = False
        while time.time() - start_time < timeout:
            _, current_activity = get_current_focus_window()
            if current_activity == self.MAIN_ACTIVITY:
                is_completed = True
                break
            time.sleep(10)
        assert is_completed,\
            "[FAILURE] Test time out: %s" % (timeout)
示例#3
0
    def start_test(self, names, onscreen=True, offscreen=False):
        """Start test, but won't finish it"""
        self.home.go_category_testlist()

        for each in names.split(','):
            print "[Debug] test: %s onscreen:%s offscreen:%s" % (
                each, onscreen, offscreen)
            if onscreen:
                onscreen_checkbox = self.testlist.search_item_onscreen_checkbox(
                    each)
                onscreen_checkbox.click()
            if offscreen:
                offscreen_checkbox = self.testlist.search_item_offscreen_checkbox(
                    each)
                offscreen_checkbox.click()

        self.testlist.btn_start.click()
        print "[Debug] start test: %s" % (names)
        end_time = 60
        cur_time = time.time()
        while time.time() - cur_time < end_time:
            _, current_activity = common.get_current_focus_window()
            if current_activity == self.TEST_ACTIVITY:
                break
            time.sleep(1)
        time.sleep(12)
示例#4
0
 def stop_camera_am():
     """ Stop Camera via adb am command
     """
     print "Stop Camera by adb am"
     g_common_obj.stop_app_am("com.google.android.GoogleCamera")
     PKGname, _ = get_current_focus_window()
     if PKGname == "com.android.camera2":
         g_common_obj.stop_app_am("com.android.camera2")
 def test_Rotate_180Degree(self):
     print "[RunTest]: %s" % self.__str__()
     self.common.launch_app_am("com.android.settings", ".Settings")
     self.adbExt.change_automatic_rotation(0)  # Turn off auto rotation
     self.adbExt.screen_rotation(2)  # Rotate 180
     self.adbExt.screen_rotation(0)  # Rotate back to default
     packagename = get_current_focus_window()[0]
     assert packagename == "com.android.settings", "Not focus on settings window."
示例#6
0
 def launch_spintops_am(self, wait_time=10):
     LOG.info("Launching Spin-Tops app.")
     g_common_obj.launch_app_am(SPINTOPS_PACKAGE_NAME, SPINTOPS_ACTIVITY_NAME)
     while wait_time > 0:
         windows_info.disable_fullscreen_hint()
         if SPINTOPS_PACKAGE_NAME in get_current_focus_window(): return True
         wait_time -= 1
         time.sleep(1)
     raise Exception("Launch Spin-Tops time out.")
    def run_performance_test_async(self, testid):
        orientation = self.device.orientation
        self.home.performance_test.click.wait(timeout=5000)
        self.performc.clear_choose()

        self.performc.select_performance_test(testid)
        self.performc.btn_start.click()
        time.sleep(5)
        _, current_activity = common.get_current_focus_window()
        assert current_activity == self.TEST_ACTIVITY, \
            "[FAILURE] Tests failed to start"
示例#8
0
    def run_test(self, names, timeout=1800, onscreen=True, offscreen=False):
        """run test"""
        self.home.go_category_testlist()
        # self.testlist.clean_chooses()

        for each in names.split(','):
            print "[Debug] test: %s onscreen:%s offscreen:%s" % (
                each, onscreen, offscreen)
            if onscreen:
                onscreen_checkbox = self.testlist.search_item_onscreen_checkbox(
                    each)
                onscreen_checkbox.click()
            if offscreen:
                offscreen_checkbox = self.testlist.search_item_offscreen_checkbox(
                    each)
                offscreen_checkbox.click()
        # checked_count = self.device(className="android.widget.CheckBox", checked=True).count
        # assert checked_count == len(names.split(',')),\
        #     "[FAILURE] Failed Choose Test item"

        cmd = "sync; echo 3 > /proc/sys/vm/drop_caches"
        g_common_obj.adb_cmd_capture_msg(repr(cmd))

        self.testlist.btn_start.click()
        time.sleep(8)
        print "[Debug] start test: %s" % (names)
        _, current_activity = common.get_current_focus_window()
        assert current_activity == self.TEST_ACTIVITY,\
            "[FAILURE] Tests failed to start"

        start_time = time.time()
        is_completed = False
        while time.time() - start_time < timeout:
            _, current_activity = common.get_current_focus_window()
            if current_activity == self.MAIN_ACTIVITY:
                is_completed = True
                break
            time.sleep(10)
        assert is_completed,\
            "[FAILURE] Test time out: %s" % (timeout)
    def run_performance_test(self, testid, timeout=1800):
        orientation = self.device.orientation
        self.home.performance_test.click.wait(timeout=5000)
        self.performc.clear_choose()
        # print self.performc.onscreen.info['checked']
        # if onscreen != self.performc.onscreen.info['checked']:
        #     self.performc.onscreen.click()
        # if offscreen != self.performc.offscreen.info['checked']:
        #     self.performc.offscreen.click()
        #
        # for each in names.split(','):
        #     print "[Debug] performance test: %s" % (each)
        #     if self.performc.search_item(each).exists:
        #         self.performc.search_item(each).click()
        # checked_count = self.device(className="android.widget.CheckBox", checked=True).count
        #
        # assert checked_count == len(names.split(',')), \
        #     "[FAILURE] Failed Choose Test item"
        self.performc.select_performance_test(testid)
        self.performc.btn_start.click()
        time.sleep(5)
        _, current_activity = common.get_current_focus_window()
        assert current_activity == self.TEST_ACTIVITY, \
            "[FAILURE] Tests failed to start"

        # print "[Debug] start test: %s" % (names)
        start_time = time.time()
        is_completed = False
        while time.time() - start_time < timeout:
            g_common_obj.assert_exp_happens()
            _, current_activity = common.get_current_focus_window()
            if current_activity == self.RESULT_ACTIVITY:
                is_completed = True
                break
            time.sleep(10)
        self.device.orientation = orientation
        assert is_completed, \
            "[FAILURE] Test time out: %s" % (timeout)
示例#10
0
 def _run_test(self, activity='', count=1, step_time=60):
     for i in range(1, count + 1):
         print "[Debug] run_compressed_texture count:%s" % (i)
         mark_time = logcat.get_device_time_mark()
         self.launch_sub_activity(activity)
         #pid = self.get_pid()
         start_time = time.time()
         while time.time() - start_time <= step_time:
             time.sleep(1)
             _, current_activity = common.get_current_focus_window()
             assert current_activity == activity,\
                 "[FAILURE] unexpected activity %s" % (current_activity)
             self.device().click()
         g_common_obj.assert_exp_happens()
示例#11
0
 def switch_back_home_serveraltimes(self, switch_times=100):
     """ launch camera switch_times times
     """
     for i in range(1, switch_times + 1):
         print "Lanch Camera %s times" % i
         g_common_obj.adb_cmd_common(
             "shell am start -S -n com.google.android.GoogleCamera/com.android.camera.CameraActivity"
         )
         time.sleep(2)
         if self.d(text="ALLOW").exists: self.d(text="ALLOW").click.wait()
         _, ACTname = get_current_focus_window()
         if not ACTname == "com.android.camera.CameraActivity":
             g_common_obj.launch_app_am(
                 "com.android.camera2", "com.android.camera.CameraLauncher")
         self.d.press.home()
         self.d.wait.idle()
示例#12
0
    def run_test(self,
                 name,
                 timeout=900,
                 onscreen=False,
                 offscreen=False,
                 special=False,
                 others=False):
        """run test"""
        print "[Debug] test: %s onscreen:%s offscreen:%s special:%s others:%s" % (
            name, onscreen, offscreen, special, others)
        if onscreen:
            onscreen_checkbox = self.testlist.search_item_onscreen_checkbox(
                name)
            onscreen_checkbox.click.wait()
        if offscreen:
            offscreen_checkbox = self.testlist.search_item_offscreen_checkbox(
                name)
            offscreen_checkbox.click.wait()
        if special:
            special_checkbox = self.testlist.search_item_special_checkbox(name)
            special_checkbox.click.wait()
        if others:
            others_checkbox = self.testlist.search_checkbox(name)
            others_checkbox.click.wait()

        cmd = "sync; echo 3 > /proc/sys/vm/drop_caches"
        g_common_obj.adb_cmd_capture_msg(repr(cmd))

        self.testlist.btn_start.click()
        time.sleep(5)
        _, current_activity = common.get_current_focus_window()
        assert current_activity == self.TEST_ACTIVITY or current_activity ==self.LOADING_ACTIVITY,\
            "[FAILURE] Tests failed to start"

        print "[Debug] start test: %s" % (name)
        start_time = time.time()
        is_completed = False
        while time.time() - start_time < timeout:
            cmd = "ls %s*.json" % (self.RESULT_DIR)
            cmd2 = "ls %s*.json" % (self.RESULT_DIR2)
            msg = g_common_obj.adb_cmd_capture_msg(repr(cmd))
            if msg.find("No such file or directory") != -1:
                msg = g_common_obj.adb_cmd_capture_msg(repr(cmd2))
            if msg.find("No such file or directory") == -1:
                break
            time.sleep(10)
        assert msg.find("No such file or directory") == -1, "Test time out"
示例#13
0
 def launch_camera_am(self):
     g_common_obj.launch_app_am("com.android.camera2",
                                "com.android.camera.CameraLauncher")
     time.sleep(2)
     _, ACTname = get_current_focus_window()
     # if not ACTname == "com.android.camera.CameraActivity":
     #    g_common_obj.launch_app_am("com.android.camera2", "com.android.camera.CameraLauncher")
     for _ in range(0, 6):
         time.sleep(2)
         self.a.permission_allower()
         if self.d(text="NEXT").exists:
             self.d(text="NEXT").click.wait()
         if self.d(resourceId="com.android.camera2:id/ok_button").exists:
             self.d(resourceId="com.android.camera2:id/ok_button"
                    ).click.wait()
         if self.d(text="com.android.camera2:id/shutter_button").exists:
             break
示例#14
0
 def _wait_init(self, timeout=60 * 15):
     """wait app initialize"""
     start_time = time.time()
     is_completed = False
     while time.time() - start_time < timeout:
         _, current_activity = common.get_current_focus_window()
         if current_activity == self.MAIN_ACTIVITY:
             is_completed = True
             break
         if self.device(text='Accept').exists:
             self.device(text='Accept').click()
         if self.device(text='OK').exists:
             self.device(text='OK').click()
         if self.device(text='Retry').exists:
             self.device(text='Retry').click()
         time.sleep(5)
     assert is_completed,\
         "[FAILURE] Server timeout: %s" % (timeout)
示例#15
0
    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.")