def share_with_renren_inner(self,message): ''' share with renren. @note: Be sure it is in the write message interface @type message:string @param message:the message want to share with renren ''' #enter the message click_textview_by_id('input_editor', 1, 0) sleep(1) self.ime.IME_input(1,message,'c') sleep(1) #click the delete position button(textView) click_button_by_id('flipper_head_action') waitActivity = lambda:get_activity_name() == "com.renren.mobile.android.publisher.InputPublisherActivity" if not wait_for_fun(waitActivity, False, 7): # if the editActivity is still alive , close it loopTimes = 0 while loopTimes < 5: if search_text(self.get_value('cancel_post_tip'), 1, 0): click_button_by_text(self.get_value('ok')) break else: goback() loopTimes = loopTimes + 1 log_test_case(self.mode_name, 'Cancel post the renren status') return False return True
def share_with_renren(self,message): ''' share with renren. @note: Be sure it is in the viewing picture interface @type message:string @param message:the message want to share with renren ''' shareWithRenren = self.get_value('share_to_renren') if search_view_by_desc(self.get_value('default_share_to_renren')): click_view_by_container_id('default_activity_button','android.widget.ImageView',0) else: click_imageview_by_desc(self.get_value('share_object')) #click the text sell all click_textview_by_text(self.get_value('see_all')) if search_text(shareWithRenren): click_textview_by_text(shareWithRenren) else: log_test_case(self.mode_name, 'Can not find the renren') return False sleep(1) waitActivity = lambda:get_activity_name().startswith("com.renren.mobile.android") if not wait_for_fun(waitActivity, True, 5): return False if not self.is_login(): self.login() sleep(2) click_button_by_id('edit_photo_done') sleep(2) click_button_by_id('edit_photo_done') sleep(3) return self.share_with_renren_inner(message)
def test_case_init(self): ''' init the test case . such as: set the L{current_case_continue_flag<current_case_continue_flag>} to True; save the current case name; init the logging; launcher this application ''' if getprop_suspend() : signal.signal(signal.SIGUSR1, OnshakeSignal_handler) log_test_case('suspend', 'suspended, wait for shake-signal from java resume --- 3') signal.pause() log_test_case('Finally!!!', 'good luck, already gotten signal and resumed.... --- 4') log_test_framework(self.name, 'case init...') set_can_continue() set_cur_case_name(self.name) qsst_log_case_init() self.launcher.launch_from_launcher(self.app_name) clear_logcat()
def test_case_end(self): ''' record the case result ''' log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], 'end') if can_continue() and case_flag == True: log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], 'case pass') print_report_line(self.case_config_map[fs_wrapper.CASE_NAME_ATTR] + '\tpass') else: log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], 'case fail') print_report_line(self.case_config_map[fs_wrapper.CASE_NAME_ATTR] + '\tfail') save_fail_log()
def test_case_end(self): ''' record the case result ''' ''' @attention: modify by min.sheng ''' log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], TAG + ' : end') if can_continue() and case_flag == True: # shutdown() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], TAG + ': case pass') print_report_line(self.case_config_map[fs_wrapper.CASE_NAME_ATTR] + TAG + ' : \tpass') else: log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], TAG + ' : case fail') print_report_line(self.case_config_map[fs_wrapper.CASE_NAME_ATTR] + TAG + ' : \tfail') save_fail_log() '''
def test_case_main(self, case_results): case_flag = False # # STEP 1: before operation, record the photo number # work_dir = '/sdcard/DCIM/Camera' filetype = '.jpg' num1 = suit_FE.num_of_filetype_in_folder(work_dir, filetype) log_test_case(self.tag, "num1 = " + str(num1)) # # STEP 2: take photo in gallery # take_photo_in_gallery(self.tag) # # STEP 3:after operation, record the photo number # if can_continue(): # have to wait for operation completing, about 3 seconds sleep(5) # caculate the .jpg number num2 = suit_FE.num_of_filetype_in_folder(work_dir, filetype) log_test_case(self.tag, "num2 = " + str(num2)) # # STEP 4: check if number increase # if can_continue(): if num2 > num1: case_flag = True # # STEP 5: exit # exit_cur_case(self.tag) log_test_case(self.tag, "case_flag = " + str(case_flag)) if case_flag: qsst_log_case_status(STATUS_SUCCESS, "", SEVERITY_HIGH) else: qsst_log_case_status(STATUS_FAILED, "take photo is failed", SEVERITY_HIGH) case_results.append( (self.case_config_map[fs_wrapper.CASE_NAME_ATTR], can_continue()))
def test_case_main(self, case_results): ''' main entry. @type case_results: tuple @param case_results: record some case result information ''' case_flag = False # # STEP 1: run monkey # package = 'com.android.calculator2' monkey_num = '500' internal = '5000' strCMD = "adb shell monkey -p %s %s --throttle %s --monitor-native-crashes --kill-process-after-error"%(package,monkey_num,internal) try: p1 = subprocess.Popen(shlex.split(strCMD), shell = False, stdout=subprocess.PIPE) (result,erroutput) = p1.communicate() p1.stdout.close() except: set_cannot_continue() log_test_case(self.tag, "cannot start monkey") if can_continue(): # # STEP 2: check # log_test_case(self.tag,"monkey result: " + result) if (re.findall("Events injected: "+monkey_num,result)): case_flag = True else:take_screenshot() # # STEP 3: exit # exit_cur_case(self.tag) log_test_case(self.tag, "case_flag = "+str(case_flag)) if case_flag: qsst_log_case_status(STATUS_SUCCESS, "" , SEVERITY_HIGH) else: qsst_log_case_status(STATUS_FAILED, "native caculator is failed", SEVERITY_HIGH) case_results.append((self.case_config_map[fs_wrapper.CASE_NAME_ATTR], can_continue()))
def send_state(receiver_num): tag = 'send_state(receiver_num)' flag = False #launcher = Launcher(); send_key(KEY_HOME) launcher.launch_from_launcher('mms') #start_activity("com.android.mms","com.android.mms.ui.ConversationList") mms.click_home_icon() func = lambda: search_text(receiver_num, searchFlag=TEXT_CONTAINS ) # search '1 363-659-1260' if not wait_for_fun(func, True, 3): set_cannot_continue() log_test_case( TAG, "cannot find the 'receiver_num' in Messaging conversation list") else: click_textview_by_text( receiver_num, searchFlag=TEXT_CONTAINS) # click '1 363-659-1260' # wait until MMS has been sent func = lambda: search_text('SENDING', searchFlag=TEXT_CONTAINS) if not wait_for_fun(func, False, 60): set_cannot_continue() log_test_case(TAG, "the MMS has been sending for more than 60s") else: mms.click_home_icon() func = lambda: search_text(mms.get_value("received"), searchFlag=TEXT_CONTAINS, isScrollable=0) if not wait_for_fun(func, True, 5): set_cannot_continue() log_test_case(TAG, "Received MMS on slot1 failed.") else: flag = True return flag
def execute(): start_activity("com.android.settings", "com.android.settings.Settings") if wait_for_fun(lambda:search_view_by_id('permission_allow_button'), True, 5): phone.permission_allow() if wait_for_fun(lambda:search_text("WLAN"), True, 5): click_textview_by_text('WLAN') if wait_for_fun(lambda:search_text("On"), True, 5): click_button_by_id("switch_widget") if wait_for_fun(lambda:search_text("Off"), True, 5): click_button_by_id("switch_widget") if wait_for_fun(lambda:search_text("On"), True, 5): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Open WLAN successfully") sleep(2) click_button_by_id("switch_widget") if wait_for_fun(lambda:search_text("Off"), True, 5): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Close WLAN successfully") send_key(KEY_BACK) send_key(KEY_BACK) send_key(KEY_HOME) if wait_for_fun(lambda:search_view_by_desc("Apps list"), True, 3): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Back to home successfully") case_flag=True elif search_text("Unfortunately", isScrollable=0): take_screenshot() if search_text("OK"): click_button_by_text("OK") sleep(2) if search_text("Close"): click_button_by_text("Close") sleep(2) log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs Crash") elif search_text("isn't responding", isScrollable=0): take_screenshot() if search_text("OK"): click_button_by_text("OK") sleep(2) if search_text("Close"): click_button_by_text("Close") sleep(2) log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs ANR") else: take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Can't find WLAN") return case_flag
def test_case_main(self, case_results): global case_flag, TAG, testresult, success_flag, i, success_time1, right_to_left_flag, left_to_right_flag, success_time2, fail_time1, fail_time2, recoreName, p recordName = ''.join(__name__.split('_')[-2:]) case_flag = False right_to_left_flag = False left_to_right_flag = False testresult1 = [] testresult2 = [] success_time1 = 0 fail_time1 = 0 success_time2 = 0 fail_time2 = 0 iterationNum = 10 TAG = "switch between different snapshot from the thumbnail: Camera " log_test_framework(TAG, self.name + " -Start") """ cases contents you need to add """ if search_text("Close app", searchFlag=TEXT_CONTAINS): click_button_by_text("Close app", searchFlag=TEXT_CONTAINS) sleep(2) p = subprocess.Popen('adb shell screenrecord /sdcard/%s.mp4' % recordName, shell=True) start_activity('org.codeaurora.snapcam', 'com.android.camera.CameraLauncher') if wait_for_fun(lambda: search_view_by_id('permission_allow_button'), True, 10): click_button_by_id('permission_allow_button') if wait_for_fun(lambda: search_text('OK'), True, 5): click_textview_by_text('OK') if wait_for_fun(lambda: search_view_by_id('shutter_button'), True, 5): log_test_framework("step1:", "Launch camera pass") takePhoto(iterationNum) if wait_for_fun(lambda: search_view_by_id('preview_thumb'), True, 5): click_imageview_by_id("preview_thumb") if wait_for_fun( lambda: search_view_by_id( "photopage_bottom_control_delete"), True, 5): log_test_framework( "step2:", "tap thumbnail to view the snapshot pass") ''' from right to left ''' for i in range(iterationNum): print_log_line('from right to left iteration %d' % (i + 1)) log_test_framework( self.name, 'from right to left iteration %d' % (i + 1)) success_flag = False drag_by_param(90, 50, 10, 50, 10) sleep(2) if search_text("Close app", searchFlag=TEXT_CONTAINS) == False: log_test_framework( "step3:", "switch from right to left pass") success_flag = True if success_flag == True: testresult1.append('%d.Pass' % (i + 1)) success_time1 = success_time1 + 1 print_log( self.case_config_map[ fs_wrapper.CASE_NAME_ATTR], '%d.Pass' % (i + 1)) else: testresult1.append('%d.Fail' % (i + 1)) take_screenshot() fail_time1 = fail_time1 + 1 print_log( self.case_config_map[ fs_wrapper.CASE_NAME_ATTR], '%d.Fail' % (i + 1)) if search_text("Close app", searchFlag=TEXT_CONTAINS): print_log( self.case_config_map[ fs_wrapper.CASE_NAME_ATTR], '%d.Popup Close app' % (i + 1)) click_button_by_text("Close app", searchFlag=TEXT_CONTAINS) sleep(2) start_activity( 'org.codeaurora.snapcam', 'com.android.camera.CameraLauncher') if wait_for_fun( lambda: search_view_by_id('shutter_button' ), True, 8): if wait_for_fun( lambda: search_view_by_id( 'preview_thumb'), True, 5): click_imageview_by_id("preview_thumb") sleep(3) if success_time1 == iterationNum: right_to_left_flag = True print_log( self.case_config_map[fs_wrapper.CASE_NAME_ATTR], 'from right to left success:%d fail:%d iteration:%d' % (success_time1, fail_time1, iterationNum)) print_log(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], testresult1) ''' from left to right ''' for i in range(iterationNum): print_log_line('from left to right iteration %d' % (i + 1)) log_test_framework( self.name, 'from left to right iteration %d' % (i + 1)) success_flag = False drag_by_param(10, 50, 90, 50, 10) sleep(2) if search_text("Close app", searchFlag=TEXT_CONTAINS) == False: log_test_framework( "step4:", "switch from left to right pass") success_flag = True if success_flag == True: testresult2.append('%d.Pass' % (i + 1)) success_time2 = success_time2 + 1 print_log( self.case_config_map[ fs_wrapper.CASE_NAME_ATTR], '%d.Pass' % (i + 1)) else: testresult2.append('%d.Fail' % (i + 1)) take_screenshot() fail_time2 = fail_time2 + 1 print_log( self.case_config_map[ fs_wrapper.CASE_NAME_ATTR], '%d.Fail' % (i + 1)) if search_text("Close app", searchFlag=TEXT_CONTAINS): print_log( self.case_config_map[ fs_wrapper.CASE_NAME_ATTR], '%d.Popup Close app' % (i + 1)) click_button_by_text("Close app", searchFlag=TEXT_CONTAINS) sleep(2) start_activity( 'org.codeaurora.snapcam', 'com.android.camera.CameraLauncher') if wait_for_fun( lambda: search_view_by_id('shutter_button' ), True, 8): if wait_for_fun( lambda: search_view_by_id( 'preview_thumb'), True, 5): click_imageview_by_id("preview_thumb") sleep(3) if success_time2 == iterationNum: left_to_right_flag = True print_log( self.case_config_map[fs_wrapper.CASE_NAME_ATTR], 'from left to right success:%d fail:%d iteration:%d' % (success_time2, fail_time2, iterationNum)) print_log(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], testresult2) case_flag = right_to_left_flag and left_to_right_flag if search_text("isn't responding", searchFlag=TEXT_CONTAINS): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs ANR") take_screenshot() if search_text("Close app", searchFlag=TEXT_CONTAINS): click_button_by_text("Close app", searchFlag=TEXT_CONTAINS) sleep(2) if search_text("Close", searchFlag=TEXT_CONTAINS): click_button_by_text("Close") sleep(2) elif search_text("Unfortunately", searchFlag=TEXT_CONTAINS): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs crash") take_screenshot() if search_text("OK", searchFlag=TEXT_CONTAINS): click_button_by_text("OK") sleep(2) if search_text("Close", searchFlag=TEXT_CONTAINS): click_button_by_text("Close") sleep(2) elif search_text("stopped", searchFlag=TEXT_CONTAINS): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Popup has stopped") take_screenshot() if search_text("Close", searchFlag=TEXT_CONTAINS): click_button_by_text("Close") sleep(2) if search_text("OK", searchFlag=TEXT_CONTAINS): click_button_by_text("OK") sleep(2) elif search_text("Close app", searchFlag=TEXT_CONTAINS): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Popup Close app error") take_screenshot() click_button_by_text("Close app", searchFlag=TEXT_CONTAINS) sleep(2) send_key(KEY_BACK) sleep(1) send_key(KEY_BACK) sleep(1) send_key(KEY_HOME) sleep(1) if case_flag: qsst_log_case_status(STATUS_SUCCESS, "", SEVERITY_HIGH) else: qsst_log_case_status(STATUS_FAILED, "", SEVERITY_HIGH) case_results.append( (self.case_config_map[fs_wrapper.CASE_NAME_ATTR], case_flag))
def test_case_main(self, case_results): global case_flag , TAG, i case_flag = False TAG = "Dev-ci cases: Messager " log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], self.name +' : case Start') log_test_framework(TAG, self.name + " -Start") # start_activity('com.android.settings','.Settings') # sleep(1) # settings.set_default_sms(1) start_activity("com.android.mms", "com.android.mms.ui.ConversationList") # if wait_for_fun(lambda:search_text("NEXT", searchFlag=TEXT_CONTAINS), True, 5) or wait_for_fun(lambda:search_view_by_id('permission_allow_button'), True, 5): # phone.permission_allow() if wait_for_fun(lambda:search_view_by_id("action_compose_new"), True, 5) or wait_for_fun(lambda:search_view_by_id("create"), True, 5): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Enter Message successfully") mms.forward_sms_saved_in_sim_card("10086") send_key(KEY_BACK) sleep(2) send_key(KEY_BACK) sleep(2) send_key(KEY_BACK) sleep(2) if wait_for_fun(lambda:search_text("10086"), True, 120): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "case pass") case_flag=True elif search_text("Unfortunately"): if search_text("OK"): click_button_by_text("OK") take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs Crash") elif search_text("isn't responding"): if search_text("OK"): click_button_by_text("OK") take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs ANR") else: take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "case fail") send_key(KEY_BACK) sleep(1) send_key(KEY_BACK) sleep(1) send_key(KEY_HOME) sleep(1) if case_flag: qsst_log_case_status(STATUS_SUCCESS, "" , SEVERITY_HIGH) else: qsst_log_case_status(STATUS_FAILED, "", SEVERITY_HIGH) case_results.append((self.case_config_map[fs_wrapper.CASE_NAME_ATTR], case_flag))
def test_case_main(self, case_results): global case_flag, TAG, case_flag_special_name, case_flag_empty_name case_flag = False case_flag_special_name = False case_flag_empty_name = False TAG = "Dev-ci cases: Contact " log_test_framework(self.name, " -Start") """ cases contnets you need to add """ settings.check_after_resetphone() start_activity("com.android.contacts", "com.android.contacts.activities.PeopleActivity") sleep(5) phone.permission_allow() contact.add_contact_to_phone("testui@#$%+", "18721469139") sleep(3) if search_text("testui@#$%+", searchFlag=TEXT_CONTAINS): log_test_framework( self.name, "Add special name contact with some punctuation success. Find in the phone" ) case_flag_special_name = True contact.add_contact_to_phone(" ", "19721469139") sleep(3) if search_text("19721 469 139", searchFlag=TEXT_CONTAINS): log_test_framework( self.name, "Add blank name contact success. Find in the phone") case_flag_empty_name = True elif search_text("Unfortunately"): if search_text("OK"): click_button_by_text("OK") take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs Crash") elif search_text("isn't responding"): if search_text("OK"): click_button_by_text("OK") take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs ANR") else: take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "case fail") send_key(KEY_BACK) sleep(3) send_key(KEY_BACK) sleep(3) send_key(KEY_HOME) sleep(3) case_flag = case_flag_special_name and case_flag_empty_name if case_flag: qsst_log_case_status(STATUS_SUCCESS, "", SEVERITY_HIGH) else: qsst_log_case_status(STATUS_FAILED, "", SEVERITY_HIGH) case_results.append( (self.case_config_map[fs_wrapper.CASE_NAME_ATTR], case_flag))
def import_from_simcard(self): """ This function import from simcard. @return: none """ send_key(KEY_MENU) #import/export #click_in_list_by_index(2) log_test_case(self.name, 'sometime cant find the ui,so wait for 1 s.') sleep(1) str_menu_import_export = contact.get_value('menu_import_export') log_test_case(self.name, str_menu_import_export) click_in_list_by_index(2) log_test_case(self.name, 'import from simcard') click_in_list_by_index(0) str_import_from_sim = contact.get_value('import_from_sim') if search_text(str_import_from_sim): click_button_by_index(0) #click_button_by_id('btn_ok') log_test_case(self.name, ' to phone') click_in_list_by_index(0) log_test_case(self.name, 'only select first') click_in_list_by_index(0) log_test_case(self.name, ' ok') click_button_by_id('btn_ok') #click ok click_button_by_index(1) log_test_case(self.name, ' wait for at least 4s') sleep(4) return
def test_case_main(self, case_results): global case_flag, TAG case_flag = False TAG = "Dev-ci cases: Gallery " log_test_framework(TAG, self.name + " -Start") """ cases contents you need to add """ start_activity('com.android.gallery3d', 'com.android.gallery3d.app.GalleryActivity') if wait_for_fun(lambda: search_view_by_id('permission_allow_button'), True, 5): phone.permission_allow() start_activity('org.codeaurora.gallery', 'com.android.gallery3d.app.GalleryActivity') if wait_for_fun(lambda: search_view_by_id('permission_allow_button'), True, 5): phone.permission_allow() if wait_for_fun(lambda: search_text('Timeline'), True, 5) or search_text('Albums') or search_view_by_desc( "drawer") or search_view_by_desc("More options"): log_test_framework("gp_sanity_gallery_case1:", "Launch gallery pass") send_key(KEY_BACK) send_key(KEY_BACK) send_key(KEY_HOME) if wait_for_fun(lambda: search_view_by_desc("Apps list"), True, 3): log_test_framework("gp_sanity_gallery_case1:", "Exit pass") case_flag = True if search_text('has stopped'): log_test_framework("gp_sanity_gallery_case1:", "Popup has stopped") take_screenshot() if search_text("OK"): click_button_by_text("OK") sleep(2) if search_text("Close"): click_button_by_text("Close") sleep(2) elif search_text("Unfortunately"): take_screenshot() if search_text("OK"): click_button_by_text("OK") sleep(2) if search_text("Close"): click_button_by_text("Close") sleep(2) log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs Crash") elif search_text("isn't responding"): take_screenshot() if search_text("OK"): click_button_by_text("OK") sleep(2) if search_text("Close"): click_button_by_text("Close") sleep(2) log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs ANR") else: log_test_framework("gp_sanity_gallery_case1:", "Launch gallery fail") if case_flag: qsst_log_case_status(STATUS_SUCCESS, "", SEVERITY_HIGH) else: qsst_log_case_status(STATUS_FAILED, "", SEVERITY_HIGH) case_results.append( (self.case_config_map[fs_wrapper.CASE_NAME_ATTR], case_flag))
def test_case_main(self, case_results): global case_flag , TAG case_flag = False TAG = "Dev-ci cases: Phone " log_test_framework(TAG, self.name+" -Start") """ cases contents you need to add """ wakeUpDevice() settings.kill_allpid() start_activity('com.android.settings','.Settings') sleep(1) settings.set_default_voice(2) start_activity("com.android.dialer", "com.android.dialer.DialtactsActivity") sleep(10) phone.permission_allow() if search_view_by_desc("Speed dial"): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Enter dialer successfully") if search_view_by_desc("dial pad"): click_button_by_id("floating_action_button") sleep(3) if search_view_by_id("deleteButton"): click_imageview_by_id("deleteButton", 1, 0, 0, LONG_CLICK) sleep(5) if phone.phone_call("10086", "",slot=1,call_duration=30): case_flag = True else: log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], " MO call from SIM2 failed") elif search_text("Unfortunately"): if search_text("OK"): click_button_by_text("OK") take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs Crash") elif search_text("isn't responding"): if search_text("OK"): click_button_by_text("OK") take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs ANR") else: take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Case fail") if case_flag: qsst_log_case_status(STATUS_SUCCESS, "" , SEVERITY_HIGH) else: qsst_log_case_status(STATUS_FAILED, "", SEVERITY_HIGH) case_results.append((self.case_config_map[fs_wrapper.CASE_NAME_ATTR], case_flag))
def test_case_end(self): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], 'end')
def test_case_main(self, case_results): global case_flag, TAG, recoreName, p recordName = ''.join(__name__.split('_')[-2:]) case_flag = False result = [] TAG = "data switch in quick settings: Settings " log_test_framework(TAG, self.name + " -Start") """ cases contents you need to add """ p = subprocess.Popen('adb shell screenrecord /sdcard/%s.mp4' % recordName, shell=True) openNotification() quickData() switchDataO() # result.append(switchData('OFF')) # sleep(5) # result.append(switchData('ON')) # sleep(5) # result.append(switchData('OFF')) # sleep(5) # result.append(switchData('ON')) # log_test_framework(self.name, str(result)) # case_flag=not False in result send_key(KEY_BACK) send_key(KEY_BACK) case_flag = True if search_text("stopped", searchFlag=TEXT_CONTAINS): log_test_framework(self.name, "Popup has stopped") case_flag = False take_screenshot() if search_text("OK"): click_button_by_text("OK") sleep(2) if search_text("Close"): click_button_by_text("Close") sleep(2) elif search_text("Unfortunately", searchFlag=TEXT_CONTAINS): take_screenshot() case_flag = False if search_text("OK"): click_button_by_text("OK") sleep(2) if search_text("Close"): click_button_by_text("Close") sleep(2) log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs Crash") elif search_text("isn't responding", searchFlag=TEXT_CONTAINS): take_screenshot() case_flag = False if search_text("OK"): click_button_by_text("OK") sleep(2) if search_text("Close"): click_button_by_text("Close") sleep(2) log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs ANR") send_key(KEY_BACK) sleep(1) send_key(KEY_BACK) sleep(1) send_key(KEY_HOME) sleep(1) if case_flag: qsst_log_case_status(STATUS_SUCCESS, "", SEVERITY_HIGH) else: qsst_log_case_status(STATUS_FAILED, "", SEVERITY_HIGH) case_results.append( (self.case_config_map[fs_wrapper.CASE_NAME_ATTR], case_flag))
def execute(): start_activity('com.android.calendar', 'com.android.calendar.AllInOneActivity') if wait_for_fun( lambda: search_view_by_id('permission_allow_button'), True, 5): phone.permission_allow() if search_text('NEXT'): send_key(KEY_BACK) sleep(3) if is_view_enabled_by_id( VIEW_TEXT_VIEW, "top_button_date") or search_text("Week") or search_text( "January 2017") or is_view_enabled_by_id( VIEW_TEXT_VIEW, "action_today" ) or search_view_by_desc("More options"): log_test_framework("gp_sanity_calendar_case1:", "Launch calendar pass") send_key(KEY_BACK) send_key(KEY_BACK) send_key(KEY_HOME) if wait_for_fun(lambda: search_view_by_desc("Apps list"), True, 3): log_test_framework("gp_sanity_calendar_case1:", "Exit pass") case_flag = True if search_text('has stopped'): log_test_framework("gp_sanity_calendar_case1:", "Popup has stopped") take_screenshot() if search_text("OK"): click_button_by_text("OK") sleep(2) if search_text("Close"): click_button_by_text("Close") sleep(2) elif search_text("Unfortunately"): take_screenshot() if search_text("OK"): click_button_by_text("OK") sleep(2) if search_text("Close"): click_button_by_text("Close") sleep(2) log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs Crash") elif search_text("isn't responding"): take_screenshot() if search_text("OK"): click_button_by_text("OK") sleep(2) if search_text("Close"): click_button_by_text("Close") sleep(2) log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs ANR") else: log_test_framework("gp_sanity_calendar_case1:", "Launch calendar fail") return case_flag
def test_case_main(self, case_results): global case_flag, TAG, testresult, success_flag, i, success_time, record_flag, picture_flag case_flag = False testresult = [] success_time = 0 fail_time = 0 iterationNum = 100 TAG = "Dev-ci cases: Camera " log_test_framework(TAG, self.name + " -Start") """ cases contents you need to add """ if search_text("Close app", searchFlag=TEXT_CONTAINS): click_button_by_text("Close app", searchFlag=TEXT_CONTAINS) sleep(2) start_activity('org.codeaurora.snapcam', 'com.android.camera.CameraLauncher') if wait_for_fun(lambda: search_view_by_id('permission_allow_button'), True, 10): click_button_by_id('permission_allow_button') if wait_for_fun(lambda: search_text('OK'), True, 5): click_textview_by_text('OK') if wait_for_fun(lambda: search_view_by_id('shutter_button'), True, 5): log_test_framework("step1:", "Launch camera and use rear camera pass") for i in range(iterationNum): print_log_line('This is iteration %d' % (i + 1)) success_flag = False record_flag = False picture_flag = False if wait_for_fun(lambda: search_view_by_id('camera_switcher'), True, 5): click_imageview_by_id("camera_switcher") if wait_for_fun( lambda: search_view_by_desc("Switch to video"), True, 5): click_imageview_by_desc("Switch to video") camera.take_video_camera1(3) if wait_for_fun(lambda: search_view_by_id('shutter_button'), True, 5): log_test_framework( "step2:", "Switch to Video Record use rear camera pass") record_flag = True if wait_for_fun( lambda: search_view_by_id('camera_switcher'), True, 5): click_imageview_by_id("camera_switcher") if wait_for_fun( lambda: search_view_by_desc("Switch to photo"), True, 5): click_imageview_by_desc("Switch to photo") camera.take_picture() log_test_framework( "step3:", "Switch to camera to take a picture pass") picture_flag = True success_flag = record_flag and picture_flag if success_flag == True: testresult.append('%d.Pass' % (i + 1)) success_time = success_time + 1 print_log(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], '%d.Pass' % (i + 1)) else: testresult.append('%d.Fail' % (i + 1)) take_screenshot() fail_time = fail_time + 1 print_log(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], '%d.Fail' % (i + 1)) if search_text("Close app", searchFlag=TEXT_CONTAINS): print_log( self.case_config_map[fs_wrapper.CASE_NAME_ATTR], '%d.Popup Close app' % (i + 1)) click_button_by_text("Close app", searchFlag=TEXT_CONTAINS) sleep(2) start_activity('org.codeaurora.snapcam', 'com.android.camera.CameraLauncher') if success_time == iterationNum: case_flag = True start_activity('org.codeaurora.snapcam', 'com.android.camera.CameraLauncher') if wait_for_fun(lambda: search_view_by_id('camera_switcher'), True, 5): click_imageview_by_id("camera_switcher") if wait_for_fun(lambda: search_view_by_desc("Switch to photo"), True, 5): click_imageview_by_desc("Switch to photo") if search_text("isn't responding", searchFlag=TEXT_CONTAINS): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs ANR") take_screenshot() if search_text("Close app", searchFlag=TEXT_CONTAINS): click_button_by_text("Close app", searchFlag=TEXT_CONTAINS) sleep(2) if search_text("Close", searchFlag=TEXT_CONTAINS): click_button_by_text("Close") sleep(2) elif search_text("Unfortunately", searchFlag=TEXT_CONTAINS): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs crash") take_screenshot() if search_text("OK", searchFlag=TEXT_CONTAINS): click_button_by_text("OK") sleep(2) if search_text("Close", searchFlag=TEXT_CONTAINS): click_button_by_text("Close") sleep(2) elif search_text("stopped", searchFlag=TEXT_CONTAINS): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Popup has stopped") take_screenshot() if search_text("Close", searchFlag=TEXT_CONTAINS): click_button_by_text("Close") sleep(2) if search_text("OK", searchFlag=TEXT_CONTAINS): click_button_by_text("OK") sleep(2) elif search_text("Close app", searchFlag=TEXT_CONTAINS): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Popup Close app error") take_screenshot() click_button_by_text("Close app", searchFlag=TEXT_CONTAINS) sleep(2) send_key(KEY_BACK) sleep(1) send_key(KEY_BACK) sleep(1) send_key(KEY_HOME) sleep(1) print_log( self.case_config_map[fs_wrapper.CASE_NAME_ATTR], 'success:%d fail:%d iteration:%d' % (success_time, fail_time, iterationNum)) print_log(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], testresult) if case_flag: qsst_log_case_status(STATUS_SUCCESS, "", SEVERITY_HIGH) else: qsst_log_case_status(STATUS_FAILED, "", SEVERITY_HIGH) case_results.append( (self.case_config_map[fs_wrapper.CASE_NAME_ATTR], case_flag))
def test_case_main(self, case_results): global case_flag, TAG case_flag = False TAG = "Dev-ci cases: Contact " log_test_framework(self.name, " -Start") """ cases contnets you need to add """ # launch contact start_activity("com.android.contacts", "com.android.contacts.activities.PeopleActivity") # if wait_for_fun(lambda:search_view_by_id('permission_allow_button'), True, 5): # phone.permission_allow() if wait_for_fun( lambda: search_text("Contacts", searchFlag=TEXT_CONTAINS), True, 5) or search_text("All contacts") or search_text( "ADD NEW ACCOUNT"): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Enter contact successfully") sleep(3) contact.add_contact_to_phone("deall", "123") contact.del_all_contact() if search_text("deall") == False: log_test_case("concatct30", "Delete all contacts successfully") case_flag = True elif search_text("No contacts"): log_test_case("concatct30", "Delete all contacts successfully") case_flag = True elif search_text("Unfortunately"): if search_text("OK"): click_button_by_text("OK") take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs Crash") elif search_text("isn't responding"): if search_text("OK"): click_button_by_text("OK") take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs ANR") else: take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "case fail") send_key(KEY_BACK) sleep(1) send_key(KEY_BACK) sleep(1) send_key(KEY_HOME) sleep(1) if case_flag: qsst_log_case_status(STATUS_SUCCESS, "", SEVERITY_HIGH) else: qsst_log_case_status(STATUS_FAILED, "", SEVERITY_HIGH) case_results.append( (self.case_config_map[fs_wrapper.CASE_NAME_ATTR], case_flag))
def test_case_main(self, case_results): global case_flag , TAG, testresult, success_flag, i, success_time, auto_flag, on_flag, off_flag case_flag = True testresult = [] success_time = 0 fail_time = 0 iterationNum = 100 TAG = "Dev-ci cases: Camera " log_test_framework(TAG, self.name+" -Start") """ cases contents you need to add """ start_activity('org.codeaurora.snapcam','com.android.camera.CameraLauncher') if wait_for_fun(lambda:search_view_by_id('permission_allow_button'), True, 10): click_button_by_id('permission_allow_button') if wait_for_fun(lambda:search_text('OK'), True, 5): click_textview_by_text('OK') self.delete_photos() self.recording_video() case_flag=self.check_video_detail() if search_text("isn't responding", searchFlag=TEXT_CONTAINS): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs ANR") take_screenshot() case_flag=False if search_text("Close app", searchFlag=TEXT_CONTAINS): click_button_by_text("Close app", searchFlag=TEXT_CONTAINS) sleep(2) if search_text("Close", searchFlag=TEXT_CONTAINS): click_button_by_text("Close") sleep(2) elif search_text("Unfortunately", searchFlag=TEXT_CONTAINS): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs crash") take_screenshot() case_flag=False if search_text("OK", searchFlag=TEXT_CONTAINS): click_button_by_text("OK") sleep(2) if search_text("Close", searchFlag=TEXT_CONTAINS): click_button_by_text("Close") sleep(2) elif search_text("stopped", searchFlag=TEXT_CONTAINS): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Popup has stopped") take_screenshot() case_flag=False if search_text("Close", searchFlag=TEXT_CONTAINS): click_button_by_text("Close") sleep(2) if search_text("OK", searchFlag=TEXT_CONTAINS): click_button_by_text("OK") sleep(2) elif search_text("Close app", searchFlag=TEXT_CONTAINS): case_flag=False log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Popup Close app error") take_screenshot() click_button_by_text("Close app", searchFlag=TEXT_CONTAINS) sleep(2) send_key(KEY_BACK) sleep(1) send_key(KEY_BACK) sleep(1) send_key(KEY_HOME) sleep(1) if case_flag: qsst_log_case_status(STATUS_SUCCESS, "" , SEVERITY_HIGH) else: qsst_log_case_status(STATUS_FAILED, "", SEVERITY_HIGH) case_results.append((self.case_config_map[fs_wrapper.CASE_NAME_ATTR], case_flag))
def test_case_main(self, case_results): ''' main entry. @type case_results: tuple @param case_results: record some case result information ''' #deal_with_install_block() (apk_list, apk_library_dir, apk_source_dir, sep) = get_files_in_dir(self.category) PATTERN1 = 'PackageManager' PATTERN2 = 'Running dexopt on' pmPattern = re.compile("%s.+%s.+\n" % (PATTERN1, PATTERN2)) case_flag = True count = 0 count_fail = 0 fail_apk_list = [] for apk in apk_list: os.popen('adb logcat -c') count += 1 log_test_framework(self.tag, "now the apk is No." + str(count)) if (count % 5 == 0): sleep(30) # # STEP 1: install # # WindowsError: [Error 183] Cannot create a file when that file already exists try: os.remove( apk_source_dir + 'new.apk' ) #pull one apk in newDIR and rename it as new.apk, push it to device and install new.apk except WindowsError: pass shutil.copy(apk_library_dir + apk, apk_source_dir) log_test_framework(self.tag, "now the apk is " + apk) os.rename(apk_source_dir + apk, apk_source_dir + 'new.apk') os.system('adb push ' + '"' + apk_source_dir + 'new.apk' + '"' + " /sdcard/Download/") sleep(5) goto_dir('/Phone storage/Download', go_from_home_screen=True) #sleep(3) try: # cannot find some apks, skip them click_textview_by_text('new.apk') except AssertFailedException: log_test_case(self.tag, 'cannot find ' + apk) case_flag = False count_fail += 1 fail_apk_list.append(apk) continue sleep(2) while search_text('Next', 1, 0): # 0:disable scroll click_button_by_text('Next') click_button_by_text('Install') sleep(3) # add for Android L if is_view_enabled_by_text(VIEW_TEXT_VIEW, 'Preferred install location', isScrollable=0): click_textview_by_text('Let the system decide') while not search_text('Done', 1, 0): pass click_button_by_id('done_button') log = get_logcat_string(raw_cmd='-v time') #while not search_text('Folder'):pass # wait for back # # STEP 2: run monkey test # #open log log_test_framework('look', "look at me!!!\n" + log + "\nlook at me!!!\n") line = pmPattern.findall(log)[-1] log_test_framework(self.tag, "before monkey: " + line) package = re.findall("\w+(?:\.\w+){1,6}", line)[0] log_test_framework(self.tag, "before monkey: " + package) #run monkey send_key(KEY_HOME) monkey_num = '1000' result = os.popen( "adb shell monkey -p " + package + " " + monkey_num + " --throttle 500 --monitor-native-crashes --kill-process-after-error" ) result = copy.copy(result.read()) log_test_framework(self.tag, "after monkey:\n" + result) if not (re.findall("Events injected: " + monkey_num, result)): case_flag = False take_screenshot() log_test_case(self.tag, "%s failed in monkey" % apk) count_fail += 1 fail_apk_list.append(apk) # # STEP 3: exit # sleep(2) send_key(KEY_HOME) sleep(2) # # STEP 4: uninstall # os.system("adb uninstall " + package) sleep(5) os.system("adb shell rm -r /sdcard/Download/" + 'new.apk') sleep(5) goback() send_key(KEY_HOME) goback() log_test_case( self.tag, "%s apks to check; %s apks have checked" % (str(len(apk_list)), count)) exit_cur_case(self.tag) if case_flag: qsst_log_case_status(STATUS_SUCCESS, "", SEVERITY_HIGH) else: qsst_log_case_status(STATUS_FAILED, "some apps are failed", SEVERITY_HIGH) case_results.append( (self.case_config_map[fs_wrapper.CASE_NAME_ATTR], can_continue()))
def test_case_main(self, case_results): global case_flag, TAG case_flag = False TAG = "Dev-ci cases: Settings " log_test_framework(TAG, self.name + " -Start") """ cases contents you need to add """ start_activity('com.android.settings', 'com.android.settings.Settings') # if wait_for_fun(lambda:search_view_by_id('permission_allow_button'), True, 5): # phone.permission_allow() settings.add_calendar_event() if wait_for_fun(lambda: search_view_by_desc("More options"), True, 5): log_test_framework("cmcc_devci_settings_case12:", "case pass") case_flag = True if search_text("stopped", searchFlag=TEXT_CONTAINS): log_test_framework("cmcc_devci_settings_case12:", "Popup has stopped") take_screenshot() if search_text("OK"): click_button_by_text("OK") sleep(2) if search_text("Close"): click_button_by_text("Close") sleep(2) elif search_text("Unfortunately"): take_screenshot() if search_text("OK"): click_button_by_text("OK") sleep(2) if search_text("Close"): click_button_by_text("Close") sleep(2) log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs Crash") elif search_text("isn't responding"): take_screenshot() if search_text("OK"): click_button_by_text("OK") sleep(2) if search_text("Close"): click_button_by_text("Close") sleep(2) log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs ANR") else: log_test_framework("cmcc_devci_settings_case12:", "case fail") send_key(KEY_BACK) sleep(1) send_key(KEY_BACK) sleep(1) send_key(KEY_HOME) sleep(1) if case_flag: qsst_log_case_status(STATUS_SUCCESS, "", SEVERITY_HIGH) else: qsst_log_case_status(STATUS_FAILED, "", SEVERITY_HIGH) case_results.append( (self.case_config_map[fs_wrapper.CASE_NAME_ATTR], case_flag))
def export_to_simcard(self): """ This function export to simcard. @return: none """ send_key(KEY_MENU) #import/export #click_in_list_by_index(2) log_test_case(self.name, 'sometime cant find the ui,so wait for 1 s.') sleep(1) log_test_case(self.name, 'export or import') click_in_list_by_index(2) log_test_case(self.name, 'export to simcard') click_in_list_by_index(2) str_export_to_sim = contact.get_value('export_to_sim') if search_text(str_export_to_sim): click_button_by_index(0) #click_button_by_id('btn_ok') log_test_case(self.name, 'select first') click_in_list_by_index(0) log_test_case(self.name, ' ok') click_button_by_id('btn_ok') log_test_case(self.name, ' wait for at least 4s') sleep(5) return
def test_case_main(self, case_results): ''' main entry. @type case_results: tuple @param case_results: record some case result information ''' log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], 'ui_message_case1 : case Start') global case_flag case_flag = False global case_flag_sms_send case_flag_sms_send = False global case_flag_sms_receive case_flag_sms_receive = False start_activity('com.android.settings', '.Settings') settings.set_default_sms(1) # lunch Message start_activity("com.android.mms", "com.android.mms.ui.ConversationList") # click_imageview_by_id("home") local_assert(True, mms.go_home()) click_textview_by_text('All') sleep(1) click_textview_by_text('All') mms.delete_all_threads() send_num = SC.PUBLIC_SLOT2_PHONE_NUMBER receive_num = self.format_phone_number(SC.PUBLIC_SLOT1_PHONE_NUMBER) sms_text = "ui automation test send sms" click_imageview_by_desc('New message') click_textview_by_id("recipients_editor") ime.IME_input_number(1, send_num, "c") click_textview_by_text(mms.get_value("type_message")) ime.IME_input_english(1, sms_text) if search_view_by_id('send_button_sms'): click_imageview_by_id('send_button_sms') else: log_test_framework("ui_message_case1 :", "Please check sim state") func = lambda: search_text(mms.get_value("sent"), searchFlag=TEXT_CONTAINS) if not wait_for_fun(func, True, 10): case_flag_sms_send = False # mms.click_home_icon() set_cannot_continue() log_test_framework("ui_message_case1 :", "send SMS failed") else: case_flag_sms_send = True # mms.click_home_icon() sleep(1) mms.go_home() func1 = lambda: search_text(receive_num, searchFlag=TEXT_CONTAINS) if not wait_for_fun(func1, True, 10): set_cannot_continue() click_textview_by_text(receive_num, searchFlag=TEXT_CONTAINS) if not search_text(mms.get_value("received"), searchFlag=TEXT_CONTAINS): case_flag_sms_receive = False # mms.click_home_icon() set_cannot_continue() log_test_framework("ui_message_case1 :", "Receive SMS failed") else: case_flag_sms_receive = True # mms.click_home_icon() case_flag = case_flag_sms_send & case_flag_sms_receive goback() if case_flag: qsst_log_case_status(STATUS_SUCCESS, "", SEVERITY_HIGH) else: qsst_log_case_status( STATUS_FAILED, "case_flag_sms_receive: " + str(case_flag_sms_receive) + ", case_flag_sms_send: " + str(case_flag_sms_send), SEVERITY_HIGH) case_results.append( (self.case_config_map[fs_wrapper.CASE_NAME_ATTR], case_flag))
def test_case_main(self, case_results): global case_flag, TAG case_flag = False TAG = "Dev-ci cases: Phone " log_test_framework(TAG, self.name + " -Start") """ cases contnets you need to add """ settings.check_after_resetphone() start_activity('com.android.settings', '.Settings') sleep(5) settings.set_default_sms(1) sleep(1) send_key(KEY_BACK) sleep(2) settings.set_default_voice(1) sleep(1) send_key(KEY_HOME) start_activity("com.android.dialer", "com.android.dialer.DialtactsActivity") sleep(5) phone.permission_allow() click_button_by_id("floating_action_button") sleep(3) phone.dial("10086") sleep(3) start_activity("com.android.mms", "com.android.mms.ui.ConversationList") sleep(5) phone.permission_allow() mms.send_sms("13636583073", "receive sms when calling") if search_text('receive sms when calling', searchFlag=TEXT_CONTAINS): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Receive sms from SIM1 successfully") case_flag = True elif search_text("Unfortunately"): if search_text("OK"): click_button_by_text("OK") take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs Crash") elif search_text("isn't responding"): if search_text("OK"): click_button_by_text("OK") take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs ANR") else: take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "case fail") send_key(KEY_BACK) sleep(1) send_key(KEY_BACK) sleep(1) send_key(KEY_HOME) sleep(1) if case_flag: qsst_log_case_status(STATUS_SUCCESS, "", SEVERITY_HIGH) else: qsst_log_case_status(STATUS_FAILED, "", SEVERITY_HIGH) case_results.append( (self.case_config_map[fs_wrapper.CASE_NAME_ATTR], case_flag))
def test_case_main(self, case_results): global case_flag, TAG case_flag = False TAG = "Dev-ci cases: Messager " log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], self.name + ' : case Start') log_test_framework(TAG, self.name + " -Start") #Preconditions: Requires photo to be most recent picture taken and for the video to be directly across from it """ cases contnets you need to add """ wakeUpDevice() settings.kill_allpid() start_activity('com.android.settings', '.Settings') sleep(1) settings.set_default_sms(1) start_activity("com.android.mms", "com.android.mms.ui.ConversationList") sleep(10) phone.permission_allow() if search_view_by_id("action_compose_new") or search_view_by_id( "create"): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Enter Message successfully") sleep(1) if search_view_by_id('create'): click_button_by_id('create') sleep(5) if search_view_by_id('action_compose_new'): click_button_by_id('action_compose_new') sleep(5) #mms.add_recipient('13916370096') mms.add_recipient('15629036631') sleep(3) take_screenshot() sleep(3) mms.add_picture() sleep(5) if search_view_by_id('send_button_mms'): click_imageview_by_id('send_button_mms') sleep(120) if search_text('Sent'): log_test_case( self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Send mms from SIM1 succussfully") case_flag = True else: log_test_case( self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Send mms from SIM1 failed") take_screenshot() elif search_text("Unfortunately"): if search_text("OK"): click_button_by_text("OK") take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs Crash") elif search_text("isn't responding"): if search_text("OK"): click_button_by_text("OK") take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs ANR") else: take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "case fail") send_key(KEY_BACK) sleep(2) send_key(KEY_BACK) sleep(2) send_key(KEY_HOME) sleep(3) if case_flag: qsst_log_case_status(STATUS_SUCCESS, "", SEVERITY_HIGH) else: qsst_log_case_status(STATUS_FAILED, "", SEVERITY_HIGH) case_results.append( (self.case_config_map[fs_wrapper.CASE_NAME_ATTR], case_flag))
def test_case_main(self, case_results): global case_flag, TAG case_flag = False TAG = "Dev-ci cases: Messager " log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], self.name + ' : case Start') log_test_framework(TAG, self.name + " -Start") wakeUpDevice() settings.check_after_resetphone() settings.kill_allpid() start_activity("com.android.mms", "com.android.mms.ui.ConversationList") sleep(10) phone.permission_allow() if search_view_by_id("action_compose_new") or search_view_by_id( "create"): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Enter Message successfully") sleep(1) mms.send_sms("10086", "186") send_key(KEY_BACK) sleep(5) click_textview_by_text("Sent", clickType=LONG_CLICK) sleep(3) click_textview_by_desc("Call") sleep(2) click_textview_by_text("OK") sleep(2) click_imageview_by_id("avatar") sleep(3) if search_text("OK"): click_textview_by_text("OK") sleep(3) click_textview_by_text("Create new contact") sleep(3) click_textview_by_id("menu_save") sleep(3) send_key(KEY_BACK) sleep(2) send_key(KEY_BACK) sleep(2) send_key(KEY_HOME) sleep(2) start_activity("com.android.contacts", "com.android.contacts.activities.PeopleActivity") sleep(10) if search_text("10086"): case_flag = True elif search_text("Unfortunately"): if search_text("OK"): click_button_by_text("OK") take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs Crash") elif search_text("isn't responding"): if search_text("OK"): click_button_by_text("OK") take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs ANR") else: take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "case fail") send_key(KEY_BACK) sleep(2) send_key(KEY_BACK) sleep(2) send_key(KEY_HOME) sleep(3) if case_flag: qsst_log_case_status(STATUS_SUCCESS, "", SEVERITY_HIGH) else: qsst_log_case_status(STATUS_FAILED, "", SEVERITY_HIGH) case_results.append( (self.case_config_map[fs_wrapper.CASE_NAME_ATTR], case_flag))
def test_case_main(self, case_results): global case_flag , TAG, i,recoreName,p recordName=''.join(__name__.split('_')[-2:]) case_flag = False TAG = "Dev-ci cases: Messager " log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], self.name +' : case Start') log_test_framework(TAG, self.name + " -Start") # start_activity('com.android.settings','.Settings') # sleep(1) # settings.set_default_voice(1) p=subprocess.Popen('adb shell screenrecord /sdcard/%s.mp4'%recordName,shell=True) start_activity("com.android.dialer", "com.android.dialer.DialtactsActivity") if wait_for_fun(lambda:search_text("NEXT", searchFlag=TEXT_CONTAINS), True, 5) or wait_for_fun(lambda:search_view_by_id('permission_allow_button'), True, 5): phone.permission_allow() if wait_for_fun(lambda:search_view_by_id("floating_action_button"),True,5): click_button_by_id("floating_action_button") sleep(3) phone.phone_call("10086", "",slot=0,call_duration=15) sleep(3) wait_for_fun(lambda:search_view_by_id("dialtacts_options_menu_button"),True,10) click_button_by_id("dialtacts_options_menu_button") sleep(3) click_textview_by_text("Call History") sleep(3) click_textview_by_text("10086") sleep(3) click_textview_by_text("Send a message") if wait_for_fun(lambda:search_text("NEXT", searchFlag=TEXT_CONTAINS), True, 5) or wait_for_fun(lambda:search_view_by_id('permission_allow_button'), True, 5): phone.permission_allow() if wait_for_fun(lambda:search_view_by_id("embedded_text_editor"), True, 60): entertext_edittext_by_id("embedded_text_editor", "value") sleep(3) click_imageview_by_id("send_button_sms") if wait_for_fun(lambda:search_text("Now"), True, 120): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "case pass") case_flag=True else: log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "case fail") take_screenshot() if search_text("Unfortunately",isScrollable=0,searchFlag=TEXT_CONTAINS): if search_text("OK"): click_button_by_text("OK") take_screenshot() case_flag=False log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs Crash") elif search_text("isn't responding",isScrollable=0,searchFlag=TEXT_CONTAINS): if search_text("OK"): click_button_by_text("OK") take_screenshot() case_flag=False log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs ANR") send_key(KEY_BACK) sleep(1) send_key(KEY_BACK) sleep(1) send_key(KEY_HOME) sleep(1) if case_flag: qsst_log_case_status(STATUS_SUCCESS, "" , SEVERITY_HIGH) else: qsst_log_case_status(STATUS_FAILED, "", SEVERITY_HIGH) case_results.append((self.case_config_map[fs_wrapper.CASE_NAME_ATTR], case_flag))
def test_case_main(self, case_results): global case_flag, case_flag_slot1, case_flag_slot2, TAG case_flag_slot1 = False case_flag_slot2 = False case_flag = False TAG = "Dev-ci cases: Phone " log_test_framework(TAG, self.name + " -Start") """ cases contnets you need to add """ settings.check_after_resetphone() start_activity('com.android.settings', '.Settings') settings.set_default_voice(1) sleep(1) send_key(KEY_HOME) start_activity("com.android.phone", "com.android.phone.EmergencyDialer") sleep(3) phone.dial("911") sleep(3) if search_text('Emergency', searchFlag=TEXT_CONTAINS): case_flag_slot1 = True log_test_framework( TAG, "Dial emergency call from card 1 successfully ") click_button_by_id("floating_end_call_action_button") sleep(2) start_activity('com.android.settings', '.Settings') settings.set_default_voice(2) sleep(1) send_key(KEY_HOME) start_activity("com.android.phone", "com.android.phone.EmergencyDialer") sleep(3) phone.dial('911') sleep(3) if search_text('Emergency', searchFlag=TEXT_CONTAINS): case_flag_slot2 = True log_test_framework( TAG, "Dial emergency call from card 2 successfully ") click_button_by_id("floating_end_call_action_button") sleep(2) elif search_text("Unfortunately"): if search_text("OK"): click_button_by_text("OK") take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs Crash") elif search_text("isn't responding"): if search_text("OK"): click_button_by_text("OK") take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs ANR") else: take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "case fail") send_key(KEY_BACK) sleep(1) send_key(KEY_BACK) sleep(1) send_key(KEY_HOME) sleep(1) case_flag = case_flag_slot1 and case_flag_slot2 if case_flag: qsst_log_case_status(STATUS_SUCCESS, "", SEVERITY_HIGH) else: qsst_log_case_status(STATUS_FAILED, "", SEVERITY_HIGH) case_results.append( (self.case_config_map[fs_wrapper.CASE_NAME_ATTR], case_flag))
def test_case_main(self, case_results): global case_flag, TAG, i, recoreName, p, x, y recordName = ''.join(__name__.split('_')[-2:]) case_flag = False result = [] TAG = "Take picture for sporting object in Sports mode: Camera " log_test_framework(TAG, self.name + " -Start") """ cases contents you need to add """ if search_text("Close app", searchFlag=TEXT_CONTAINS): click_button_by_text("Close app", searchFlag=TEXT_CONTAINS) sleep(2) p = subprocess.Popen('adb shell screenrecord /sdcard/%s.mp4' % recordName, shell=True) start_activity('org.codeaurora.snapcam', 'com.android.camera.CameraLauncher') if wait_for_fun(lambda: search_view_by_id('permission_allow_button'), True, 10): click_button_by_id('permission_allow_button') if wait_for_fun(lambda: search_text('OK'), True, 5): click_textview_by_text('OK') if wait_for_fun(lambda: search_view_by_id('shutter_button'), True, 5): log_test_framework("step1:", "Launch camera pass") switchCR('Picture') camera.setSports() if wait_for_fun(lambda: search_view_by_id('shutter_button'), True, 5): click_textview_by_id('shutter_button') sleep(8) case_flag = True if search_text("isn't responding", searchFlag=TEXT_CONTAINS): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs ANR") case_flag = False take_screenshot() if search_text("Close app", searchFlag=TEXT_CONTAINS): click_button_by_text("Close app", searchFlag=TEXT_CONTAINS) sleep(2) if search_text("Close", searchFlag=TEXT_CONTAINS): click_button_by_text("Close") sleep(2) elif search_text("Unfortunately", searchFlag=TEXT_CONTAINS): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs crash") case_flag = False take_screenshot() if search_text("OK", searchFlag=TEXT_CONTAINS): click_button_by_text("OK") sleep(2) if search_text("Close", searchFlag=TEXT_CONTAINS): click_button_by_text("Close") sleep(2) elif search_text("stopped", searchFlag=TEXT_CONTAINS): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Popup has stopped") case_flag = False take_screenshot() if search_text("Close", searchFlag=TEXT_CONTAINS): click_button_by_text("Close") sleep(2) if search_text("OK", searchFlag=TEXT_CONTAINS): click_button_by_text("OK") sleep(2) elif search_text("Close app", searchFlag=TEXT_CONTAINS): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Popup Close app error") case_flag = False take_screenshot() click_button_by_text("Close app", searchFlag=TEXT_CONTAINS) sleep(2) send_key(KEY_BACK) sleep(1) send_key(KEY_BACK) sleep(1) send_key(KEY_HOME) sleep(1) if case_flag: qsst_log_case_status(STATUS_SUCCESS, "", SEVERITY_HIGH) else: qsst_log_case_status(STATUS_FAILED, "", SEVERITY_HIGH) case_results.append( (self.case_config_map[fs_wrapper.CASE_NAME_ATTR], case_flag))
def test_case_main(self, case_results): global case_flag, TAG case_flag = False camera = Camera() TAG = "Dev-ci cases: Messager " log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], self.name + ' : case Start') log_test_framework(TAG, self.name + " -Start") start_activity('com.android.settings', '.Settings') sleep(1) settings.set_default_sms(2) start_activity("com.android.mms", "com.android.mms.ui.ConversationList") sleep(10) phone.permission_allow() if search_view_by_id("action_compose_new") or search_view_by_id( "create"): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Enter Message successfully") sleep(1) mms.send_sms("13916371096", "sim2") if wait_for_fun(lambda: search_text('Sent'), True, 120): log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "send from SIM2 succussfully") case_flag = True elif search_text("Unfortunately"): if search_text("OK"): click_button_by_text("OK") take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs Crash") elif search_text("isn't responding"): if search_text("OK"): click_button_by_text("OK") take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "Occurs ANR") else: take_screenshot() log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], "case fail") send_key(KEY_BACK) sleep(2) send_key(KEY_BACK) sleep(2) send_key(KEY_HOME) sleep(3) if case_flag: qsst_log_case_status(STATUS_SUCCESS, "", SEVERITY_HIGH) else: qsst_log_case_status(STATUS_FAILED, "", SEVERITY_HIGH) case_results.append( (self.case_config_map[fs_wrapper.CASE_NAME_ATTR], case_flag))
def test_case_main(self, case_results): global case_flag , TAG case_flag = False TAG = "Dev-ci cases: Messager " log_test_case(self.case_config_map[fs_wrapper.CASE_NAME_ATTR], self.name +' : case Start') log_test_framework(TAG, self.name + " -Start") settings.kill_allpid() start_activity('com.android.settings','.Settings') settings.set_default_sms(1) start_activity("com.android.mms", "com.android.mms.ui.ConversationList") sleep(1) mms.go_home() mms.check_default_mms_app() mms.go_home() mms.delete_all_threads() sleep(1) ''' @attention: change to PUBLIC_SLOT2_PHONE_NUMBER ''' send_num = SC.PUBLIC_SLOT2_PHONE_NUMBER sms_text = "ui automation test send" click_textview_by_desc('New message') click_textview_by_id("recipients_editor") ime.IME_input_number(1, send_num, "c") click_textview_by_text(mms.get_value("type_message")) entertext_edittext_on_focused(sms_text) #ime.IME_input_english(1, sms_text) sleep(1) mms.attach_capture_video(1) sleep(1) attach_size1=get_view_text_by_id(VIEW_TEXT_VIEW, "mms_size_indicator") if search_text("^\d\dK/300K$", searchFlag=TEXT_MATCHES_REGEX): log_test_case("test_suit_cmcc_devci_message_case10", "attach first attachment successfully") take_screenshot() else: take_screenshot() log_test_case("test_suit_cmcc_devci_message_case10", "Fail to attach first attachment") set_cannot_continue() sleep(3) #click_button_by_id("replace_image_button") click_button_by_text(mms.get_value("replace"),searchFlag=TEXT_CONTAINS) mms.attach_capture_video(2) sleep(1) func_size = lambda:search_view_by_id("mms_size_indicator") if not wait_for_fun(func_size, True, 10): log_test_case("test_suit_cmcc_devci_message_case10", "can not found the size of video") attach_size2=get_view_text_by_id(VIEW_TEXT_VIEW, "mms_size_indicator") if search_text("^\d\d+K/300K$", searchFlag=TEXT_MATCHES_REGEX)and(not attach_size1==attach_size2): log_test_case("test_suit_cmcc_devci_message_case10", "Replace attachment successfully") take_screenshot() else: take_screenshot() log_test_case("test_suit_cmcc_devci_message_case10", "Fail to replace first attachment") set_cannot_continue() func2 = lambda:search_text('MMS', isScrollable=1, searchFlag=TEXT_CONTAINS) if not wait_for_fun(func2, True, 10): set_cannot_continue() log_test_framework("cmcc_devci_message_case10:", "send button not found") else: click_imageview_by_id('send_button_mms') func3 = lambda:search_text(mms.get_value("sent"), searchFlag=TEXT_CONTAINS) if not wait_for_fun(func3, True, 120): log_test_framework("cmcc_devci_message_case10:", "Sent mms failed") else: log_test_framework("cmcc_devci_message_case10:", "Sent mms successful") case_flag = True if case_flag: qsst_log_case_status(STATUS_SUCCESS, "" , SEVERITY_HIGH) else: qsst_log_case_status(STATUS_FAILED, "", SEVERITY_HIGH) case_results.append((self.case_config_map[fs_wrapper.CASE_NAME_ATTR], case_flag))