def add_widgets(homescreen_test):
    kill_adb_uiautomator_block_old()
    homescreen_test.ui_operation.click_by_event("HOME")
    time.sleep(2)
    kill_adb_uiautomator_block_old()
    homescreen_test.swiping.left()
    time.sleep(3)
    wid_num = int(
        homescreen_test.device(
            className='com.android.launcher3.LauncherAppWidgetHostView').count)
    if wid_num == 6:
        pass
    else:
        while True:
            if wid_num != 6:
                homescreen_test.log.info("begin test>>>>>>>>>>>>>>>>>>>>>>")
                open_widgets(homescreen_test)
                time.sleep(1)
                drag_widgets(homescreen_test)
                time.sleep(2)
                wid_num += 1
                homescreen_test.log.info(wid_num)
                time.sleep(1)
            else:
                return False
示例#2
0
    def run_test(self):
        self.clean_app()
        self.daimler.logout(self.daimler.my_func_name(), '...')
        self.daimler.launch_app()
        self.daimler.ui_operation.wait_for_root_page("tvDaimler")
        self.daimler.logout(self.daimler.my_func_name(), 'Begin testing......')
        time.sleep(1)

        if not self.daimler.ui_operation.click_ui_button_by_text(self.item_text):
            return False
        if not self.daimler.ui_operation.wait_for_complete_by_text("AutoBots"):
            return False
        time.sleep(2)
        kill_adb_uiautomator_block_old()
        result = self.collect_result()

        self.daimler.device.screenshot("%s/result.png" % self.result_dir)
        self.daimler.logout(self.daimler.my_func_name(), "%s test finshed..." % self.daimler.app_name)
        time.sleep(5)
        kill_adb_uiautomator_block()

        if not result:
            self.daimler.logout(self.daimler.my_func_name(), "Error, NO result found......")
            return False
        else:
            return result
def run_test(log_dir, rl):
    clean_app(rl)
    rl.logout(rl.my_func_name(), '...')
    rl.launch_app()

    rl.ui_operation.wait_for_root_page("app_title")
    rl.logout(rl.my_func_name(), 'Begin testing......')
    time.sleep(1)

    if not rl.ui_operation.click_ui_button_by_text('Start'):
        return False
    if not rl.ui_operation.wait_for_complete("time", timeout=60):
        return False
    time.sleep(2)
    kill_adb_uiautomator_block_old()
    result = collect_result(log_dir, rl)

    rl.device.screenshot("%s/result.png" % log_dir)
    rl.logout(rl.my_func_name(), "%s test finshed..." % rl.app_name)
    time.sleep(5)
    kill_adb_uiautomator_block()

    if not result:
        rl.logout(rl.my_func_name(), "Error, NO result found......")
        return False
    else:
        return result
def drag_widgets(homescreen_test):
    kill_adb_uiautomator_block()
    bounds = homescreen_test.device(textContains='Month').info['bounds']
    x = int(bounds['left']) / 2 + int(bounds['right']) / 2
    y = int(bounds['top']) / 2 + int(bounds['bottom']) / 2
    kill_adb_uiautomator_block_old()
    homescreen_test.device.drag(x, y, x + x, y)
    time.sleep(3)
def run_watcher(antutu):
    antutu.logout(antutu.my_func_name(), '...')
    kill_adb_uiautomator_block_old()
    antutu.device.watcher('permissions').when(
        resourceIdMatches='.+/alertTitle$',
        text='No Permissions').click(resourceIdMatches='.+/button1$',
                                     text='OK')
    antutu.device.watchers.run()
示例#6
0
    def run_test(self, timeout=100):
        # self.clear_data()
        self.mobile_test.launch_app()
        # time.sleep(30)
        self.mobile_test.ui_operation.wait_for_root_page("ok_button")
        kill_adb_uiautomator_block_old()
        self.mobile_test.ui_operation.click_ui_button_by_resourceIdMatches(
            'ok_button')
        self.mobile_test.ui_operation.click_ui_button_by_resourceIdMatches(
            'launch_button', timeout=timeout)
        while "Extracting content" in self.mobile_test.device.dump():
            time.sleep(10)
            kill_adb_uiautomator_block_old()
            time.sleep(2)
        # 	time.sleep
        # time.sleep(60)
        if self.tr_name == "MobileXPRT_perf":
            self.mobile_test.ui_operation.click_ui_button_by_resourceIdMatches(
                'cancel_button', timeout=timeout)
            # self.mobile_test.wait_for_root_page('button_media_tests')
            if not self.mobile_test.ui_operation.click_ui_button_by_resourceIdMatches(
                    'button_media_tests', timeout=120):
                return False
        if self.tr_name == "MobileXPRT_ux":
            self.mobile_test.ui_operation.click_ui_button_by_resourceIdMatches(
                'ok_button', timeout=timeout)
            self.mobile_test.ui_operation.click_ui_button_by_resourceIdMatches(
                'done_button', timeout=timeout)
            # self.mobile_test.wait_for_root_page('button_ux_tests')
            if not self.mobile_test.ui_operation.click_ui_button_by_resourceIdMatches(
                    'button_ux_tests', timeout=120):
                return False
        kill_adb_uiautomator_block()
        kill_uiautomator()
        time.sleep(5)
        # time.sleep(400)
        if self.mobile_test.ui_operation.wait_for_complete(
                "group_score", splittime=400, timeout=500) == False:
            return False
        time.sleep(2)
        # self.tr.kill_watt_runtime()
        kill_adb_uiautomator_block()
        if not app_exception_kill_case(self.mobile_test.app_package):
            return False
        app_device = self.mobile_test.device(resourceIdMatches=".+/group_name")

        if (app_device.exists):
            right_dev = app_device.right(resourceIdMatches=".+/group_score")
            if right_dev.exists:
                self.data = str(right_dev.info['text'])
        kill_adb_uiautomator_block()

        if self.data != "" and self.data.isdigit():
            self.mobile_test.logout(self.mobile_test.my_func_name(),
                                    "Test data is %s" % self.data)
            return self.data
        return False
def run_test(antutu, tr):
    antutu.logout(antutu.my_func_name(), '...')
    result_dict = {}
    antutu.app_install()
    antutu.kill_app()
    time.sleep(1)
    antutu.launch_app()
    enable_permissions(antutu)
    if not antutu.ui_operation.wait_for_root_page('start_test_text'):
        return False
    kill_adb_uiautomator_block_old()

    if not antutu.ui_operation.click_ui_button_by_resourceIdMatches(
            'start_test_text', timeout=10, package='antutu'):
        return False
    time.sleep(3)

    if antutu.ui_operation.wait_for_complete('detail_btn',
                                             timeout=1800,
                                             package='antutu'):
        try:
            result_dict_ex = collect_result_ex(antutu, tr)
            antutu.logout(antutu.my_func_name(), str(result_dict_ex))
            for key, velue in result_dict_ex.items():
                tr.sub_score(key, velue)
            result_dict.update(result_dict_ex)
            antutu.device.screenshot("%s/result.png" % tr.result_dir)
        except Exception, e:
            antutu.logout('ERROR', 'get result total is fail,error :%s' % e)
            return False
        time.sleep(2)
        antutu.ui_operation.click_ui_button_by_resourceIdMatches(
            "detail_btn", package='antutu')
        if antutu.ui_operation.wait_for_open_spacial_function('Details - v5.6',
                                                              timeout=100):
            kill_adb_uiautomator_block_old()
            antutu.device.screenshot("%s/result.png" % tr.result_dir)

        antutu.kill_app()
        antutu.logout(antutu.my_func_name(), "%s test finished..." % app[0])
        time.sleep(5)
        if result_dict["total_score"] == "":
            antutu.logout(antutu.my_func_name(),
                          "Error, NO result found......")
            return False
        else:
            antutu.logout(
                antutu.my_func_name(),
                'Antutu total_score is %s' % result_dict["total_score"])
            for item in result_dict.keys():
                if not "total_score" == item:
                    antutu.logout(
                        antutu.my_func_name(),
                        'Antutu %s is %s' % (item, result_dict[item]))
            return result_dict
def set_settings(zooming_test):
    zooming_test.logout(zooming_test.my_func_name(), ">>>>>>Set config<<<<<<")
    kill_adb_uiautomator_block_old()
    try:
        system_operation.modify_wifi()
        system_operation.turn_bluetooth('0')
        time.sleep(2)
        kill_adb_uiautomator_block_old()
        zooming_test.ui_operation.click_by_event("HOME")
        time.sleep(1)
    except Exception, e:
        zooming_test.logout(zooming_test.my_func_name(),
                            "preload setup failed :%s" % e)
        return False
 def choose_video(self, timeout=10):
     icount = 0
     kill_adb_uiautomator_block_old()
     while icount < timeout:
         try:
             dev = self.video_test.device(
                 resourceId="com.android.gallery3d:id/gl_root_view")
             print "+++start click+++++"
             kill_adb_uiautomator_block_old()
             if dev.exists:
                 print "====click ======="
                 kill_adb_uiautomator_block_old()
                 dev.click()
             else:
                 break
             time.sleep(2)
             kill_adb_uiautomator_block_old()
             self.video_test.device(
                 resourceId="com.android.gallery3d:id/gl_root_view").click(
                 )
             return True
         except Exception, e:
             self.video_fps_test.logout(self.video_fps_test.my_func_name(),
                                        "choose video is error:%s" % e)
             return False
         icount += 1
         time.sleep(1)
示例#10
0
    def turn_airplane(self):
        if self.state == self.get_state('airplane_mode_on'):
            print('airplane already turned ' + self.state)
            return True

        for i in range(4):
            os.system(
                'adb shell am start -a android.settings.AIRPLANE_MODE_SETTINGS'
            )
            kill_adb_uiautomator_block_old()
            self.device(text="Airplane mode").click.wait()
            time.sleep(1)
            os.system('adb shell am force-stop com.android.settings')
            if self.state == self.get_state('airplane_mode_on'):
                return True
        return False
def enable_permissions(antutu, antutu3d):
    antutu.logout(antutu.my_func_name(), '...')
    kill_adb_uiautomator_block()
    antutu.ui_operation.click_ui_button_by_text('Permissions')
    if antutu.device(resourceId='com.antutu.ABenchMark:id/info').exists:
        antutu.device(resourceId="com.antutu.ABenchMark:id/btn_close").click()
    list_text = ['Camera', 'Location', 'Phone', 'Storage']
    time.sleep(3)
    for item in list_text:
        kill_adb_uiautomator_block()
        if antutu.device(text=item).right(text='OFF').exists:
            kill_adb_uiautomator_block()
            antutu.device(text=item).right(text='OFF').click()
    kill_adb_uiautomator_block_old()
    antutu.ui_operation.click_by_event("BACK")
    kill_adb_uiautomator_block_old()
    antutu.ui_operation.click_by_event("BACK")
def run_test(panning_fps_test, panning_test, log):
    push_html()
    clean_app(panning_test)
    panning_test.skip_chrome_wizard()
    panning_test.launch_chrome_with_page("permission_allow_button")
    time.sleep(3)
    kill_adb_uiautomator_block_old()
    kill_uiautomator()
    panning_fps_test.doInThread(down_up, panning_test, 50)
    time.sleep(2)
    panning_fps_test.doInThread(panning_fps_test.run_fpstool_ext, log)
    if not panning_test.ui_operation.wait_for_compelet_for_fps(timeout=60):
        return False
    avg_fps = panning_fps_test.collect_result(log)
    panning_fps_test.kill_fps_tools()
    panning_test.kill_app()
    panning_test.logout(panning_test.my_func_name(), "Frame rate while panning web page in Browser- average:%s"%avg_fps)
    return avg_fps
示例#13
0
 def run_test(self, log):
     self.Prepare_data()
     self.set_gallery()
     time.sleep(1)
     self.gallery_fps_test.doInThread(self.swiping_action)
     time.sleep(3)
     self.gallery_fps_test.doInThread(self.gallery_fps_test.run_fpstool, log)
     self.gallery_test.ui_operation.wait_for_compelet_for_fps(timeout=80)
     avg_fps = self.gallery_fps_test.collect_result(log)
     self.gallery_fps_test.kill_fps_tools()
     print avg_fps
     if avg_fps < 1.0:
         return False
     time.sleep(2)
     kill_adb_uiautomator_block_old()
     self.gallery_test.ui_operation.click_by_event("HOME")
     self.gallery_test.kill_app()
     self.gallery_test.logout(self.gallery_test.my_func_name(), "Flinging_image_list_in_gallery result is:%s" % avg_fps)
     return avg_fps
示例#14
0
def main():
    tr = TestResult(sys.argv)
    watt_operat = watt_operate(tr.output_path, tr.current_loop)
    set_settings()
    prepare_data()
    log_dir = tr.result_dir
    if not os.path.exists(log_dir):
        os.mkdir(log_dir)
    log = log_dir + "/result.txt"
    result = run_test(log, watt_operat)
    if result == '':
        logger.error("stream_Triad value not found")
        return False
    logger.info("Stream_Triad value is:" + str(result))
    time.sleep(5)
    kill_adb_uiautomator_block_old()
    time.sleep(1)
    tr.result('Stream_Triad_Rate', result, 'MB/s')
    tr.save()
    time.sleep(10)
def main(test_mode):
    tr = TestResult(sys.argv)
    test_mode.logout(test_mode.my_func_name(), CUR_DIR)
    if not os.path.exists(os.path.join(CUR_DIR, './'+out_dir+'/')):
        os.mkdir(os.path.join(CUR_DIR, './'+out_dir+'/'))
    kill_adb_uiautomator_block_old()
    test_mode.device.watcher("google_accept").when(text="ACCEPT").click()
    test_mode.ui_operation.click_by_event("MENU")
    kill_adb_uiautomator_block_old()
    time.sleep(1)
    test_mode.ui_operation.click_by_event("HOME")
    time.sleep(1)
    kill_adb_uiautomator_block_old()
    system_operation.connect_wifi(test_mode.log)
    time.sleep(10)
    if run_test(test_mode, tr) == False:
        clean_app(test_mode)
        return False
    test_mode.ui_operation.click_ui_button_by_text_or_resid('Always show')
    try :
        result=test_mode.device(resourceId="com.android.chrome:id/url_bar").text.split("/")[1]
    except Exception, e:
        test_mode.logout(test_mode.my_func_name(), "get result error%s"%e)
        clean_app(test_mode)
        return False
def run_test(log_dir, rl):
    build_info = os.popen(
        'adb shell getprop |grep system.build.fingerprint').read()
    build_version = re.findall('gordon_peak:([A-Za-z])/', build_info)
    clean_app(rl)
    rl.logout(rl.my_func_name(), '...')
    rl.launch_app()
    if build_version and build_version[0] == 'Q':
        rl.ui_operation.click_ui_button_by_text("OK", skip_utiliy=True)
        time.sleep(1)

    if rl.ui_operation.wait_for_open_spacial_function('RL Benchmark: SQLite',
                                                      timeout=10):
        rl.ui_operation.click(852, 606)
        # rl.ui_operation.click_ui_button_by_resourceIdMatches("button1")

    rl.ui_operation.wait_for_root_page("app_title")
    rl.logout(rl.my_func_name(), 'Begin testing......')
    time.sleep(1)

    if not rl.ui_operation.click_ui_button_by_text('Start'):
        return False
    if not rl.ui_operation.wait_for_complete("time", timeout=60):
        return False
    time.sleep(2)
    kill_adb_uiautomator_block_old()
    result = collect_result(log_dir, rl)

    rl.device.screenshot("%s/result.png" % log_dir)
    rl.logout(rl.my_func_name(), "%s test finshed..." % rl.app_name)
    clean_app(rl)
    time.sleep(5)
    kill_adb_uiautomator_block()

    if not result:
        rl.logout(rl.my_func_name(), "Error, NO result found......")
        return False
    else:
        return result
示例#17
0
def main(tr):
    kill_adb_uiautomator_block_old()
    if dmark.command_timeout("adb wait-for-device", timeout=10):
        os.system("adb root")
        time.sleep(1)
        system_operation.screen_on()
        time.sleep(1)
        try:
            system_operation.turn_airplane('1')
            system_operation.turn_bluetooth('0')
            system_operation.turn_wifi('0')
            system_operation.turn_gps('0')
            system_operation.set_display_time()
        except Exception, e:
            dmark.logout(dmark.my_func_name(), 'preload failse %s' % e)
            return False
        time.sleep(2)

        log_dir = os.path.join(tr.result_dir)
        if not os.path.exists(log_dir):
            os.mkdir(log_dir)
        results = run_test(log_dir, tr)
        if not results:
            return False

        d_result = {
            'total_score': results[0],
            'physics_test': results[1],
            'physics_score': results[2],
            'graphics_score': results[3],
            'graphics_test1': results[4],
            'g raphics_test2': results[5]
        }
        rj = open("%sresult.json" % log_dir, 'w+')
        cpu_watt = dmark.ui_operation.watt_operate.get_watt_average()
        if not cpu_watt == False:
            d_result['cpu_watt'] = cpu_watt
        rj.write(json.dumps(d_result))
        rj.close()
示例#18
0
def main(test_mode):
    kill_adb_uiautomator_block_old()
    test_mode.device.watcher("google_accept").when(text="Accept").click()
    test_mode.ui_operation.click_by_event("MENU")
    kill_adb_uiautomator_block_old()
    time.sleep(1)
    test_mode.ui_operation.click_by_event("HOME")
    kill_adb_uiautomator_block_old()
    system_operation.connect_wifi(test_mode.log)

    if not run_test(test_mode, tr):
        clean_app(test_mode)
        return False
    test_mode.ui_operation.click_ui_button_by_text_or_resid('Always show')
    try:
        result = test_mode.device(
            resourceId="com.android.chrome:id/url_bar").text.split("/")[1]
    except Exception, e:
        test_mode.logout(test_mode.my_func_name(), "get result error%s" % e)
        clean_app(test_mode)
        return False
def enable_permissions(antutu):
    kill_adb_uiautomator_block_old()
    antutu.logout(antutu.my_func_name(), '...')
    back_times = 0
    if antutu.ui_operation.wait_for_open_spacial_function('Enable 64-bit',
                                                          timeout=10):
        time.sleep(1)
        antutu.ui_operation.click_ui_button_by_resourceIdMatches("btn_ok")
        back_times += 1
    if antutu.ui_operation.wait_for_open_spacial_function('AnTuTu Benchmark',
                                                          timeout=10):
        time.sleep(1)
        antutu.ui_operation.click_ui_button_by_resourceIdMatches(
            "button1", package='antutu')
    if antutu.ui_operation.wait_for_open_spacial_function(
            'Install unknown apps', timeout=10):
        back_times += 1
        time.sleep(1)
        antutu.ui_operation.click_ui_button_by_resourceIdMatches(
            "switch_widget", package='antutu')
        time.sleep(2)
        antutu.ui_operation.click_by_event("BACK")
        back_times -= 1
    if antutu.ui_operation.wait_for_open_spacial_function(
            'AnTuTu Benchmark 64-bit', timeout=10):
        print "find -- AnTuTu Benchmark 64-bit"
        time.sleep(2)
        antutu.ui_operation.click(1872, 933)  # click(ok_button)
        time.sleep(3)
    if antutu.ui_operation.wait_for_open_spacial_function('App insttalled',
                                                          timeout=10):
        print "find -- App insttalled"
        time.sleep(2)
        antutu.ui_operation.click(1816, 933)  # click(done_button)
        time.sleep(3)

    kill_adb_uiautomator_block_old()
    for i in range(back_times):
        antutu.ui_operation.click_by_event("BACK")
        kill_adb_uiautomator_block_old()
def clean_app(antutu):
    kill_adb_uiautomator_block_old()
 if button_operation(andebench, tr) == False:
     return False
 time.sleep(5)
 if andebench.ui_operation.watt_operate.watt_flags:
     andebench.ui_operation.watt_operate.start_watt()
 iconut = 0
 while iconut < timeout:
     if not app_exception_kill_case(andebench.app_package):
         if andebench.ui_operation.watt_operate.watt_flags:
             andebench.ui_operation.watt_operate.stop_watt()
         return False
     app_device = andebench.device(resourceIdMatches='.+/cid$')
     if app_device.exists and (re.search(r'.+\n.+: \d+\n.+: \d+\n',
                                         app_device.info['text'],
                                         re.I | re.M)):
         kill_adb_uiautomator_block_old()
         iconut = 0
         if andebench.ui_operation.watt_operate.watt_flags:
             andebench.ui_operation.watt_operate.stop_watt()
             try:
                 andebench.ui_operation.watt_operate.watt_result_treat(
                     ABS=30)
             except Exception, e:
                 andebench.logout(andebench.my_func_name(),
                                  "watt_operate error %s." % e)
                 return False
         break
     iconut += 1
     time.sleep(5)
     kill_adb_uiautomator_block()
 if not iconut == 0:
def clean_app(rl):
    rl.kill_app()
    rl.clear_app_data()
    kill_adb_uiautomator_block_old()
示例#23
0
 def clean_app(self):
     self.daimler.kill_app()
     self.daimler.clear_app_data()
     kill_adb_uiautomator_block_old()
示例#24
0
def run_test(zooming_fps_test, zooming_test, log, timeout=10):
    kill_adb_uiautomator_block_old()
    time.sleep(3)
    zooming_test.launch_app()
    time.sleep(3)
    kill_adb_uiautomator_block_old()
    zooming_test.ui_operation.click_ui_button_by_text("SKIP")
    time.sleep(2)
    kill_adb_uiautomator_block_old()
    disable_google(zooming_test, 'ok')
    kill_adb_uiautomator_block_old()
    zooming_test.ui_operation.click_ui_button_by_text("GOT IT")
    time.sleep(5)
    kill_adb_uiautomator_block_old()
    try:
        zooming_test.device(className="android.widget.ImageView",
                            instance=5).click.wait(timeout=50)
        time.sleep(3)
        kill_adb_uiautomator_block_old()
        disable_google(zooming_test, 'ok')
        time.sleep(3)
        kill_adb_uiautomator_block_old()
        disable_google(zooming_test, 'accept')
    except Exception, e:
        zooming_test.logout(zooming_test.my_func_name(),
                            "click android.widget.ImageView error")
        return False
示例#25
0
def swiping_action():
    kill_adb_uiautomator_block_old()
    os.system("adb root")
    time.sleep(1)
    event = eventHunter()
    event.test_zooming(repeat_zoom=5)
示例#26
0
 def swiping_action(self):
     kill_adb_uiautomator_block_old()
     os.system("adb root")
     time.sleep(1)
     leftright = eventHunter(self.gallery_test.device)
     leftright.center_left(repeat_swipes=3, cltimes=30, clstep=0)