• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5
6from autotest_lib.client.bin import test, utils
7from autotest_lib.client.common_lib import error
8from autotest_lib.client.common_lib.cros import chrome
9from autotest_lib.client.cros import httpd
10from autotest_lib.client.cros.video import youtube_helper
11
12
13FLASH_PROCESS_NAME = 'chrome/chrome --type=ppapi'
14PLAYER_PLAYING_STATE = 'Playing'
15
16
17class video_YouTubeHTML5(test.test):
18    """This test verify the YouTube HTML5 video.
19
20    - verify the video playback.
21    - verify the available video resolutions.
22    - verify the player functionalities.
23
24    """
25    version = 2
26
27
28    def initialize(self):
29        self._testServer = httpd.HTTPListener(8000, docroot=self.bindir)
30        self._testServer.run()
31
32
33    def cleanup(self):
34        if self._testServer:
35            self._testServer.stop()
36
37
38    def run_youtube_tests(self, browser):
39        """Run YouTube HTML5 sanity tests.
40
41        @param browser: The Browser object to run the test with.
42
43        """
44        tab = browser.tabs[0]
45        tab.Navigate('http://localhost:8000/youtube5.html')
46        yh = youtube_helper.YouTubeHelper(tab)
47        # Waiting for test video to load.
48        yh.wait_for_player_state(PLAYER_PLAYING_STATE)
49
50        # Set tiny resolution to prevent inadvertently caching a higher
51        # bandwidth stream which taints resolution verification.
52        yh.set_playback_quality('tiny')
53        yh.set_video_duration()
54
55        # Verify that YouTube is running in html5 mode.
56        prc = utils.get_process_list('chrome', '--type=ppapi( |$)')
57        if prc:
58            raise error.TestFail('Running YouTube in Flash mode. '
59                                 'Process list: %s.' % prc)
60
61        tab.ExecuteJavaScript('player.mute()')
62        yh.verify_video_playback()
63        yh.verify_video_resolutions()
64        yh.verify_player_states()
65
66
67    def run_once(self):
68        with chrome.Chrome() as cr:
69            self.run_youtube_tests(cr.browser)
70