# Copyright (c) 2012 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import logging, time from autotest_lib.client.bin import test, utils from autotest_lib.client.common_lib import error from autotest_lib.client.common_lib.cros import chrome from autotest_lib.client.cros import httpd WAIT_TIMEOUT_S = 5 PLAYBACK_TEST_TIME_S = 5 MEDIA_SUPPORT_AVAILABLE = 'maybe' class video_VideoSanity(test.test): """This test verify the media elements and video sanity. - verify support for mp4, ogg and webm media. - verify html5 video playback. """ version = 2 def initialize(self): self._testServer = httpd.HTTPListener(8000, docroot=self.bindir) self._testServer.run() def cleanup(self): if self._testServer: self._testServer.stop() def video_current_time(self): """Returns video's current playback time. Returns: returns the current playback location in seconds (int). """ return self.tab.EvaluateJavaScript('testvideo.currentTime') def video_duration(self): """Returns video total length. Returns: returns the total video length in seconds (int). """ return self.tab.EvaluateJavaScript('testvideo.duration') def run_video_sanity_test(self, browser): """Run the video sanity test. @param browser: The Browser object to run the test with. """ self.tab = browser.tabs[0] # Verifying