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 _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 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 _setWifistatus(self,status): #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 status == 'on': d(resourceId = 'com.android.settings:id/item_switch').swipe.right(steps = 5) assert d(text = '已连接').wait.exists(timeout = 30000),'Turn on wifi failed in 30s!' elif status == 'off': d(resourceId = 'com.android.settings:id/item_switch').swipe.left(steps = 5) assert d(text = '要查看可用网络,请打开无线网络').wait.exists(timeout = 5000),'Turn off wifi failed in 5s!' else: print 'Input wrong string, on/off only!' d.press('back') d.press('back') d.press('home')
def testTurnOnOffBT(self): #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 BT failed in 5s!' if d(text = '要查看可用蓝牙设备,请打开蓝牙功能').exists: print 'Current BT status: Off' d(resourceId = 'com.android.settings:id/item_switch').swipe.right(steps = 5) d(text = '范围内可配对设备').wait.exists(timeout = 5000) else: print 'Current BT status: On' d(text = '范围内可配对设备').wait.exists(timeout = 5000) for i in range(1000): #Turn off BT d(resourceId = 'com.android.settings:id/item_switch').swipe.left(steps = 5) assert d(text = '要查看可用蓝牙设备,请打开蓝牙功能').wait.exists(timeout = 5000),'Turn off BT failed in 5s!' #Turn on wifi d(resourceId = 'com.android.settings:id/item_switch').swipe.right(steps = 5) assert d(text = '范围内可配对设备').wait.exists(timeout = 5000),'Turn on BT failed in 5s!'
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 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 testSendEmail(self): #Launch Email self._launchEmail() #Edit mail content and then send out for i in range(500): d(resourceId = 'com.android.email:id/compsoe_view').click.wait() # edit receiver d(resourceId = 'com.android.email:id/to_recipient_view').set_text(SEND_TO) d.press('enter') # edit cc #d(resourceId = 'com.android.email:id/compose_thumbnail').click.wait() #d(resourceId = 'com.android.email:id/cc_recipient_view').set_text(CC_TO) # edit mail content d(resourceId = 'com.android.email:id/subject').set_text(SUBJECT) d(resourceId = 'com.android.email:id/body').set_text(BODY) # add attachment d(resourceId = 'com.android.email:id/compose_attach').click.wait() d(text = 'ES文件浏览器').click.wait() u.selectOption('JPG_640x480_8bit_standart.jpg') d(text = '发送').click.wait() d.sleep(3)
def testAppstore(self): ##################################################################################################### # Download application from appstore # ##################################################################################################### #Launch app store d.start_activity(component='com.smartisanos.appstore/.AppStoreActivity') assert d(text = '推荐').wait.exists(timeout = 5000),'Launch app store failed in 5s!' #Download app d(text = '榜单').click.wait() assert d(resourceId = 'com.smartisanos.appstore:id/title_tv',text = '榜单').wait.exists(timeout = 5000),"Switch to '排行' view failed in 5s!" if d(text = '总排行').wait.exists(timeout = 5000): d(text = '总排行').click.wait() assert d(text = 'QQ').wait.exists(timeout = 30000),"Can not switch to 总排行 or QQ is not in the list!" d(text = 'QQ').click.wait() assert d(resourceId = 'com.smartisanos.appstore:id/appName',text = 'QQ').wait.exists(timeout = 15000),"Switch to app 'QQ' detail failed in 15s!" self._downloadOption() ##################################################################################################### # Open downloaded application from appstore # ##################################################################################################### assert d(text = '打开').wait.exists(timeout = 5000),'Application download did not finish!' d(text = '打开').click.wait() assert d(packageName = 'com.tencent.mobileqq').wait.exists(timeout = 5000),'Launch application from AppStore failed in 5s!' ##################################################################################################### # Uninstall downloaded application from packagemanager # ##################################################################################################### d.press('home') d.start_activity(component='com.android.settings/.Settings') assert d(text = '设置').wait.exists(timeout = 5000),'Launch settings failed in 5s!' #Uninstall app u.selectOption('全局高级设置') assert d(resourceId = 'smartisanos:id/tv_title',text = '全局高级设置').wait.exists(timeout = 5000),'Switch to advanced setting view failed in 5s!' u.selectOption('应用程序管理') assert d(resourceId = 'smartisanos:id/tv_title',text = '应用程序管理').wait.exists(timeout = 5000),'Switch to app manager view failed in 5s!' u.selectOption('QQ') assert d(resourceId = 'smartisanos:id/tv_title',text = '应用信息').wait.exists(timeout = 5000),'Switch to app details view failed in 5s!' d(text = '卸载').click.wait() assert d(textContains = '要卸载此应用吗').wait.exists(timeout = 5000),'Delete alarm does not pop-up in 5s!' d(text = '确定').click.wait() assert d(text = 'QQ').wait.gone(timeout = 5000),'Uninstall failed in 5s!'