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