Index: chrome/test/functional/media/pyauto_media.py |
diff --git a/chrome/test/functional/media/pyauto_media.py b/chrome/test/functional/media/pyauto_media.py |
index 2a2853766c7100500d18eebd009f77341de54f79..4dd1ae6328ab485b7ae5bc7f33c1ecd65baf9cc8 100755 |
--- a/chrome/test/functional/media/pyauto_media.py |
+++ b/chrome/test/functional/media/pyauto_media.py |
@@ -10,18 +10,18 @@ test must include this snippet: |
# This should be at the top |
import pyauto_media |
- <test code> |
+ class TestName(pyauto_media.MediaTestBase): |
+ <test code> |
# This should be at the bottom. |
if __name__ == '__main__': |
pyauto_media.Main() |
""" |
- |
+import json |
import os |
import sys |
-import tempfile |
-from media_test_env_names import MediaTestEnvNames |
+import media_test_utils |
def _SetupPaths(): |
@@ -30,27 +30,36 @@ def _SetupPaths(): |
sys.path.append(media_dir) |
sys.path.append(os.path.normpath(os.path.join(media_dir, os.pardir))) |
- # Add psutil library path. |
- # TODO(dalecurtis): This should only be added for tests which use psutil. |
- sys.path.append(os.path.normpath(os.path.join( |
- media_dir, os.pardir, os.pardir, os.pardir, os.pardir, |
- 'third_party', 'psutil'))) |
- |
- # Setting PYTHONPATH for reference build. |
- # TODO(dalecurtis): Don't use env variables, each test can process a command |
- # line before passing off control to PyAuto. |
- if os.getenv(MediaTestEnvNames.REFERENCE_BUILD_ENV_NAME): |
- reference_build_dir = os.getenv( |
- MediaTestEnvNames.REFERENCE_BUILD_DIR_ENV_NAME, |
- # TODO(imasaki): Change the following default value. |
- # Default directory is just for testing so the correct directory |
- # must be set in the build script. |
- os.path.join(tempfile.gettempdir(), 'chrome-media-test')) |
- sys.path.insert(0, reference_build_dir) |
- |
_SetupPaths() |
+import pyauto_functional |
+import pyauto |
+ |
+ |
+class MediaTestBase(pyauto.PyUITest): |
+ def setUp(self): |
+ pyauto.PyUITest.setUp(self) |
+ self._test_matrix = json.load(open( |
+ os.path.join(self.DataDir(), 'media', 'csv', 'media.json'))) |
+ |
+ def FindMedia(self, **kwargs): |
+ """Returns a list of matching media paths from the test matrix. |
+ |
+ Given a list of keys like audio=True, duration=1.0, etc... returns a list |
+ of files matching these constraints. |
+ |
+ See media_test_utils.FindMediaFiles for more advanced syntax. |
+ |
+ Arguments: |
+ **kwargs: List of attributes desired for each media file. |
+ |
+ Returns: |
+ List of matching file names. |
+ """ |
+ media_files = media_test_utils.FindMediaFiles(self._test_matrix, **kwargs) |
+ # Covert unicode strings to regular strings because PyAuto doesn't know how |
+ # to process unicode at the moment. |
+ return map(str, media_files) |
-import pyauto_functional |
Main = pyauto_functional.Main |