blob: 5f42f7924258cc1e869346bb997e96d218bc3f31 [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 fnmatch
import logging
import os
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 import device_capability
from import helper_logger
class video_VideoSeek(test.test):
"""This test verifies video seek works in Chrome."""
version = 1
def is_skipping_test(self, codec, is_switchres):
"""Determine whether this test should skip.
@param codec: the codec to be tested, ex. 'vp8', 'vp9', 'h264'.
@param is_switchres: bool, True if using switch resolution video.
blacklist = [
# (board, codec, is_switchres); None if don't care.
# "board" supports Unix shell-type wildcards
# Disable vp8 switchres for nyan devices temporarily due to:
# crbug/699260
('nyan', 'vp8', True), ('nyan_*', 'vp8', True)
board = utils.get_current_board()
for entry in blacklist:
if ((entry[0] is None or fnmatch.fnmatch(board, entry[0])) and
(entry[1] is None or codec == entry[1]) and
(entry[2] is None or is_switchres == entry[2])):
return True
return False
def run_once(self, codec, is_switchres, video, capability):
"""Tests whether video seek works by random seeks forward and backward.
@param codec: the codec to be tested, ex. 'vp8', 'vp9', 'h264'.
@param is_switchres: bool, True if using switch resolution video.
@param video: Sample video file to be seeked in Chrome.
@param capability: The capability required for executing the test.
if self.is_skipping_test(codec, is_switchres):'Skipping test run on this board.')
return # return immediately to pass this test
with chrome.Chrome(
init_network_controller=True) as cr:
tab = cr.browser.tabs[0]
os.path.join(self.bindir, 'video.html')))
tab.EvaluateJavaScript('loadSourceAndRunSeekTest("%s")' % video)
def get_seek_test_status():
seek_test_status = tab.EvaluateJavaScript('getSeekTestStatus()')'Seeking: %s', seek_test_status)
return seek_test_status
# Wait until we get the 'pass' status, meaning the test has been
# successful. Also timeout and fail the test if we stay on the same
# seek for more than WAIT_TIMEOUT_S.
cur_status = get_seek_test_status()
while True:
lambda: get_seek_test_status() != cur_status,
exception=error.TestError('Seek test is stuck and timeout'),
cur_status = get_seek_test_status()
if cur_status == 'pass': break