Home | History | Annotate | Download | only in video_VideoSeek
      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 logging
      6 import os
      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 
     12 WAIT_TIMEOUT_S = 180
     13 
     14 class video_VideoSeek(test.test):
     15     """This test verifies video seek works in Chrome."""
     16     version = 1
     17 
     18     def run_once(self, video):
     19         """Tests whether video seek works by random seeks forward and backward.
     20 
     21         @param video: Sample video file to be seeked in Chrome.
     22         """
     23         with chrome.Chrome() as cr:
     24             cr.browser.platform.SetHTTPServerDirectories(self.bindir)
     25             tab = cr.browser.tabs[0]
     26             tab.Navigate(cr.browser.platform.http_server.UrlOf(
     27                     os.path.join(self.bindir, 'video.html')))
     28             tab.WaitForDocumentReadyStateToBeComplete()
     29 
     30             tab.EvaluateJavaScript('loadSourceAndRunSeekTest("%s")' % video)
     31 
     32             def get_seek_test_status():
     33                 seek_test_status = tab.EvaluateJavaScript('getSeekTestStatus()')
     34                 logging.info('Seeking: %s', seek_test_status)
     35                 return seek_test_status
     36 
     37             utils.poll_for_condition(
     38                     lambda: get_seek_test_status() == 'pass',
     39                     exception=error.TestError('Seek test is stuck and timeout'),
     40                     timeout=WAIT_TIMEOUT_S,
     41                     sleep_interval=1)
     42