Exemplo n.º 1
0
    def verify_video_resolutions(self):
        """Verify available video resolutions.

        Video resolution should be 360p, 480p, 720p and 1080p.

        """
        logging.info('Verifying the video resolutions.')
        video_qualities = self._tab.EvaluateJavaScript(
            'player.getAvailableQualityLevels()')
        logging.info('Available video resolutions: %s', video_qualities)
        if not video_qualities:
            raise error.TestError(
                'Player failed to return available video qualities.')
        video_qualities.reverse()

        running_quality = self.get_playback_quality()
        index = video_qualities.index(running_quality)
        supporting_qualities = video_qualities[index:]
        logging.info("new video quality %s ", supporting_qualities)

        width, height = graphics_utils.get_internal_resolution()
        logging.info('checking resolution: %d width  %d height', width, height)
        for quality in supporting_qualities:
            logging.info('Playing video in %s quality.', quality)
            self.set_playback_quality(quality)
            self.wait_for_player_state(PLAYER_PLAYING_STATE)
            self.wait_for_expected_resolution(quality)
            current_quality = self.get_playback_quality()

            if current_quality != quality:
                raise error.TestError(
                    'Expected video quality: %s. Current video quality: %s' %
                    (quality, current_quality))

            time.sleep(1)
Exemplo n.º 2
0
    def verify_video_resolutions(self):
        """Verify available video resolutions.

        Video resolution should be 360p, 480p, 720p and 1080p.

        """
        logging.info('Verifying the video resolutions.')
        video_qualities = self._tab.EvaluateJavaScript(
            'player.getAvailableQualityLevels()')
        logging.info('Available video resolutions: %s', video_qualities)
        if not video_qualities:
            raise error.TestError(
                'Player failed to return available video qualities.')
        video_qualities.reverse()
        width, height = graphics_utils.get_internal_resolution()
        logging.info('checking resolution: %d width  %d height', width, height)
        for quality in video_qualities:
            logging.info('Playing video in %s quality.', quality)
            self.set_playback_quality(quality)
            self.wait_for_player_state(PLAYER_PLAYING_STATE)
            self.wait_for_expected_resolution(quality)
            current_quality = self.get_playback_quality()
            if (quality not in ['auto', 'tiny', 'small']
                    and quality != current_quality):
                if current_quality in ['hd720', 'hd1080'] and width == 2560:
                    logging.info('HD devices starts playing YouTube video in '
                                 'HD so skipping 480p test.')
                    continue
                raise error.TestError(
                    'Expected video quality: %s. Current video quality: %s' %
                    (quality, current_quality))
            time.sleep(1)
        # setting the video resolution to 480p for rest of the tests.
        self.set_playback_quality('large')
Exemplo n.º 3
0
    def capture_screenshot(self, filepath):
        """
        Take a screenshot of the App Launcher page.

        Implements the abstract method capture_screenshot

        @param filepath: string, Complete path to save the screenshot to.

        """

        # Login and load the default apps
        with chrome.Chrome(disable_default_apps=False):

            # Setup the keyboard file's paths
            property_file = os.path.join(self.bindir, self._KEYBOARD_PROP)
            playback_file = os.path.join(self.bindir, self._KEYBOARD_PLAYBACK)

            # Setup and playback the keyboard commands to open the launcher
            with input_playback.InputPlayback() as player:
                player.emulate('keyboard', property_file)
                player.find_connected_inputs()
                player.blocking_playback(playback_file, 'keyboard')

            # Take a screenshot and crop to just the launcher
            w, h = graphics_utils.get_internal_resolution()
            upper_x = (w - self.launcher_width) / 2
            upper_y = (h - self.launcher_height) / 2
            box = (upper_x, upper_y, upper_x + self.launcher_width,
                   upper_y + self.launcher_height)

            graphics_utils.take_screenshot_crop(filepath, box)
    def verify_video_resolutions(self, power_measurement=False):
        """Verify available video resolutions.

        Video resolution should be 360p, 480p, 720p and 1080p.

        """
        logging.info('Verifying the video resolutions.')
        video_qualities = self._tab.EvaluateJavaScript(
            'player.getAvailableQualityLevels()')
        logging.info('Available video resolutions: %s', video_qualities)
        if not video_qualities:
            raise error.TestError(
                'Player failed to return available video qualities.')
        video_qualities.reverse()

        running_quality = self.get_playback_quality()
        index = video_qualities.index(running_quality)
        supporting_qualities = video_qualities[index:]
        logging.info("new video quality %s ", supporting_qualities)

        width, height = graphics_utils.get_internal_resolution()
        logging.info('checking resolution: %d width  %d height', width, height)
        for quality in supporting_qualities:
            logging.info('Playing video in %s quality.', quality)

            if quality == "hd1080":
                self._tab.ExecuteJavaScript('player.setSize(1920, 1080)')
            if quality == "hd720":
                self._tab.ExecuteJavaScript('player.setSize(1280, 720)')
            if quality == "large":
                self._tab.ExecuteJavaScript('player.setSize(853, 480)')
            if quality == "medium":
                self._tab.ExecuteJavaScript('player.setSize(640, 360)')
            if quality == "small":
                self._tab.ExecuteJavaScript('player.setSize(320, 240)')

            self.set_playback_quality(quality)
            self.wait_for_player_state(PLAYER_PLAYING_STATE)
            self.wait_for_expected_resolution(quality)
            current_quality = self.get_playback_quality()

            if current_quality != quality:
                raise error.TestError(
                    'Expected video quality: %s. Current video quality: %s'
                    % (quality, current_quality))

            if power_measurement and self.power_logger:
                # Seeking to the beginning and ensure the player is playing.
                self._tab.ExecuteJavaScript('player.seekTo(0, true)')
                self._tab.ExecuteJavaScript('player.playVideo()')
                self.wait_for_player_state(PLAYER_PLAYING_STATE)
                with self.power_logger.checkblock('youtube-' + quality):
                    time.sleep(10)
            else:
                time.sleep(1)
    def test_something_on_screen(self):
        """Check if something is drawn on screen: i.e. not a black screen.

        @raises TestFail if we cannot determine there was something on screen.
        """
        def can_take_screenshot():
            """Check that taking a screenshot can succeed.

            There are cases when trying to take a screenshot on the device
            fails. e.g. the display has gone to sleep, we have logged out and
            the UI has not come back up yet etc.
            """
            try:
                graphics_utils.take_screenshot(self.resultsdir,
                                               'temp screenshot', '.png')
                return True
            except:
                return False

        utils.poll_for_condition(
            can_take_screenshot,
            sleep_interval=1,
            desc='Failed to take a screenshot. There may be an issue with this '
            'ChromeOS image.')

        w, h = graphics_utils.get_internal_resolution()
        megapixels = (w * h) / 1000000
        filesize_threshold = 25 * megapixels
        screenshot1 = graphics_utils.take_screenshot(self.resultsdir,
                                                     'oobe or signin', '.png')

        with chrome.Chrome() as cr:
            tab = cr.browser.tabs[0]
            tab.Navigate('chrome://settings')
            tab.WaitForDocumentReadyStateToBeComplete()

            screenshot2 = graphics_utils.take_screenshot(
                self.resultsdir, 'settings page', '.png')

        for screenshot in [screenshot1, screenshot2]:
            file_size_kb = os.path.getsize(screenshot) / 1000

            # Use compressed file size to tell if anything is on screen.
            if file_size_kb > filesize_threshold:
                return

        raise error.TestFail(
            'Screenshot filesize is very small. This indicates that '
            'there is nothing on screen. This ChromeOS image could be '
            'unusable. Check the screenshot in the results folder.')
Exemplo n.º 6
0
    def run_once(self):
        # The default launcher dimensions
        self.launcher_width = 768
        self.launcher_height = 570

        w, h = graphics_utils.get_internal_resolution()
        logging.info('DUT screen width: %d' % w)
        logging.info('DUT screen height: %d' % h)

        # If we have a high DPI screen, launcher size is doubled
        if self.launcher_width * 2 < w:
            self.launcher_width *= 2
            self.launcher_height *= 2
            self.tagged_testname += '.large'

        self.run_screenshot_comparison_test()
    def __init__(self):
        """Prepare an emulated stylus device based on the internal display."""
        self.dirname = os.path.dirname(__file__)
        width, height = graphics_utils.get_internal_resolution()
        logging.info('internal display W = %d H = %d ', width, height)
        # Skip the test if there is no internal display
        if width == -1:
            raise error.TestNAError('No internal display')

        # Enlarge resolution of the emulated stylus.
        self.width = width * 10
        self.height = height * 10
        stylus_template = os.path.join(self.dirname, _STYLUS_TEMPLATE)
        self.replace_with_prefix(stylus_template, _STYLUS_PROPERTY,
                                 _PREFIX_RESOLUTION, self.width, self.height)
        # Create an emulated stylus device.
        self.stylus = input_playback.InputPlayback()
        self.stylus.emulate(input_type=_STYLUS_DEVICE,
                            property_file=_STYLUS_PROPERTY)
        self.stylus.find_connected_inputs()