def exitmenus(): StormTest.PressButton(EXIT) StormTest.WaitSec(3) StormTest.PressButton(SELECT) #in case there is an error on screen StormTest.WaitSec(3) StormTest.PressButton(EXIT) StormTest.WaitSec(3)
def pauseplay(): exitmenus() StormTest.PressButton(PAUSE) StormTest.WaitSec(3) StormTest.PressButton(PLAY) StormTest.WaitSec(3) SThelperNew.takeScreenshot("Play Live", "Live TV should be playing")
def test_tap_element_using_text(self): print "TEST TAP ELEMENT USING TEXT" self.device.tap(mappedText='OpenMenu') StormTest.WaitSec(4) isPressed = self.device.tap(text='Cinema') colorMatch = StormTest.WaitColorMatch((0, 0, 68), tolerances=(16, 16, 16), flatness=90, peakError=50, includedAreas=[600, 140, 10, 10], timeToWait=10) isCinema = colorMatch[0][1] print "Open cinema " + str(colorMatch) StormTest.WaitSec(1) self.device.tap(mappedText='Home') #colorNoMatch = StormTest.WaitColorNoMatch((0,0,68), tolerances=(16,16,16), flatness=90, peakError=50, includedAreas=[400,430,10,10], timeToWait=15) colorMatch = StormTest.WaitColorMatch( (40, 120, 178), tolerances=(16, 16, 16), flatness=90, peakError=50, includedAreas=[1000, 750, 10, 10], timeToWait=10) StormTest.CaptureImageEx((0, 0, 1920, 1080), "Screenshot") isHome = colorMatch[0][1] print "Return to Home " + str(colorMatch) #StormTest.WaitSec(6) self.assertTrue(isPressed, "Tap on Cinema failed") self.assertTrue(isCinema, "Tap on Cinema failed") pass
def goToWiFi(galaxyTab3): PressButton("SWIPE:220:110:220:760:0") PressButton("SWIPE:220:110:220:760:0") PressButton("SWIPE:220:110:220:760:0") StormTest.WaitSec(1) galaxyTab3.tap(text='Wi-Fi') StormTest.WaitSec(1) pass
def recharge(self, rechargeTime): time = str(rechargeTime) StormTest.PressButton("LOCK:{0}".format(time)) StormTest.WaitSec(rechargeTime + 20) #StormTest.PressButton('SWIPE:1000:400:500:400') self.swipe([1000,400,300,400], 2) StormTest.WaitSec(1) pass
def logout(galaxyTab3): galaxyTab3.tap(mappedText='openMenu') StormTest.WaitSec(1) galaxyTab3.tap(text='Logout') StormTest.WaitSec(1) galaxyTab3.tap(mappedText='closeMenu') StormTest.WaitSec(1) pass
def replayfeed(takeShot): if takeShot != True: StormTest.PressButton(REPLAY) StormTest.WaitSec(3) else: StormTest.PressButton(REPLAY) StormTest.WaitSec(3) SThelperNew.takeScreenshot('Replay test', 'Feed is replayed')
def wakebox(): StormTest.PressButton(INFO) StormTest.WaitSec(3) StormTest.PressButton(INFO) StormTest.WaitSec(3) exitmenus() exitmenus() SThelperNew.takeScreenshot('Wake up Boxes', 'Are boxes awake? (Live TV Displays)')
def login(galaxyTab3): galaxyTab3.tap(mappedText='openMenu') StormTest.WaitSec(1) enterEmail(galaxyTab3) enterPassword(galaxyTab3) galaxyTab3.tap(text='Accedi') StormTest.WaitSec(7) pass
def disconnectToTheNetwork(galaxyTab3, assistanceMenu): goToSettings(assistanceMenu) goToWiFi(galaxyTab3) galaxyTab3.tap(text='Vodafone-WIFI') StormTest.WaitSec(2) galaxyTab3.tap(text='Forget') StormTest.WaitSec(5) closeSettings(assistanceMenu) pass
def closeSettings(assistanceMenu): assistanceMenu.open() StormTest.WaitSec(2) assistanceMenu.down() StormTest.WaitSec(1) assistanceMenu.back() StormTest.WaitSec(1) assistanceMenu.close() pass
def test_tap_element_using_text(self): print "TEST TAP ELEMENT USING TEXT" self.device.tap(mappedText='openMenu') StormTest.WaitSec(4) isCinemaPressed = self.device.tap(text='Cinema') StormTest.WaitSec(4) self.device.tap(mappedText='Home') StormTest.WaitSec(6) self.assertEqual(isCinemaPressed, True, "Tap on Cinema failed") pass
def forward(fvelocity): fspeed = [1, 2, 3, 4] ivarf = 0 #loop iteration variable #if the specified fvelocity is not in fspeed, error out and exit function if fvelocity not in fspeed: return SThelperNew.takeScreenshot( 'No Forward', 'No forward occured, ensure valid input is added (1-4)') try: #iterate through fspeed list for fnum in range(len(fspeed)): #check whether fvelocity matches fspeed at fnum index if fspeed[fnum] == fvelocity: #send IR commands until reaching the specified fvelocity while ivarf < fvelocity: StormTest.PressButton(FORWARD) StormTest.WaitSec(3) ivarf += 1 #print out test case with corresponding fvelocity SThelperNew.takeScreenshot( 'Forward test at x' + str(fvelocity), 'Box is forwarding at x' + str(fvelocity) + ' speed.') #break out of loop to save computation time break except: SThelperNew.takeScreenshot( 'No Forward', 'Valid input given but no forward occured, check main body of forward function' ) return
def closeApp(device): StormTest.BeginLogRegion('Close App') StormTest.WaitSec(2) device.tap(mappedText='Home') result = colorMatch(color=(233, 235, 233), tolerances=(16, 16, 16), flatness=95, peakError=15, includedAreas=[940, 990, 10, 10], timeToWait=60, imageName='CloseApp', comment='Match color on returning to home') if not result: device.tap(mappedText='Home') colorMatch(color=(233, 235, 233), tolerances=(16, 16, 16), flatness=95, peakError=15, includedAreas=[940, 990, 10, 10], timeToWait=60, imageName='CloseApp', comment='Match color on returning to home') device.stop() StormTest.EndLogRegion('Close App') return result
def login(device): log.warning('App not logged') __enterEmail(device) __enterPassword(device) device.tap(text='Accedi') StormTest.WaitSec(7) pass
def rewind(rvelocity): rspeed = [1, 2, 3, 4] ivarr = 0 #iteration variable for loop #if the specified velocity is invalid, spill error and exit function if rvelocity not in rspeed: return SThelperNew.takeScreenshot( 'No Rewind', 'No rewind occured, ensure valid input is added (1-4).') try: #iterate through rspeed list for rnum in range(len(rspeed)): #check whether rvelocity matches rspeed at rnum index if rspeed[rnum] == rvelocity: #Send IR commands until reaching the specified rvelocity while ivarr < rvelocity: StormTest.PressButton(REWIND) StormTest.WaitSec(3) ivarr += 1 #print out test case with corresponding rvelocity SThelperNew.takeScreenshot( 'Rewind test at x' + str(rvelocity), 'Box is rewinding at x' + str(rvelocity) + ' speed.') #break loop after this to save computation time break except: SThelperNew.takeScreenshot( 'No Rewind', 'Valid Input given but no rewind occured, check body of rewind function' ) return
def test_tap_using_mapped_text(self): print "TEST TAP MAPPED TEXT" isOpenPressed = self.device.tap(mappedText='OpenMenu') colorMatch = StormTest.WaitColorMatch((66, 171, 159), tolerances=(16, 16, 16), flatness=90, peakError=50, includedAreas=[420, 300, 10, 10], timeToWait=10) isOpen = colorMatch[0][1] print "Open menu " + str(colorMatch) StormTest.WaitSec(1) isClosePressed = self.device.tap(mappedText='CloseMenu') colorNoMatch = StormTest.WaitColorNoMatch( (41, 100, 168), tolerances=(16, 16, 16), flatness=90, peakError=50, includedAreas=[400, 430, 10, 10], timeToWait=10) isClose = colorNoMatch[0][1] print "Close menu " + str(colorNoMatch) self.assertTrue(isOpenPressed, "Tap failed") self.assertTrue(isOpen, "Tap failed") self.assertTrue(isClosePressed, "Tap failed") self.assertTrue(isClose, "Tap failed") pass
def test_tap_using_mapped_text(self): print "TEST TAP MAPPED TEXT" isPressed = self.device.tap(mappedText='openMenu') StormTest.WaitSec(4) self.device.tap(mappedText='closeMenu') self.assertEqual(isPressed, True, "Tap failed") pass
def connectToTheNetwork(galaxyTab3, assistanceMenu): goToSettings(assistanceMenu) goToWiFi(galaxyTab3) galaxyTab3.tap(text='Vodafone-WIFI') enterPassword() galaxyTab3.tap(text='Connect') StormTest.WaitSec(5) closeSettings(assistanceMenu) pass
def test_enter_email(self): print "TEST ENTER EMAIL" self.device.tap(mappedText='OpenMenu') self.device.tap(text='Indirizzo mail. Editing.') StormTest.WaitSec(2) isEmailEntered = self.device.enterText("*****@*****.**") self.device.tap(mappedText='OpenAssistantMenu') self.device.tap(mappedText='CloseAssistantMenu') self.device.tap(mappedText='CloseMenu') self.assertTrue(isEmailEntered, "Fail to enter text") pass
def enterText(self, text): specialChars = ['@'] upperChars = ['A', 'B', 'C'] for c in text: if c in specialChars: if not self.tap(mappedText='Sym'): return False StormTest.WaitSec(1) if not self.tap(mappedText=c): return False StormTest.WaitSec(1) if not self.tap(mappedText='Sym'): return False StormTest.WaitSec(1) continue if c in upperChars: if not self.tap(mappedText='Shift'): return False StormTest.WaitSec(1) if not self.tap(mappedText=c): return False StormTest.WaitSec(1) continue if not self.tap(mappedText=c): return False StormTest.WaitSec(1) return True
def advance(avelocity): #dictionary for every state of the advance feature, where key is the input (how many times advanced is pressed), and value is the corresponding advance time. adict = { 1: '30s', 2: '1m', 3: '1m30s', 4: '2m', 5: '2m30s', 6: '3m', 7: '3m30s', 8: '4m', 9: '4m30s', 10: '5m', 11: '5m30s', 12: '6m', 13: '6m30s', 14: '7m', 15: '7m30s', 16: '8m', 17: '8m30s', 18: '9m', 19: '9m30s', 20: '10m' } ivara = 0 #loop iteration variable #if the specified avelocity is not a valid key in adic, quit out of function if avelocity not in adict: return SThelperNew.takeScreenshot( 'No Advance', 'No advance occured, ensure valid input is added (1-20)') try: #iterate through adic dictionary. items() returns a tuple, hence the for loop has key, value pair for key, value in adict.items(): #find the correct key corresponding with avelocity if key == avelocity: #send IR commands for advance until desired input is reached while ivara < avelocity: StormTest.PressButton(ADVANCE) StormTest.WaitSec(1) ivara += 1 #print out test case with corresponding key and value pair SThelperNew.takeScreenshot( 'Advance test' + str(key), 'Advance forward ' + str(value) + ' at ' + str(key) + ' input.') #break out of loop to save computation time break except: SThelperNew.takeScreenshot( 'No Advance', 'Valid input given but advance did not occur, check main body of advance function' ) return
def createbuffer(minutes): maxbuffer = 90 #90 minutes try: if minutes > maxbuffer: minutes = maxbuffer #change to minutes seconds = minutes * 60 #convert minutes to seconds, formula is minutes x 60s/min exitmenus( ) #make sure nothing is on screen preventing the buffer from being created StormTest.WaitSec(seconds) except: SThelperNew.takeScreenshot( 'No Buffer', 'No buffer was created, troubleshoot code createbuffer') return
def changechannel(cnumber): maxchannel = 9999 try: if cnumber > maxchannel: cnumber = maxchannel StormTest.PressButton(cnumber) StormTest.PressButton(ENTER) StormTest.WaitSec(3) SThelperNew.takeScreenshot('Tune to channel' + str(cnumber), 'Tuned to channel ' + str(cnumber)) except: SThelperNew.takeScreenshot( 'Change Channel', 'Invalid channel given, input correct channel (1-9999)') return
def checkCrash(device): result = colorMatch(color=(48, 50, 48), tolerances=(4, 4, 4), flatness=99, peakError=10, includedAreas=(820, 590, 10, 10), timeToWait=10, imageName='Crash', comment='Crash happened?') StormTest.WaitSec(5) if result[0]: log.error('CRASH!') device.tap(text='OK') return True return False
def openCatalog(self, catalogName): self._device.tap(text=catalogName) StormTest.WaitSec(5) match1 = StormTest.WaitColorNoMatch(color=(41, 116, 168), tolerances=(16, 16, 16), flatness=10, peakError=85, includedAreas=[495, 280, 663, 445], timeToWait=60) image = StormTest.CaptureImageEx(None, 'Catalog', slotNo=True)[2] if not match1[0][1]: comment = 'No match color of the poster failed on opening {0} catalog {1}'.format( catalogName, match1) log.error(comment) return False, comment, image comment = 'No match color of the poster successful on opening {0} catalog {1}'.format( catalogName, match1) log.info(comment) # match color sulla barra del menu blu match2 = StormTest.WaitColorMatch(color=(15, 15, 75), tolerances=(16, 16, 16), flatness=95, peakError=20, includedAreas=[1770, 140, 10, 10], timeToWait=60) image = StormTest.CaptureImageEx(None, 'Catalog2', slotNo=True)[2] if not match2[0][1]: comment = 'Match color of the dark blue menu failed on opening {0} catalog {1}'.format( catalogName, match2) log.error(comment) return False, comment, image comment = 'Match color of the dark blue menu successful on opening {0} catalog {1}'.format( catalogName, match2) log.info(comment) if match1 and match2: return True, comment, image else: return False, comment, image
def enterPassword(): StormTest.WaitSec(2) PressButton("TAP:55:680") StormTest.WaitSec(1) PressButton("TAP:55:680") StormTest.WaitSec(1) for i in range(3): PressButton("TAP:570:600:0") StormTest.WaitSec(1) PressButton("TAP:790:600:0") StormTest.WaitSec(1) PressButton("TAP:860:680:0") StormTest.WaitSec(1) pass
def _videoPresentTest(): """ Checks if video is present, by comparing screen colour against a black colour Requires: - a Screen Definition file called "DetectVideoPresence.stscreen" Returns: - result: boolean True or False - comment: a comment giving more details of the test result - image: a screenshot of the test """ result = False repeat = 10 count = 0 SDO = StormTest.ScreenDefinition() try: SDO.Load('DetectVideoPresence.stscreen') while (result == False) and (count <= repeat): #note this SDO returns True when a match does *not* occur retSDO = StormTest.WaitScreenDefMatch(SDO)[0][1] result = retSDO.VerifyStatus StormTest.WriteDebugLine( 'Result of matching screen with black was ' + str(not result)) count = count + 1 if (result == False) and (count <= repeat): StormTest.WaitSec(4) StormTest.WriteDebugLine('Retry, count = ' + str(count)) image = retSDO.Image image.Save('VideoPresent_%d_%t.jpeg') comment = 'Result of matching screen with black was ' + str(not result) SDO.Close() return [result, comment, image] except: print 'Could not load DetectVideoPresence.stscreen - exiting test' SDO.Close() return [ False, 'Could not load DetectVideoPresence.stscreen - exiting test', image ]
def openCatalogFind(self): self._device.tap(text="Cerca nel catalogo. Double tap to edit.") StormTest.WaitSec(5) match = StormTest.WaitColorMatch((197, 199, 200), tolerances=(16, 16, 16), flatness=80, peakError=85, includedAreas=[1200, 1000, 10, 10], timeToWait=60) StormTest.CaptureImageEx(None, 'Keyboard', slotNo=True)[2] if not match[0][1]: comment = 'Match color failed on opening the keyboard {0}'.format( match) log.error(comment) return False comment = 'Match color successful on opening the keyboard catalog {0}'.format( match) log.info(comment) return True
def setUpClass(self): super(Test, self).setUpClass() self.device = AndroidDevice("samsung_galaxy_tab_3") self.device.start("it.sky.river") StormTest.WaitSec(4) pass