def main(argv): parser = argparse.ArgumentParser() parser.add_argument("--test-pipeline-restart", action="store_true") args = parser.parse_args(argv[1:]) try: stbt.wait_for_match("../videotestsrc-redblue.png") except stbt.MatchTimeout: # This is ok. In the future when we have more control of what is on # screen we can really check for matches. pass if args.test_pipeline_restart: # TODO: Automate this by using a Raspberry Pi to stimulate the capture # hardware sys.stdout.write("Waiting for a long time for match to check pipeline " "restart behaviour. Please restart the set-top box " "to check that stb-tester recovers") try: stbt.wait_for_match("../../tests/template.png", timeout_secs=60) except stbt.MatchTimeout: # This is ok. In the future when we have more control of what is # on screen we can really check for matches. pass
def main(argv): parser = argparse.ArgumentParser() parser.add_argument("--test-pipeline-restart", action="store_true") args = parser.parse_args(argv[1:]) try: stbt.wait_for_match("../videotestsrc-redblue.png") except stbt.MatchTimeout: # This is ok. In the future when we have more control of what is on # screen we can really check for matches. pass if args.test_pipeline_restart: # TODO: Automate this by using a Raspberry Pi to stimulate the capture # hardware sys.stdout.write( "Waiting for a long time for match to check pipeline " "restart behaviour. Please restart the set-top box " "to check that stb-tester recovers" ) try: stbt.wait_for_match("../../tests/template.png", timeout_secs=60) except stbt.MatchTimeout: # This is ok. In the future when we have more control of what is # on screen we can really check for matches. pass
def _wait_for_selection_to_move(source): for m in _matches("images/any-player-selected.png"): if m.position != source.position: break # Wait for animation to end, so selection is stable stbt.wait_for_match("images/any-player-selected.png", consecutive_matches=2)
def verify_cell_highlight(): #2 cells #stbt.wait_for_match('images/blue_cell_vertical.png') #stbt.wait_for_match('images/blue_cell_horizontal.png') #4 cells stbt.wait_for_match('images/blue_cell_highlight_vertical_4_cell.png') stbt.wait_for_match('images/blue_cell_highlight_horizontal_4_cell.png') print "blue cells detected"
def pierwszaInstalacja(self): stbt.wait_for_match("images/t1/first_installation_image.png", self.rebootWaitingTime) stbt.press("KEY_OK", self.timeBeforePress) stbt.wait_for_match("images/t1/searching_chanels_done_image.png", self.searchingChanelsTime) stbt.press("KEY_OK", self.timeBeforePress) stbt.press("KEY_BACK", self.afterChanelsConfirmedTime) stbt.press("KEY_OK", self.timeBeforePress) stbt.press("KEY_OK", self.timeBeforePress) stbt.press("KEY_OK", self.timeBeforePress)
def main(): print stbt.ocr() keySend.keyPressAPI(rack, "exit", slot) time.sleep(1) # tune to sports mix keySend.tune("205", rack, slot) # verify snipe red button stbt.wait_for_match('images/red_button.png') # verify blue cells verify_cell_highlight() # verify highlights can navigate to all cells keySend.keyPressAPI(rack, "rightArrow", slot) verify_cell_highlight() keySend.keyPressAPI(rack, "rightArrow", slot) verify_cell_highlight() keySend.keyPressAPI(rack, "downArrow", slot) verify_cell_highlight() keySend.keyPressAPI(rack, "leftArrow", slot) verify_cell_highlight() keySend.keyPressAPI(rack, "leftArrow", slot) verify_cell_highlight() keySend.keyPressAPI(rack, "upArrow", slot) # verify app transitions to channel when press select # beware of possible false positive if info banner for 205 shows up # first cell keySend.keyPressAPI(rack, "select", slot) verify_channel_tune() # second cell keySend.keyPressAPI(rack, "rightArrow", slot) keySend.keyPressAPI(rack, "select", slot) verify_channel_tune() # return to mix channel keySend.tune("205", rack, slot) keySend.keyPressAPI(rack, 'exit', slot) time.sleep(2) # internet connected, verify scoreguide keySend.keyPressAPI(rack, "red", slot) # detect combo mix keySend.keyPressAPI(rack, "downArrow", slot) stbt.wait_for_match('images/scoreguide_highlight.png') keySend.keyPressAPI(rack, "select", slot) stbt.wait_for_match('images/scoreguide_banner_hd.png') # verify scoreguide highlights stbt.wait_for_match('images/nba_highlight.png') keySend.keyPressAPI(rack, "downArrow", slot) print "test output:" + str( image_verified('images/scoreguide_minimize_highlight.png', 3)) while not image_verified('images/scoreguide_minimize_gray.png', 3): keySend.keyPressAPI(rack, "downArrow", slot) print "test file executed and completed"
def channelSwitchDetection(channelToCompare, maxAttempts=10): result = [0, 0] stbt.wait_for_match( "images/t1/up_arrow_image.png") # oczekiwanie na wcisnienie przycisku channelNumber = stbt.ocr(None, stbt.Region(90, 592, width=45, height=41), stbt.OcrMode.PAGE_SEGMENTATION_WITHOUT_OSD) cn = int(channelNumber) result[1] = cn if cn < channelToCompare: result[0] = 1 elif cn > channelToCompare: result[0] = 2 else: result[0] = -1 return result
def pierwszaInstalacja(self): try: stbt.wait_for_match("sciezka do obrazka lista kanalow", 60) except stbt.MatchTimeout: self.testsResults["power"] = False return self.testsResults["power"] = True try: stbt.wait_for_match( "sciezka do obrazka aktualizacja oprogramowania", 60) except stbt.MatchTimeout: self.testsResults["signal_level_1"] = False self.testsResults["signal_quality_1"] = False return try: stbt.wait_for_match( "sciezka do obrazka przycisku aktualizacja oprogramowania", 30, stbt.Region(260, 200, width=690, height=340)) except stbt.MatchTimeout: try: stbt.wait_for_match( "obrazek ptaszek(zaznaczenie - ethernet)", 20, stbt.Region(260, 200, width=690, height=340)) except: stbt.press("KEY_UP", Test.timeBeforePress) stbt.press("KEY_OK", Test.timeBeforePress) stbt.press("KEY_OK", Test.timeBeforePress) try: stbt.wait_for_match("sciezka do obrazka odbierasz(aktywacja)", 30, stbt.Region(905, 450, width=35, height=30)) except MatchTimeout: self.sprawdzSileIJakosSygnalu( 1, stbt.Region(730, 365, width=65, height=25), stbt.Region(730, 405, width=65, height=25)) if self.model == "3740SX": self.sprawdzSileIJakosSygnalu( 2, stbt.Region(730, 495, width=65, height=25), stbt.Region(730, 535, width=65, height=25)) return try: stbt.wait_for_motion(30) except MotionTimeout: self.activationCode() else: stbt.press("KEY_OK", Test.timeBeforePress) self.uruchomienieDekodera()
def test_that_image_is_rotated_by_arrows(): press("KEY_LEFT") wait_for_match('stb-tester-left.png') press("KEY_RIGHT") wait_for_match('stb-tester-right.png') press("KEY_UP") wait_for_match('stb-tester-up.png') press("KEY_DOWN") wait_for_match('stb-tester-down.png')
def test_VOD_ME_4434_check_VODpage_not_in_Recently_Watched(): tv_shows_launch() time.sleep(65) stbt.press('KEY_EXIT') my_library_launch() while True: stbt.press('KEY_DOWN') if stbt.wait_for_match('images/lane/recently_watched.png'): break stbt.press('KEY_ENTER')
def test_smoke_trigger_open(): """Open MySky app""" itu.clear_test() try: itu.go_to_channel(interactive_constants.CHANNEL_SKY_ONE_HD) match_result = wait_for_match(TRIGGER_IMAGE, timeout_secs=15, region=TRIGGER_REGION) assert match_result.match, '[Trigger] Could not find trigger icon' stbt.press('KEY_GREEN') sleep(5) for i in range(10): frame = stbt.get_frame() # Save image for testing manually later cv2.imwrite('trigger_screen_{0}.jpg'.format(i), frame) finally: itu.clear_test()
def check_icon_on_screen(icon, scope={}, validate=True): coordinates = getCoordinatesOfIcon(icon) status = False try: if (stbt.wait_for_match(coordinates['image'], region=stbt.Region( x=coordinates['x'], y=coordinates['y'], right=coordinates['right'], bottom=coordinates['bottom']))): print "Icon present on screen" status = True else: print "Icon not present on screen" status = False except Exception, e: print e print "Exception thrown"
def check_for_recording_icon(icon, scope={}, validate=True): status = False dismissPopupIfPresent() coordinates = getCoordinatesOfIcon(icon) image = coordinates['image'] x = coordinates['x'] y = coordinates['y'] right = coordinates['right'] bottom = coordinates['bottom'] imageRegion = stbt.Region(x, y, right, bottom) try: if (stbt.wait_for_match(image, region=stbt.Region(x, y, right, bottom))): print "Icon present on screen" status = True else: print "Icon not present on screen" status = False except Exception, e: print e print "Exception thrown"
def test_that_image_returns_to_normal_on_OK(): press("KEY_OK") wait_for_match('stb-tester-350px.png')
def wait_for_vstb_startup(): wait_for_match('stb-tester-350px.png')
def testAutodiag(self): scanedSN #zeskanowany SN dekodera self.sprawdzSN(scannedSN) stbt.press("KEY_OK", Test.timeBeforePress) for i in range(10): result = stbt.match_text("OK", None, stbt.Region(x=665, y=293 + 16 * i, width=30, height=16)) if result == False: self.testsResults["hds_autodiag_hardware_test"] = False return stbt.prsss("KEY_DOWN", Test.timeBeforePress) for i in range(3): result = stbt.match_text("OK", None, stbt.Region(x=665, y=293 + 16 * i, width=30, height=16)) if result == False: self.testsResults["hds_autodiag_hardware_test"] = False return stbt.press("KEY_MENU", Test.timeBeforePress) stbt.press_until_match("KEY_DOWN", "./images/t1/hds_hard_disk.png", self.timeBeforePress, 5, region = stbt.Region(x=464, y=357, width=117, height=13)) stbt.press("KEY_OK", Test.timeBeforePress) stbt.press("KEY_OK", Test.timeBeforePress) result = stbt.match_text("PASS") if result == False: self.testsResults["hdd"] = False return stbt.press("KEY_MENU", Test.timeBeforePress) stbt.press("KEY_DOWN", Test.timeBeforePress) stbt.press("KEY_OK", Test.timeBeforePress) stbt.press("KEY_OK", Test.timeBeforePress) while True: time.sleep(2) if stbt.match_text("PASS", region = stbt.Region(x=663, y=290, width=70, height=20)): self.testsResults["hdd"] = True break elif stbt.match_text("FAIL", region = stbt.Region(x=663, y=290, width=70, height=20)): self.testsResults["hdd"] = False return stbt.press("KEY_MENU", Test.timeBeforePress) stbt.press("KEY_DOWN", Test.timeBeforePress) stbt.press("KEY_DOWN", Test.timeBeforePress) stbt.press("KEY_OK", Test.timeBeforePress) self.typeAutodiagPassword() while True: time.sleep(2) if stbt.match_text("PASS", region = stbt.Region(x=663, y=290, width=70, height=20)): self.testsResults["hdd"] = True break elif stbt.match_text("FAIL", region = stbt.Region(x=663, y=290, width=70, height=20)): self.testsResults["hdd"] = False return stbt.press("KEY_MENU", Test.timeBeforePress) stbt.press("KEY_MENU", Test.timeBeforePress) stbt.press_until_match("KEY_DOWN", "./images/t1/hds_autodiag_factory_settings.png", Test.timeBeforePress, 5, region = stbt.Region(x=464, y=371, width=212, height=21)) stbt.press("KEY_OK", Test.timeBeforePress) self.typeAutodiagPassword() stbt.press("KEY_OK", Test.timeBeforePress) stbt.press("KEY_DOWN", Test.timeBeforePress) stbt.press("KEY_DOWN", Test.timeBeforePress) stbt.press("KEY_OK", Test.timeBeforePress) while True: time.sleep(2) if stbt.match_text("DONE", region = stbt.Region(x=637, y=292, width=78, height=14))): while True: time.sleep(1) if stbt.match_text("DONE", region = stbt.Region(x=636, y=309, width=70, height=14): self.testsResults["hds_factory_settings"] = True break elif stbt.match_text("FAIL", region = stbt.Region(x=636, y=309, width=70, height=14): self.testsResults["hds_factory_settings"] = False return break elif stbt.match_text("FAIL", region = stbt.Region(x=637, y=292, width=78, height=14)): self.testsResults["hds_factory_settings"] = False return stbt.press("KEY_MENU", Test.timeBeforePress) stbt.press("KEY_MENU", Test.timeBeforePress) def wejdzWUstawienia(self): stbt.press("KEY_MENU", self.timeBeforePress) self.myPressUntilMatchText("USTAWIENIA", "KEY_RIGHT", stbt.Region(x=550, y=605, width=180, height=41), 10) stbt.press("KEY_OK", self.timeBeforePress) def typeAutodiagPassword(self): stbt.press("KEY_5", Test.timeBeforePress) stbt.press("KEY_5", Test.timeBeforePress) stbt.press("KEY_5", Test.timeBeforePress) def sprawdzRachunki(self): result = stbt.match_text("BRAK", None, stbt.Region(x=845, y=235, width=72, height=26)) if result: self.testsResults["bills"] = True else: self.testsResults["bills"] = False def sprawdzWiadomosci(self): result = stbt.ocr(region = stbt.Region(x=101, y=135, width=1075, height=32)) if result == "": self.testsResults["messages"] = True else: self.testsResults["messages"] = False def sprawdzHDD(self): today = stbt.ocr(region = stbt.Region(x=1026, y=35, width=86, height=33)) recordingDate = ocr(region = stbt.Region(x=673, y=543, width=62, height=22)) if recordingDate == today: stbt.press("KEY_PLAY", Test.timeBeforePress) time.sleep(10) stbt.press("KEY_PAUSE", Test.timeBeforePress) try: stbt.wait_for_motion(timeout_sec = 3, region = stbt.Region(x=10, y=11, width=1260, height=540)) except MotionTimeout: stbt.press("KEY_REV", Test.timeBeforePress) if stbt.match_text("x4", region = stbt.Region(x=186, y=588, width=30, height=21)): stbt.press("KEY_FWD", Test.timeBeforePress) stbt.press("KEY_FWD", Test.timeBeforePress) if stbt.match_text("x8", region = stbt.Region(x=186, y=588, width=30, height=21)): selft.testsResults["hdd"] = True else: self.testsResults["hdd"] = False else: self.testsResults["hdd"] = False else: self.testsResults["hdd"] = False stbt.press("KEY_STOP", Test.timeBeforePress) stbt.press("KEY_3", Test.timeBeforePress) stbt.press("KEY_OK", Test.timeBeforePress) else: self.testsResults["hdd"] = False def sprawdzSN(self, scannedSN): SN = stbt.ocr(region = stbt.Region(x=600, y=251, width=164, height=19)) print("Odczytany SN: ", SN) if SN != scannedSN: self.testsResults["sn"] = False else: self.testsResults["sn"] = True def sprawdzCzytnikKart(self): print("Wloz karte do czytnika.") result = myWaitWhileMatchText("BRAK KARTY", stbt.Region(x=555, y=127, width=165, height=33)) if result: result = stbt.match("./images/t1/hds_smart_card_error.png", region = stbt.Region(x=555, y=127, width=165, height=33)) if result: self.testsResults["card_reader"] = False else: self.testsResults["card_reader"] = True else: self.testsResults["card_reader"] = False def sprawdzMaxIndex(self): maxIndex = stbt.ocr(region = stbt.Region(x=669, y=418, width=56, height=35)) #stbt.ocr(None, stbt.Region(x=669, y=418, width=56, height=35), stbt.OcrMode.PAGE_SEGMENTATION_WITHOUT_OSD) if maxIndex == "0": self.testsResults["max_index"] = True else: self.testsResults["max_index"] = False def sprawdzSiec(self): ipTestResult = stbt.match_text("172.16", None, stbt.Region(x=655, y=233, width=56, height=24)) if ipTestResult == False: self.testsResults["ethernet"] = False else: self.testsResults["ethernet"] = True def sprawdzWersjeOprogramowania(self): softVersion = stbt.ocr(region = stbt.Region(x=811, y=323, width=47, height=21)) #stbt.ocr(None, stbt.Region(x=811, y=323, width=47, height=21), stbt.OcrMode.PAGE_SEGMENTATION_WITHOUT_OSD) if softVersion == currentUpdateVersions[0]uv or softVersion == currentUpdateVersions[1]: self.testsResults["soft_version"] = True else: self.testsResults["soft_version"] = False def sprawdzSileIJakosSygnalu(self): self.testsResults["signal_level"] = stbt.match("./images/t1/hds_signal_level.png", region = stbt.Region(x=743, y=324, width=111, height=19)) def sprawdzUSB(self, port): print("Wloz Pendrive do gniazda USB umieszczonego z boku.") input = input("Czy dioda Pendrive swieci?\n1) Tak\n2) Nie") while input != "1" and input != "2": input = input("Czy dioda Pendrive swieci?\n1) Tak\n2) Nie") if input == "1": self.testsResults[port] = True else: self.testsResults[port] = False def sprawdzTimeshifting(self): stbt.press("KEY_PAUSE", Test.timeBeforePress) try: stbt.wait_for_motion(timeout_sec = 3, region = stbt.Region(x=10, y=70, width=1260, height=480)) except MotionTimeout: stbt.press("KEY_STOP", Test.timeBeforePress) try: stbt.wait_for_motion() except MotionTimeout: self.testsResults["timeshifting"] = False else: self.testsResults["timeshifting"] = True else: self.testsResults["timeshifting"] = False def sprawdzWyswietlacz(self): self.runChannel("888") input = input("Czy wyswietlacz swieci prawidlowo?\n1) Tak\n2) Nie") while input != "1" and input != "2": input = input("Czy wyswietlacz swieci prawidlowo?\n1) Tak\n2) Nie") if input == "1": self.testsResults["display"] = True else self.testsResults["dispaly"] = False def sprawdzTVNaziemna(self): self.runChannel("998") input = input("Czy obraz na ekranie wyswietlany jest prawidlowo?\n1) Tak\n2) Nie") while input != "1" and input != "2": input = input("Czy obraz na ekranie wyswietlany jest prawidlowo?\n1) Tak\n2) Nie") if input == "1": self.testsResults["terrestrial_siganl_quality"] = True else: self.runChannel("994") input = input("Czy obraz na ekranie wyswietlany jest prawidlowo?\n1) Tak\n2) Nie") while input != "1" and input != "2": input = input("Czy obraz na ekranie wyswietlany jest prawidlowo?\n1) Tak\n2) Nie") if input == "1": self.testsResults["terrestrial_siganl_quality"] = True else: self.testsResults["terrestrial_siganl_quality"] = False def sprawdzPrzyciski(self, maxAttempts = 5): result = {} counter = 0 print("Wcisnij kalwisz P-") detection = channelSwitchDetection(self.mainTestChannels[0]) while detection[0] != 1 and counter < maxAttempts: detection = channelSwitchDetection(self.mainTestChannels[0]) counter += 1 if counter == maxAttempts: result["P-"] = False else: result["P-"] = True time.sleep(5) print("Wciśnij klawisz 'P+'") counter = 0 detection = channelSwitchDetection(detection[1]) while detection[0] != 2 and counter < maxAttempts: detection = channelSwitchDetection(detection[1]) counter += 1 if counter == maxAttempts: result["P+"] = False else: result["P+"] = True print("Wcisnij klawisz 'V+'") result["V+"] = self.volumeUpSwitchDetection() print("Wcisnij klawisz 'V-'") result["V-"] = self.volumeDownSwitchDetection() time.sleep(5) print("Wcisnij klawisz 'St-By'") counter = 0 detection = stbySwitchDetection() while detection == False and counter < maxAttempts: detection = stbySwitchDetection() counter += 1 if counter == maxAttempts: result["St-By"] = False else: result["St-By"] = True self.testsResults["switches"] = result def channelSwitchDetection(channelToCompare): result = [0, 0] try: stbt.wait_for_match("./images/t1/hds_up_arrow.png", region = stbt.Region(x=255, y=539, width=39, height=31)) # oczekiwanie na wcisnienie przycisku except stbt.MatchTimeout: result[0] = -1 result[1] = channelToCompare return result channelNumber = stbt.ocr(None, stbt.Region(90, 592, width=45, height=41), stbt.OcrMode.PAGE_SEGMENTATION_WITHOUT_OSD) cn = int(channelNumber) result[1] = cn if cn < channelToCompare: result[0] = 1 elif cn > channelToCompare: result[0] = 2 return result def stbySwitchDetection(maxAttempts = 5, sleepTime = 1): counter = 0 result = stbt.is_screen_black() while result.black == False and counter <= maxAttempts: time.sleep(sleepTime) result = stbt.is_screen_black() counter += 1 if counter > maxAttempts: return False return True def volumeUpSwitchDetection(self): try: stbt.wait_for_match("./images/t1/hds_max_volume_belt.png", region = stbt.Region(x=178, y=94, width=118, height=16)) except stbt.MatchTimeout: return False return True def volumeDownSwitchDetection(self): try: stbt.wait_for_match("./hds_part_volume_belt.png", region = stbt.Region(x=178, y=94, width=64, height=16)) except stbt.MatchTimeout: return False else if stbt.match("./images/t1/hds_max_volume_belt.png", region = stbt.Region(x=178, y=94, width=118, height=16)): return False return True def lodeConfiguration(self, path): domeTree = minidom.parse(path) parameters = domeTree.firstChild # <parameters> paramChilds = parameters.childNodes soft = paramChilds[1] # <soft> softChilds = soft.getElementsByTagName("version") self.currentUpdateVersions.append(int(soft.childNodes[1].firstChild.data)) # <version> self.currentUpdateVersions.append(int(soft.childNodes[3].firstChild.data)) # <version> testChannels = paramChilds[7] # <test_channels> channels = testChannels.childNodes self.mainTestChannels.append(int(testChannels.childNodes[1].firstChild.data)) # <channel> self.mainTestChannels.append(int(testChannels.childNodes[3].firstChild.data)) # <channel> self.mainTestChannels.append(int(testChannels.childNodes[5].firstChild.data)) # <channel> self.mainTestChannels.append(int(testChannels.childNodes[7].firstChild.data)) # <channel> self.alternativeTestChannels.append(int(testChannels.childNodes[9].firstChild.data)) # <channel> self.alternativeTestChannels.append(int(testChannels.childNodes[11].firstChild.data)) # <channel> self.alternativeTestChannels.append(int(testChannels.childNodes[13].firstChild.data)) # <channel> self.alternativeTestChannels.append(int(testChannels.childNodes[15].firstChild.data)) # <channel> self.mainTerrestrialTestChannel = testChannels.childNodes[17].firstChild.data # <channel> self.alternativeTerrestrialTestChannel = testChannels.childNodes[19].firstChild.data # <channel>
def checkers_via_gamut(): """Change input video to "gamut" patterns, then "checkers" pattern""" wait_for_match("videotestsrc-redblue.png") press("gamut") wait_for_match("videotestsrc-gamut.png") press("checkers-8")
def sprawdzWiadomosci(): result = stbt.wait_for_match("images/t1/no_message_image.png") if result.match == False: return -1 return 0
def test_that_stb_tester_logo_is_shown(): stbt.press('KEY_CHANNELUP') assert stbt.wait_for_match('stb-tester-logo.png')
def checkers_via_gamut(): """Change input video to "gamut" patterns, then "checkers" pattern""" wait_for_match("videotestsrc-redblue.png", consecutive_matches=24) press("15") wait_for_match("videotestsrc-gamut.png", consecutive_matches=24) press("10")
def sprawdzRachunki(): result = stbt.wait_for_match("images/t1/no_bill_image.png") if result.match == False: return -1 return 0
def test_that_custom_key_is_recognised(): press("KEY_CUSTOM") wait_for_match('stb-tester-up.png', timeout_secs=1)
import glob import os import sys import time import stbt for arg in sys.argv[1:]: print "Command-line argument: %s\n" % arg # Fail if this script is run more than once from the same $scratchdir n_runs = len(glob.glob("../????-??-??_??.??.??*")) # includes current run if n_runs == 2: raise stbt.UITestError("Not the system-under-test's fault") elif n_runs > 2: # UITestFailure stbt.wait_for_match("videotestsrc-checkers-8.png", timeout_secs=1) stbt.press("gamut") stbt.wait_for_match("videotestsrc-gamut.png") time.sleep(float(os.getenv("sleep", 0))) stbt.press("smpte") stbt.wait_for_motion()
def wait_for_vstb_startup(): wait_for_match('stb-tester-350px.png', timeout_secs=20)
def verify_channel_tune(): # note: this only check if the info banner was detected, it does not validate the specific channel it was tuned to stbt.wait_for_match('images/info_banner_corner.png') keySend.keyPressAPI(rack, "prev", slot) time.sleep(6)
import glob import os import sys import time import stbt for arg in sys.argv[1:]: print("Command-line argument: %s\n" % arg) # Fail if this script is run more than once from the same $scratchdir n_runs = len(glob.glob("../????-??-??_??.??.??*")) # includes current run if n_runs == 2: raise stbt.UITestError("Not the system-under-test's fault") elif n_runs > 2: # UITestFailure stbt.wait_for_match("videotestsrc-checkers-8.png", timeout_secs=1) stbt.press("gamut") stbt.wait_for_match("videotestsrc-gamut.png") time.sleep(float(os.getenv("sleep", 0))) stbt.press("smpte") stbt.wait_for_motion()
def sprawdzWiadomosci(): result = stbt.wait_for_match("images/t1/no_message_image.png") if result.match == False: self.testsResults["messages"] = False else: self.testsResults["messages"] = True
def validate(video, driver, validate_match=True): import stbt driver.show(video) colours = STANDARD_COLOURS[video] pristine = svg_to_array(generate_letters_svg(*colours)) # Attempt to wait until correct video is showing. try: # environment variable controls the timeout here as with the # fake-video-source with the parallel test runner 10s can not be enough timeout = int(os.environ.get('STBT_TEST_VALIDATION_WAIT_TIMEOUT', 10)) stbt.wait_for_match(pristine[80 * 3:80 * 6, 80 * 6:80 * 10], timeout_secs=timeout) except stbt.MatchTimeout: pass res = [] for square, char in zip(SQUARES, GLYPHS): pos = square_to_pos(square) template = pristine[pos.y:pos.y + 80, pos.x:pos.x + 80] result = (stbt.detect_match( template, match_parameters=stbt.MatchParameters(match_method="ccoeff-normed")) .next()) sys.stdout.write( "%s%s" % ([FAIL, WARNING, OKGREEN][rate(square, result)], char)) if square.x == 15: sys.stdout.write('\n') sys.stdout.flush() res.append((square, char, result)) sys.stdout.write(ENDC) sys.stdout.write('\n\n') for square, char, result in res: expected = square_to_pos(square) off = Coord(result.position[0] - expected.x, result.position[1] - expected.y) sys.stdout.write( "%s%s" % ([FAIL, WARNING, OKGREEN][rate(square, result)], off_to_arrow(off))) if square.x == 15: sys.stdout.write('\n') sys.stdout.write(ENDC) if validate_match: sys.stdout.write('\n\n') for square, char, result in res: if result.match: rating = 2 else: rating = 1 if result.first_pass_result > 0.9 else 0 quality = "0123456789"[int(result.first_pass_result * 10)] sys.stdout.write( "%s%s" % ([FAIL, WARNING, OKGREEN][rating], quality)) if square.x == 15: sys.stdout.write('\n') sys.stdout.write(ENDC) is_bad = 0 for square, char, result in res: good = rate(square, result) == 2 if validate_match: good = good and result.match if not good: if is_bad == 0: is_bad = 1 sys.stdout.write('\nChar\tPos\tOffset\tDist\tMatch\n' + '-' * 40 + '\n') expected = square_to_pos(square) off = Coord(result.position[0] - expected.x, result.position[1] - expected.y) sys.stdout.write('%s%s\t(%i, %i)\t(%i, %i)\t%02f\t%s\n' % ([FAIL, WARNING, OKGREEN][rate(square, result)], char, square.x, square.y, off.x, off.y, distance(expected, result.position), "MATCH" if result.match else "NO MATCH")) sys.stdout.write(ENDC) sys.stdout.flush() return is_bad
def sprawdzRachunki(self): result = stbt.wait_for_match("images/t1/no_bill_image.png") if result.match == False: self.testsResults["bills"] = False else: self.testsResults["bills"] = True