Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(874)

Side by Side Diff: chrome/test/functional/media/media_basic_playback.py

Issue 9233046: Bug fixes for basic playback test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review fixes. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/data/media/html/media_basic_playback.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Basic playback test. Checks playback, seek, and replay based on events. 6 """Basic playback test. Checks playback, seek, and replay based on events.
7 7
8 This test uses the bear videos from the test matrix in h264, vp8, and theora 8 This test uses the bear videos from the test matrix in h264, vp8, and theora
9 formats. 9 formats.
10 """ 10 """
11 import logging 11 import logging
12 import os 12 import os
13 13
14 import pyauto_media 14 import pyauto_media
15 import pyauto 15 import pyauto
16 16
17 17
18 # HTML test path; relative to src/chrome/test/data. 18 # HTML test path; relative to src/chrome/test/data.
19 _TEST_HTML_PATH = os.path.join('media', 'html', 'media_basic_playback.html') 19 _TEST_HTML_PATH = os.path.join('media', 'html', 'media_basic_playback.html')
20 20
21 # Test videos to play. TODO(dalecurtis): Convert to text matrix parser when we 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: 22 # have more test videos in the matrix. Code already written, see patch here:
23 # https://chromiumcodereview.appspot.com/9290008/#ps12 23 # https://chromiumcodereview.appspot.com/9290008/#ps12
24 _TEST_VIDEOS = [ 24 _TEST_VIDEOS = [
25 'bear.mp4', 'bear.ogv', 'bear.webm', 'bear_silent.mp4', 'bear_silent.ogv', 25 'bear.mp4', 'bear.ogv', 'bear.webm', 'bear_silent.mp4', 'bear_silent.ogv',
26 'bear_silent.webm'] 26 'bear_silent.webm']
27 27
28 # Expected events for the first iteration and every iteration thereafter.
29 _EXPECTED_EVENTS_0 = [('ended', 2), ('playing', 2), ('seeked', 1)]
30 _EXPECTED_EVENTS_n = [('abort', 1), ('emptied', 1)] + _EXPECTED_EVENTS_0
31
28 32
29 class MediaConstrainedNetworkPerfTest(pyauto.PyUITest): 33 class MediaConstrainedNetworkPerfTest(pyauto.PyUITest):
30 """PyAuto test container. See file doc string for more information.""" 34 """PyAuto test container. See file doc string for more information."""
31 35
32 def testBasicPlaybackMatrix(self): 36 def testBasicPlaybackMatrix(self):
33 """Launches HTML test which plays a video until end, seeks, and replays. 37 """Launches HTML test which plays each video until end, seeks, and replays.
34 38
35 Specifically ensures that after the above sequence of events, the following 39 Specifically ensures that after the above sequence of events, the following
36 is true: 40 are true:
37 41
38 1. 2x playing, 2x ended, 1x seeked, 0x error, and 0x abort events. 42 1. The first video has only 2x playing, 2x ended, and 1x seeked events.
39 2. video.currentTime == video.duration. 43 2. Each subsequent video additionally has 1x abort and 1x emptied due to
44 switching of the src attribute.
45 3. video.currentTime == video.duration for each video.
46
47 See the HTML file at _TEST_HTML_PATH for more information.
40 """ 48 """
41 for media in _TEST_VIDEOS: 49 self.NavigateToURL(self.GetFileURLForDataPath(_TEST_HTML_PATH))
50
51 for i, media in enumerate(_TEST_VIDEOS):
42 logging.debug('Running basic playback test for %s', media) 52 logging.debug('Running basic playback test for %s', media)
43 53
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 54 # Block until the test finishes and notifies us. Upon return the value of
48 # video.currentTime == video.duration is provided. 55 # video.currentTime == video.duration is provided.
49 self.assertTrue(self.ExecuteJavascript('true;')) 56 try:
57 self.assertTrue(self.ExecuteJavascript("startTest('%s');" % media))
50 58
51 events = self.GetDOMValue('events').split(',') 59 # PyAuto has trouble with arrays, so convert to string prior to request.
52 counts = [(item, events.count(item)) for item in sorted(set(events))] 60 events = self.GetDOMValue("events.join(',')").split(',')
53 self.assertEqual(counts, [('ended', 2), ('playing', 2), ('seeked', 1)]) 61 counts = [(item, events.count(item)) for item in sorted(set(events))]
62
63 # The first loop will not have the abort and emptied events triggered by
64 # changing the video src.
65 if (i == 0):
66 self.assertEqual(counts, _EXPECTED_EVENTS_0)
67 else:
68 self.assertEqual(counts, _EXPECTED_EVENTS_n)
69 except:
70 logging.debug(
71 'Test failed with events: %s', self.GetDOMValue("events.join(',')"))
72 raise
54 73
55 74
56 if __name__ == '__main__': 75 if __name__ == '__main__':
57 pyauto_media.Main() 76 pyauto_media.Main()
OLDNEW
« no previous file with comments | « chrome/test/data/media/html/media_basic_playback.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698