blob: 4620734640d08fa49f65ff66436cd5637f144867 [file] [log] [blame]
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import logging
from autotest_lib.client.bin import test, utils
from autotest_lib.client.common_lib import error
from autotest_lib.client.common_lib.cros import chrome
from autotest_lib.client.cros import httpd
from autotest_lib.client.cros.video import youtube_helper
from autotest_lib.client.cros.video import helper_logger
FLASH_PROCESS_NAME = 'chrome/chrome --type=ppapi'
PLAYER_PLAYING_STATE = 'Playing'
class video_YouTubeHTML5(test.test):
"""This test verify the YouTube HTML5 video.
- verify the video playback.
- verify the player functionalities.
"""
version = 2
def initialize(self):
self._testServer = httpd.HTTPListener(8000, docroot=self.bindir)
self._testServer.run()
def cleanup(self):
if self._testServer:
self._testServer.stop()
def run_youtube_tests(self, browser):
"""Run YouTube HTML5 sanity tests.
@param browser: The Browser object to run the test with.
"""
tab = browser.tabs[0]
tab.Navigate('http://localhost:8000/youtube5.html')
yh = youtube_helper.YouTubeHelper(tab)
# Waiting for test video to load.
yh.wait_for_player_state(PLAYER_PLAYING_STATE)
yh.set_video_duration()
# Verify that YouTube is running in html5 mode.
prc = utils.get_process_list('chrome', '--type=ppapi( |$)')
if prc:
raise error.TestFail('Running YouTube in Flash mode. '
'Process list: %s.' % prc)
tab.ExecuteJavaScript('player.mute()')
yh.verify_video_playback()
yh.verify_player_states()
@helper_logger.video_log_wrapper
def run_once(self):
with chrome.Chrome(
extra_browser_args=helper_logger.chrome_vmodule_flag()) as cr:
self.run_youtube_tests(cr.browser)