Home | History | Annotate | Download | only in video_VideoCorruption
      1 # Copyright (c) 2013 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 
      5 import os
      6 import shutil
      7 
      8 from autotest_lib.client.bin import test
      9 from autotest_lib.client.common_lib.cros import chrome
     10 from autotest_lib.client.cros.video import constants
     11 from autotest_lib.client.cros.video import native_html5_player
     12 from autotest_lib.client.cros.video import helper_logger
     13 
     14 
     15 class video_VideoCorruption(test.test):
     16     """This test verifies playing corrupted video in Chrome."""
     17     version = 1
     18 
     19     @helper_logger.video_log_wrapper
     20     def run_once(self, video):
     21         """Tests whether Chrome handles corrupted videos gracefully.
     22 
     23         @param video: Sample corrupted video file to be played in Chrome.
     24         """
     25         with chrome.Chrome(
     26                 extra_browser_args=helper_logger.chrome_vmodule_flag(),
     27                 init_network_controller=True) as cr:
     28             shutil.copy2(constants.VIDEO_HTML_FILEPATH, self.bindir)
     29             cr.browser.platform.SetHTTPServerDirectories(self.bindir)
     30             tab = cr.browser.tabs[0]
     31             html_fullpath = os.path.join(self.bindir, 'video.html')
     32             url = cr.browser.platform.http_server.UrlOf(html_fullpath)
     33             player = native_html5_player.NativeHtml5Player(tab,
     34                  full_url = url,
     35                  video_id = 'video',
     36                  video_src_path = video,
     37                  event_timeout = 120)
     38             #This is a corrupted video, so it cann't load for checking canplay.
     39             player.load_video(wait_for_canplay=False)
     40             # Expect corruption being detected after loading corrupted video.
     41             player.wait_for_error()
     42