def _testChangeLetvScreenRate(self): """切换直播台的画面比例|进入乐视直播台菜单,切换画面比例""" try: self.launchLetv() time.sleep(4) self.a.input.menu() time.sleep(2) self.a.input.up() self.a.input.right(2) self.a.input.center() time.sleep(2) w = self.a.ui.screen() if 'displaySwitcher' not in w.ids(): self.error = 'cannot open menu in letv live screen' runtests.log_screenshot(self.a, '', 'fail_open_menu', 'Liveplay') raise Exception self.a.input.up(2) self.a.input.down() time.sleep(2) for i in range(3): self.a.input.center() time.sleep(5) if not self.isPlaying(): raise Exception except Exception, e : self.a.log.debug("", "\n testStabLetvUpToDownSomeChannel") self.fail("Error happened: %s %s" % ( self.error, e))
def testSTAB_connect_disconnect(self): """Bluetooth test| connect and disconnect bluetooth """ try: '''if not self.launchBT(): runtests.log_screenshot(self.a, '', 'screenshot', 'bluetooth_01') self.error = 'failed to find bluetooth' raise Exception''' self.a.device.sh('input keyevent 176') time.sleep(2) self.a.input.up() self.a.input.left(8) self.a.input.right(3) self.a.input.down() self.a.input.center() time.sleep(2) self.a.input.up(2) self.a.input.down() self.a.input.center() time.sleep(2) for i in range(0, self.loop): if not self.turnOnBT(): runtests.log_screenshot(self.a, '', 'screenshot', 'bluetooth_02') print "failed at %s" % i raise Exception except Exception, e: self.a.log.debug("", "\n bluetooth") self.fail("Error happened: %s" % (self.error))
def playFiles(self): self.getPlayFiles() self.loop=len(self.play_urls) #self.loop=1 for j in range(1, self.outloop+1): for i in range (0,self.loop): print "play: %s" %self.play_urls[i] cmd = "am start -a android.intent.action.VIEW -d \'%s\' -n com.letv.videoplayer/.MainActivity" %self.play_urls[i] #cmd = "am start -n letv.lcworld.player/.MainActivity -d \'%s\' -a android.intent.action.VIEW"%self.play_urls[i] self.a.device.sh(cmd) time.sleep(10) runtests.log_screenshot(self.a, '', self.play_urls[i], 'playfiles') if self.isNoError(): # Playing right self.a.log.debug("","This link: %s is played successfully."%self.play_urls[i]) self.seek() self.a.input.back() else: # Playing error self.error_urls.append(self.play_urls[i]) print "Failed: %s" %self.play_urls[i] self.a.log.debug("","Error: %s This link can not be played."%self.play_urls[i]) time.sleep(1) self.a.input.back(2) time.sleep(5) if self.error_urls!=[]: raise Exception
def _testChangeLetvDisplay(self): """切换直播台的清晰度|进入乐视直播台菜单,切换清晰度""" try: self.a.input.home() self.launchLetv() time.sleep(5) self.a.input.menu() time.sleep(2) self.a.input.up() self.a.input.right(2) self.a.input.center() time.sleep(2) w = self.a.ui.screen() if 'displaySwitcher' not in w.ids(): self.error = 'cannot open menu in letv live screen' runtests.log_screenshot(self.a, '', 'fail_open_menu', 'Liveplay') raise Exception self.a.input.down(2) for i in range(3): self.a.input.center() time.sleep(5) if not self.isPlaying(): runtests.log_screenshot(self.a, '', 'change_display_fail', 'Liveplay') raise Exception else:pass except Exception, e : self.a.log.debug("", "\n testChangeLetvDisplay") self.fail("Error happened: %s %s" % ( self.error, e))
def testSTAB_connect_disconnect(self): """Bluetooth test| connect and disconnect bluetooth """ try : '''if not self.launchBT(): runtests.log_screenshot(self.a, '', 'screenshot', 'bluetooth_01') self.error = 'failed to find bluetooth' raise Exception''' self.a.device.sh('input keyevent 176') time.sleep(2) self.a.input.up() self.a.input.left(8) self.a.input.right(3) self.a.input.down() self.a.input.center() time.sleep(2) self.a.input.up(2) self.a.input.down() self.a.input.center() time.sleep(2) for i in range(0, self.loop): if not self.turnOnBT(): runtests.log_screenshot(self.a, '', 'screenshot', 'bluetooth_02') print "failed at %s" %i raise Exception except Exception, e : self.a.log.debug("", "\n bluetooth") self.fail("Error happened: %s" % (self.error))
def _testLaunchCNTVTime(self): """CNTV启动时间|操作步骤:;1. 启动CNTV""" try: times = self.launchCNTV() self.a.log.debug("", "raise self.failureException('CNTV启动时间: %.3f s')" % times) self.exitCNTV() except Exception, e: runtests.log_screenshot(self.a, "", "fail_testLaunchCNTVTime", "testNetworkTesting") self.a.log.debug("", "\n testLaunchCNTVTime") self.fail("Error happened: %s %s" % (self.error, e))
def _testLaunchCNTVTime(self): """CNTV启动时间|操作步骤:;1. 启动CNTV""" try: times = self.launchCNTV() self.a.log.debug( "", "raise self.failureException('CNTV启动时间: %.3f s')" % times) self.exitCNTV() except Exception, e: runtests.log_screenshot(self.a, '', 'fail_testLaunchCNTVTime', 'testNetworkTesting') self.a.log.debug("", "\n testLaunchCNTVTime") self.fail("Error happened: %s %s" % (self.error, e))
def testNetworkTesting(self): """网络测速|操作步骤:;1. 设置中进行网络测试""" try: self.a.device.sh("input keyevent 176") time.sleep(2) self.a.input.up() self.a.input.left(8) self.a.input.down() self.a.input.right(2) self.a.input.center() time.sleep(2) w = self.a.ui.screen() if 'title' not in w.ids(): self.error = 'cannot enter network page' raise Exception self.a.input.center() time.sleep(5) start_time = time.time() during = time.time() - start_time while 'text_cur_speed' in self.a.ui.screen().ids( ) and during < 180: print 'network testing ...' time.sleep(5) during = time.time() - start_time if during >= 120: self.error = 'network testing timeout' runtests.log_screenshot(self.a, '', 'fail_testNetworkTesting', 'testNetworkTesting') raise Exception try: l = self.a.ui.waitfor(id='text_speed').text() print '平均速度:%s' % l self.a.log.debug( "", "raise self.failureException('网络平均速度: %s')" % l) except: self.error = 'cannot get speed' runtests.log_screenshot(self.a, '', 'fail_testNetworkTesting', 'testNetworkTesting') raise Exception self.a.input.back(4) except Exception, e: self.a.log.debug("", "\n testNetworkTesting") self.fail("Error happened: %s %s" % (self.error, e))
def playFile(self, url): print "play ", url cmd = "am start -a android.intent.action.VIEW -d \'%s\' -n com.letv.videoplayer/.MainActivity" %url self.a.device.sh(cmd) time.sleep(10) runtests.log_screenshot(self.a, '', url, 'playfiles') w = self.a.ui.screen() status = "successfully" if "file_browse_frame" in w.ids(): print "type error" status = "type error" elif "player_error_info_tv" in w.ids(): print "cannot play" status = 'cannot play' else: print "play successfully" pass self.results[url] = status self.a.input.back() time.sleep(3)
def playFile(self, url): print "play ", url cmd = "am start -a android.intent.action.VIEW -d \'%s\' -n com.letv.videoplayer/.MainActivity" % url self.a.device.sh(cmd) time.sleep(10) runtests.log_screenshot(self.a, '', url, 'playfiles') w = self.a.ui.screen() status = "successfully" if "file_browse_frame" in w.ids(): print "type error" status = "type error" elif "player_error_info_tv" in w.ids(): print "cannot play" status = 'cannot play' else: print "play successfully" pass self.results[url] = status self.a.input.back() time.sleep(3)
def testNetworkTesting(self): """网络测速|操作步骤:;1. 设置中进行网络测试""" try: self.a.device.sh("input keyevent 176") time.sleep(2) self.a.input.up() self.a.input.left(8) self.a.input.down() self.a.input.right(2) self.a.input.center() time.sleep(2) w = self.a.ui.screen() if "title" not in w.ids(): self.error = "cannot enter network page" raise Exception self.a.input.center() time.sleep(5) start_time = time.time() during = time.time() - start_time while "text_cur_speed" in self.a.ui.screen().ids() and during < 180: print "network testing ..." time.sleep(5) during = time.time() - start_time if during >= 120: self.error = "network testing timeout" runtests.log_screenshot(self.a, "", "fail_testNetworkTesting", "testNetworkTesting") raise Exception try: l = self.a.ui.waitfor(id="text_speed").text() print "平均速度:%s" % l self.a.log.debug("", "raise self.failureException('网络平均速度: %s')" % l) except: self.error = "cannot get speed" runtests.log_screenshot(self.a, "", "fail_testNetworkTesting", "testNetworkTesting") raise Exception self.a.input.back(4) except Exception, e: self.a.log.debug("", "\n testNetworkTesting") self.fail("Error happened: %s %s" % (self.error, e))
def tearDown(self): try: runtests.log_screenshot(self.a, "", "screenshot", "Liveplay") except: pass
def tearDown(self): try : runtests.log_screenshot(self.a, '', 'screenshot', 'Liveplay') except: pass
def tearDown(self): try: runtests.log_screenshot(self.a, '', 'screenshot', 'Liveplay') except: pass