def test_DVR_on_reboot(): count = 0 while True: if stbt.is_screen_black(): break count += 1 sleep(3) assert count < 10, \ "STB did not reboot within 30 seconds with osdiag RebootNow" count = 0 while True: stbt.press('KEY_POWER') sleep(5) if stbt.match('images/menu/stick_around.png') or stbt.match( 'images/menu/reboot_logo.png'): break sleep(5) count += 1 assert count < 18, \ "Stick Around screen is not shown after reboot within 3 minutes" stbt.wait_for_motion(timeout_secs=300) stbt.press('KEY_RECORD') assert stbt.wait_until(lambda: stbt.match("images/dvr/edit_ep_rec.png") or stbt.match("images/dvr/ch_bar_rec.png")), \ "RECORD press on live TV did not set recording, or prompt for edit recording" mydvr_launch() count = 0 while True: stbt.press('KEY_ENTER') if stbt.match('images/cta/watch.png'): break count += 1 assert count < 16, \ "Could not find recording to play in DVR page" stbt.press('KEY_ENTER') assert stbt.wait_for_motion(timeout_secs=20)
def wait_for_motion_detect(timeout_secs, mask): try: wait_for_motion(mask=mask, timeout_secs=timeout_secs) passMessageWith_Screenshots("Motion detected.") except Exception, e: print "Fail/ Motion not detected after %i seconds. Exception/ %s " % timeout_secs, e.args raise e
def test_tuning_channels_20plus_times(): for _ in " " * 3: stbt.press('KEY_EXIT') if not stbt.wait_until(lambda: stbt.match("images/env/do_you_want_to_upgrade.png")) and not stbt.wait_until( lambda: stbt.match("images/env/channel_unavailable.png")): assert stbt.wait_until(lambda: stbt.wait_for_motion()), \ "Live TV not reached at test start" channels = [21, 24, 27, 29] t = 0 for _ in range(5): for ch in channels: t += 1 for x in list(str(ch)): stbt.press("KEY_" + x) sleep(0.6) sleep(4) if stbt.match('images/dvr/continue_to_miniguide.png') and t == 1: for _ in " " * 2: stbt.press('KEY_RIGHT') for _ in " " * 2: stbt.press('KEY_ENTER') stbt.press('KEY_RIGHT') stbt.press('KEY_ENTER') print (t) if not stbt.wait_until(lambda: stbt.match("images/env/do_you_want_to_upgrade.png")) and not stbt.wait_until( lambda: stbt.match("images/env/channel_unavailable.png")): assert stbt.wait_until(lambda: stbt.wait_for_motion()), \ "New channel " + str(ch) + " not reached on channel change number " + t
def test_wait_for_motion_half_motion_str_3of4(): try: with MockTime().patch(): stbt.wait_for_motion(consecutive_frames='3/4', frames=fake_frames()) assert False, "wait_for_motion succeeded unexpectedly" except stbt.MotionTimeout: pass
def testFuncjonalny(self): scanedSN #zeskanowany SN dekodera self.sprawdzSN(scannedSN) stbt.press("KEY_MENU", self.timeBeforePress) try: stbt.wait_for_motion(90) except stbt.MotionTimeout: pass self.sprawdzCzytnikKart() stbt.press("KEY_REC", self.timeBeforePress) self.testKanalow() self.sprawdzUSB() self.sprawdzTimeshifting() stbt.press("KEY_MENU", self.timeBeforePress) stbt.press("KEY_LEFT", self.timeBeforePress) stbt.press("KEY_LEFT", self.timeBeforePress) stbt.press("KEY_OK", self.timeBeforePress) self.sprawdzRachunki() stbt.press("KEY_OK", self.timeBeforePress) stbt.press("KEY_MENU", self.timeBeforePress) self.myPressUntilMatchText("WIADOMOSCI", "KEY_LEFT", stbt.Region(x=550, y=605, width=180, height=41), 10) stbt.press("KEY_OK", self.timeBeforePress) self.sprawdzWiadomosci() stbt.press("KEY_EXIT", self.timeBeforePress) stbt.press("KEY_STOP", self.timeBeforePress) stbt.press("KEY_OK", self.timeBeforePress) stbt.press("KEY_RIGHT", self.timeBeforePress) stbt.press("KEY_RIGHT", self.timeBeforePress) stbt.press("KEY_OK", self.timeBeforePress) self.sprawdzHDD() self.wejdzWUstawienia() stbt.press("KEY_OK", self.timeBeforePress) stbt.press("KEY_DOWN", self.timeBeforePress) stbt.press("KEY_OK", self.timeBeforePress) self.sprawdzMaxIndex() stbt.press("KEY_EXIT",self.timeBeforePress) self.wejdzWUstawienia() stbt.press("KEY_DOWN", self.timeBeforePress) stbt.press("KEY_OK", self.timeBeforePress) stbt.press("KEY_4", self.timeBeforePress) stbt.press("KEY_3", self.timeBeforePress) self.sprawdzSiec() stbt.press("KEY_EXIT", self.timeBeforePress) self.wejdzWUstawienia() stbt.press("KEY_DOWN", self.timeBeforePress) stbt.press("KEY_7", self.timeBeforePress) stbt.press("KEY_2", self.timeBeforePress) self.sprawdzWersjeOprogramowania() stbt.press("KEY_A", self.timeBeforePress) stbt.press("KEY_1", self.timeBeforePress) stbt.press("KEY_OK", self.timeBeforePress) self.sprawdzSileIJakosSygnalu() stbt.press("KEY_EXIT", self.timeBeforePress) self.sprawdzWyswietlacz() if self.model = "HDS7241/91": self.sprawdzTVNaziemna()
def check_video_is_paused(scope={}): sleep(10) assert stbt.wait_until( lambda: stbt.match("images/recordingsPage/pauseImageDisplayed.png")) try: stbt.wait_for_motion() print "The video has not been paused" assert False except stbt.MotionTimeout: print "The video has been paused"
def test_spectrum_ui(): stbt.press('KEY_RECORD') sleep(3) while True: if stbt.wait_until(lambda: stbt.match("images/env/ip_video_top_option.png")): break else: stbt.press('KEY_UP') sleep(3) stbt.press('KEY_ENTER') sleep(10) stbt.press('KEY_1') stbt.press('KEY_2') sleep(2) assert stbt.wait_until(lambda: stbt.wait_for_motion()), \ "Video not displayed within time constrant on channel 12" stbt.press('KEY_1') stbt.press('KEY_7') sleep(2) assert stbt.wait_until(lambda: stbt.wait_for_motion()), \ "Video not displayed within time constrant on channel 17" count =0 while True: sleep(1) count +=1 if stbt.wait_until(lambda: stbt.wait_for_motion()) or count == 3: break assert count != 3 stbt.press('KEY_MENU') assert stbt.wait_until(lambda: stbt.match("images/IP_Video_Menu.png")), \ "Menu not launched" stbt.press('KEY_DOWN') assert stbt.wait_until(lambda: stbt.match("images/Lib_Highlight.png")), \ "Scrolling down on the main menu failed" stbt.press('KEY_DOWN') assert stbt.wait_until(lambda: stbt.match("images/TV_highlight.png")), \ "Scrolling down on the main menu failed" stbt.press('KEY_UP') assert stbt.wait_until(lambda: stbt.match("images/Lib_Highlight.png")), \ "Scrolling up on the main menu failed" stbt.press('KEY_DOWN') stbt.press('KEY_ENTER') assert stbt.wait_until(lambda: stbt.match("images/IP_Video_TV_Shows.png")), \ "TV Shows not launched" stbt.press('KEY_UP') stbt.press('KEY_RIGHT') assert stbt.wait_until(lambda: stbt.match("images/hbo_highlighted.png")), \ "Scrolling right inside of TV Shows failed" stbt.press('KEY_LEFT') assert stbt.wait_until(lambda: stbt.match("images/all_sub_highlighted.png")), \ "Scrolling left inside of TV Shows failed"
def test_play_VOD_50plus_times(): for _ in " " * 3: stbt.press('KEY_EXIT') VideoStore.open() # Find an asset that hasn't been rented yet. for _ in range(20): # Try 20 assets # Wait for asset title to stabilise -- it loads slightly after the # Video Store logo appears. title = wait_until(lambda: VideoStore().selection, stable_secs=1) print "Checking asset to see if we can rent it: %s" % title stbt.press("KEY_ENTER") asset = wait_until(Asset, timeout_secs=20) if asset.rentable: print "Asset is rentable; trying to rent it" asset.rent() try: stbt.wait_for_motion(timeout_secs=30, mask="images/vod/mask-out-playbar.png") print "Successfully rented: %s" % title break except stbt.MotionTimeout: if UnableToPlayDialog(): UnableToPlayDialog().dismiss() else: assert False, "Didn't detect video playback *nor* " \ "the 'Unable to Play' dialog." stbt.press("KEY_LAST") assert wait_until(VideoStore), \ "Didn't detect VideoStore main carousel after pressing back" stbt.press("KEY_RIGHT") assert wait_until( # pylint:disable=cell-var-from-loop lambda: VideoStore().selection != title), \ "Carousel selection didn't change after pressing right" else: assert False, "Didn't find rentable playable asset after 20 attempts" for _ in range(50): stbt.press('KEY_EXIT') MyLibrary.open().navigate_to("Expiring Soon", title) # MyLibrary.open().navigate_to("Expiring Soon") stbt.press('KEY_ENTER') assert wait_until(lambda: Asset().title == title) assert Asset().selected_button.text == "RESTART" stbt.press('KEY_ENTER') assert stbt.wait_for_motion(timeout_sec=20)
def health_check(validate=True, scope=""): stbt.press("KEY_TV") dismissPopupIfPresent() stbt.press("KEY_INFO") if stbt.wait_until(lambda: infobanner.Infobanner()): print "Box is Up and responds to key presses" try: stbt.wait_for_motion() print "Video playback is present in Live TV" return {"status": True} except stbt.MotionTimeout: print "up key pressed" stbt.press("KEY_CHANNELUP") try: stbt.wait_for_motion() print "Video playback is present in Live TV" return {"status": True} except stbt.MotionTimeout: assert False, "Could not detect Video playback in Live TV" else: # TO DO else: <do one more IR event check> # if stbt.is_screen_black(): stbt.press("KEY_MENU") if stbt.wait_until(lambda: not stbt.is_screen_black()): if stbt.wait_until(lambda: mainhub_page.MainHubPage()): sleep(1) print "Box is Up and responds to key presses" stbt.press("KEY_OK") if stbt.wait_until(lambda: not mainhub_page.MainHubPage()): print "Dismissed Main Hub and tuned to live TV" else: assert False, "Failed to tune to Live TV by OK press on Televisie from Main Hub" try: stbt.wait_for_motion() print "Video playback is present in Live TV" return {"status": True} except stbt.MotionTimeout: assert False, "Could not detect Video playback in Live TV" else: assert False, "Main_hub did not load. Health check failed" else: stbt.press("KEY_POWER") if stbt.wait_until(lambda: not stbt.is_screen_black(), timeout_secs=30): if stbt.wait_until(lambda: mainhub_page.MainHubPage()): sleep(1) print "Box is Up and responds to key presses" stbt.press("KEY_OK") if stbt.wait_until(lambda: not mainhub_page.MainHubPage()): print "Dismissed Main Hub and tuned to live TV" else: assert False, "Failed to tune to Live TV by OK press on Televisie from Main Hub" try: stbt.wait_for_motion() print "Video playback is present in Live TV" return {"status": True} except stbt.MotionTimeout: assert False, "Could not detect Video playback in Live TV" else: assert False, "TV frozen with black screen"
def test_DVR_playback_50plus_times_no_TTS(): # Turn off TTS for _ in " " * 3: stbt.press('KEY_EXIT') count = 0 # GNarration_setting("Off") for _ in range(51): count = 0 for _ in " " * 3: stbt.press('KEY_EXIT') sleep(3) stbt.press('KEY_MYDVR') sleep(3) if stbt.match('images/dvr/cancel_a_recording.png'): for _ in " " * 2: stbt.press('KEY_RIGHT') for _ in " " * 2: stbt.press('KEY_ENTER') stbt.press('KEY_RIGHT') stbt.press('KEY_ENTER') assert stbt.wait_until(lambda: stbt.match("images/dvr/my_dvr.png")), \ "MyDVR not launched" while True: stbt.press('KEY_ENTER') sleep(1) if stbt.match('images/cta/watch.png') or stbt.match('images/cta/resume.png'): break count += 1 assert count < 20, \ "Could not find recording to play in DVR page" sleep(2) stbt.press('KEY_ENTER') sleep(3) assert stbt.wait_for_motion(timeout_secs=20)
def test_wait_for_motion_half_motion_str_4of10(): with MockTime().patch(): # Time is not affected by consecutive_frames parameter res = stbt.wait_for_motion(consecutive_frames='4/10', timeout_secs=20, frames=fake_frames()) assert res.time == 1466084606.
def check_motion(self, motion_time_out_secs): if stbt.wait_for_motion(motion_time_out_secs): self.LogResults.info("Motion detected") return True else: self.LogResults.warning("Motion is not detected") return False
def test_20_trickplay_buttons_on_TSB_iguide(): if stbt.wait_until(lambda: stbt.match("images/dvr/i_pause.png")): stbt.press('KEY_PLAY') count = 0 while True: if not stbt.wait_until(lambda: stbt.wait_for_motion(timeout_secs=10)): stbt.press('KEY_CHANNELUP') else: break count += 1 assert count < 4, \ "No motion found on Live after 4 channel changes" sleep(2) stbt.press('KEY_PAUSE') assert stbt.wait_until(lambda: stbt.match("images/dvr/i_pause.png")), \ "Unable to pause Live" sleep(80) for _ in range(10): stbt.press('KEY_PLAY') assert stbt.wait_until(lambda: stbt.match("images/dvr/i_play.png")), \ "Unable to play Live after pause" stbt.press('KEY_REWIND') assert stbt.wait_until(lambda: stbt.match("images/dvr/i_rewind.png")), \ "Unable to rewind Live" for _ in " " * 2: stbt.press('KEY_FASTFORWARD') assert stbt.wait_until(lambda: stbt.match("images/dvr/i_fastforward.png")), \ "Unable to fastforward Live" stbt.press('KEY_PLAY') assert stbt.wait_until(lambda: stbt.match("images/dvr/i_play.png")), \ "Unable to play Live" stbt.press('KEY_PAUSE') assert stbt.wait_until(lambda: stbt.match("images/dvr/i_pause.png")), \ "Unable to pause Live"
def test_20_trickplay_buttons_on_TSB(): for _ in " " * 3: stbt.press('KEY_EXIT') if stbt.wait_until(lambda: stbt.match("images/dvr/pause.png")): stbt.press('KEY_PLAYPAUSE') count = 0 while True: if not stbt.wait_until(lambda: stbt.wait_for_motion(timeout_secs=10)): stbt.press('KEY_CHANNELUP') else: break count += 1 assert count < 4, \ "No motion found on Live after 4 channel changes" sleep(2) stbt.press('KEY_PLAYPAUSE') assert stbt.wait_until(lambda: stbt.match("images/dvr/pause.png")), \ "Unable to pause Live" sleep(50) for _ in range(5): stbt.press('KEY_PLAYPAUSE') assert stbt.wait_until(lambda: stbt.match("images/dvr/play.png")), \ "Unable to play Live after pause" stbt.press('KEY_LEFT') assert stbt.wait_until(lambda: stbt.match("images/dvr/rewind.png")), \ "Unable to rewind Live" for _ in " " * 2: stbt.press('KEY_RIGHT') assert stbt.wait_until(lambda: stbt.match("images/dvr/fastforward.png")), \ "Unable to fastforward Live" stbt.press('KEY_PLAYPAUSE') assert stbt.wait_until(lambda: stbt.match("images/dvr/play.png")), \ "Unable to play Live" stbt.press('KEY_PLAYPAUSE') assert stbt.wait_until(lambda: stbt.match("images/dvr/pause.png")), \ "Unable to pause Live"
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 check_for_motion(scope={}): dismissPopupIfPresent() if stbt.wait_for_motion(): print "Motion Detected" return {"status": True} else: print "No motion detected" return {"status": False}
def sprawdzHDD(self): stbt.press("KEY_REC", Test.timeBeforePress) time.sleep(120) stbt.press("KEY_STOP", Test.timeBeforePress) stbt.press("KEY_OK", Test.timeBeforePress) stbt.press("KEY_LIST", Test.timeBeforePress) today = stbt.ocr(None, stbt.Region(1055, 45, width=80, height=30), stbt.OcrMode.PAGE_SEGMENTATION_WITHOUT_OSD) recordingDate = ocr(None, stbt.Region(660, 200, width=80, height=30), stbt.OcrMode.PAGE_SEGMENTATION_WITHOUT_OSD) 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(10, 100, width=1200, height=400)) except MotionTimeout: stbt.press("KEY_PLAY", Test.timeBeforePress) stbt.press("KEY_FWD", Test.timeBeforePress) result = stbt.match_text( "x1,5", None, stbt.Region(110, 610, width=160, height=30)) if result: for i in range(3): stbt.press("KEY_REV", Test.timeBeforePress) result = stbt.match_text( "x2,0", None, stbt.Region(110, 610, width=160, height=30)) if result: 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_RED", Test.timeBeforePress) stbt.press("KEY_LEFT", Test.timeBeforePress) stbt.press("KEY_OK", Test.timeBeforePress) else: self.testsResults["hdd"] = False stbt.press("KEY_LIST", Test.timeBeforePress)
def check_pip_window_shown(): motionResult = stbt.wait_for_motion(timeout_secs=10, mask="images/pip_window_mask.png") if motionResult: print "Motion detected in region" return {"status": True} else: print "No Motion Detected" return {"status": False}
def sprawdzTimeshifting(self): stbt.press("KEY_PAUSE", Test.timeBeforePress) try: stbt.wait_for_motion(timeout_sec=3, region=stbt.Region(10, 100, width=1200, height=400)) except MotionTimeout: stbt.press("KEY_PLAY", Test.timeBeforePress) try: stbt.wait_for_motion() except MotionTimeout: self.testsResults["timeshifting"] = False else: self.testsResults["timeshifting"] = True else: self.testsResults["timeshifting"] = False stbt.press("KEY_STOP", Test.timeBeforePress)
def test_random_presses_multiple_session(): for _ in " " * 3: stbt.press('KEY_EXIT') for _ in " " * 10: guide_launch() for _ in " " * 3: stbt.press('KEY_DOWN') for _ in " " * 3: stbt.press('KEY_RIGHT') for _ in " " * 3: stbt.press('KEY_LEFT') menu_launch() stbt.press('KEY_UP') stbt.press('KEY_ENTER') sleep(1) stbt.press('KEY_INFO') sleep(2) stbt.press('KEY_LAST') for _ in " " * 2: stbt.press('KEY_OPTIONS') sleep(1) for _ in " " * 3: stbt.press('KEY_EXIT') count = 0 while True: if not stbt.wait_until(lambda: stbt.wait_for_motion(timeout_secs=10)): stbt.press('KEY_CHANNELUP') else: break count += 1 assert count < 4, \ "No motion found on Live after 4 channel changes" menu_launch() for _ in " " * 5: stbt.press('KEY_UP') for _ in " " * 2: stbt.press('KEY_DOWN') stbt.press('KEY_ENTER') for _ in " " * 5: stbt.press('KEY_DOWN') for _ in " " * 5: stbt.press('KEY_UP') stbt.press('KEY_LEFT') stbt.press('KEY_RIGHT') stbt.press('KEY_LEFT') stbt.press('KEY_RIGHT') stbt.press('KEY_LEFT') stbt.press('KEY_RIGHT') stbt.press('KEY_ENTER') for _ in " " * 3: stbt.press('KEY_EXIT') assert stbt.wait_for_motion(timeout_secs=20)
def play_live_tv(scope={}): """This test presses TV Button and if any popup comes presses OK. It validates live TV by checking for motion""" stbt.press('KEY_TV') # Go to live TV sleep(3) if popup.PopupBox().is_visible: if popup.PopupBox().message in popup_messages: stbt.press('KEY_OK') assert stbt.wait_until(lambda: not popup.PopupBox().is_visible) if stbt.wait_for_motion(): print "Motion Detected" return {"status": True} else: print "No motion detected" return {"status": False}
def test_that_live_tv_is_playing(): stbt.press('KEY_CLOSE') # Close any open menus assert stbt.wait_for_motion()
def test_wait_for_motion_half_motion_int(): with pytest.raises(stbt.MotionTimeout), MockTime().patch(): stbt.wait_for_motion(consecutive_frames=2, frames=fake_frames())
def test_wait_for_motion_half_motion_str_4of10(): with MockTime().patch(): # Time is not affected by consecutive_frames parameter res = stbt.wait_for_motion( consecutive_frames='4/10', timeout_secs=20, frames=fake_frames()) assert res.time == 1466084606.
def test_wait_for_motion_half_motion_str_2of3(): with MockTime().patch(): res = stbt.wait_for_motion( consecutive_frames='2/3', frames=fake_frames()) print res assert res.time == 1466084606.
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 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>
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 test_DVR_after_changing_settings(): for _ in " " * 3: stbt.press('KEY_EXIT') sleep(1) count1 = 1 for _ in " " * 10: count1 += 1 settings_launch() for _ in " " * 3: stbt.press('KEY_DOWN') for _ in " " * 2: stbt.press('KEY_ENTER') sleep(1) for _ in " " * 2: stbt.press('KEY_RIGHT') stbt.press('KEY_ENTER') sleep(2) enter_pin() if count1 % 2 == 0: stbt.press('KEY_UP') stbt.press('KEY_ENTER') for _ in " " * 2: stbt.press('KEY_DOWN') stbt.press('KEY_ENTER') else: stbt.press('KEY_UP') stbt.press('KEY_DOWN') stbt.press('KEY_ENTER') stbt.press('KEY_DOWN') stbt.press('KEY_ENTER') stbt.press('KEY_RIGHT') stbt.press('KEY_ENTER') sleep(2) enter_pin() for _ in " " * 2: stbt.press('KEY_RIGHT') stbt.press('KEY_DOWN') stbt.press('KEY_ENTER') stbt.press('KEY_LEFT') stbt.press('KEY_ENTER') stbt.press('KEY_RIGHT') stbt.press('KEY_ENTER') stbt.press('KEY_RIGHT') stbt.press('KEY_ENTER') sleep(2) enter_pin() stbt.press('KEY_RIGHT') stbt.press('KEY_DOWN') stbt.press('KEY_ENTER') stbt.press('KEY_LEFT') stbt.press('KEY_DOWN') stbt.press('KEY_ENTER') stbt.press('KEY_RIGHT') stbt.press('KEY_ENTER') mydvr_launch() count = 0 while True: stbt.press('KEY_ENTER') sleep(1) if stbt.match('images/cta/watch.png') or stbt.match('images/cta/resume.png'): break count += 1 assert count < 16, \ "Could not find recording to play in DVR page" sleep(2) stbt.press('KEY_ENTER') sleep(3) assert stbt.wait_for_motion(timeout_secs=30)
def test_that_wait_for_motion_detects_a_wipe(): stbt.wait_for_motion(consecutive_frames="10/30", frames=wipe()) stbt.wait_for_motion(frames=gradient_wipe())