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_YouTubeFlash(test.test): 18 """This test verify the YouTube Flash video. 19 20 - verify the video playback. 21 - verify the available video resolutions. 22 - verify the player functionalities. 23 24 Note: please make sure that the test page uses nohtml5=1 flag for enforcing 25 the player to play video in Flash mode. Same for html5=1 for html5 26 mode. 27 """ 28 version = 2 29 30 31 def initialize(self): 32 self._testServer = httpd.HTTPListener(8000, docroot=self.bindir) 33 self._testServer.run() 34 35 36 def cleanup(self): 37 if self._testServer: 38 self._testServer.stop() 39 40 41 def run_youtube_tests(self, browser): 42 """Run YouTube Flash sanity tests. 43 44 @param browser: The Browser object to run the test with. 45 46 """ 47 tab = browser.tabs[0] 48 tab.Navigate('http://localhost:8000/youtube.html') 49 yh = youtube_helper.YouTubeHelper(tab) 50 # Waiting for test video to load. 51 yh.wait_for_player_state(PLAYER_PLAYING_STATE) 52 yh.set_video_duration() 53 54 # Verify that YouTube is running in Flash mode. 55 prc = utils.get_process_list('chrome', '--type=ppapi( |$)') 56 if not prc: 57 raise error.TestFail('No Flash process is running.') 58 59 tab.ExecuteJavaScript('player.mute()') 60 yh.verify_video_playback() 61 yh.verify_video_resolutions() 62 yh.verify_player_states() 63 64 65 def run_once(self): 66 utils.verify_flash_installed() 67 with chrome.Chrome() as cr: 68 self.run_youtube_tests(cr.browser) 69