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

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

Issue 9290008: Introduce new basic playback test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Documentation. Created 8 years, 11 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
OLDNEW
(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 import unittest
6
7 import media_test_utils
8
9
10 class MediaTestUtilsFindMediaFiles(unittest.TestCase):
Ami GONE FROM CHROMIUM 2012/01/25 17:58:48 ...but nice test coverage, at least ;)
11 """Unit test for FindMediaFiles method in media_test_utils."""
12
13 def setUp(self):
14 self.test_data = {
15 "test": {
16 "duration": 7.0,
17 "fps": 29.970,
18 "resolution": "1280x720",
19
20 "files": [
21 {"file": "test.mp4", "codec": "h264"},
22 {"file": "test.webm", "codec": "vp8"},
23 {"file": "test_silent.mp4", "codec": "h264", "audio": False},
24 {"file": "test_pcm.wav", "codec": "pcm", "video": False}
25 ]
26 },
27
28 "test2": {
29 "duration": 1.0,
30 "resolution": "320x240",
31
32 "files": [
33 {"file": "test2.mp4", "codec": "h264", "future_tag": 123},
34 ]
35 }
36 }
37
38 def testUnrestrictedFind(self):
39 # Find all media.
40 self.assertEqual(
41 media_test_utils.FindMediaFiles(self.test_data),
42 ['test.mp4', 'test.webm', 'test_silent.mp4', 'test_pcm.wav',
43 'test2.mp4'])
44
45 def testRestrictedFind(self):
46 # Find all media without video.
47 self.assertEqual(
48 media_test_utils.FindMediaFiles(self.test_data, video=False),
49 ['test_pcm.wav'])
50
51 # Find all media with video.
52 self.assertEqual(
53 media_test_utils.FindMediaFiles(self.test_data, video=True),
54 ['test.mp4', 'test.webm', 'test_silent.mp4', 'test2.mp4'])
55
56 # Find all media with audio.
57 self.assertEqual(
58 media_test_utils.FindMediaFiles(self.test_data, audio=True),
59 ['test.mp4', 'test.webm', 'test_pcm.wav', 'test2.mp4'])
60
61 # Find all media with audio and video.
62 self.assertEqual(
63 media_test_utils.FindMediaFiles(self.test_data, audio=True, video=True),
64 ['test.mp4', 'test.webm', 'test2.mp4'])
65
66 # Ensure that only items with the criteria match.
67 self.assertEqual(
68 media_test_utils.FindMediaFiles(self.test_data, future_tag=123),
69 ['test2.mp4'])
70
71 # Run criteria that match nothing.
72 self.assertEqual(
73 media_test_utils.FindMediaFiles(self.test_data, future_tag=None),
74 [])
75
76 # Run criteria that match on name.
77 self.assertEqual(
78 media_test_utils.FindMediaFiles(self.test_data, name='test2'),
79 ['test2.mp4'])
80
81 def testCriteriaBasedFind(self):
82 # Run criteria that match on duration < 5.0.
83 self.assertEqual(
84 media_test_utils.FindMediaFiles(
85 self.test_data, criteria={'duration': lambda v: v < 5.0}),
86 ['test2.mp4'])
87
88
89 if __name__ == '__main__':
90 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698