1# Copyright (c) 2014 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 time, logging, shutil 7 8from autotest_lib.client.bin import test, utils 9from autotest_lib.client.common_lib import error 10from autotest_lib.client.common_lib.cros import chrome 11from autotest_lib.client.cros.video import histogram_verifier 12from autotest_lib.client.cros.video import constants 13from autotest_lib.client.cros.video import native_html5_player 14from autotest_lib.client.cros.video import helper_logger 15 16 17class video_ChromeVidResChangeHWDecode(test.test): 18 """Verify that VDA works in Chrome for video with resolution changes.""" 19 version = 1 20 21 @helper_logger.video_log_wrapper 22 def run_once(self, video_file, video_len): 23 """Verify VDA and playback for the video_file. 24 25 @param video_file: test video file. 26 @param video_len : test video file length. 27 """ 28 29 with chrome.Chrome( 30 extra_browser_args=helper_logger.chrome_vmodule_flag(), 31 init_network_controller=True) as cr: 32 shutil.copy2(constants.VIDEO_HTML_FILEPATH, self.bindir) 33 cr.browser.platform.SetHTTPServerDirectories(self.bindir) 34 tab1 = cr.browser.tabs[0] 35 html_fullpath = os.path.join(self.bindir, 'video.html') 36 url = cr.browser.platform.http_server.UrlOf(html_fullpath) 37 logging.info("full url is %s", url) 38 player = native_html5_player.NativeHtml5Player(tab1, 39 full_url = url, 40 video_id = 'video', 41 video_src_path = video_file, 42 event_timeout = 120) 43 player.load_video() 44 player.play() 45 # Waits for histogram updated for the test video. 46 histogram_verifier.verify( 47 cr, 48 constants.MEDIA_GVD_INIT_STATUS, 49 constants.MEDIA_GVD_BUCKET) 50 51 # Verify the video playback. 52 for i in range(1, video_len/2): 53 if (player.paused() or player.ended()): 54 raise error.TestError('Video either stopped or ended.') 55 time.sleep(1) 56 57 # Verify that video ends successfully. 58 utils.poll_for_condition( 59 lambda: player.ended(), 60 timeout=video_len, 61 exception=error.TestError('Video did not end successfully'), 62 sleep_interval=1) 63