Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/python | |
| 2 | |
| 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 4 # Use of this source code is governed by a BSD-style license that can be | |
| 5 # found in the LICENSE file. | |
| 6 | |
| 7 import os | |
| 8 import random | |
| 9 import unittest | |
| 10 from media_test_matrix import MediaTestMatrix | |
| 11 | |
| 12 | |
| 13 class MediaTestMatrixTest(unittest.TestCase): | |
| 14 """Unit test for MediaTestMatrix class.""" | |
| 15 | |
| 16 def __ReadCSVFile(self): | |
| 17 """Reads CSV file for test and returns a media test matrix object. | |
| 18 | |
| 19 Returns: | |
| 20 a media test matrix. | |
| 21 """ | |
| 22 matrix = MediaTestMatrix() | |
| 23 # Pyauto.DataDir() method is not used to avoid dependency to pyauto. | |
| 24 data_file = os.path.join('..', 'data', 'media', 'media_matrix_data.csv') | |
| 25 matrix.ReadData(data_file) | |
| 26 return matrix | |
| 27 | |
| 28 def testGenerateAllMediaInfosInCompactForm(self): | |
| 29 matrix = self.__readCSVFile() | |
| 30 # Get video data only case. | |
| 31 media_test_matrix_list = matrix.GenerateAllMediaInfosInCompactForm(True) | |
| 32 self.assertEqual(len(media_test_matrix_list), 249) | |
|
dennis_jeffrey
2011/03/18 23:51:41
In all assert function calls, I believe there's an
imasaki1
2011/03/19 01:00:38
Done.
| |
| 33 media_test_matrix_list = matrix.GenerateAllMediaInfosInCompactForm(False) | |
| 34 # Get all media data. | |
|
dennis_jeffrey
2011/03/18 23:51:41
Move this comment right before line 33 above.
imasaki1
2011/03/19 01:00:38
Done.
| |
| 35 self.assertEqual(len(media_test_matrix_list), 466) | |
| 36 mobile_test_info = MediaTestMatrix.LookForMediaInfoInCompactFormByNickName( | |
| 37 media_test_matrix_list, 'mobile0.webm') | |
| 38 self.assertEqual(len(media_test_matrix_list), 1) | |
| 39 self.assertEqual(mobile_test_info[1], 'mobile0.webm') | |
| 40 | |
| 41 def testGenerateAllMediaInfos(self): | |
| 42 matrix = self.__readCSVFile() | |
| 43 # Get video data only case. | |
| 44 media_test_matrix_list = matrix.GenerateAllMediaInfos(True) | |
| 45 self.assertEqual(len(media_test_matrix_list), 249) | |
| 46 # Get all media data. | |
| 47 media_test_matrix_list = matrix.GenerateAllMediaInfos(False) | |
| 48 self.assertEqual(len(media_test_matrix_list), 466) | |
| 49 (info, url, link, tag, is_video, nickname) = ( | |
| 50 matrix.GenerateRandomMediaInfo()) | |
| 51 self.assertTrue(info is not None) | |
|
dennis_jeffrey
2011/03/18 23:51:41
Should we assert on any of the other return values
imasaki1
2011/03/19 01:00:38
Done.
| |
| 52 | |
| 53 if __name__ == '__main__': | |
| 54 unittest.main() | |
| OLD | NEW |