1# Copyright 2016 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 os 6import shutil 7import logging 8 9from autotest_lib.client.bin import test, utils 10from autotest_lib.client.common_lib.cros import chrome, arc_common 11from autotest_lib.client.cros.video import constants 12from autotest_lib.client.cros.video import native_html5_player 13from autotest_lib.client.cros.video import helper_logger 14 15class video_VideoSanity(test.test): 16 """This test verify the media elements and video sanity. 17 18 - verify support for mp4, vp8 and vp9 media. 19 - verify html5 video playback. 20 21 """ 22 version = 2 23 24 25 @helper_logger.video_log_wrapper 26 def run_once(self, video_file, arc_mode=False): 27 """ 28 Tests whether the requested video is playable 29 30 @param video_file: Sample video file to be played in Chrome. 31 32 """ 33 blacklist = [ 34 # (board, arc_mode) # None means don't care 35 ('x86-mario', None), 36 ('x86-zgb', None), 37 # The result on elm and oak is flaky in arc mode. 38 # TODO(wuchengli): remove them once crbug.com/679864 is fixed. 39 ('elm', True), 40 ('oak', True)] 41 42 dut_board = utils.get_current_board() 43 for (blacklist_board, blacklist_arc_mode) in blacklist: 44 if blacklist_board == dut_board: 45 if blacklist_arc_mode is None or blacklist_arc_mode == arc_mode: 46 logging.info("Skipping test run on this board.") 47 return 48 break 49 50 if arc_mode: 51 arc_mode_str = arc_common.ARC_MODE_ENABLED 52 else: 53 arc_mode_str = arc_common.ARC_MODE_DISABLED 54 with chrome.Chrome( 55 extra_browser_args=helper_logger.chrome_vmodule_flag(), 56 arc_mode=arc_mode_str, 57 init_network_controller=True) as cr: 58 shutil.copy2(constants.VIDEO_HTML_FILEPATH, self.bindir) 59 video_path = os.path.join(constants.CROS_VIDEO_DIR, 60 'files', video_file) 61 shutil.copy2(video_path, self.bindir) 62 cr.browser.platform.SetHTTPServerDirectories(self.bindir) 63 tab = cr.browser.tabs.New() 64 html_fullpath = os.path.join(self.bindir, 'video.html') 65 url = cr.browser.platform.http_server.UrlOf(html_fullpath) 66 67 player = native_html5_player.NativeHtml5Player( 68 tab, 69 full_url = url, 70 video_id = 'video', 71 video_src_path = video_file, 72 event_timeout = 120) 73 player.load_video() 74 player.play() 75 player.verify_video_can_play(constants.PLAYBACK_TEST_TIME_S) 76