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..580a29412c310a832179749e0a846ec07407d762 |
--- /dev/null |
+++ b/chrome/test/functional/media_test_matrix_unittest.py |
@@ -0,0 +1,45 @@ |
+#!/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 |
+from media_test_matrix import MediaTestMatrix |
+ |
+ |
+class MediaTestMatrixTest(unittest.TestCase): |
+ """Unit test for MediaTestMatrix class.""" |
+ |
+ def __readCSVFile(self): |
dennis_jeffrey
2011/03/18 17:47:50
In the function name, capitalize the "r" at the be
imasaki1
2011/03/18 21:54:25
Done also make this private
|
+ """read CSV file for test and returns a media test matrix object. |
dennis_jeffrey
2011/03/18 17:47:50
Capitalize the "r" in "read" and change it to "Rea
imasaki1
2011/03/18 21:54:25
Done.
|
+ |
+ Returns: |
+ a media test matrix |
dennis_jeffrey
2011/03/18 17:47:50
Capitalize the starting "a", and add a period at t
imasaki1
2011/03/18 21:54:25
Done.
|
+ """ |
+ matrix = MediaTestMatrix() |
+ # Pyauto.DataDir() method is not used to avoid dependency to pyauto. |
+ data_file = os.path.join('..', 'data', 'media', 'media_matrix_data.csv') |
+ matrix.ReadData(data_file) |
+ return matrix |
+ |
+ def testGenerateAllMediaInfosInCompactForm(self): |
+ matrix = self.__readCSVFile() |
+ media_test_matrix_list = matrix.GenerateAllMediaInfosInCompactForm(True) |
+ self.assertEqual(len(media_test_matrix_list), 240) |
+ mobile_test_info = MediaTestMatrix.LookForMediaInfoByNickName( |
+ media_test_matrix_list, "mobile0.webm") |
dennis_jeffrey
2011/03/18 17:47:50
When the function call in the previous line doesn'
imasaki1
2011/03/18 21:54:25
Done.
|
+ self.assertEqual(mobile_test_info[1], "mobile0.webm") |
dennis_jeffrey
2011/03/18 17:47:50
Prefer single quotes to double quotes in strings,
dennis_jeffrey
2011/03/18 17:47:50
Before accessing position 1 of the mobile_test_inf
imasaki1
2011/03/18 21:54:25
Done.
imasaki1
2011/03/18 21:54:25
Done.
imasaki1
2011/03/18 21:54:25
Done.
|
+ |
+ def testGenerateAllMediaInfos(self): |
+ matrix = self.__readCSVFile() |
+ media_test_matrix_list = matrix.GenerateAllMediaInfos(True) |
+ self.assertEqual(len(media_test_matrix_list), 240) |
+ (info, url, link, tag, |
+ is_video, nickname) = matrix.GenerateRandomMediaInfo() |
dennis_jeffrey
2011/03/18 17:47:50
I think lines 40-41 might look better like this:
imasaki1
2011/03/18 21:54:25
Done.
|
+ self.assertTrue(info is not None) |
dennis_jeffrey
2011/03/18 17:47:50
Thanks for adding these extra tests. Could you al
imasaki1
2011/03/18 21:54:25
Done.
|
+ |
+if __name__ == '__main__': |
+ unittest.main() |