• 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
7
8from autotest_lib.client.bin import test
9from autotest_lib.client.common_lib.cros import chrome
10from autotest_lib.client.cros.video import constants
11from autotest_lib.client.cros.video import native_html5_player
12from autotest_lib.client.cros.video import helper_logger
13
14WAIT_TIMEOUT_S = 30
15
16class video_VideoReload(test.test):
17    """This test verifies reloading video works in Chrome."""
18    version = 1
19
20    @helper_logger.video_log_wrapper
21    def run_once(self, video_file):
22        """Tests whether Chrome reloads video after reloading the tab.
23
24        @param video_file: fullpath to video to play.
25        """
26        with chrome.Chrome(
27                extra_browser_args=helper_logger.chrome_vmodule_flag(),
28                init_network_controller=True) as cr:
29            shutil.copy2(constants.VIDEO_HTML_FILEPATH, self.bindir)
30            cr.browser.platform.SetHTTPServerDirectories(self.bindir)
31            tab = cr.browser.tabs[0]
32            html_fullpath = os.path.join(self.bindir, 'video.html')
33            url = cr.browser.platform.http_server.UrlOf(html_fullpath)
34            player = native_html5_player.NativeHtml5Player(
35                 tab,
36                 full_url = url,
37                 video_id = 'video',
38                 video_src_path = video_file,
39                 event_timeout = 30)
40            player.load_video()
41            player.play()
42            player.verify_video_can_play(5)
43            player.reload_page()
44            player.load_video()
45            player.play()
46            player.verify_video_can_play(5)
47