def setUp(self): u.setUp() #Launch music player d.start_activity(component='com.smartisanos.music/.activities.MusicMain') assert d(resourceId = 'com.smartisanos.music:id/ib_right').wait.exists(timeout=5000),'Launch music player failed in 5s!' d(text = '歌曲',resourceId = 'com.smartisanos.music:id/rb_song').click.wait() assert d(resourceId = 'com.smartisanos.music:id/tv_title',text = '歌曲').wait.exists(timeout = 5000),'Switch to music list failed in 5s!'
def testVisitWebPage4G(self): # turn off wifi self._setWifistatus('off') d.sleep(3) #Launch Browser self._launchBrowser() # visite webpage d(resourceId = 'com.android.browser:id/url', text = '输入网址').set_text(TOP5[3]) d.press('enter') d.expect(CHECK_POINT[3], timeout=15) # browse webpage d.swipe(1000,1300,1000,600,10) d.sleep(1) d.swipe(1000,1300,1000,600,10) d.sleep(1) d.swipe(1000,600,1000,1300,10) d.sleep(1) d.swipe(1000,600,1000,1300,10) d.sleep(1) # turn on wifi self._setWifistatus('on') d.start_activity(component='com.android.browser/.BrowserActivity') assert d(resourceId = 'com.android.browser:id/switch_btn').wait.exists(timeout = 5000),'Launch browser failed in 5s!'
def testPlayStreamingVideo(self): #Start Browser d.start_activity(component='com.android.browser/.BrowserActivity') assert d(resourceId = 'com.android.browser:id/switch_btn').wait.exists(timeout = 5000),'Launch browser failed in 5s!' d(resourceId = 'com.android.browser:id/newtab_btn').click.wait() # input download audio url d(resourceId = 'com.android.browser:id/url', text = '输入网址').set_text('auto.smartisan.com/media/Auto_Test_Video.mp4') d.press('enter') # play without element on webpage # d.sleep(10) # #d.click('Streaming_Play.png') # d.click(540,960) # #d(description = '播放').click.wait() # assert d(description = '网页视图').wait.exists(timeout = 15000),'Loading streaming video failed in 15s!' # # play time # d.sleep(15) # #assert d(description = '媒体控件').wait.exists(timeout = 10000),'Switch to webview failed in 10s!' # if d.orientation != 'natural': # d.orientation = 'n' #play with element on webpage assert d(description = '播放').wait.exists(timeout = 20000),'Loading webpage failed in 20s!' d(description = '播放').click.wait() assert d(description = '视频').wait.exists(timeout = 10000),'Start playing streaming video failed in 10s!' d.sleep(10)
def testTurnOnOffWifi(self): ''' before running, keep wi-fi connected. ''' #Launch Setting d.start_activity(component='com.android.settings/.Settings') assert d(text = '设置').wait.exists(timeout = 5000),'Launch settings failed in 5s!' u.selectOption('无线网络') assert d(resourceId = 'smartisanos:id/tv_title',text = '无线网络').wait.exists(timeout = 5000),'Switch to WIFI failed in 5s!' if d(text = '要查看可用网络,请打开无线网络').exists: print 'Current wifi status: Off' d(resourceId = 'com.android.settings:id/item_switch').swipe.right(steps = 5) d(text = '已连接').wait.exists(timeout = 15000) else: print 'Current wifi status: On' d(text = '已连接').wait.exists(timeout = 15000) for i in range(1000): #Turn off wifi d(resourceId = 'com.android.settings:id/item_switch').swipe.left(steps = 5) assert d(text = '要查看可用网络,请打开无线网络').wait.exists(timeout = 15000),'Turn off wifi failed in 5s!' #Turn on wifi d(resourceId = 'com.android.settings:id/item_switch').swipe.right(steps = 5) assert d(text = '已连接').wait.exists(timeout = 15000),'Turn on wifi failed in 5s!(UI)' assert self._getWifiStatus(),'Turn on wifi failed in 5s!(Dumpsys)'
def launchGallery(self): d.start_activity(component = ACTIVITY_NAME) if d(text = 'Camera Roll').wait.exists(timeout = 3000): d(text = 'Camera Roll').click.wait() d(text = 'Albums').click.wait() self.setMenuOptions('Sort by name, A-Z') time.sleep(1) #Switch filter may take a few seconds
def testShareNoteToWeibo(self): # Launch Note d.start_activity(component='com.smartisanos.notes/.NotesActivity') assert d(text = '便签').wait.exists(timeout = 5000),'Launch Note failed in 5s!' for i in range(500): d(resourceId = 'com.smartisanos.notes:id/add_button').click.wait() assert d(resourceId = 'com.smartisanos.notes:id/delete_insert_button').wait.exists(timeout = 5000),'Switch to note editer failed in 5s!' d(resourceId = 'com.smartisanos.notes:id/detail_note_editor').set_text('test content...') d(resourceId = 'com.smartisanos.notes:id/delete_insert_button').click.wait() d.sleep(1) d.click(900,1830) d.click('image.png') # select first pic d.click(150,370) d.click('done.png') assert d(resourceId = 'com.smartisanos.notes:id/detail_note_image').wait.exists(timeout = 5000),'Add pic to note failed in 5s!' d(resourceId = 'com.smartisanos.notes:id/send_finish_button').click.wait() d(resourceId = 'com.smartisanos.notes:id/send_finish_button').click.wait() assert d(text = '请选择操作').wait.exists(timeout = 5000),'Share selector does not pop-up in 5s!' d(text = '发送至新浪微博').click.wait() #d(text = '生成长微博').click.wait() #d(text = '保存到相册并继续').click.wait() assert d(resourceId = 'com.smartisanos.notes:id/weibo_body_view').wait.exists(timeout = 5000),'Switch to Weibo proview failed in 5s!' d(text = '下一步').click.wait() assert d(text = '发送').wait.exists(timeout = 5000),'Prepare to send weibo failed in 5s!' d(text = '取消').click.wait() d(text = '取消').click.wait() d(text = '列表').click.wait()
def testWifiOpenAndClose(self): d.start_activity('--activity-clear-task', component='com.android.settings/.Settings') d(text="无线和网络").wait.exists(timeout=2000) #d(className="android.widget.ListView", resourceId="android:id/list").child(text='WLAN').click.wait() #d(text="WLAN").click.wait() d.press('enter') d(resourceId='android:id/action_bar').child(text='WLAN').wait.exists(timeout=3000) if d(className='android.widget.Switch', text='打开').exists: d.press('right') d.sleep(2) d.press('up') d.sleep(2) for i in xrange(10): d.press('enter') assert d(resourceId='android:id/action_bar').child(text='关闭').wait.exists(timeout=3000), 'wifi close failed!' d.press('enter') assert d(resourceId='android:id/action_bar').child(text='打开').wait.exists(timeout=3000), 'wifi open failed!' assert d(resourceId='android:id/list').child(text='已连接').wait.exists(timeout=20000), 'wifi connect failed!' elif d(className='android.widget.Switch', text='关闭').exists: d.press('right') d.sleep(2) d.press('up') d.sleep(2) for i in xrange(10): d.press('enter') assert d(resourceId='android:id/action_bar').child(text='打开').wait.exists(timeout=3000), 'wifi close failed!' assert d(resourceId='android:id/list').child(text='已连接').wait.exists(timeout=20000), 'wifi connect failed!' d.press('enter') assert d(resourceId='android:id/action_bar').child(text='打开').wait.exists(timeout=3000), 'wifi open failed!'
def _switchLauncherSettings(self,viewmode): # launch setting d.start_activity(component='com.android.settings/.Settings') assert d(text = '设置').wait.exists(timeout = 5000),'Launch settings failed in 5s!' # get into launcher settings if d(text = '单板块视图').wait.exists(timeout = 5000): pass else: u.selectOption('桌面设置项') assert d(text = '单板块视图').wait.exists(timeout = 5000),'Switch to Desktop Settings failed in 5s!' if viewmode == '36' or viewmode == '81': if d(text = '多板块视图').exists: d(text = VIEW_MODE[viewmode]).click.wait() if d(text = '设置桌面').wait.exists(timeout = 5000): d(text = '确定').click.wait() else: d(text = '九宫格').click.wait() d.sleep(3) if d(text = '设置桌面').wait.exists(timeout = 5000): d(text = '确定').click.wait() d.sleep(3) d.start_activity(component='com.android.settings/.Settings') assert d(text = '设置').wait.exists(timeout = 5000),'Launch settings failed in 5s!' d(text = VIEW_MODE[viewmode]).click.wait() if d(text = '设置桌面').wait.exists(timeout = 5000): d(text = '确定').click.wait() else: d(text = VIEW_MODE[viewmode]).click.wait() if d(text = '设置桌面').wait.exists(timeout = 5000): d(text = '确定').click.wait()
def testSaveNoteAsPic(self): # Launch Note d.start_activity(component='com.smartisanos.notes/.NotesActivity') if d(text = '列表').exists: d(text = '列表').click.wait() assert d(text = '便签').wait.exists(timeout = 5000),'Launch Note failed in 5s!' for i in range(500): d(resourceId = 'com.smartisanos.notes:id/add_button').click.wait() assert d(resourceId = 'com.smartisanos.notes:id/delete_insert_button').wait.exists(timeout = 5000),'Switch to note editer failed in 5s!' d(resourceId = 'com.smartisanos.notes:id/detail_note_editor').set_text('test content...') d(resourceId = 'com.smartisanos.notes:id/delete_insert_button').click.wait() d.sleep(1) d.click(900,1830) d.click('image.png') # select first pic d.click(150,370) d.click('done.png') assert d(resourceId = 'com.smartisanos.notes:id/detail_note_image').wait.exists(timeout = 5000),'Add pic to note failed in 5s!' d(resourceId = 'com.smartisanos.notes:id/send_finish_button').click.wait() d(resourceId = 'com.smartisanos.notes:id/send_finish_button').click.wait() assert d(text = '请选择操作').wait.exists(timeout = 5000),'Share selector does not pop-up in 5s!' d(text = '以图片形式分享').click.wait() assert d(text = '保存图片').wait.exists(timeout = 5000),'Switch to thumbs failed in 5s!' d(text = '取消').click.wait() d(text = '列表').click.wait()
def testSwitchLanguage(self): #language_dir = {'English':'Language', # '中文 (简体)':'语言', # '中文 (繁體)':'語言' # } d.start_activity(component='com.android.settings/.Settings') assert d(text = '设置').wait.exists(timeout = 5000),'Launch settings failed in 5s!' u.selectOption('语言和键盘') assert d(text = '语言').wait.exists(timeout = 5000),'Switch to language setting failed in 5s!' for i in range(50): d(text = '语言').click.wait() assert d(resourceId = 'smartisanos:id/tv_title',text = '语言').wait.exists(timeout = 5000),'Get into language setting failed in 5s!' # switch to traditional chinese d(text = '中文 (繁體)').click.wait() assert d(text = '語言').wait.exists(timeout = 5000),'Switch to Traditional Chinese failed in 5s!' d(text = '語言').click.wait() assert d(resourceId = 'smartisanos:id/tv_title',text = '語言').wait.exists(timeout = 5000),'Get into language setting failed in 5s!' # switch to english d(text = 'English').click.wait() assert d(text = 'Language').wait.exists(timeout = 5000),'Switch to English failed in 5s!' d(text = 'Language').click.wait() assert d(resourceId = 'smartisanos:id/tv_title',text = 'Language').wait.exists(timeout = 5000),'Get into language setting failed in 5s!' # switch to simple chinese d(text = '中文 (简体)').click.wait() assert d(text = '语言').wait.exists(timeout = 5000),'Switch to English failed in 5s!'
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 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 testSetTheme(self): u.launchSettings() u.selectOption('主题、壁纸、图标') assert d(resourceId = 'smartisanos:id/tv_title',text = '主题、壁纸、图标').wait.exists(timeout = 5000),'Switch to theme view failed in 5s!' u.selectOption('桌面主题') assert d(resourceId = 'com.smartisanos.launcher:id/tv_title',text = '桌面主题').wait.exists(timeout = 5000),'Switch to theme view failed in 5s!' for theme in THEME_LIST: # if theme == '经典': # u.selectOption(theme) # assert d(resourceId = 'smartisanos:id/tv_title',text = theme).wait.exists(timeout = 5000),'Switch to theme thumbnail failed in 5s!' # d(text = '设定').click.wait() # if d(text = '桌面主题').wait.exists(timeout = 5000): # continue # else: # assert d(resourceId = 'com.smartisanos.launcher:id/glview').wait.exists(timeout = 15000), 'Switch to launcher failed in 15s!' # if theme == '经典': d(resourceId = 'com.smartisanos.launcher:id/list_theme').swipe.down() d(resourceId = 'com.smartisanos.launcher:id/list_theme').swipe.down() d(resourceId = 'com.smartisanos.launcher:id/list_theme').swipe.down() d.sleep(1) u.selectOption(theme) assert d(resourceId = 'smartisanos:id/tv_title',text = theme).wait.exists(timeout = 5000),'Switch to theme thumbnail failed in 5s!' d(text = '设定').click.wait() assert d(text = '正在加载主题').wait.exists(timeout = 5000),'Loading theme view does not show up in 5s!' assert d(text = '正在加载主题').wait.gone(timeout = 10000),'Loading theme view does not disappeared in 10s!' assert d(resourceId = 'com.smartisanos.launcher:id/glview').wait.exists(timeout = 5000), 'Switch to launcher failed in 5s!' d.sleep(3) # exit theme setting d.start_activity(component='com.android.settings/.Settings') d.sleep(1)
def testGame(self): #Launch DiTiePaoKu d.start_activity(component='com.kiloo.subwaysurf/.RRAndroidPluginActivity') assert d(packageName = 'com.kiloo.subwaysurf').wait.exists(timeout = 5000),'Launch game failed in 5s!' d.sleep(10) if d(text = '地铁跑酷正试图发送短信').exists: d(text = '允许').click.wait() if d(text = '地铁跑酷正试图获取位置信息').exists: d(text = '允许').click.wait() if d(text = '免费礼包大派送').exists: d(text = '7天内不再显示').click.wait() d(text = '暂不领取').click.wait() if d(text = '提示').exists: d(text = '取消').click.wait() if d(className = 'android.widget.TextView').exists: d(className = 'android.widget.TextView').click.wait() #Click screen to start game d.click(300,1540) d.sleep(4) for i in range(900): direction = random.choice(['left','right','up','down']) step = random.randint(2,20) self._swipeGame(direction,step) d.sleep(1) #Exit game d.press('back') d.sleep(1) d.click(150,1800) d.sleep(1) d.click(700,1100) d.sleep(1)
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 if d(text = 'OK').wait.exists(timeout = 3000): d(text = 'OK').click.wait() if d(text = 'Skip').wait.exists(timeout = 3000): d(text = 'Skip').click.wait() assert d(resourceId = 'com.intel.camera22:id/mode_button').wait.exists(timeout = 3000), 'Launch camera failed in 3s'
def testLaunchMultipleApp(self): # Launch an for app in MULTIPLE_APP_LIST: d.start_activity(component= app) assert d(resourceId = MULTIPLE_APP_LIST[app]).wait.exists(timeout = 5000),'Launch %s failed in 5s'%app d.sleep(5) d.press('home') d.sleep(1)
def testLaunchMultipleApp(self): # Launch an for app in MULTIPLE_APP_LIST: d.start_activity(component=app) assert d(packageName=MULTIPLE_APP_LIST[app]).wait.exists(timeout=5000), "Launch %s failed in 5s" % app d.sleep(5) d.press("home") d.sleep(1)
def testSwitchView(self): #Launch camera d.start_activity(component = 'com.smartisanos.appstore/.AppStoreActivity') assert d(resourceId = 'com.smartisanos.appstore:id/main_header').wait.exists(timeout = 5000), 'Launch appstore failed in 5s!' view_list = ['推荐','榜单','分类','搜索','应用管理'] for i in range(500): view = random.choice(view_list) d(text = view).click()
def testSwitchView(self): #Launch calander d.start_activity(component='com.android.calendar/.AllInOneActivity') assert d(text='今天').wait.exists(timeout = 5000),'Launch calendar failed in 5s!' view_list = ['日','周','月'] for i in range(500): view = random.choice(view_list) d(text = view).click()
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 _launchEmail(self): #Launch Email d.start_activity(component='com.android.email/.activity.Welcome') #Check if login account is needed. if d(text = '添加账户').wait.exists(timeout = 5000): self._loginAccount() else: pass assert d(resourceId = 'com.android.email:id/subtitle',text = 'Exchange').wait.exists(timeout = 10000),'Launch email failed in 10s!'
def launchGallery(self): time.sleep(2) d.start_activity(component = ACTIVITY_NAME) time.sleep(2) #Confirm gallery launch successfully by the icon on left-top corner #assert d(packageName = PACKAGE_NAME).wait.exists(timeout = 3000), 'Gallery launch failed' if d(text = 'Camera Roll').wait.exists(timeout = 3000): d(text = 'Camera Roll').click.wait() d(text = 'Albums').click.wait() time.sleep(2)
def testReadSMS(self): # insert SMS self._insertSMS(SMS_SENDER_INSERT,SMS_CONT_INSERT) #Launch message d.start_activity(component='com.android.mms/.ui.ConversationList') assert d(text = '短信').wait.exists(timeout = 5000),'Launch message failed in 5s!' #Read a SMS d(text = SMS_CONT).click.wait() assert d(resourceId = 'com.android.mms:id/text_view',text = SMS_CONT).wait.exists(timeout = 5000),'There is no text view, read SMS failed is 5s!'
def _launchAndEnterNewMsg(self): #Start message d.start_activity(component='com.android.mms/.ui.ConversationList') if d(text = '短信',resourceId = 'com.android.mms:id/button_left').exists: d(text = '短信',resourceId = 'com.android.mms:id/button_left').click.wait() if d(text = '返回').exists: d(text = '返回').click.wait() if d(resourceId = 'com.android.mms:id/creat_new_message').wait.exists(timeout=1000): d(resourceId = 'com.android.mms:id/creat_new_message').click.wait() assert d(description='发送').wait.exists(timeout=5000), 'Can not switch to new message screen. '
def launchSettings(): d.start_activity(component='com.android.settings/.Settings') while d(resourceId = 'smartisanos:id/btn_back').exists: d(resourceId = 'smartisanos:id/btn_back').click.wait() if not d(text = '无线网络').exists: for i in range(4): if d(text = '无线网络').exists: break d.swipe(360,200,360,1000,50) assert d(text = '设置').wait.exists(timeout = 5000),'Launch settings failed in 5s!'
def testTurnOnOffNFC(self): #Launch Setting d.start_activity(component='com.android.settings/.Settings') assert d(text = '设置').wait.exists(timeout = 5000),'Launch settings failed in 5s!' self._selectOption('NFC') assert d(resourceId = 'smartisanos:id/tv_title',text = 'NFC').wait.exists(timeout = 5000),'Switch to NFC failed in 5s!' d(className="android.widget.RelativeLayout", resourceId="com.android.settings:id/item_id_nfc").child(className="smartisanos.widget.SwitchEx").swipe.right(steps = 5) d.sleep(3) assert d(className="android.widget.RelativeLayout", resourceId="com.android.settings:id/item_id_android_beam").child(className="smartisanos.widget.SwitchEx").info['enabled'],'Turn NFC failed in 3s!' #d(text="NFC").right(className="smartisanos.widget.SwitchEx").click() d(className="android.widget.RelativeLayout", resourceId="com.android.settings:id/item_id_nfc").child(className="smartisanos.widget.SwitchEx").swipe.left(steps = 5) assert not d(className="android.widget.RelativeLayout", resourceId="com.android.settings:id/item_id_android_beam").child(className="smartisanos.widget.SwitchEx").info['enabled'],'Turn NFC failed in 3s!'
def testReadMMSVideo(self): # insert MMS video self._insertMMS('\"Mms_v\"',MMS_VIDEO_SENDER_INSERT,MMS_VIDEO_CONT_INSERT) #Launch message d.start_activity(component='com.android.mms/.ui.ConversationList') assert d(text = '短信').wait.exists(timeout = 5000),'Launch message failed in 5s!' #Open and read MMS video attachment d(text = MMS_VIDEO_SENDER).click.wait() d(resourceId = 'com.android.mms:id/mms_type_icon').click.wait() assert d(text = '彩信').wait.exists(timeout = 5000),'Switch to MMS view failed in 5s!' d(resourceId = 'com.android.mms:id/mms_video').click.wait() assert d(packageName = 'com.android.gallery3d').wait.exists(timeout = 5000), 'Read MMS in gallery failed in 5s!'
def _launch_apps(self): cmp = [] cmp.append("com.chaozhuo.filemanager/.activities.MainActivity") cmp.append("com.chaozhuo.browser/org.chromium.chrome.shell.ChaoZhuoActivity") cmp.append("com.chaozhuo.texteditor/.activity.TextEditorMainActivity") cmp.append("com.chaozhuo.permission.controller/.CZPermissionControllActivity") cmp.append("com.android.camera2/com.android.camera.CameraLauncher") cmp.append("com.android.gallery3d/.app.GalleryActivity") cmp.append("com.android.calculator2/.Calculator") cmp.append("com.android.deskclock/.DeskClock") for item in cmp: d.start_activity(component=item) time.sleep(2)
def testSwitchView(self): #Launch clock d.start_activity(component='com.smartisanos.clock/.activity.ClockActivity') if d(textContains = '时钟需要获取定位数据').wait.exists(timeout=3000): d(text = '同意').click.wait() if d(text = '提醒').exists: d(text = '同意').click.wait() assert d(text = '闹钟').wait.exists(timeout=5000),'Launch clock failed in 5s!' view_list = ['世界时钟','闹钟','秒表','计时器'] for i in range(500): view = random.choice(view_list) d(text = view).click()
def testWeibo(self): # launch weibo d.start_activity(component='com.sina.weibo/.SplashActivity') assert d(packageName = 'com.sina.weibo').wait.exists(timeout = 5000),'Launch Weibo failed in 5s!' if d(text = '特别提示').wait.exists(timeout = 5000): d(text = '确定').click.wait() if d(text = '给我们评分').wait.exists(timeout = 5000): d(text = '不了,谢谢').click.wait() #Refresh weibo d(description = '首页').click.wait() d.sleep(3) if d(text = '赞').exists: d(text = '赞').click.wait()
def testReadMMSPics(self): # insert MMS pics self._insertMMS('\"Mms_p\"',MMS_PICS_SENDER_INSERT,MMS_PICS_CONT_INSERT) #Launch message d.start_activity(component='com.android.mms/.ui.ConversationList') assert d(text = '短信').wait.exists(timeout = 5000),'Launch message failed in 5s!' #Open and read MMS Pics attachment d(text = MMS_PICS_SENDER).click.wait() d(resourceId = 'com.android.mms:id/mms_image_view').click.wait() #assert d(text = '彩信').wait.exists(timeout = 5000),'Switch to MMS view failed in 5s!' if d(resourceId = 'com.android.mms:id/mms_image_part').wait.exists(timeout = 5000): d(resourceId = 'com.android.mms:id/mms_image_part').click.wait() #d(resourceId = 'com.android.mms:id/mms_image_part').click.wait() assert d(packageName = 'com.android.gallery3d').wait.exists(timeout = 5000), 'Read MMS in gallery failed in 5s!'
def _setMobileNetWork(self,net): d.start_activity(component='com.android.settings/.Settings') assert d(text = '设置').wait.exists(timeout=5000), 'Settings application can not be launched' #Switch to network, and find the network switcher d(text = '蜂窝移动数据').click.wait() assert d(textContains = '网络').wait.exists(timeout=5000), 'Can not switch the screen to network' netSwitcher = d(className = 'android.widget.LinearLayout', resourceId = 'com.android.phone:id/network_mode_switch').child(className = 'smartisanos.widget.SwitchEx') #netSwitcher = d(textContains = '使用 3G 网络').sibling(className='android.widget.CheckBox') if net == '3G': netSwitcher.swipe.right() else: netSwitcher.swipe.left()
def testWifiOpenAndClose(self): d.start_activity('--activity-clear-task', component='com.android.settings/.Settings') d(text="无线和网络").wait.exists(timeout=2000) #d(className="android.widget.ListView", resourceId="android:id/list").child(text='WLAN').click.wait() #d(text="WLAN").click.wait() d.press('enter') d(resourceId='android:id/action_bar').child(text='WLAN').wait.exists( timeout=3000) if d(className='android.widget.Switch', text='打开').exists: d.press('right') d.sleep(2) d.press('up') d.sleep(2) for i in xrange(10): d.press('enter') assert d(resourceId='android:id/action_bar').child( text='关闭').wait.exists(timeout=3000), 'wifi close failed!' d.press('enter') assert d(resourceId='android:id/action_bar').child( text='打开').wait.exists(timeout=3000), 'wifi open failed!' assert d(resourceId='android:id/list').child( text='已连接').wait.exists( timeout=20000), 'wifi connect failed!' elif d(className='android.widget.Switch', text='关闭').exists: d.press('right') d.sleep(2) d.press('up') d.sleep(2) for i in xrange(10): d.press('enter') assert d(resourceId='android:id/action_bar').child( text='打开').wait.exists(timeout=3000), 'wifi close failed!' assert d(resourceId='android:id/list').child( text='已连接').wait.exists( timeout=20000), 'wifi connect failed!' d.press('enter') assert d(resourceId='android:id/action_bar').child( text='打开').wait.exists(timeout=3000), 'wifi open failed!'
def _launchCamera(self): d.start_activity(component=ACTIVITY_NAME) time.sleep(1) assert d(resourceId='com.intel.camera22:id/mode_button').wait.exists( timeout=3000), 'Launch camera failed in 3s'
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()
def testPlayVideoBetweenApp_short(self): """ Suma: play a video Step1: click " video online" Step2: verify the new screen was luanched successfully Step3: click the top video Step4: verify the new screen was luanched successfully Step4: click "play icon" to play the video. Step5: """ #APP1 VST d.start_activity( '--activity-clear-task', component= 'net.myvst.v2/.component.activity.homepage.LancherActivity') assert d(text="最新推荐").wait.exists( timeout=30000), "最新推荐 not found on screen" d.press('right') d.sleep(2) d.press('enter') assert d(text="收藏").wait.exists( timeout=15000), "收藏 not found on screen" d.press('enter') d.sleep(120) d.press('back') d.press('back') d.sleep(5) d.press('back') assert d(text="最新推荐").wait.exists( timeout=15000), "最新推荐 not found on screen" d.press('back') d.sleep(2) d.press('enter') ##return to home d.sleep(3) #enter APP2 APP2 = '优酷' ###for i in xrange(8): ### d.press('right') ###assert d(text=APP2 ).wait.exists(timeout=3000), "优酷 not found on screen" ###d(text=APP2).click.wait() d.start_activity('--activity-clear-task', component="com.youku.tv/.WelcomeActivity") assert d(text="首页").wait.exists( timeout=20000), " 首页 not found on screen" d(text="首页").click.wait() d.press('down') d.sleep(2) d.press('right') d.sleep(2) d.press('enter') assert d(text="收藏").wait.exists( timeout=15000), "收藏 not found on screen" d.press('enter') d.sleep(120) d.press('back') #assert d(text='确定').wait.exists(timeout=5000), "结束观看 not found on screen" #d(text='确定').click.wait() d.press('enter') d.sleep(5) assert d(text='收藏').wait.exists( timeout=15000), "收藏 not found on screen" d.press('back') assert d(text='首页').wait.exists( timeout=15000), "首页 not found on screen" d.press('back') d.press('back') ##return to home d.sleep(3) #APP3 = '搜狐视频TV版' d.start_activity('--activity-clear-task', component='com.sohutv.tv/.activity.WelcomeActivity') assert d(text="推荐").wait.exists( timeout=20000), " 推荐 not found on screen" d.press('enter') d.sleep(120) d.press('back') d.sleep(3) d.press('back') d.sleep(2) d.press('left') d.sleep(2) d.press('enter')