def goto_fullscreen_tv():
    """This function moves to fullscreen TV. It does not check for video"""

    stbt.draw_text('Action                           : Go to fullscreen TV')

    if not LinearTV().fullscreen:
        assert False, stbt.draw_text('The STB has not reached fullscreen TV')
    def check_motion(self):
        """
         Detects if there is any motion on full screen
         Asserts if blackscreen is still seen after <timeout>
         :return:
        """
        stbt.draw_text(
            'Action                           : Check for motion on fullscreen TV'
        )

        for m in stbt.detect_motion(timeout_secs=float(
                profile['MOTION_IMAGE_TIMEOUT']),
                                    mask=tests.core.bitmap.get_bitmap(
                                        self, "VideoMovementMaskCropped.png"),
                                    region=stbt.Region(x=127,
                                                       y=71,
                                                       width=1024,
                                                       height=576)):
            if m.motion:
                stbt.draw_text(
                    'Action                          : Fullscreen TV motion detected'
                )
                break

        assert False, stbt.draw_text(
            'Action                          : Motion TIMEOUT reached, %s seconds',
            timeout=profile["MOTION_IMAGE_TIMEOUT"])
def check_for_video():
    """This function will check for motion on fullscreen TV"""

    stbt.draw_text('Action                           : Check for motion on fullscreen TV')

    if not LinearTV().check_motion:
        assert False, stbt.draw_text('Action                          : Motion not detected in %s seconds',
                                     timeout=profile["MOTION_IMAGE_TIMEOUT"])
        def get_banner():
            """Wait unti banner is visible
             :return: banner object
            """

            b = ChannelBanner()
            if b.is_visible:
                stbt.draw_text('Channel banner                  : Visible - OK')
                return b
Exemple #5
0
def wait(duration=2, unit='seconds'):
    """Sleep for a duration

    :param duration: Integer/float value
    :param unit: sleep unit
   """
    stbt.draw_text('Action                           : Wait for %s %s',
                   duration, unit)
    time.sleep(durationToSeconds(duration, unit))
def tune_to_channel(channel_number):
    """This function tunes to channel number (channel_number)"""

    stbt.draw_text('Tune to channel                  : Channel %s', channel_number)

    for digit in str(channel_number):
        stbt.press('KEY_' + digit)
        wait(0.5)

    stbt.wait_until(lambda: ChannelBanner().is_visible, timeout_secs=5)
def get_banner_channel_title():
    """This function returns the channel title on the channel banner"""

    stbt.draw_text('Action                           : Get the banner channel title')

    channel_title = ChannelBanner().program_title

    assert (channel_title is None), stbt.draw_text("Unable to capture the channel title")
    stbt.draw_text('Channel title                    :  {}'.format(channel_title))

    return channel_title
def get_banner_channel_timings():
    """This function will check for the event timings"""

    stbt.draw_text('Action                           : Get the event timings')

    event_timings = ChannelBanner().program_timing

    assert (event_timings is None), stbt.draw_text("Unable to capture event time details")
    stbt.draw_text('Progress Bar                     :  {}'.format(event_timings))

    return event_timings
def get_banner_event_progress():
    """This function will check for the event progress"""

    stbt.draw_text('Action                           : Get the event progress')

    event_progress = ChannelBanner().progress_bar_progress

    assert (event_progress is None), stbt.draw_text("Unable to capture progress bar details")
    stbt.draw_text('Progress Bar                     :  {}'.format(event_progress))

    return event_progress
def get_banner_channel_number():
    """This function returns the channel number on the channel banner"""

    stbt.draw_text('Action                           : Get the banner channel number')

    chan_num = int(ChannelBanner().channel_number)

    assert (chan_num is None), stbt.draw_text("Unable to capture the channel number")
    stbt.draw_text('Channel number                   :  {}'.format(chan_num))

    return chan_num
    def check_black_screen(self):
        """
         Checks for a black screen.
         Asserts if blackscreen is still seen after <timeout>
        """
        stbt.draw_text(
            'Action                           : Wait until black screen is dismissed'
        )

        if not stbt.wait_until(
                lambda: stbt.is_screen_black(mask=tests.core.bitmap.get_bitmap(
                    self, "BlackScreenMaskCropped.png")),
                timeout_secs=float(profile["MOTION_IMAGE_TIMEOUT"])):
            assert True, stbt.draw_text(
                'Black Screen                    : Visible after timeout %s seconds',
                timeout=float(profile["MOTION_IMAGE_TIMEOUT"]))
def wait_until_channel_banner_dismissed():
    """This function will wait until the channel banneris dismissed.
         Assert if the channel banner is still visible after the <CHANNEL_BANNER_TIMEOUT> timeout value.
    """

    assert stbt.wait_until(lambda: not ChannelBanner().is_visible,
                           timeout=profile["CHANNEL_BANNER_TIMEOUT"]), stbt.draw_text(
        'Channel banner                  : Visible - NOK')
Exemple #13
0
def get_randomized_item(target_list):
    """Select a random item from the <target list>.

     :param target_list: list of items
     :return: single item from target list
    """
    stbt.draw_text(
        'Action                           : Get a random item from the target list'
    )

    items = []
    for x in target_list.values():
        items.append(x)

    variables = int(random.randint(0, len(items) - 1))
    var = (items[variables])
    stbt.draw_text('Action                           : Return value %s', var)

    return var
def test_displayBannerLiveTV():
    """
     Display the banner in live tv and check that the correct channel number and channel title is displayed
     Asserts if either the channel number or the channel title is not as expected
    """

    stbt.draw_text("Sanity - Display Banner in LiveTV test starts here..")

    goto_fullscreen_tv()
    tune_clear_sd_service()
    # wait_till_black_screen_dismissed()
    check_for_video()
    bring_up_channel_banner()
    verify_channel_number(get_banner_channel_number())
    verify_channel_title(get_banner_channel_title())
    get_banner_channel_timings()
    get_banner_event_progress()
    wait_until_channel_banner_dismissed()
    wait(3)

    stbt.draw_text("Sanity - Display Banner in LiveTV test is COMPLETED!")
def bring_up_channel_banner():
    """Bring up the channel banner"""

    stbt.draw_text('Action                           : Bring up Channel Banner')
    if stbt.wait_until(lambda: not ChannelBanner().is_visible):
        stbt.press('KEY_SELECT')

    class GetBanner:
        count = 0

        @staticmethod
        def get_banner():
            """Wait unti banner is visible
             :return: banner object
            """

            b = ChannelBanner()
            if b.is_visible:
                stbt.draw_text('Channel banner                  : Visible - OK')
                return b

    return stbt.wait_until(GetBanner().get_banner, predicate=lambda x: x is not None)
def verify_channel_title(channel_title):
    """This function will verify if the channel title is as expected (channel_title)"""

    curr_title = get_banner_channel_title
    assert curr_title == channel_title, stbt.draw_text('Expected channel title %s, Actual channel title %s',
                                                       channel_title, curr_title)
def verify_channel_number(chan_num):
    """This function will verify if the stb is tuned to expected channel number (channel_number)"""

    curr_channel = get_banner_channel_number
    assert curr_channel == chan_num, stbt.draw_text('Expected channel number %s, Actual channel number %s',
                                                    chan_num, curr_channel)