Chromium Code Reviews| Index: chrome/test/functional/media/media_test_utils_unittest.py |
| diff --git a/chrome/test/functional/media/media_test_utils_unittest.py b/chrome/test/functional/media/media_test_utils_unittest.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..897857de6ab32c723232be22d7a83f3d71ec9e68 |
| --- /dev/null |
| +++ b/chrome/test/functional/media/media_test_utils_unittest.py |
| @@ -0,0 +1,90 @@ |
| +#!/usr/bin/env python |
| +# Copyright (c) 2012 The Chromium 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 unittest |
| + |
| +import media_test_utils |
| + |
| + |
| +class MediaTestUtilsFindMediaFiles(unittest.TestCase): |
|
Ami GONE FROM CHROMIUM
2012/01/25 17:58:48
...but nice test coverage, at least ;)
|
| + """Unit test for FindMediaFiles method in media_test_utils.""" |
| + |
| + def setUp(self): |
| + self.test_data = { |
| + "test": { |
| + "duration": 7.0, |
| + "fps": 29.970, |
| + "resolution": "1280x720", |
| + |
| + "files": [ |
| + {"file": "test.mp4", "codec": "h264"}, |
| + {"file": "test.webm", "codec": "vp8"}, |
| + {"file": "test_silent.mp4", "codec": "h264", "audio": False}, |
| + {"file": "test_pcm.wav", "codec": "pcm", "video": False} |
| + ] |
| + }, |
| + |
| + "test2": { |
| + "duration": 1.0, |
| + "resolution": "320x240", |
| + |
| + "files": [ |
| + {"file": "test2.mp4", "codec": "h264", "future_tag": 123}, |
| + ] |
| + } |
| + } |
| + |
| + def testUnrestrictedFind(self): |
| + # Find all media. |
| + self.assertEqual( |
| + media_test_utils.FindMediaFiles(self.test_data), |
| + ['test.mp4', 'test.webm', 'test_silent.mp4', 'test_pcm.wav', |
| + 'test2.mp4']) |
| + |
| + def testRestrictedFind(self): |
| + # Find all media without video. |
| + self.assertEqual( |
| + media_test_utils.FindMediaFiles(self.test_data, video=False), |
| + ['test_pcm.wav']) |
| + |
| + # Find all media with video. |
| + self.assertEqual( |
| + media_test_utils.FindMediaFiles(self.test_data, video=True), |
| + ['test.mp4', 'test.webm', 'test_silent.mp4', 'test2.mp4']) |
| + |
| + # Find all media with audio. |
| + self.assertEqual( |
| + media_test_utils.FindMediaFiles(self.test_data, audio=True), |
| + ['test.mp4', 'test.webm', 'test_pcm.wav', 'test2.mp4']) |
| + |
| + # Find all media with audio and video. |
| + self.assertEqual( |
| + media_test_utils.FindMediaFiles(self.test_data, audio=True, video=True), |
| + ['test.mp4', 'test.webm', 'test2.mp4']) |
| + |
| + # Ensure that only items with the criteria match. |
| + self.assertEqual( |
| + media_test_utils.FindMediaFiles(self.test_data, future_tag=123), |
| + ['test2.mp4']) |
| + |
| + # Run criteria that match nothing. |
| + self.assertEqual( |
| + media_test_utils.FindMediaFiles(self.test_data, future_tag=None), |
| + []) |
| + |
| + # Run criteria that match on name. |
| + self.assertEqual( |
| + media_test_utils.FindMediaFiles(self.test_data, name='test2'), |
| + ['test2.mp4']) |
| + |
| + def testCriteriaBasedFind(self): |
| + # Run criteria that match on duration < 5.0. |
| + self.assertEqual( |
| + media_test_utils.FindMediaFiles( |
| + self.test_data, criteria={'duration': lambda v: v < 5.0}), |
| + ['test2.mp4']) |
| + |
| + |
| +if __name__ == '__main__': |
| + unittest.main() |