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