OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 """Basic playback test. Checks playback, seek, and replay based on events. |
| 7 |
| 8 This test uses the bear videos from the test matrix in h264, vp8, and theora |
| 9 formats. |
| 10 """ |
| 11 import logging |
| 12 import os |
| 13 |
| 14 import pyauto_media |
| 15 import pyauto |
| 16 |
| 17 |
| 18 # HTML test path; relative to src/chrome/test/data. |
| 19 _TEST_HTML_PATH = os.path.join('media', 'html', 'media_basic_playback.html') |
| 20 |
| 21 # Test videos to play. TODO(dalecurtis): Convert to text matrix parser when we |
| 22 # have more test videos in the matrix. Code already written, see patch here: |
| 23 # https://chromiumcodereview.appspot.com/9290008/#ps12 |
| 24 _TEST_VIDEOS = [ |
| 25 'bear.mp4', 'bear.ogv', 'bear.webm', 'bear_silent.mp4', 'bear_silent.ogv', |
| 26 'bear_silent.webm'] |
| 27 |
| 28 |
| 29 class MediaConstrainedNetworkPerfTest(pyauto.PyUITest): |
| 30 """PyAuto test container. See file doc string for more information.""" |
| 31 |
| 32 def testBasicPlaybackMatrix(self): |
| 33 """Launches HTML test which plays a video until end, seeks, and replays. |
| 34 |
| 35 Specifically ensures that after the above sequence of events, the following |
| 36 is true: |
| 37 |
| 38 1. 2x playing, 2x ended, 1x seeked, 0x error, and 0x abort events. |
| 39 2. video.currentTime == video.duration. |
| 40 """ |
| 41 for media in _TEST_VIDEOS: |
| 42 logging.debug('Running basic playback test for %s', media) |
| 43 |
| 44 self.NavigateToURL('%s?media=%s' % ( |
| 45 self.GetFileURLForDataPath(_TEST_HTML_PATH), media)) |
| 46 |
| 47 # Block until the test finishes and notifies us. Upon return the value of |
| 48 # video.currentTime == video.duration is provided. |
| 49 self.assertTrue(self.ExecuteJavascript('true;')) |
| 50 |
| 51 events = self.GetDOMValue('events').split(',') |
| 52 counts = [(item, events.count(item)) for item in sorted(set(events))] |
| 53 self.assertEqual(counts, [('ended', 2), ('playing', 2), ('seeked', 1)]) |
| 54 |
| 55 |
| 56 if __name__ == '__main__': |
| 57 pyauto_media.Main() |
OLD | NEW |