def wait_for_complete_ex(self, complete_text, timeout=1800): i = 0 failed_time = 0 self.logout(self.my_func_name(), "%s test waiting..." % self.app_package) kill_adb_uiautomator_block() while i < timeout: unclock_android_o_screen() if self.device(resourceId="%s" % complete_text).exists: return True else: i += 5 kill_adb_uiautomator_block() time.sleep(5) if not utiliy.is_app_runing(self.app_package): if failed_time > 2: self.logout(self.my_func_name(), "%s test is failed..." % self.app_package) return False failed_time += 1 continue sys.stdout.write("\r>>>Please wait for test complete. %s (s)" % i) sys.stdout.flush() failed_time = 0 else: self.logout(self.my_func_name(), "Timeout for %s test" % self.app_name) return False
def wait_for_open_spacial_function(self, sp_text="", resourceIdMatches_txt="", timeout=600): failed_time = 0 self.logout(self.my_func_name(), "Wait for %s spacial function." % self.app_package) for i in range(timeout): unclock_android_o_screen() if i % 5 == 0: kill_adb_uiautomator_block() if resourceIdMatches_txt == "": if self.device(text=sp_text).exists: return True else: if self.device(resourceIdMatches=".+/%s$" % resourceIdMatches_txt).exists: return True i += 1 time.sleep(1) if not app_exception_kill_case(self.app_package): if failed_time > 6: self.logout(self.my_func_name(), "%s test is failed..." % self.app_package) return False failed_time += 1 continue failed_time = 0 return False
def wait_for_complete(self, complete_text, timeout=600, splittime=5, package=''): i = 0 failed_time = 0 if not splittime == 5: time.sleep(splittime) kill_adb_uiautomator_block_old() while i < timeout: unclock_android_o_screen() kill_adb_uiautomator_block() if package == '' and not utiliy.is_app_runing(self.app_package): if failed_time > 2: return False failed_time += 1 continue app_dev = self.device(resourceIdMatches=".+/%s$" % complete_text) if app_dev: if app_dev.exists: self.logout(self.my_func_name(), "%s test finshed..." % self.app_name) return True else: i += 5 time.sleep(5) self.logout(self.my_func_name(), "\r>>>Please wait for test complete. %s (s)" % i) failed_time = 0 else: self.logout(self.my_func_name(), "Timeout for %s test" % self.app_package) return False
def get_screen_orientation(log_mes): kill_adb_uiautomator_block() os.system("adb root") time.sleep(1) orientation_st = device.orientation log_mes.info("the screen display orientation is %s" % orientation_st) kill_adb_uiautomator_block() return orientation_st.lstrip().strip()
def screen_on(log_mes): time.sleep(5) kill_adb_uiautomator_block() if device.screen == "off": log_mes.info("unlock screen...") kill_adb_uiautomator_block_old() device.wakeup() #os.system("adb shell input keyevent 82") time.sleep(1) else: log_mes.info("Screen On.")
def screen_on(): if build_version and build_version[0] == '10': os.system("adb shell svc power stayon true") else: time.sleep(5) kill_adb_uiautomator_block() if device.screen == "off": logger.info("unlock screen...") kill_adb_uiautomator_block_old() device.wakeup() time.sleep(1) else: logger.info("Screen On.")
def wait_for_complete(self, complete_text, timeout=1800, splittime=5, ABS=30, skipstep=30, package=''): i = 0 failed_time = 0 if self.watt_operate.watt_flags: self.watt_operate.start_watt() if not splittime == 5: time.sleep(splittime) kill_adb_uiautomator_block_old() while i < timeout: unclock_android_o_screen() kill_adb_uiautomator_block() if package == '' and not app_exception_kill_case(self.app_package): if failed_time > 2: if self.watt_operate.watt_flags: self.watt_operate.stop_watt() return False failed_time += 1 continue app_dev = self.device(resourceIdMatches=".+/%s$" % complete_text) if app_dev: if app_dev.exists: print self.logout(self.my_func_name(), "%s test finshed..." % self.app_name) if self.watt_operate.watt_flags: self.watt_operate.stop_watt() try: self.watt_operate.watt_result_treat(ABS) except Exception, e: self.logout(self.my_func_name(), "watt_operate error %s." % e) return False return True else: i += skipstep time.sleep(skipstep) self.logout(self.my_func_name(), "\r>>>Please wait for test complete. %s (s)" % i) failed_time = 0
def wait_for_complete_ex(self, complete_text, timeout=1800, ABS=30): i = 0 failed_time = 0 self.logout(self.my_func_name(), "%s test waiting..." % self.app_package) kill_adb_uiautomator_block() if self.watt_operate.watt_flags: self.watt_operate.start_watt() while i < timeout: unclock_android_o_screen() if self.device(resourceId="%s" % complete_text).exists: print self.logout(self.my_func_name(), "%s test finshed..." % self.app_package) if self.watt_operate.watt_flags: self.watt_operate.stop_watt() try: self.watt_operate.watt_result_treat(ABS) except Exception, e: self.logout(self.my_func_name(), "watt_operate error %s." % e) return False return True else: i += 5 kill_adb_uiautomator_block() time.sleep(5) if not app_exception_kill_case(self.app_package): if failed_time > 2: self.logout(self.my_func_name(), "%s test is failed..." % self.app_package) if self.watt_operate.watt_flags: self.watt_operate.stop_watt() return False failed_time += 1 continue sys.stdout.write("\r>>>Please wait for test complete. %s (s)" % i) sys.stdout.flush() failed_time = 0
def set_display_orientaion(set_orientation, log_mes): log_mes.info("the screen display set_orientation is %s" % set_orientation) orientation_st = get_screen_orientation(log_mes) if not set_orientation is orientation_st: device.orientation = set_orientation kill_adb_uiautomator_block()
def set_display_orientaion(set_orientation): logger.info("the screen display set_orientation is %s" % set_orientation) orientation_st = get_screen_orientation() if set_orientation is not orientation_st: device.orientation = set_orientation kill_adb_uiautomator_block()