def set_up(self): # set vlife theme theme.set_device_theme(self.uid, self.name) self.robot.reboot() sleep(120) # clear background app self.launch.start()
def test_vlife_theme(self): logger.debug(u'TestCase: 下载并应用主题') self.case_id = '130' theme.set_device_theme(DEVICENAME, 'VLIFE') result = self.unlock_screen() self.assertEqual(False, result)
def set_up(self): # set vlife theme theme.set_device_theme(self.uid, self.name) state = self.robot.get_display_state() if state: self.robot.send_keyevent(26) sleep(30) self.launch.start()
def test_vlife_system_switch(self): logger.debug(u'TestCase:不同引擎间多次切换') self.case_id = '132' theme.set_device_theme(DEVICENAME, 'VLIFE') result = self.unlock_screen() self.assertEqual(False, result) theme.set_device_theme(DEVICENAME, 'SYSTEM') result = self.unlock_screen() self.assertEqual(False, result)
def test_third_party_theme(self): logger.debug(u'TestCase:解锁到三方应用') self.case_id = '133' theme.set_device_theme(DEVICENAME, 'VLIFE') # access to the third party of app custom_app = device_config.getValue(DEVICENAME, 'custom_third_app') DEVICE.start_application(custom_app) sleep(2) result = self.unlock_screen() self.assertEqual(False, result) DEVICE.screenshot(self._testMethodName, self.log_path)
def set_up(self): # set vlife theme theme.set_device_theme(self.uid, 'VLIFE') state = self.robot.get_display_state() if state: self.robot.send_keyevent(26) sleep(30) # screen on and unlock screen myaction = action.DeviceAction(self.uid) myaction.unlock_screen('DEFAULT') sleep(1) self.launch.start()
def test_multiple_vlife_theme(self): logger.debug(u'TestCase: 切换不同vlife主题') self.case_id = '131' for i in range(1): # set theme1 theme.set_device_theme(DEVICENAME, 'VLIFE') result = self.unlock_screen() self.assertEqual(False, result) # set theme2 theme.set_device_theme(DEVICENAME, 'VLIFE', 1) result = self.unlock_screen() self.assertEqual(False, result)
def test_screen_on_off_30(self): logger.debug(u'TestCase: 反复亮灭屏') theme.set_device_theme(DEVICENAME, 'VLIFE') self.case_id = '137' for i in range(30): DEVICE.send_keyevent(26) sleep(2) DEVICE.send_keyevent(26) DEVICE.screenshot(self._testMethodName, target_path=self.log_path) result = self.get_device_state() self.assertEqual(True, result) # recovery to initial state self.unlock_screen()
def test_unlock_30(self): logger.debug(u'TestCase: 反复亮灭屏解锁') theme.set_device_theme(DEVICENAME, 'VLIFE') self.case_id = '138' for i in range(30): if DEVICE.get_lock_screen_state(): DEVICE.send_keyevent(26) sleep(1) DEVICE.send_keyevent(26) else: DEVICE.send_keyevent(26) result = self.unlock_screen() self.assertEqual(False, result)
def start_app(self, value): """ :return: """ if value.upper() != 'NONE': logger.debug('Step:start_app') if self.pname.upper() == 'MAGAZINE': self.device.app_operation('START', pkg=self.pkg) sleep(5) elif self.pname.upper() == 'THEME': theme.set_device_theme(self.dname, 'vlife') elif self.pname.upper() == 'WALLPAPER': pass else: pass
def test_dropdown_notification_recovery(self): logger.debug(u'TestCase:下拉通知栏可复原') self.case_id = '134' theme.set_device_theme(DEVICENAME, 'VLIFE') result = self.unlock_screen() self.assertEqual(False, result) width, height = DEVICE.get_screen_normal_size() DEVICE.shell('input swipe {0} {1} {2} {3} 200'.format( int(width) / 2, 50, int(width) / 2, int(height) / 2)) sleep(2) DEVICE.send_keyevent(26) sleep(2) result = self.unlock_screen() self.assertEqual(False, result)
def set_up(self): # set vlife theme theme.set_device_theme(self.uid, self.name) self.robot.reboot() sleep(20) # screen on/off state = self.robot.get_display_state() if not state: self.robot.send_keyevent(26) # unlock screen myaction = action.DeviceAction(self.uid) myaction.unlock_screen('DEFAULT') sleep(10) # clear background app self.launch.start()
def test_home_back_key(self): logger.debug(u'TestCase: Home、Back键不会解锁') self.case_id = '135' theme.set_device_theme(DEVICENAME, 'VLIFE') DEVICE.send_keyevent(26) sleep(2) DEVICE.send_keyevent(26) DEVICE.screenshot(self._testMethodName, target_path=self.log_path) # press home logger.debug('Press Home Key') DEVICE.send_keyevent(3) sleep(1) result = DEVICE.get_lock_screen_state() logger.debug('Verify state of lock screen') self.assertEqual(True, result) # press back key DEVICE.send_keyevent(4) sleep(1) result = DEVICE.get_lock_screen_state() logger.debug('Verify state of lock screen') self.assertEqual(True, result)
def init_module_version(uid, orig_path, path_index, loop_number): shell_paths = module_config.getValue('SHELL_MODULE', 'upgrade_shell_path').split(';') result_list = [] count = 0 for new_shell in shell_paths: logger.debug('***key step****: upgrade to ' + new_shell) test_result = True new_shell_index = shell_paths.index(new_shell) + 1 # get root device.adb('root') device.adb('remount') # delete files delete_files_from_device() # clear app pkg_name = module_config.getValue('SHELL_MODULE', 'pkg_name') logger.debug('step: clear pkg content ' + pkg_name) device.clear_app_data(pkg_name) logger.debug('step: clear system ui') device.clear_app_data('com.android.systemui') device.uninstall(pkg_name) # push new api file apk_path = module_config.getValue('SHELL_MODULE', 'push_apk_path') so_path = module_config.getValue('SHELL_MODULE', 'push_so_path') logger.debug('step: push apk file to device') files = get_full_name(orig_path, '.apk') device.push(files[0], apk_path) desktop_path = os.path.join(orig_path, 'so') files = get_full_name(desktop_path, '.so') logger.debug('step: push so files to device') for fl in files: device.push(fl, so_path) ######################################################################### # # reboot and unlock screen da = action.DeviceAction(uid) logger.debug('step: reboot device and unlock screen') da.reboot_device('default') da.unlock_screen('default') # set root permission before reboot device.adb('root') device.adb('remount') # push .xml file to /data/data/com.vlife.vivo.wallpaper/shared_prefs# device.push('/home/lang/testfile/function.xml', '/data/data/com.vlife.vivo.wallpaper/shared_prefs') # self-activation pkg_name = module_config.getValue('SHELL_MODULE', 'pkg_name') acti_flag = module_config.getValue('SHELL_MODULE', 'self_activation') product_type = device_config.getValue(uid, 'product_type') if acti_flag.upper() == 'FALSE': logger.debug('step: access to vlife theme, start-up main process') if product_type.upper() == 'THEME': theme.set_device_theme(uid, 'vlife') # configure server option mid = module_config.getValue('SHELL_MODULE', 'module_id') try: logger.debug('step: config server and enable module ') tc.update_stage_module_status(int(mid), True) flag1 = tc.update_stage_module_network(int(mid), 1, 0) flag2 = tc.check_amount_limit(int(mid)) if flag1 or flag2: config_srv.enableModule('STAGECONFIG') logger.debug('step: set date to after two months') da.update_time('DAYS-61') da.unlock_screen('default') #connect network and waiting for module download logger.debug('step: connect network and download module') for i in range(2): da.connect_network_trigger('CLOSE_ALL:ONLY_WIFI') #check module has download config_dict = {"module": mid} result = tc.get_all_module_info(config_dict) search_path = result['module']['path'] soft_version = result['module']['version'] full_path = os.path.join(r'/data/data/', pkg_name, os.path.dirname(search_path)).replace( '\\', '/') base_name = os.path.basename(search_path) res = device.find_file_from_appfolder(pkg_name, full_path) if res.find(base_name) != -1: logger.debug( '***key step***: module is download successfully, ' + search_path + ' has found') # reboot and unlock screen for applying module name = collect_log(uid, path_index, loop_number) # get pid of app pkg_process = pkg_name + ':main' pkg_pid = device.get_pid(pkg_process) #check log for login package and verify if module update loginfo = filter_log_result(name, 'jabber:iq:auth', pkg_pid) init_result = verify_pkg_content(loginfo, soft_version) if init_result: logger.debug('***key step***: module is made effect for ' + str(mid)) # test basic func sid = module_config.getValue('COMMON', 'basic_fun_suite_id') cmd = ' '.join(['run', uid, str(sid)]) if count == 0: logger.debug( '***key step***: start to run basic test cases') subprocess.call(cmd, shell=True, stdout=None) # test new shell for upgrade result = install_new_shell(new_shell, pkg_name, soft_version, uid, path_index, loop_number, new_shell_index) if result: logger.debug( '***key step***:Install new shell is success for SHELL' + str(new_shell_index)) else: logger.error( '***key step***:Install new shell is failed. login package is not right for SHELL' + str(new_shell_index)) test_result = False else: logger.error( '***key step***:Login package content is not right, made effect is failed' ) test_result = False else: logger.error( '***key step***: module is not downloaded successfully') test_result = False except Exception, ex: print ex test_result = False count += 1 result_list.append(test_result)
def init_module_version(uid, test_path): init_result = False # # delete old apk file # logger.debug('step: delete old apk file') # del_path = module_config.getValue(test_path, 'device_delete_apk_path') # logger.debug('step: delete old apk file from ' + del_path) # del_path = os.path.join(del_path, '*.apk') # device.remove(del_path) # # # clear app # pkg_name = module_config.getValue(test_path, 'pkg_name') # logger.debug('step: clear pkg content ' + pkg_name) # device.clear_app_data(pkg_name) # logger.debug('step: clear system ui') # device.clear_app_data('com.android.systemui') # # # push new api file # source = module_config.getValue(test_path, 'push_orig_path') # target = module_config.getValue(test_path, 'push_dest_path') # logger.debug('step: push apk file to device') # device.push(source, target) ######################################################################### # # reboot and unlock screen da = action.DeviceAction(uid) logger.debug('step: reboot device and unlock screen') da.reboot_device('default') da.unlock_screen('default') # self-activation pkg_name = module_config.getValue(test_path, 'pkg_name') acti_flag = module_config.getValue(test_path, 'self_activation') product_type = device_config.getValue(uid, 'product_type') if acti_flag.upper() == 'FALSE': logger.debug('step: access to vlife theme, start-up main process') if product_type.upper() == 'THEME': theme.set_device_theme(uid, 'vlife') # configure server option mid_list = module_config.getValue(test_path, 'module_upgrade_path').split(';') count = 0 try: for mid in mid_list: logger.debug('step: config server and enable module ') tc.update_stage_module_status(int(mid), True) flag1 = tc.update_stage_module_network(int(mid), 1, 0) flag2 = tc.check_amount_limit(int(mid)) if flag1 or flag2: config_srv.enableModule('STAGECONFIG') #connect network and waiting for module download logger.debug('step: connect network and download module') for i in range(2): da.connect_network_trigger('CLOSE_ALL:ONLY_WIFI') #check module has download config_dict = {"module": mid} result = tc.get_all_module_info(config_dict) search_path = result['module']['path'] soft_version = result['module']['version'] full_path = os.path.join(r'/data/data/', pkg_name, os.path.dirname(search_path)).replace( '\\', '/') base_name = os.path.basename(search_path) res = device.find_file_from_appfolder(pkg_name, full_path) if res.find(base_name) != -1: logger.debug('step: module is download successfully, ' + search_path + ' has found') # reboot and unlock screen for applying module logger.debug('step: reboot device') da.reboot_device('default') da.unlock_screen('default') # start collect log name = desktop.get_log_name(uid, 'SmokeModule') #LogPath = os.path.dirname(os.path.abspath(name)) log_reader = dumplog.DumpLogcatFileReader(name, uid) log_reader.clear_logcat() log_reader.start() #connect network and waiting for module download logger.debug('step: connect network and download module') for i in range(2): da.connect_network_trigger('CLOSE_ALL:ONLY_WIFI') sleep(10) log_reader.stop() # get pid of app pkg_pid = device.get_pid(pkg_name) #check log for login package and verify if module update loginfo = filter_log_result(name, 'jabber:iq:auth', pkg_pid) init_result = verify_pkg_content(loginfo, soft_version) if init_result: logger.debug('step: module is made effect for ' + str(mid)) if count == len(mid_list) - 2: sid = module_config.getValue('COMMON', 'basic_fun_suite_id') cmd = ' '.join(['run', uid, str(sid)]) subprocess.Popen(cmd, shell=True, stdout=None) # test new module for upgrade device_config.setValue(uid, 'background_module_id1', mid_list[count + 1]) sid = module_config.getValue('COMMON', 'upgrade_fun_suite_id') cmd = ' '.join(['run', uid, str(sid)]) subprocess.call(cmd, shell=True, stdout=None) break count += 1 else: logger.error('step: module is not made effect for ' + str(mid)) break else: logger.error('step: module is not downloaded successfully') break except Exception, ex: print ex
def set_up(self): # set vlife theme theme.set_device_theme(self.uid, self.name)
def set_up(self): # set vlife theme theme.set_device_theme(self.uid, 'VLIFE') # clear background app self.launch.start()