def testSwitchSong(self): """ launch app store and exit """ for i in xrange(8): d.press('right') assert d(text="网络电台").exists, 'FM app icon not found!' d(text="网络电台").click.wait() assert d(resourceId='com.xiaomi.mimusic:id/play_btn').wait.exists(timeout=10000), 'Open FM failed!' d.sleep(10) assert d(resourceId='com.xiaomi.mimusic:id/title').child(className="android.widget.TextView").exists, 'song play screen not found!' first_song_name = d(resourceId='com.xiaomi.mimusic:id/title').child(className="android.widget.TextView").info['text'] d.press('right') d.sleep(15) assert d(resourceId='com.xiaomi.mimusic:id/title').child(className="android.widget.TextView").exists, 'song play screen not found!' second_song_name = d(resourceId='com.xiaomi.mimusic:id/title').child(className="android.widget.TextView").info['text'] assert not second_song_name == first_song_name, 'switch song failed!' d.press('right') d.sleep(15) assert d(resourceId='com.xiaomi.mimusic:id/title').child(className="android.widget.TextView").exists, 'song play screen not found!' third_song_name = d(resourceId='com.xiaomi.mimusic:id/title').child(className="android.widget.TextView").info['text'] assert not third_song_name == second_song_name, 'switch song failed!' d.press('back') d.sleep(2) d.press('back')
def test_fm_copy(self): u.recordcase(self.test_fm_copy, "FileManager.Priority1") self._launch_filemanager() d(resourceId="com.chaozhuo.filemanager:id/text_navigation_child", text=u"文档").click() time.sleep(2) d(resourceId="com.chaozhuo.filemanager:id/more").wait(5000) d(resourceId="com.chaozhuo.filemanager:id/more").click() time.sleep(2) d(resourceId="com.chaozhuo.filemanager:id/item_title", text=u"新建文件").click() time.sleep(2) d(resourceId="com.chaozhuo.filemanager:id/file_name_edit").set_text("test.txt") time.sleep(2) d.press("enter") time.sleep(2) d(resourceId="com.chaozhuo.filemanager:id/node_list").click() time.sleep(2) d(resourceId="com.chaozhuo.filemanager:id/more").click() time.sleep(2) d(resourceId="com.chaozhuo.filemanager:id/item_title", text=u"全选").click() time.sleep(2) d(resourceId="com.chaozhuo.filemanager:id/copy", text=u"复制").click() time.sleep(2) for i in xrange(self.loop): d(resourceId="com.chaozhuo.filemanager:id/more").click() time.sleep(2) d(resourceId="com.chaozhuo.filemanager:id/item_title", text=u"粘贴").click() time.sleep(2) u.log()
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 testSwitchTheme(self): 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 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 i in range(30): for theme in THEME_LIST: if i==0 and theme == '经典': continue d.start_activity(component='com.android.settings/.Settings') assert d(resourceId = 'com.smartisanos.launcher:id/tv_title',text = '桌面主题').wait.exists(timeout = 5000),'Switch to theme view failed in 5s!' 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.press('back')
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 tearDown(): for i in xrange(2): d.press('back') if d(textContains = '退出').exists: d(text = '确定').click() d.press('home') checkSystemWatchers()
def testDownloadVideo(self): #Launch Browser self._launchBrowser() # input download audio url d(resourceId = 'com.android.browser:id/url', text = '输入网址').set_text('http://pan.baidu.com/s/1eQcRK3o') d.press('enter') d.sleep(5) d.swipe(540,1400,540,400,100) # click download d.click(800,1550) assert d(text = '是否下载该文件?').wait.exists(timeout = 10000), 'Not trigger download. ' d(text = '下载').click.wait() if d(textContains = '您正在通过移动数据下载').exists: d(text = '继续').click.wait() #Looping 60s to check if download is ok for i in range(60): if u.getFileCount('/sdcard/Download', 'mp4') > 0: return d.sleep(1) assert False, 'Can not download video in 60s. ' #Close all webpage windows and clear downloaded resource #self._closeWindows() self._clearData()
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 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 testDownloadPics(self): #Launch Browser self._launchBrowser() #Input download pics url d(resourceId = 'com.android.browser:id/url', text = '输入网址').set_text('auto.smartisan.com/media/Auto_Test_Image.jpg') d.sleep(1) d.press('enter') d.sleep(5) # swipe up to show '普通下载' d.long_click(500, 670) d.sleep(1) assert d(text = '保存图片').wait.exists(timeout = 5000),'Save download window does not pop-up in 5s!' d(text = '保存图片').click() if d(textContains = '您正在通过移动数据下载').wait.exists(timeout=1000): d(text = '继续').click.wait() #Looping 60s to check if download is ok for i in range(60): if u.getFileCount('/sdcard/Download', 'jpg') > 0: return d.sleep(1) assert False, 'Can not download pics in 60s. ' #Close all webpage windows and clear downloaded resource #self._closeWindows() self._clearData()
def testLaunchAndExitMiracast(self): for i in xrange(4): d.press('right') assert d(text="无线显示").exists, 'Miracast icon not found!' d(text="无线显示").click.wait() d.press('back') assert d(text="无线显示").wait.exists(timeout=10000), 'exit from Miracast failed!'
def testSendEmailNoAtt(self): #Launch Email self._launchEmail() #Edit mail content and then send out d(resourceId = 'com.android.email:id/compsoe_view').click.wait() assert d(text = '写邮件').wait.exists(timeout = 5000),'Switch to compose view failed in 5s!' d(resourceId = 'com.android.email:id/to_recipient_view').set_text(SEND_TO) d.press('enter') d(resourceId = 'com.android.email:id/subject').set_text(SUBJECT) d(resourceId = 'com.android.email:id/body').set_text(BODY) d(text = '发送').click.wait() assert d(text = '设置').wait.exists(timeout = 5000),'Switch to mail list (after click send icon) failed in 5s!' #Delete mail from sendbox d(resourceId = 'com.android.email:id/options_view').click.wait() assert d(resourceId = 'com.android.email:id/bottom_dialog_title_text',text = 'Exchange').wait.exists(timeout = 5000),'Trigger menu list failed in 5s!' d(text = '已发送邮件').click.wait() assert d(resourceId = 'com.android.email:id/title',text = '已发送邮件').wait.exists(timeout = 5000),'Switch to sended box failed in 5s!' # looping 60s to check if mail sending finished for i in range(12): #d(resourceId = 'com.android.email:id/refresh_view').click.wait() if d(descriptionContains = SUBJECT).wait.exists(timeout=5000): break if i == 11: assert False, 'Can not send out email in 60s. ' d(resourceId = 'com.android.email:id/refresh_view').click.wait() d(descriptionContains = SUBJECT).click.wait() if d(descriptionContains = SUBJECT).exists: d(descriptionContains = SUBJECT).click.wait() assert d(resourceId = 'com.android.email:id/send_calendar_btn').wait.exists(timeout = 5000),'Open mail failed in 5s!' d(resourceId = 'com.android.email:id/detail_delete_view').click.wait() d(text = '确认删除').click.wait() assert d(text = '来往邮件').wait.exists(timeout = 5000),'Switch to sending box failed (after delete send mail) in 5s!'
def test_fm_copy(self): self._launch_apps() d(resourceId="com.chaozhuo.filemanager:id/text_navigation_child",text=u"文档").click() time.sleep(2) d(resourceId="com.chaozhuo.filemanager:id/more").click() time.sleep(2) d(resourceId="com.chaozhuo.filemanager:id/item_title", text=u"新建文件").click() time.sleep(2) d(resourceId="com.chaozhuo.filemanager:id/file_name_edit").set_text("test.txt") time.sleep(2) d.press("enter") time.sleep(2) d(resourceId="com.chaozhuo.filemanager:id/node_list").click() time.sleep(2) d(resourceId="com.chaozhuo.filemanager:id/more").click() time.sleep(2) d(resourceId="com.chaozhuo.filemanager:id/item_title", text=u"全选").click() time.sleep(2) d(resourceId="com.chaozhuo.filemanager:id/copy",text=u"复制").click() time.sleep(2) for i in xrange(100): d(resourceId="com.chaozhuo.filemanager:id/more").click() time.sleep(2) d(resourceId="com.chaozhuo.filemanager:id/item_title", text=u"粘贴").click() time.sleep(2)
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 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 showPopCard(self): d.click(self.getSizeOfGallery()[4], self.getSizeOfGallery()[0] + 1) d(description = 'More options').click.wait() if d(text = 'View photonotes').wait.exists(timeout = 2000): d(text = 'View photonotes').click.wait() else: d.press('back') time.sleep(1)
def testLaunchAndExitGameCenter(self): """ launch app store and exit """ assert d(text="游戏中心").exists, 'Game Center icon not found!' d(text="游戏中心").sibling(className='android.view.View').click.wait() assert d(className='android.widget.FrameLayout').child(text="热门精选").wait.exists(timeout=20000), 'Launch Game Center failed!' d.press('home') assert d(text="游戏中心").wait.exists(timeout=10000), 'exit from Game Center failed!'
def testLaunchAndExitAppStore(self): """ launch app store and exit """ assert d(text="应用商店").exists, 'App Store icon not found!' d(text="应用商店").sibling(className='android.view.View').click.wait() assert d(resourceId='com.xiaomi.mitv.appstore:id/title_chinese_textview', text='应用商店').wait.exists(timeout=10000), 'launch App Store failed!' d.press('back') assert d(text="应用商店").wait.exists(timeout=10000), 'exit from App Store failed!'
def setUp(self): u.clog() self.checkScreen() d.click(1380, 800) self.inputCode() time.sleep(2) for i in xrange(4): d.press("back") self._launch_filemanager()
def testMenuKeyOfSync(self): """ Summary:This case test rotate left burst pictures by menu key in burst view. Precondition: There are burst pictures in sdcard Steps: 1. Launch Intel gallery and enter to burst view 2. Tap menu -> Rotate left,check Rotate left progress pops up. """ d.press('menu') assert d(text = 'Social Sync').wait.exists(timeout = 3000), 'unable to find sync icon'
def testLaunchAndExitMediaExplorer(self): for i in xrange(6): d.press('right') assert d(text="高清播放器").exists, 'Media Explorer icon not found!' d(text="高清播放器").click.wait() #assert d(resourceId='com.xiaomi.mitv.mediaexplorer:id/entry_name', text='设备').wait.exists(timeout=5000), 'launch Media Explorer failed!' #assert d(resourceId='com.xiaomi.mitv.mediaexplorer:id/entry_name', text="视频").wait.exists(timeout=5000), 'launch Media Explorer failed!' assert d(resourceId='com.xiaomi.mitv.mediaexplorer:id/dev', text='设备').wait.exists(timeout=5000), 'launch Media Explorer failed!' assert d(resourceId='com.xiaomi.mitv.mediaexplorer:id/video', text="视频").wait.exists(timeout=5000), 'launch Media Explorer failed!' d.press('back') assert d(text="高清播放器").wait.exists(timeout=10000), 'exit from Media Explorer failed!'
def testViewPicture(self): u._confirmResourceExists() u.launchGallery() u.enterXView('fullview') u.showPopCard() for i in range(100): d.press('back') #If it goes to fullview suc, it shall back to the grid view after pressing back key assert d(resourceId = 'com.intel.android.gallery3d:id/action_slideshow').wait.exists(timeout = 2000) u.pressBack(4) u.launchGallery() u.enterXView('fullview')
def testViewPicture(self): u._confirmResourceExists() u.launchGallery() u.enterXView('fullview') u.showPopCard() for i in range(2): d.press('back') #If it goes to fullview suc, it shall back to the grid view after pressing back key assert d(description = 'Switch to camera').wait.exists(timeout = 2000) u.pressBack(4) u.launchGallery() u.enterXView('fullview')
def setMenuOptions(self,setoption = None): if setoption == 'Slideshow': d(resourceId = 'com.intel.android.gallery3d:id/action_slideshow').click.wait() else: d(description = 'More options').click.wait() if d(text = setoption).wait.exists(timeout = 1000): d(text = setoption).click.wait() else: d.press('back') if d(text = 'Choose an action').wait.exists(timeout = 2000): d(text = 'com.intel.android.gallery3d').click.wait()
def testWebNavigation(self): #Launch Browser self._launchBrowser() #Visite webpage d(resourceId = 'com.android.browser:id/url', text = '输入网址').set_text('wap.sohu.com') d.press('enter') d.expect('Web_Navigation_News.png',timeout=10, msg = 'Loading webpage failed in 10s!') #Click Navigation '新闻' d.click('Web_Navigation_News.png')
def setUp(): # unlock screen # unlock() for i in xrange(2): d.press('back') d.press('home') d.sleep(1) # clear logcat commands.getoutput('adb shell logcat -c') d.sleep(1) registerSysWatchers()
def testLaunchAndExitCloudGallery(self): """ launch app store and exit """ for i in xrange(8): d.press('right') assert d(text="云相册").exists, 'Cloud Gallery icon not found!' d(text="云相册").click.wait() #gallery_check_png = os.path.join(PIC_DIR, 'cloudgallery_sub_1.png') d.expect('cloudgallery_sub_1.png', timeout=20000) d.press('back') assert d(text="云相册").wait.exists(timeout=10000), 'exit from cloud gallery failed!'
def testLaunchAndExitSetting(self): """ launch app store and exit """ for i in xrange(4): d.press('right') assert d(text="小米盒子设置").exists, 'MiBox Setting icon not found!' d(text="小米盒子设置").click.wait() assert d(text="帐户与安全").wait.exists(timeout=5000), 'launch MiBox setting failed!' assert d(text="图像与声音").wait.exists(timeout=5000), 'launch MiBox setting failed!' assert d(text="关于").wait.exists(timeout=5000), 'open setting failed!' d.press('back') assert d(text="小米盒子设置").wait.exists(timeout=10000), 'exit from MiBox Setting failed!'
def testVisitTop5(self): #Launch Browser self._launchBrowser() #Visite TOP5 webpage for i in range(5): d(resourceId = 'com.android.browser:id/url', text = '输入网址').set_text(TOP5[i]) d.sleep(2) d.press('enter') if d(textContains = '需要了解您的位置信息').wait.exists(): d(text = '拒绝').click.wait() d.expect(CHECK_POINT[i],timeout=10, msg = 'Loading webpage %s failed in 10s!'%TOP5[i]) d(resourceId = 'com.android.browser:id/newtab_btn').click.wait()
def testLaunchAndExitVideo(self): assert d(text="在线影视").exists, 'Online Video icon not found!' d(text="在线影视").sibling(className='android.view.View').click.wait() #menu_hot_highlight_focus_png = os.path.join(PIC_DIR, 'menu_hot_highlight_focus.png') #menu_hot_highlight_nofocus_png = os.path.join(PIC_DIR, 'menu_hot_highlight_nofocus.png') if d.find('menu_hot_highlight_focus.png', timeout=30) : pass elif d.find('menu_hot_highlight_nofocus.png', timeout=30): pass else: assert False, 'open online video failed!' d.press('back') assert d(text="在线影视").wait.exists(timeout=10000), 'exit from online video failed!'
def tearDown(self): """ called after each test method end or exception occur. """ for i in xrange(8): d.press('back') d.press('home') d.press('home')
def _swipeCaptureList(self, mode): mode_index = CONFIRM_MODE_LIST.index(mode) result = commands.getoutput( 'adb shell cat /data/data/com.intel.camera22/shared_prefs/mode_selected.xml| grep currentMode' ) a = str(result) b = a[a.index('value="') + 1:a.rindex('/')] cmode = b[b.index('"') + 1:b.rindex('"')] cmodenew = int(cmode) modenew = Mode[cmode] currentindex = CONFIRM_MODE_LIST.index(modenew) tg_mode = mode_index - currentindex if tg_mode < 0: for i in range(abs(tg_mode)): # mode image coordinate: right_x_coordinate = 2252 left_x_coordinate = 2252. swipe from right to left. d.swipe(2120, 944, 2252, 944) if tg_mode == 0: #print ('current is ' + mode + ' mode') d.press('back') if tg_mode > 0: for i in range(tg_mode): # mode image coordinate: right_x_coordinate = 2252 left_x_coordinate = 2252. swipe from right to left. d.swipe(2252, 944, 2120, 944)
def setUp(self): """ called before each test method start. """ #super(MediaExplorerTest, self).setUp() #d.watcher("AUTO_FC_WHEN_ANR")#.when(text="ANR").when(text="Wait") .press.back.home() #d.watcher("AUTO_FC_WHEN_ANR").when(text="ANR").when(text="强行关闭") .click(text="确定") #d.watcher("AUTO_FC_WHEN_ANR").press.left.left.left.home() #d.handlers.on(fc_close) d.wakeup() for i in xrange(3): d.press('back') d.press('home') d.press('home') for i in xrange(8): d.press('left')
def tearDown(self): """ called after each test method end or exception occur. """ d.watchers.remove("AUTO_FC_WHEN_ANR") for i in xrange(8): d.press('back') d.press('home') d.press('home')
def tearDown(self): """ called after each test method end or exception occur. """ #super(VideoPlay, self).tearDown() #d.watcher("AUTO_FC_WHEN_ANR").when(text="ANR").when(text="Wait") .press.back.home() d.watcher("AUTO_FC_WHEN_ANR").when(text="ANR").when(text="Wait").click( text="确定") for i in xrange(8): d.press('back') d.press('home') # 'home, back,menu'd.press.home() d.press('home')
def setUp(self): """ called before each test method start. """ #super(VideoPlay, self).setUp() #d.watcher("AUTO_FC_WHEN_ANR").when(text="ANR").when(text="Wait") .press.back.home() d.watcher("AUTO_FC_WHEN_ANR").when(text="ANR").when(text="强行关闭").click( text="确定") d.wakeup() d.press('home') d.press('home') for i in xrange(8): d.press('left')
def testLaunchAndExitFM(self): for i in xrange(8): d.press('right') assert d(text="网络电台").exists, 'FM app icon not found!' d(text="网络电台").click.wait() assert d(resourceId='com.xiaomi.mimusic:id/play_btn').child( className='android.widget.ImageView').wait.exists( timeout=10000), 'Open FM failed!' d.sleep(10) d.press('back') d.sleep(2) d.press('back') assert d(text="网络电台").wait.exists( timeout=10000), 'exit from FM failed!'
def testLaunchAndExitMediaExplorer(self): for i in xrange(4): d.press('right') assert d(text="高清播放器").exists, 'Media Explorer icon not found!' d(text="高清播放器").click.wait() assert d(resourceId='com.xiaomi.mitv.mediaexplorer:id/entry_name', text='设备').wait.exists( timeout=5000), 'launch Media Explorer failed!' assert d(resourceId='com.xiaomi.mitv.mediaexplorer:id/entry_name', text="视频").wait.exists( timeout=5000), 'launch Media Explorer failed!' d.press('back') d.sleep(3) d.press('back') assert d(text="高清播放器").wait.exists( timeout=10000), 'exit from Media Explorer failed!'
def tearDown(self): """ called after each test method end or exception occur. """ self.after_install = d.server.adb.cmd( 'shell pm list package -3').communicate()[0].split() del_apk = [ i.split('=')[1] for i in self.after_install if i not in self.before_install ] for apk in del_apk: d.server.adb.cmd('shell pm uninstall %s' % apk) d.sleep(3) for i in xrange(8): d.press('back') d.press('home') d.press('home')
def _pressBack(self, touchtimes): for i in range(1, touchtimes + 1): d.press('back')
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 testPlayVideoOnline(self): #d.start_activity('--activity-clear-task', component='com.duokan.duokantv/.MainActivity') assert d(text="在线影视").exists, 'Online Video icon not found!' d(text="在线影视").sibling(className='android.view.View').click.wait() #menu_hot_highlight_focus_png = os.path.join(PIC_DIR, 'menu_hot_highlight_focus.png') #menu_hot_highlight_nofocus_png = os.path.join(PIC_DIR, 'menu_hot_highlight_nofocus.png') #preview_shoucang_png = os.path.join(PIC_DIR, 'video_preview_sub_shoucang.png') #preview_pinglun_png = os.path.join(PIC_DIR, 'video_preview_sub_pinglun.png') if d.find('menu_hot_highlight_focus.png', timeout=30): d.press('down') d.sleep(2) d.press('enter') elif d.find('menu_hot_highlight_nofocus.png', timeout=30): d.press('enter') else: assert False, 'launch video failed' d.expect('video_preview_sub_shoucang.png', timeout=30) d.sleep(2) d.press('enter') assert d(resourceId='com.duokan.duokantv:id/main_frame').wait.exists( timeout=30000), 'video not start!' #assert not d.find('video_preview_sub_shoucang.png', timeout=30), 'video not start!' d.sleep(120) d.press('back') d.expect('video_preview_sub_shoucang.png', timeout=30) d.press('back')
def pressBack(self,touchtimes): for i in range(0,touchtimes): d.press('back')
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')
def testPlayOnlineVideoLong(self): """ launch app store and exit """ #d.start_activity('--activity-clear-task', component='com.duokan.duokantv/.MainActivity') assert d(text="在线影视").exists, 'Online Video icon not found!' d(text="在线影视").sibling(className='android.view.View').click.wait() if d.find('menu_hot_highlight_nofocus.png', timeout=30): d.press('left') d.sleep(3) d.press('left') d.sleep(3) d.press('left') d.sleep(3) d.press('right') d.sleep(3) d.press('enter') d.sleep(5) d.press('enter') elif d.find('menu_hot_highlight_focus.png', threshold=0.01, timeout=30): d.press('down') d.sleep(3) d.press('right') d.sleep(3) d.press('enter') d.sleep(5) d.press('enter') else: assert False, 'launch video failed' d.expect('video_preview_sub_shoucang2.png', threshold=0.05, timeout=30) d.sleep(2) d.press('enter') assert d(resourceId='com.duokan.duokantv:id/main_frame').wait.exists( timeout=30000), 'video not start!' #assert not d.find('video_preview_sub_shoucang.png', timeout=30), 'video not start!' d.sleep(1200) assert not d(textContains='播放失败').exists or not d( textContains='无法获取视频地址').exists or not d( textContains="正在读取视频信息").exists, 'Video start failed!' d.press('back') d.expect('video_preview_sub_shoucang2.png', threshold=0.05, timeout=30) d.press('back')
def testInstallAndUninstallGame(self): """ launch app store and exit """ assert d(text="游戏中心").exists, 'Game Center icon not found!' d(text="游戏中心").sibling(className='android.view.View').click.wait() assert d(resourceId='android:id/content').child(text="推荐").wait.exists( timeout=20000), 'Launch Game Center failed!' d.sleep(5) d.press('left') d.sleep(2) d.press('left') d.sleep(2) d.press('left') d.sleep(2) d.press('down') d.sleep(2) d.press('enter') d.sleep(3) #if d(resourceId='com.xiaomi.mibox.gamecenter:id/update', text='打开').wait.exists(timeout=5000): if d(className='android.widget.Button', text='启 动').wait.exists(timeout=5000): #self.after_install = d.server.adb.cmd('shell pm list package -3').communicate()[0].split() #del_apk = [i.split('=')[1] for i in self.after_install if i not in self.before_install] #for apk in del_apk: # d.server.adb.cmd('shell pm uninstall %s' % apk) # d.sleep(3) assert d(resourceId='com.xiaomi.mibox.gamecenter:id/uninstall', text='卸载').wait.exists( timeout=5000), 'uninstall buuton not found!' #d(resourceId='com.xiaomi.mibox.gamecenter:id/uninstall', text='卸载').click.wait() d.press('right') d.sleep(3) d.press('right') d.sleep(3) d.press('enter') assert d(text='取消').wait.exists( timeout=5000), 'cancel button not found!' d.press('left') d.sleep(3) d.press('enter') assert d(resourceId='com.xiaomi.mibox.gamecenter:id/pop_selector_2' ).wait.exists(timeout=5000), 'return button not found!' d.press('enter') assert d(className='android.widget.FrameLayout').child( text="热门精选").wait.exists( timeout=5000), 'game main screen not found!' #elif d(resourceId='com.xiaomi.mibox.gamecenter:id/app_install_button', text='安装').exists: elif d(className='android.widget.Button', text='安 装').exists: d(className='android.widget.Button', text='安 装').click.wait() d.sleep(60) #assert d(resourceId='com.xiaomi.mibox.gamecenter:id/update', text='打开').wait.exists(timeout=40000), 'install game failed in 30 seconds!' assert d(className='android.widget.Button', text='启 动').wait.exists( timeout=5000), 'install game failed in 30 seconds!' #d.press('left') #d.sleep(2) #d.press('left') #d.sleep(2) #d.press('left') #d.sleep(2) #d.press('down') #d.sleep(2) #d.press('enter') #d.sleep(3) #assert d(resourceId='com.xiaomi.mibox.gamecenter:id/uninstall', text='卸载').wait.exists(timeout=5000), 'uninstall buuton not found!' ##d(resourceId='com.xiaomi.mibox.gamecenter:id/uninstall', text='卸载').click.wait() #d.press('right') #d.sleep(3) #d.press('right') #d.sleep(3) #d.press('enter') #assert d(text='取消').wait.exists(timeout=5000), 'cancel button not found!' #d.press('left') #d.sleep(3) #d.press('enter') #assert d(resourceId='com.xiaomi.mibox.gamecenter:id/pop_selector_2').wait.exists(timeout=5000), 'return button not found!' #d.press('enter') #assert d(className='android.widget.FrameLayout').child(text="热门精选").wait.exists(timeout=5000), 'game main screen not found!' self.after_install = d.server.adb.cmd( 'shell pm list package -3').communicate()[0].split() del_apk = [ i.split('=')[1] for i in self.after_install if i not in self.before_install ] for apk in del_apk: d.server.adb.cmd('shell pm uninstall %s' % apk) d.sleep(3) assert d( className='android.widget.Button', text='安 装').wait.exists(timeout=18000), 'uninstall game failed' d.press('back') assert d(resourceId='android:id/content').child( text="推荐").wait.exists( timeout=5000), 'game main screen not found!' else: assert False, 'game preview screen not appear!' d.press('back')
def testPlayLocalVideo(self): """ launch app store and exit """ for i in xrange(5): d.press('right') assert d(text="高清播放器").exists, 'Media Explorer icon not found!' d(text="高清播放器").click.wait() assert d(resourceId='com.xiaomi.mitv.mediaexplorer:id/entry_name', text='设备').wait.exists( timeout=5000), 'launch Media Explorer failed!' assert d(resourceId='com.xiaomi.mitv.mediaexplorer:id/entry_name', text="视频").wait.exists( timeout=5000), 'launch Media Explorer failed!' d.press('right') d.sleep(2) d.press('right') d.sleep(2) d.press('down') d.sleep(2) d.press('enter') assert d(resourceId='com.xiaomi.mitv.mediaexplorer:id/device_label', text="移动存储设备").wait.exists( timeout=10000), 'enter Device list screen failed!' d.press('enter') assert d(className="android.widget.ListView").child( text="视频").wait.exists( timeout=10000), 'enter USB device list failed!' d.press('enter') assert d(className="android.widget.ListView").child( resourceId="com.xiaomi.mitv.mediaexplorer:id/iv_image" ).wait.exists(timeout=10000), 'enter USB device video list failed!' for i in xrange(16): for j in xrange(random.randint(0, 16)): d.press('down') d.sleep(1) for k in xrange(random.randint(0, 8)): d.press('up') d.sleep(1) d.press('enter') assert d(className="android.widget.ListView").child( resourceId="com.xiaomi.mitv.mediaexplorer:id/iv_image" ).wait.gone(timeout=10000), 'start to play video failed!' d.sleep(600) d.press('back') assert d(className="android.widget.ListView").child( resourceId="com.xiaomi.mitv.mediaexplorer:id/iv_image" ).wait.exists(timeout=10000), 'enter USB device video list failed!'