def main(self, tr): kill_adb_uiautomator_block() try: system_operation.screen_on() time.sleep(1) system_operation.turn_airplane('1') system_operation.turn_bluetooth_p('0') system_operation.turn_wifi('0') system_operation.turn_gps('0') system_operation.set_display_time() except Exception: self.mobile_test.logout(self.mobile_test.my_func_name(), "Error setup load......") return False time.sleep(2) log_dir = tr.result_dir if not os.path.exists(log_dir): os.mkdir(log_dir) result = self.test_jio(log_dir) if not result: return False else: for key, velue in result.items(): tr.sub_score(key, velue) tr.result(result["rr_score"]) tr.add_attachment(log_dir + "/result.png") tr.save()
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 main(antutu, antutu3d, tr): kill_adb_uiautomator_block() if antutu.command_timeout("adb wait-for-device", timeout=10): os.system("adb root") antutu.check_system_app_package("com.antutu.ABenchMark") system_operation.screen_on() time.sleep(1) system_operation.turn_bluetooth('0') system_operation.turn_wifi('0') time.sleep(2) results = run_test(antutu, antutu3d, tr) if not results: antutu.logout(antutu.my_func_name(), "Error, run test result get error......") return False if len(results['total_score']) == 0: antutu.logout( antutu.my_func_name(), "Error, run test result get total score error......") return False rj = open("%s/result.json" % tr.result_dir, 'w+') rj.write(json.dumps(results)) rj.close() else: antutu.logout(antutu.my_func_name(), "Timeout to wait for device,device is disconnect.") return False tr.result(results["total_score"]) tr.add_attachment(tr.result_dir + "/result.json") tr.add_attachment(tr.result_dir + "/result.png") tr.save() clean_app(antutu, antutu3d) return True
def run_test(log, ui_operat, logs): kill_adb_uiautomator_block() logs.info(">>>>>>>>Begin_test<<<<<<<<") try: time.sleep(2) command = "adb shell /data/perf bench sched messaging -g 64 >" kill_adb_uiautomator_block() os.system(command + log) logs.info(command + log) if ui_operat.watt_operate.watt_flags: ui_operat.watt_operate.start_watt() time.sleep(5) result = collect_result(log, logs) if ui_operat.watt_operate.watt_flags: ui_operat.watt_operate.stop_watt() try: ui_operat.watt_operate.watt_result_treat() except Exception, e: logs.error("watt_operate error %s." % e) return False if not result: logs.error("No result data,test failed!!!!!!") return False else: return result
def run_test(log, ui_operat, logs): kill_adb_uiautomator_block() logs.info(">>>>>>>>Begin_test<<<<<<<<") try: time.sleep(2) command = "adb shell /data/sysbench --test=cpu --cpu-max-prime=20000 --num-threads=32 run >" kill_adb_uiautomator_block() os.system(command+log) logs.info(command+log) if ui_operat.watt_operate.watt_flags: ui_operat.watt_operate.start_watt() time.sleep(6) result = collect_result(log, logs) if ui_operat.watt_operate.watt_flags: ui_operat.watt_operate.stop_watt() try: ui_operat.watt_operate.watt_result_treat() except Exception, e: logs.error("watt_operate error %s." % e) return False if not result: logs.error("No result data,test failed!!!!!!") return False else: return result
def run_test(self, log): self.video_test.logout(self.video_test.my_func_name(), ">>>>>>>> Start video test <<<<<<<< ") self.video_test.clear_app_data() self.video_test.launch_app() time.sleep(2) print "lunch......" time.sleep(2) if not self.choose_video(): return 0 time.sleep(25) self.video_fps_test.doInThread(self.video_fps_test.run_fpstool, log) duration = 20 while duration > 0: if utiliy.is_app_runing(self.app_package): self.video_test.logout( self.video_test.my_func_name(), "\r>>>Please wait for test complete ... %s(s)" % duration) duration -= 10 time.sleep(10) else: self.video_fps_test.kill_fps_tools() return 0 avg_fps = self.video_fps_test.collect_result(log) self.video_fps_test.logout( self.video_fps_test.my_func_name(), "%s result is:%s" % (self.test_case, avg_fps)) self.video_fps_test.kill_fps_tools() kill_adb_uiautomator_block() return avg_fps
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 long_click(homescreen_test, app_no): kill_adb_uiautomator_block() bounds = homescreen_test.device(resourceIdMatches='.+/icon', index=app_no).info['bounds'] x = int(bounds['left']) / 2 + int(bounds['right']) / 2 y = int(bounds['top']) / 2 + int(bounds['bottom']) / 2 kill_adb_uiautomator_block() homescreen_test.device.swipe(x, y, x - 20, y - 20)
def run_test(antutu, antutu3d, tr): build_info = os.popen( 'adb shell getprop |grep system.build.fingerprint').read() build_version = re.findall('gordon_peak:([0-9.]+)/', build_info) antutu.logout(antutu.my_func_name(), '...') antutu.app_install() antutu3d.app_install() antutu3d.kill_app() antutu.kill_app() antutu3d.clear_app_data() antutu.clear_app_data() time.sleep(1) antutu.launch_app() if build_version and build_version[0] == '10': antutu.ui_operation.click_ui_button_by_text("CONTINUE", skip_utiliy=True) time.sleep(2) antutu.ui_operation.click_ui_button_by_text("OK", skip_utiliy=True) time.sleep(2) antutu.ui_operation.wait_for_root_page('fl_bg') kill_adb_uiautomator_block() antutu.ui_operation.click_ui_button_by_resourceIdMatches('start_test_text') time.sleep(3) antutu.ui_operation.click_ui_button_by_text("CONTINUE", skip_utiliy=True) time.sleep(2) antutu.ui_operation.click_ui_button_by_text("OK", skip_utiliy=True) run_watcher(antutu) time.sleep(3) if antutu.device.watcher('permissions').triggered: enable_permissions(antutu, antutu3d) antutu.ui_operation.wait_for_root_page('fl_bg') kill_adb_uiautomator_block() antutu.ui_operation.click_ui_button_by_resourceIdMatches( 'start_test_text') if antutu3d.ui_operation.wait_for_complete( 'tv_score') or antutu.ui_operation.wait_for_complete('tv_score'): time.sleep(2) try: lines = antutu.device.dump() with open("score_antutu.xml", 'wb+') as fp: fp.write(lines) except Exception, e: antutu.logout(antutu.my_func_name(), "test error %s" % e) return False time.sleep(2) antutu.device.screenshot("%s/result.png" % tr.result_dir) result_dict = parse_xml_data("score_antutu.xml", antutu) for key, velue in result_dict.items(): tr.sub_score(key, velue) 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: return result_dict
def main(tr, panning_fps_test, panning_test): kill_adb_uiautomator_block() try: system_operation.turn_bluetooth('0') system_operation.turn_wifi('1') except Exception, e: panning_test.log.error("exception error :%s !!!!" % e) return False
def main(self, tr): kill_adb_uiautomator_block() system_operation.screen_on() time.sleep(1) try: system_operation.turn_bluetooth('0') system_operation.turn_wifi('0') except Exception, e: self.mobile_test.logout(self.mobile_test.my_func_name(), "preload setup is error %s" % e) return False
def main(rl, tr): rl.logout(rl.my_func_name(), '...') kill_adb_uiautomator_block() try: system_operation.turn_bluetooth('0') system_operation.turn_wifi('0') except Exception, e: rl.logout(rl.my_func_name(), "Setup Failure. %s" % e) return False
def main(tr, panning_fps_test, panning_test): kill_adb_uiautomator_block() try: system_operation.turn_airplane('1') system_operation.turn_bluetooth_p('0') system_operation.turn_wifi('1') system_operation.turn_gps('0') system_operation.set_display_time() except Exception,e: panning_test.log.error("exception error :%s !!!!"%e) return False
def main(self): self.daimler.logout(self.daimler.my_func_name(), '...') try: kill_adb_uiautomator_block() # system_operation.set_display_time() system_operation.turn_airplane('1') system_operation.turn_bluetooth_p('0') system_operation.turn_wifi('0') system_operation.turn_gps('0') except Exception, e: self.daimler.logout(self.daimler.my_func_name(), "Setup Failure. %s" % e) return False
def collect_result(log, logs): kill_adb_uiautomator_block() logs.info(">>>>>>>>Collect_result<<<<<<<<") time.sleep(2) with open(log) as tfp: total_time = tfp.readlines() try: result = total_time[4].strip().split()[2] result = round(float(result), 2) except Exception, e: logs.error("result file open error %s" % e) return False
def collect_result(self): try: kill_adb_uiautomator_block() fps_score = self.mobile_test.device(text=self.test_text).right( resourceIdMatches=".+/textViewFps$").info['text'] if fps_score == "": return False return fps_score except Exception, e: self.mobile_test.logout(self.mobile_test.my_func_name(), "get collect result is error: %s " % e) return False
def main(self, tr): kill_adb_uiautomator_block() try: system_operation.screen_on() time.sleep(1) 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: self.mobile_test.logout(self.mobile_test.my_func_name(), "Error setup load......") return False
def set_settings(): logger.info(">>>>>>Setup settings<<<<<<") time.sleep(2) kill_adb_uiautomator_block() try: os.system("adb root") system_operation.turn_wifi('0') system_operation.turn_bluetooth('0') time.sleep(1) os.system("adb root") time.sleep(2) except Exception, e: logger.error("set_settings error") return False
def button_operation(andebench, tr): try: andebench.ui_operation.click_by_event("MENU") kill_adb_uiautomator_block() andebench.ui_operation.click_ui_button_by_text('Settings') kill_adb_uiautomator_block() andebench.ui_operation.click_by_event("BACK") kill_adb_uiautomator_block() andebench.ui_operation.click_ui_button_by_text('Reset') kill_adb_uiautomator_block() andebench.ui_operation.click_by_event("BACK") kill_adb_uiautomator_block() andebench.ui_operation.click_ui_button_by_resourceIdMatches('btn_start_on') except Exception, e: andebench.logout(andebench.my_func_name(),"button operation is error,error code is %s"%e) return False
def main(zooming_fps_test, zooming_test): tr = TestResult(sys.argv) if not set_settings(zooming_test): return False log_dir = tr.result_dir if not os.path.exists(log_dir): os.mkdir(log_dir) log = log_dir + "result.txt" result = run_test(zooming_fps_test, zooming_test, log) if not result: zooming_fps_test.kill_fps_tools() return False tr.result('Fps_while_zooming_in_map', result, 'fps') tr.save() kill_adb_uiautomator_block() zooming_test.device.watchers.remove()
def main(self): kill_adb_uiautomator_block() time.sleep(1) try: system_operation.turn_bluetooth('0') system_operation.turn_wifi('0') except Exception: return False time.sleep(2) result = self.run_test() if not result: return False print result self.result = result return True
def main(self, tr): self.mobile_test.logout(self.mobile_test.my_func_name(), '...') self.check_corporate() time.sleep(2) kill_adb_uiautomator_block() time.sleep(1) system_operation.screen_on() time.sleep(1) try: system_operation.turn_airplane('1') system_operation.turn_bluetooth_p('0') system_operation.turn_wifi('0') system_operation.turn_gps('0') system_operation.set_display_time() except Exception, e: self.mobile_test.logout(self.mobile_test.my_func_name(), "preload setup is error %s" % e) return False
def run_test(self, log): self.Prepare_data() if not self.choose_video(): return False time.sleep(2) self.video_fps_test.doInThread(self.video_fps_test.run_fpstool, log) if not self.video_test.ui_operation.wait_for_compelet_for_fps(40): return False avg_fps = self.video_fps_test.collect_result(log) self.video_fps_test.kill_fps_tools() if avg_fps < 20.0: return False time.sleep(2) kill_adb_uiautomator_block() self.video_fps_test.logout( self.video_fps_test.my_func_name(), "%s result is:%s" % (self.test_case, avg_fps)) return avg_fps
def run_test(homescreen_fpstest, homescreen_test, log): kill_adb_uiautomator_block() add_icon(homescreen_test) add_widgets(homescreen_test) time.sleep(3) homescreen_fpstest.doInThread(left_right, homescreen_test) time.sleep(3) homescreen_fpstest.doInThread(homescreen_fpstest.run_fpstool_ext, log) if not homescreen_test.ui_operation.wait_for_compelet_for_fps(timeout=60): return False avg_fps = homescreen_fpstest.collect_result(log) homescreen_fpstest.kill_fps_tools() if avg_fps < 1.0: return False homescreen_fpstest.logout( homescreen_fpstest.my_func_name(), "Frame rate of Home screen flicking result is:%s" % avg_fps) return avg_fps
def select_item(self, timeout=5): self.mobile_test.logout(self.mobile_test.my_func_name(), '...') kill_adb_uiautomator_block() texts = self.item_text.split('#') if len(texts) > 1: item_dev = self.mobile_test.device( className="android.widget.LinearLayout").child( text=texts[0]).sibling(textContains=texts[1]) else: item_dev = self.mobile_test.device( className="android.widget.LinearLayout").child(text=texts[0]) if item_dev.exists: item_dev.click() return True else: self.mobile_test.logout(self.mobile_test.my_func_name(), "select_item failed.....") return False
def main(antutu, tr): kill_adb_uiautomator_block() if antutu.command_timeout("adb wait-for-device", timeout=10): antutu.check_system_app_package("antutu") time.sleep(3) os.system("adb root") system_operation.screen_on() time.sleep(2) results = run_test(antutu, tr) if not results: antutu.logout(antutu.my_func_name(), "Error, run test result get error......") return False if len(results['total_score']) == 0: antutu.logout( antutu.my_func_name(), "Error, run test result get total score error......") return False rj = open("%s/result.json" % tr.result_dir, 'w+') rj.write(json.dumps(results)) rj.close() else: antutu.logout(antutu.my_func_name(), "Timeout to wait for device,device is disconnect.") raise Exception("Device is disconnect...") return False tr.result(results['total_score']) tr.add_attachment(os.path.join(tr.result_dir, 'antutu.txt'), 'antutu.txt') tr.add_attachment(os.path.join(tr.result_dir, "result.png")) for file in os.listdir(tr.result_dir): if not file.endswith('.zip'): target_file = file + '.zip' f = zipfile.ZipFile(os.path.join(tr.result_dir, target_file), 'w', zipfile.ZIP_DEFLATED) f.write(os.path.join(tr.result_dir, file), file) f.close() tr.add_attachment(os.path.join(tr.result_dir, target_file)) tr.save() return True
def main(self): kill_adb_uiautomator_block() self.mobile_test.check_system_app_package("glbenchmark27.corporate") system_operation.screen_on() time.sleep(1) try: system_operation.turn_bluetooth('0') system_operation.turn_wifi('0') except Exception: return False time.sleep(2) result = self.run_test() if not result: return False self.mobile_test.logout(self.mobile_test.my_func_name(), "Test result is : %s" % result) self.result = result self.mobile_test.app_uninstall() return True
def prepare_data(ui_operat, log): kill_adb_uiautomator_block() log.info(">>>>>>>>Push data to DUT<<<<<<<<") try: time.sleep(2) os.system("adb root") time.sleep(2) src_file1 = "./src/cpufreq-bench" src_file2 = "./src/perf" src_file3 = "./src/sysbench" ui_operat.push_data(src_file1, '/data/') ui_operat.push_data(src_file2, '/data/') ui_operat.push_data(src_file3, '/data/') os.system("adb shell chmod 777 /data/cpufreq-bench") os.system("adb shell chmod 777 /data/perf") os.system("adb shell chmod 777 /data/sysbench") except Exception, e: log.info("prepare_data error: " + e.message) return False
def run_test(self, log_dir): self.clear_data() self.mobile_test.logout(self.mobile_test.my_func_name(), '...') time.sleep(1) self.mobile_test.launch_app() time.sleep(2) self.mobile_test.ui_operation.wait_for_root_page("listView1") time.sleep(2) kill_adb_uiautomator_block() self.mobile_test.ui_operation.click_ui_button_by_text( "Performance Tests") time.sleep(1) self.mobile_test.logout(self.mobile_test.my_func_name(), 'Select test item...') kill_adb_uiautomator_block() time.sleep(1) try: self.mobile_test.device(scrollable=True).scroll.to( text=self.test_text) kill_adb_uiautomator_block() self.mobile_test.device(text=self.test_text).right( className="android.widget.CheckBox").click.wait() except Exception, e: self.mobile_test.logout(self.mobile_test.my_func_name(), "scroll click error: %s " % e) return False