Index: chrome/test/functional/media_test_matrix_unittest.py |
diff --git a/chrome/test/functional/media_test_matrix_unittest.py b/chrome/test/functional/media_test_matrix_unittest.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..616c449f80f973d76d9b9026154945365fdf2f4b |
--- /dev/null |
+++ b/chrome/test/functional/media_test_matrix_unittest.py |
@@ -0,0 +1,67 @@ |
+#!/usr/bin/python |
+ |
+# Copyright (c) 2011 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 os |
+import random |
+import unittest |
Nirnimesh
2011/03/20 09:14:06
nit: Please leave a blank line after all the syste
imasaki1
2011/03/20 16:17:16
Done.
|
+from media_test_matrix import MediaTestMatrix |
+ |
+ |
+class MediaTestMatrixTest(unittest.TestCase): |
+ """Unit test for MediaTestMatrix class.""" |
+ |
+ def __ReadCSVFile(self): |
Nirnimesh
2011/03/20 09:14:06
nit: use single underscore
imasaki1
2011/03/20 16:17:16
Done.
|
+ """Reads CSV file for test and returns a media test matrix object. |
+ |
+ Returns: |
+ a media test matrix. |
+ """ |
+ matrix = MediaTestMatrix() |
+ # Pyauto.DataDir() method is not used to avoid dependency to pyauto. |
+ data_file = os.path.join('..', 'data', 'media', 'media_matrix_data.csv') |
Nirnimesh
2011/03/20 09:14:06
use os.pardir instead of '..'
imasaki1
2011/03/20 16:17:16
Done.
|
+ matrix.ReadData(data_file) |
+ return matrix |
+ |
+ def testGenerateAllMediaInfosInCompactForm(self): |
+ matrix = self.__ReadCSVFile() |
+ # Get video data only case. |
+ media_test_matrix_list = matrix.GenerateAllMediaInfosInCompactForm(True) |
+ self.assertEqual(len(media_test_matrix_list), 249, |
+ "total number of elements in the returned list is wrong") |
+ # Get all media data. |
+ media_test_matrix_list = matrix.GenerateAllMediaInfosInCompactForm(False) |
+ self.assertEqual(len(media_test_matrix_list), 466, |
+ "total number of elements in the returned list is wrong") |
+ mobile_test_info = MediaTestMatrix.LookForMediaInfoInCompactFormByNickName( |
+ media_test_matrix_list, 'mobile0.webm') |
+ self.assertEqual(mobile_test_info[1], 'mobile0.webm', |
+ "the nickname of the returned element is wrong") |
+ |
+ def testGenerateAllMediaInfos(self): |
+ matrix = self.__ReadCSVFile() |
+ # Get video data only case. |
+ media_test_matrix_list = matrix.GenerateAllMediaInfos(True) |
+ self.assertEqual(len(media_test_matrix_list), 249, |
+ "total number of elements in the returned list is wrong") |
+ # Get all media data. |
+ media_test_matrix_list = matrix.GenerateAllMediaInfos(False) |
+ self.assertEqual(len(media_test_matrix_list), 466, |
+ "total number of elements in the returned list is wrong") |
Nirnimesh
2011/03/20 09:14:06
nit: use single quote char ' please
Repeat elsewhe
imasaki1
2011/03/20 16:17:16
Done.
|
+ (info, url, link, tag, is_video, nickname) = ( |
+ matrix.GenerateRandomMediaInfo()) |
+ self.assertTrue(info is not None, |
+ "randomly generated media info does not have spec") |
+ self.assertTrue(url is not None, |
+ "randomly generated media info does not have url") |
+ self.assertTrue(link is not None, |
+ "randomly generated media info does not have link") |
+ self.assertTrue(tag is not None, |
+ "randomly generated media info does not have tag") |
+ self.assertTrue(nickname is not None, |
+ "randomly generated media info does not have nickname") |
+ |
Nirnimesh
2011/03/20 09:14:06
leave another blank line here.
Need 2 blank lines
imasaki1
2011/03/20 16:17:16
Done.
|
+if __name__ == '__main__': |
+ unittest.main() |