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 5import logging 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 11from autotest_lib.client.cros.video import helper_logger 12 13 14FLASH_PROCESS_NAME = 'chrome/chrome --type=ppapi' 15PLAYER_PLAYING_STATE = 'Playing' 16 17 18class video_YouTubeHTML5(test.test): 19 """This test verify the YouTube HTML5 video. 20 21 - verify the video playback. 22 - verify the player functionalities. 23 24 """ 25 version = 2 26 27 def initialize(self): 28 self._testServer = httpd.HTTPListener(8000, docroot=self.bindir) 29 self._testServer.run() 30 31 def cleanup(self): 32 if self._testServer: 33 self._testServer.stop() 34 35 def run_youtube_tests(self, browser): 36 """Run YouTube HTML5 sanity tests. 37 38 @param browser: The Browser object to run the test with. 39 40 """ 41 tab = browser.tabs[0] 42 tab.Navigate('http://localhost:8000/youtube5.html') 43 yh = youtube_helper.YouTubeHelper(tab) 44 # Waiting for test video to load. 45 yh.wait_for_player_state(PLAYER_PLAYING_STATE) 46 47 yh.set_video_duration() 48 49 # Verify that YouTube is running in html5 mode. 50 prc = utils.get_process_list('chrome', '--type=ppapi( |$)') 51 if prc: 52 raise error.TestFail('Running YouTube in Flash mode. ' 53 'Process list: %s.' % prc) 54 55 tab.ExecuteJavaScript('player.mute()') 56 yh.verify_video_playback() 57 yh.verify_player_states() 58 59 @helper_logger.video_log_wrapper 60 def run_once(self): 61 with chrome.Chrome( 62 extra_browser_args=helper_logger.chrome_vmodule_flag()) as cr: 63 self.run_youtube_tests(cr.browser) 64