Home | History | Annotate | Download | only in video_YouTubeHTML5
      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 
      6 from autotest_lib.client.bin import test, utils
      7 from autotest_lib.client.common_lib import error
      8 from autotest_lib.client.common_lib.cros import chrome
      9 from autotest_lib.client.cros import httpd
     10 from autotest_lib.client.cros.video import youtube_helper
     11 
     12 
     13 FLASH_PROCESS_NAME = 'chrome/chrome --type=ppapi'
     14 PLAYER_PLAYING_STATE = 'Playing'
     15 
     16 
     17 class 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         yh.set_video_duration()
     50 
     51         # Verify that YouTube is running in html5 mode.
     52         prc = utils.get_process_list('chrome', '--type=ppapi( |$)')
     53         if prc:
     54             raise error.TestFail('Running YouTube in Flash mode. '
     55                                  'Process list: %s.' % prc)
     56 
     57         tab.ExecuteJavaScript('player.mute()')
     58         yh.verify_video_playback()
     59         yh.verify_video_resolutions()
     60         yh.verify_player_states()
     61 
     62 
     63     def run_once(self):
     64         with chrome.Chrome() as cr:
     65             self.run_youtube_tests(cr.browser)
     66