Home | History | Annotate | Download | only in video_ChromeVidResChangeHWDecode
      1 # Copyright (c) 2014 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 time, logging, shutil
      7 
      8 from autotest_lib.client.bin import test, utils
      9 from autotest_lib.client.common_lib import error
     10 from autotest_lib.client.common_lib.cros import chrome
     11 from autotest_lib.client.cros.video import histogram_verifier
     12 from autotest_lib.client.cros.video import constants
     13 from autotest_lib.client.cros.video import native_html5_player
     14 
     15 
     16 class video_ChromeVidResChangeHWDecode(test.test):
     17     """Verify that VDA works in Chrome for video with resolution changes."""
     18     version = 1
     19 
     20 
     21     def run_once(self, video_file, video_len):
     22         """Verify VDA and playback for the video_file.
     23 
     24         @param video_file: test video file.
     25         @param video_len : test video file length.
     26         """
     27 
     28         with chrome.Chrome() as cr:
     29             shutil.copy2(constants.VIDEO_HTML_FILEPATH, self.bindir)
     30             cr.browser.platform.SetHTTPServerDirectories(self.bindir)
     31             tab1 = 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             logging.info("full url is %s", url)
     35             player = native_html5_player.NativeHtml5Player(tab1,
     36                  full_url = url,
     37                  video_id = 'video',
     38                  video_src_path = video_file,
     39                  event_timeout = 120)
     40             player.load_video()
     41             player.play()
     42             # Waits for histogram updated for the test video.
     43             histogram_verifier.verify(
     44                     cr,
     45                     constants.MEDIA_GVD_INIT_STATUS,
     46                     constants.MEDIA_GVD_BUCKET)
     47 
     48             # Verify the video playback.
     49             for i in range(1, video_len/2):
     50                 if (player.paused() or player.ended()):
     51                     raise error.TestError('Video either stopped or ended.')
     52                 time.sleep(1)
     53 
     54             # Verify that video ends successfully.
     55             utils.poll_for_condition(
     56                     lambda: player.ended(),
     57                     timeout=video_len,
     58                     exception=error.TestError('Video did not end successfully'),
     59                     sleep_interval=1)
     60