blob: 7e88c17581b64e272bed4c376c1c94ef110b945e [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 os
import time
import shutil
import logging
from autotest_lib.client.bin import test
from autotest_lib.client.common_lib import error, utils
from autotest_lib.client.common_lib.cros import chrome
from import constants
from import device_capability
from import helper_logger
from import histogram_verifier
from import native_html5_player
class video_ChromeHWDecodeUsed(test.test):
"""This test verifies VDA works in Chrome."""
version = 1
def is_skipping_test(self, codec):
"""Determine whether this test should skip.
@param codec: the codec to be tested. Example values: 'vp8', 'vp9',
blacklist = [
# (board, milestone, codec); None if don't care.
# kevin did support hw decode, but not ready in M54 and M55.
('kevin', 54, 'vp8'),('kevin', 55, 'vp8')
entry = (utils.get_current_board(), utils.get_chrome_milestone(), codec)
for black_entry in blacklist:
for i, to_match in enumerate(black_entry):
if to_match and str(to_match) != entry[i]:
return True
return False
def run_once(self, codec, is_mse, video_file, capability, arc_mode=None):
Tests whether VDA works by verifying histogram for the loaded video.
@param is_mse: bool, True if the content uses MSE, False otherwise.
@param video_file: Sample video file to be loaded in Chrome.
@param capability: Capability required for executing this test.
if self.is_skipping_test(codec):
raise error.TestNAError('Skipping test run on this board.')
if not device_capability.DeviceCapability().have_capability(capability):
logging.warning("Missing Capability: %s", capability)
with chrome.Chrome(
init_network_controller=True) as cr:
init_status_differ = histogram_verifier.HistogramDiffer(
cr, constants.MEDIA_GVD_INIT_STATUS)
error_differ = histogram_verifier.HistogramDiffer(
cr, constants.MEDIA_GVD_ERROR)
# This will execute for MSE video by accesing shaka player
if is_mse:
tab1 = cr.browser.tabs.New()
# Running the test longer to check errors and longer playback
# for MSE videos.
#This execute for normal video for downloading html file
shutil.copy2(constants.VIDEO_HTML_FILEPATH, self.bindir)
video_path = os.path.join(constants.CROS_VIDEO_DIR,
'files', video_file)
shutil.copy2(video_path, self.bindir)
tab = cr.browser.tabs.New()
html_fullpath = os.path.join(self.bindir, 'video.html')
url = cr.browser.platform.http_server.UrlOf(html_fullpath)
player = native_html5_player.NativeHtml5Player(
full_url = url,
video_id = 'video',
video_src_path = video_file,
event_timeout = 120)
# Waits until the video ends or an error happens.
# Wait for histogram updated for the test video.
init_status_differ, constants.MEDIA_GVD_BUCKET, 'OK (0)')
# Check if there's GPU Video Error for a period of time.
has_error, diff_error = histogram_verifier.poll_histogram_grow(
if has_error:
raise error.TestError(
'GPU Video Decoder Error. Histogram diff: %r' % diff_error)
# Verify the video ends successully for normal videos.
if not is_mse and player.check_error():
raise error.TestError('player did not end successully '\
'(HTML5 Player Error %s: %s)'
% player.get_error_info())