def tearDown(self): super(GalleryTest,self).tearDown() u.pressBack(4) #Discard sharing action if d(text = 'OK').wait.exists(timeout = 2000): d(text = 'OK').click.wait() u.pressBack(4)
def switchBackOrFrontCamera(self,status): # Dictionary camerastatus = {'back': '0','front':'1'} # Get the current camera status currentstatus = commands.getoutput(CAMERA_ID) # Confirm the current status of the user is required if currentstatus.find(camerastatus.get(status)) == -1: # draw down the menu commands.getoutput(DRAWDOWN_MENU) time.sleep(1) # set the camera status d(description = FRONTBACKBUTTON_DESCR).click.wait() time.sleep(3) # Get the current camera status currentstatus = commands.getoutput(CAMERA_ID) # check the result if currentstatus.find(camerastatus.get(status)) != -1: #print ('set camera is '+status) return True else: #print ('set camera is '+status+' fail') return False else: #print('Current camera is ' + status) pass
def _launchCamera(self): d.start_activity(component = ACTIVITY_NAME) time.sleep(2) #When it is the first time to launch camera there will be a dialog to ask user 'remember location', so need to check if d(text = 'OK').wait.exists(timeout = 2000): d(text = 'OK').click.wait() assert d(resourceId = 'com.intel.camera22:id/mode_button').wait.exists(timeout = 3000), 'Launch camera failed in 3s'
def _enableGalleryFR(self): d(description = 'More options').click.wait() try: assert d(text = 'Face recognition Off').wait.exists(timeout = 2000) d.click(660,120) except: d(text = 'Face recognition On').click.wait()
def testAnimateToGIFAllInGridView(self): """ Summary: Animate all in gallery Step: 1.Launch gallery activity 2.Enter Grid view 3.Long touch a pic or video to select 4.Tap select file dropdown 5.Tap select all option 6.Tap extra menu 7.Tap Convert option 8.Select the GIF convert settings 9.Tap animate button 10.Tap Save button """ # Step 3 self._longtouchscreencenter() # Step 4 + Step 5 d(text = '1 selected').click() d(text = 'Select all').click() # Step 6 + Step 7 u.setMenuOptions('Animate') d(text = 'Animated GIF').click() d(text = 'Create').click() time.sleep(2) d(text = 'Save').click.wait() time.sleep(2) # confirm create complete result = commands.getoutput('adb shell ls -l /sdcard/Sharing | grep gif | wc -l') if string.atoi(result) != 1: self.fail('animated failed')
def tearDown(self): super(GalleryTest,self).tearDown() u.pressBack(4) #There will be a dialog ask user if save the edited photo when pressing back after case failed if d(text = 'Cancel').wait.exists(timeout = 2000): d(text = 'Cancel').click.wait() u.pressBack(4)
def _setGeoOn(self): geovalue = commands.getoutput(CAMERA_GEOTAG_ON_OFF) geoonoffv = geovalue.find('off') if geoonoffv != -1: d(description = 'Camera settings').click.wait() d.click(290,170) #Tap on Geo point d.click(170,300) #Set Geo On
def _setFDFRMode(self,option): d(resourceId = 'com.intel.camera22:id/left_menus_face_tracking').click() FDFRStatus = commands.getoutput('adb shell cat /data/data/com.intel.camera22/shared_prefs/com.intel.camera22_preferences_0.xml | grep pref_fdfr_key') if FDFRStatus.find(option) == -1: d(resourceId = 'com.intel.camera22:id/left_menus_face_tracking').click() else: pass
def _launchMMS(self): commands.getoutput("adb shell am start -n com.android.mms/.ui.ConversationList") time.sleep(1) d(resourceId="com.android.mms:id/action_compose_new").click.wait() assert d(resourceId="com.android.mms:id/send_button_sms").wait.exists( timeout=3000 ), "enter MMS send screen fail"
def switchcamera(self, mode): d(resourceId=MODE_LIST_BUTTON).click.wait() try: assert d(resourceId='com.intel.camera22:id/mode_wave_smile') self._touchmode(mode) except: d(resourceId='com.intel.camera22:id/mode_wave_photo').click() self._touchmode(mode)
def _takePicture(self): before = commands.getoutput('adb shell ls /sdcard/DCIM/* | grep IMG | wc -l') #Count before taking picture d(resourceId = 'com.intel.camera22:id/shutter_button').click.wait() #Tap on capture button after = commands.getoutput('adb shell ls /sdcard/DCIM/* | grep IMG | wc -l') #Count after taking picture if string.atoi(before) == string.atoi(after) - 1 or string.atoi(before) == string.atoi(after) - 2: pass else: self.fail('Take picture failed.')
def takeVideo(self,status): # Start record video d(resourceId = CPTUREBUTTON_RESOURCEID).click.wait() # Set recording time time.sleep(status - 2) #Stop record video d(resourceId = CPTUREBUTTON_RESOURCEID).click.wait() return True
def _SlideShowIconEditScreen(self,status): d(resourceId = 'com.intel.android.gallery3d:id/action_edit_burst').click.wait() time.sleep(1) d(resourceId = 'com.intel.android.gallery3d:id/selection_menu').click.wait() d(text = 'Select all').click.wait() d(className = 'android.widget.TextView').click.wait() d(text = status).click.wait() time.sleep(10)
def _setPicAs(self, setact): d.press('menu') d(text='Set picture as').click.wait() setmode = { 'contact': 'Contact photo', 'wallpaper': 'com.intel.android.gallery3d' } d(text=setmode[setact]).click.wait()
def _launchemail(self): commands.getoutput("adb shell am start -n com.android.email/.activity.Welcome") time.sleep(2) if d(text="Account setup").wait.exists(timeout=1000): print "login the email account" else: assert d(resourceId="com.android.email:id/compose").wait.exists(timeout=2000), "enter email fail" time.sleep(1)
def testOpenBrowser(self): assert d.exists(text='Internet') , 'not appear on the home screen' assert d.exists(text='Apps') , 'not appear on the home screen' d(text='Internet').click.wait() assert d(description="Bookmarks").wait.exists(timeout=10000), 'browser unable to open in 10 secs' d(className='android.widget.EditText').set_text('www.baidu.com') d.click('go.png', threshold=0.01) d.expect('baidu_logo.png', timeout=20)
def testUPIcon(self): for i in range(100): d(resourceId = 'android:id/home').click.wait() assert d(description = 'Switch to camera').wait.exists(timeout = 2000) u.pressBack(4) u.launchGallery() u.enterXView('fullview') u.showPopCard()
def takeVideo(self, status): # Start record video d(resourceId=CPTUREBUTTON_RESOURCEID).click.wait() # Set recording time time.sleep(string.atoi(status) - string.atoi('2')) #Stop record video d(resourceId=CPTUREBUTTON_RESOURCEID).click.wait() return True
def testDeleteOneByOne(self): self._clearAndPush500Pic() u.launchGallery() u.enterXView('fullview') u.showPopCard() for i in range(100): d(description = 'Delete').click.wait() d(text = 'Delete').click.wait() #Confirm it
def _SlideShowIconEditScreen(self,status): d(resourceId = 'com.intel.android.gallery3d:id/action_edit_burst').click.wait() time.sleep(1) d(resourceId = 'com.intel.android.gallery3d:id/selection_menu').click.wait() d(text = 'Select all').click.wait() d(description = 'Slideshow').click.wait() d(text = status).click.wait() time.sleep(10)
def switchcamera(self,mode): d(resourceId = MODE_LIST_BUTTON).click.wait() try: assert d(resourceId = 'com.intel.camera22:id/mode_wave_smile') self._touchmode(mode) except: d(resourceId = 'com.intel.camera22:id/mode_wave_photo').click() self._touchmode(mode)
def tearDown(self): super(GalleryTest,self).tearDown() #4.Exit activity u.pressBack(4) #Force close tap on OK if d(text = 'OK').wait.exists(timeout = 2000): d(text = 'OK').click.wait() u.pressBack(4)
def _launchCamera(self): d.start_activity(component=ACTIVITY_NAME) time.sleep(2) #When it is the first time to launch camera there will be a dialog to ask user 'remember location', so need to check if d(text='OK').wait.exists(timeout=2000): d(text='OK').click.wait() assert d(resourceId='com.intel.camera22:id/mode_button').wait.exists( timeout=3000), 'Launch camera failed in 3s'
def testFRBackgroundProcess(self): self._checkResource() self._launchGallery() d(text = 'Albums').click.wait() #Tap on album to switch other view assert d(text = 'People').wait.exists(timeout = 2000) d(text = 'People').click.wait() #Swtich to people view time.sleep(3) d.expect('Unknown_New_Face.png')
def _touchmode(self,mode): if mode == 'burstslow': d(resourceId = MODE_ID[mode]).click.wait() d(text = 'SLOW').click.wait() elif mode == 'burstfast': d(resourceId = MODE_ID[mode]).click.wait() d(text = 'FAST').click.wait() else: d(resourceId = MODE_ID[mode]).click.wait()
def testCardpopDetails(self): self._checkResource() self._launchGallery() self._enterSingleView() self._showPopupCard() d.swipe(350,1100,350,350) #Pull pop up card up assert d(text = 'Facebook').wait.exists(timeout = 2000), 'Pop up card has not been pulled up' d.swipe(350,1100,350,350) #Pull up second time to show details assert d(text = 'Advanced photo details').wait.exists(timeout = 2000), 'Details in pop up card does not shown'
def testEditingPerfectShot(self): self._deleteAllPictures() self._takePicUnderPerfectMode() self._launchGallery() self._enterSingleView() self._showPopupCard() d(resourceId = 'com.intel.android.gallery3d:id/action_edit_perfectshot').click.wait() time.sleep(5) #This may take a few seconds assert d(index = '8', resourceId = 'com.intel.android.gallery3d:id/base_image_button8').wait.exists(timeout = 2000), 'Count for Perfect pictures is not touch 9.'
def _touchmode(self, mode): if mode == 'burstslow': d(resourceId=MODE_ID[mode]).click.wait() d(text='SLOW').click.wait() elif mode == 'burstfast': d(resourceId=MODE_ID[mode]).click.wait() d(text='FAST').click.wait() else: d(resourceId=MODE_ID[mode]).click.wait()
def _setFDFRMode(self, option): FDFRStatus = commands.getoutput( 'adb shell cat /data/data/com.intel.camera22/shared_prefs/com.intel.camera22_preferences_0.xml | grep pref_fdfr_key' ) if FDFRStatus.find(option) == -1: d(resourceId='com.intel.camera22:id/left_menus_face_tracking' ).click() else: pass
def _launchCamera(self): d.start_activity(component=ACTIVITY_NAME) # When it is the first time to launch camera there will be a dialog to ask user 'remember location', so need to check try: assert d(text="OK").wait.exists(timeout=2000) d(text="OK").click.wait() except: pass assert d(resourceId="com.intel.camera22:id/mode_button").wait.exists(timeout=3000), "Launch camera failed in 3s"
def _launchSmail(self): try: d(text = 'OK').wait.exists(timeout=3000) d(text = 'OK').click.wait() except: pass finally: d.click(650,1090) d.click(650,930)
def deleteItem(self, deleteoption): ''' deleteoption has two args: Delete, Cancel(str type, initial capital), usage: -> deleteItem('Cancel') It means you will cancel deleting image/video file ''' d(description='Delete').click.wait() d(text=deleteoption).click.wait()
def deleteItem(self, deleteoption): """ deleteoption has two args: Delete, Cancel(str type, initial capital), usage: -> deleteItem('Cancel') It means you will cancel deleting image/video file """ d(description="Delete").click.wait() d(text=deleteoption).click.wait()
def _launchcamera(self): commands.getoutput(CAMERA_ACTIVITY) try: d(text = 'OK').wait.exists(timeout=3000) d(text = 'OK').click.wait() except: pass finally: pass
def _launchperfectshot(self): try: d(text = 'OK').wait.exists(timeout=3000) d(text = 'OK').click.wait() except: pass finally: d.click(650,1090) time.sleep(3) d.click(230,1097)
def _launchpanorama(self): try: d(text = 'OK').wait.exists(timeout=3000) d(text = 'OK').click.wait() except: pass finally: d.click(650,1090) time.sleep(2) d.click(80,1084)
def testRotateAllInGridView(self): """ Summary: rotate all in grid view Step: 1.Launch gallery activity 2.Enter Grid view 3.Long touch a pic or video to select 4.Tap select file dropdown 5.Tap select all option 6.Tap extra menu 7.Tap Rotate left/Rotate right """ # Step 3 self._longtouchscreencenter() # Step 4 + Step 5 d(text = '1 selected').click() d(text = 'Select all').click() # Step 6 + Step 7 u.setMenuOptions('Rotate left') time.sleep(2) self._longtouchscreencenter() d(text = '1 selected').click() d(text = 'Select all').click() u.setMenuOptions('Rotate right') # confirm back to gallery assert d(description = 'Switch to camera').wait.exists(timeout = 2000)
def testSharePictureToBlueTooth(self): ''' Summary: Share 1 picture in bluetooth Steps: 1.Enter full view 2.Click share icon 3.Click bluetooth icon ''' u.shareItem('Bluetooth') if d(text='Turn on').wait.exists(timeout=2000): d(text='Turn on').click.wait() assert d(text='Scan for devices').wait.exists(timeout=2000)
def testEnterCropScreen(self): ''' Summary: Enter Crop interface Steps: 1.Enter full view 2.Click setting menu 3.Touch edit 4.Touch Crop icon ''' u.setMenuOptions('Edit') d(resourceId = 'com.intel.android.gallery3d:id/geometryButton').click.wait() assert d(resourceId = 'com.intel.android.gallery3d:id/straightenButton').wait.exists(timeout = 2000)
def testCropCancel(self): ''' Summary: Crop cancel Steps: 1.Enter full view 2.Click setting menu 3.Click crop 4.Click cancel ''' u.setMenuOptions('Crop') assert d(text='Crop picture').wait.exists(timeout=3000) d(text='Cancel').click.wait() assert d(text='Crop').wait.gone(timeout=2000)
def testChangeContactPhoto(self): ''' Summary: Test change contact photo Steps: 1. Launch gallery and open a picture has recognized face 2. Tap on the face menu icon and select change contact photo 3. Click crop ''' self._recognizeAFace() #Change contact photo self._editFDFR('Change contact photo') d(text='Crop').click.wait() assert d(description='Delete').wait.exists(timeout=2000)
def setUp(self): super(CameraTest,self).setUp() # rm DCIM folder and refresh from adb shell a.cmd('rm','/sdcard/DCIM/100ANDRO') a.cmd('refresh','/sdcard/DCIM/100ANDRO') #Because default camera after launching is single mode, so we set this step in setUp(). #Step 1. Launch single capture activity a.cmd('launch','com.intel.camera22/.Camera') time.sleep(2) if d(text = 'OK').wait.exists(timeout = 3000): d(text = 'OK').click.wait() else: assert d(resourceId = 'com.intel.camera22:id/shutter_button'),'Launch camera failed!!'
def _setPictureSizeStatus(self, status): #commands.getoutput('adb shell input swipe 530 6 523 22') d.swipe(530, 6, 523, 22) d(description='Camera settings').click.wait() #.d() if status == 'WideScreen': d.click(60, 292) elif status == 'StandardScreen': d.click(180, 292) state = commands.getoutput() statevalue = state.find(status) if statevalue == -1: self.fail('set camera picture size to' + status + 'fail!')
def setCameraSetting(mode,setting,option): settings = MODE[mode][0] options = MODE[mode][1] if setting == 'flash': _setFlashMode(option) else: d(resourceId = 'com.intel.camera22:id/left_menus_camera_setting').click.wait(timeout=2000) if SINGLE_SETTING.index(setting)<=len(settings): # 6 is the max index element in the screen d(resourceId = HORI_LIST_BUTTON)[settings.index(setting)].click.wait() d(resourceId = HORI_LIST_BUTTON)[options[setting].index(option)+len(settings)].click.wait() else: d.swipe(680,180,100,180) d(resourceId = HORI_LIST_BUTTON)[settings.index(setting)-2].click.wait() d(resourceId = HORI_LIST_BUTTON)[options[setting].index(option)+len(settings)].click.wait() # def setSmileCameraSetting(setting,option): # if setting == 'flash': # _setFlashMode(option) # else: # d(resourceId = 'com.intel.camera22:id/left_menus_camera_setting').click.wait(timeout=2000) # d(resourceId = HORI_LIST_BUTTON)[SMILE_SETTING.index(setting)].click.wait() # d(resourceId = HORI_LIST_BUTTON)[SMILE_OPTION[setting].index(option)+len(SMILE_SETTING)].click.wait() # def setHDRCameraSetting(setting,option): # d(resourceId = 'com.intel.camera22:id/left_menus_camera_setting').click.wait(timeout=2000) # d(resourceId = HORI_LIST_BUTTON)[HDR_SETTING.index(setting)].click.wait() # d(resourceId = HORI_LIST_BUTTON)[HDR_OPTION[setting].index(option)+len(HDR_SETTING)].click.wait() # def setVideoCameraSetting(setting,option): # if setting == 'flash': # _setFlashMode(option) # else: # d(resourceId = 'com.intel.camera22:id/left_menus_camera_setting').click.wait(timeout=2000) # d(resourceId = HORI_LIST_BUTTON)[SMILE_SETTING.index(setting)].click.wait() # d(resourceId = HORI_LIST_BUTTON)[SMILE_OPTION[setting].index(option)+len(SMILE_SETTING)].click.wait() # def setBurstCameraSetting(setting,option): # d(resourceId = 'com.intel.camera22:id/left_menus_camera_setting').click.wait(timeout=2000) # d(resourceId = HORI_LIST_BUTTON)[BURST_SETTING.index(setting)].click.wait() # d(resourceId = HORI_LIST_BUTTON)[BURST_OPTION[setting].index(option)+len(BURST_SETTING)].click.wait() # def setPerfectshotCameraSetting(setting,option): # d(resourceId = 'com.intel.camera22:id/left_menus_camera_setting').click.wait(timeout=2000) # d(resourceId = HORI_LIST_BUTTON)[PERFECTSHOT_SETTING.index(setting)].click.wait() # d(resourceId = HORI_LIST_BUTTON)[PERFECTSHOT_OPTION[setting].index(option)+len(PERFECTSHOT_SETTING)].click.wait() # def setBurstCameraSetting(setting,option): # d(resourceId = 'com.intel.camera22:id/left_menus_camera_setting').click.wait(timeout=2000) # d(resourceId = HORI_LIST_BUTTON)[PANORAMA_SETTING.index(setting)].click.wait() # d(resourceId = HORI_LIST_BUTTON)[PANORAMA_OPTION[setting].index(option)+len(PANORAMA_SETTING)].click.wait()
def shareItem(self, shareto=None): ''' The function simulate user sharing items in gallery. Usage: If you want to share item with Facebook(this item at the bottom of the share list as default) -> shareItem('Facebook') *Do not write press menu/share icon step(s) before using ''' d(description='Share').click.wait( ) #Its description is 'Share' in each view if shareto != None: try: assert d(text=shareto).wait.exists(timeout=2000) except: d(text='See all').click.wait() #Display all share path finally: try: assert d(text=shareto).wait.exists(timeout=2000) except: d.swipe(500, 1050, 500, 200) #Slide share list up finally: d(text=shareto).click.wait( ) #Tap on the path you want to share to
def _setFlashStatus(self, status): #commands.getoutput('adb shell input swipe 530 6 523 22') # Touch flash setting d.swipe(530, 6, 523, 22) d(description='Camera settings').click.wait() if status == 'on': d.click(176, 176) elif status == 'off': d.click(59, 178) else: self.touch((296, 176)) state = commands.getoutput(PictureSize_STATE) statevalue = state.find(status) if statevalue == -1: self.fail('set camera flash status to' + status + 'fail!')
def _turnFDFR(self, fdfroption): ''' The function is to turn on/off face identity, usage as below: -> _turnFDFR('On') *You may need inputing 'On' but not 'on' ''' u.showPopCard() d.press('menu') if d(text='Face recognition %s' % fdfroption).wait.exists(timeout=2000): d(text='Face recognition %s' % fdfroption).click.wait() else: d.press('menu')
def testTurnFDFROnOff(self): ''' Summary: Test turn on/off FD/FR icon Steps: 1. Launch gallery and open a picture 2. Press menu key 3. Turn on/off FD/FR icon ''' self._turnFDFR('Off') u.tapOnCenter() #Tap on the face #If FDFR has been turned off, tap on the face will make pop card disappear assert d(resourceId='com.intel.android.gallery3d:id/handle').wait.gone( timeout=2000) self._turnFDFR('On') u.tapOnCenter() #Tap on the face assert d(text='Create new contact').wait.exists(timeout=2000)
def _removeIdentity(self): u.tapOnCenter() #Tap on the face on image #Below is to remove the exists face recognize if d(description='Edit menu').wait.exists(timeout=2000): self._editFDFR('Remove identity') else: d.press('back')
def showPopCard(self): d.click(350, 100).wait(1000) #The center of the top action bar d.click(350, 100).wait( 1000 ) #Sometimes there is no response if tap here only once. Although it has poped up, tap here would do no thing for the case assert d(description='Share').wait.exists( timeout=2000 ), 'Pop card does not display after tapping on the top bar twice'
def testCheckShareListIcons(self): ''' Summary: Click share icon the share list would appear Steps: 1.Enter full view 2.Click share icon ''' u.shareItem() assert d(text='See all').wait.exists(timeout=2000)
def testPlayVideoFile(self): ''' Summary: Play video file Steps: 1.Launch socialgallery 2. Select video file and Enter full view 3.Touch play icon and play video file 4.Touch screen any point twice and pause this video 5. Exit socialgallery ''' u.tapOnCenter() #Press playback icon if d(text='Complete action using').wait.exists(timeout=2000): try: assert d(text='Always', enabled='true').wait.exists(timeout=2000) except: d(text='com.intel.android.gallery3d').click.wait() finally: d(text='Always').click.wait() time.sleep(10) #Play video file 10 s u.showPopCard() #Invoke pop card u.tapOnCenter() #Pause the video playback assert d( resourceId= 'com.intel.android.gallery3d:id/background_play_action_provider_button' ).wait.exists(timeout=2000)
def testSharePictureToPicasa(self): ''' Summary: Share 1 picture in picasa Steps: 1.Enter full view 2.Click share icon 3.Click picasa icon ''' u.shareItem('Picasa') assert d(text='Upload').wait.exists(timeout=2000)
def testSharePictureToOrkut(self): ''' Summary: Share 1 picture in orkut Steps: 1.Enter full view 2.Click share icon 3.Click orkut icon ''' u.shareItem('Orkut') assert d(text='Add a new account').wait.exists(timeout=2000)
def testSharePictureToFacebook(self): ''' Summary: Share 1 picture in FaceBook Steps: 1.Enter full view 2.Click share icon 3.Click FaceBook icon ''' u.shareItem('Facebook') assert d(text='Loading...').wait.exists(timeout=2000)
def testSharePictureToDrive(self): ''' Summary: Share 1 picture in Gmail Steps: 1.Enter full view 2.Click share icon 3.Click Gmail icon ''' u.shareItem('Drive') assert d(text='Upload to Drive').wait.exists(timeout=2000)
def testSharePictureToGmail(self): ''' Summary: Share 1 picture in Gmail Steps: 1.Enter full view 2.Click share icon 3.Click Gmail icon ''' u.shareItem('Gmail') assert d(text='Subject').wait.exists(timeout=2000)
def testSharePictureTowifidirect(self): ''' Summary: Share 1 picture in Wi‑Fi Direct Steps: 1.Enter full view 2.Click share icon 3.Click Wi‑Fi Direct icon ''' u.shareItem('Wi‑Fi Direct') assert d(text='Peer devices').wait.exists(timeout=2000)
def testDeleteCancel(self): ''' Summary: Delete the photo Steps: 1.Enter full view 2.Touch trash icon 3.Touch cancel ''' u.deleteItem('Cancel') assert d(text='Delete').wait.gone(timeout=5000)