Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/python | |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 import copy | |
| 7 import os | |
| 8 import pickle | |
| 9 import unittest | |
| 10 | |
| 11 import layouttest_analyzer_helpers | |
| 12 from layouttest_analyzer_helpers import AnalyzerResultMap | |
|
dennis_jeffrey
2011/08/25 00:36:46
Do we need this, given that we've already imported
imasaki1
2011/08/25 23:57:03
Done.
| |
| 13 | |
| 14 | |
| 15 class TestLayoutTestAnalyzerHelpers(unittest.TestCase): | |
| 16 | |
| 17 def testFindLatestTime(self): | |
| 18 l = ['2011-08-18-19', '2011-08-18-22', '2011-08-18-21', '2012-01-11-21'] | |
| 19 self.assertEquals(layouttest_analyzer_helpers.FindLatestTime(l), | |
| 20 '2012-01-11-21') | |
| 21 | |
| 22 def GenerateTestDataWholeAndSkip(self): | |
|
dennis_jeffrey
2011/08/25 00:36:46
Is this function meant to be invoked manually? I
imasaki1
2011/08/25 23:57:03
Yes. Only when you want to generate the test data.
| |
| 23 """You should call this method if you want to generate test data.""" | |
| 24 file_path = os.path.join('test_data', 'base') | |
| 25 analyzerResultMapBase = AnalyzerResultMap.Load(file_path) | |
| 26 # Remove this first part | |
| 27 m = analyzerResultMapBase.result_map['whole'] | |
| 28 del m['media/video-source-type.html'] | |
| 29 m = analyzerResultMapBase.result_map['skip'] | |
| 30 del m['media/track/track-webvtt-tc004-magicheader.html'] | |
| 31 | |
| 32 file_path = os.path.join('test_data', 'less') | |
| 33 analyzerResultMapBase.Save(file_path) | |
| 34 | |
| 35 file_path = os.path.join('test_data', 'base') | |
| 36 analyzerResultMapBase = AnalyzerResultMap.Load(file_path) | |
| 37 | |
| 38 analyzerResultMapBase.result_map['whole']['add1.html'] = True | |
| 39 analyzerResultMapBase.result_map['skip']['add2.html'] = True | |
| 40 | |
| 41 file_path = os.path.join('test_data', 'more') | |
| 42 analyzerResultMapBase.Save(file_path) | |
| 43 | |
| 44 def GenerateTestDataNonSkip(self): | |
|
dennis_jeffrey
2011/08/25 00:36:46
Is this function meant to be invoked manually? I
imasaki1
2011/08/25 23:57:03
Same comments as above.
| |
| 45 """You should call this method if you want to generate test data.""" | |
| 46 file_path = os.path.join('test_data', 'base') | |
| 47 analyzerResultMapBase = AnalyzerResultMap.Load(file_path) | |
| 48 m = analyzerResultMapBase.result_map['nonskip'] | |
| 49 ex = m['media/media-document-audio-repaint.html'] | |
| 50 te_info_map1 = ex['te_info'][0] | |
| 51 te_info_map2 = copy.copy(te_info_map1) | |
| 52 te_info_map2['NEWADDED'] = True | |
| 53 ex['te_info'].append(te_info_map2) | |
| 54 m = analyzerResultMapBase.result_map['nonskip'] | |
| 55 | |
| 56 file_path = os.path.join('test_data', 'more_te_info') | |
| 57 analyzerResultMapBase.Save(file_path) | |
| 58 | |
| 59 def testCompareResultMapsWholeAndSkip(self): | |
| 60 file_path = os.path.join('test_data', 'base') | |
| 61 analyzerResultMapBase = AnalyzerResultMap.Load(file_path) | |
| 62 | |
| 63 file_path = os.path.join('test_data', 'less') | |
| 64 analyzerResultMapLess = AnalyzerResultMap.Load(file_path) | |
| 65 | |
| 66 diff = analyzerResultMapBase.CompareResultMaps(analyzerResultMapLess) | |
| 67 self.assertEquals(diff['skip'][0][0][0], | |
| 68 'media/track/track-webvtt-tc004-magicheader.html') | |
| 69 self.assertEquals(diff['whole'][0][0][0], | |
| 70 'media/video-source-type.html') | |
| 71 file_path = os.path.join('test_data', 'more') | |
| 72 analyzerResultMapMore = AnalyzerResultMap.Load(file_path) | |
| 73 diff = analyzerResultMapBase.CompareResultMaps(analyzerResultMapMore) | |
| 74 self.assertEquals(diff['whole'][1][0][0], 'add1.html') | |
| 75 self.assertEquals(diff['skip'][1][0][0], 'add2.html') | |
| 76 | |
| 77 def testCompareResultMapsNonSkip(self): | |
| 78 file_path = os.path.join('test_data', 'base') | |
| 79 analyzerResultMapBase = AnalyzerResultMap.Load(file_path) | |
| 80 file_path = os.path.join('test_data', 'more_te_info') | |
| 81 analyzerResultMapMoreTEInfo = AnalyzerResultMap.Load(file_path) | |
| 82 m = analyzerResultMapBase.CompareResultMaps(analyzerResultMapMoreTEInfo) | |
| 83 self.assertTrue('NEWADDED' in m['nonskip'][1][0][1][0]) | |
| 84 | |
| 85 def testGetListOfBugsForNonSkippedTests(self): | |
| 86 file_path = os.path.join('test_data', 'base') | |
| 87 analyzerResultMapBase = AnalyzerResultMap.Load(file_path) | |
| 88 self.assertEquals( | |
| 89 len(analyzerResultMapBase.GetListOfBugsForNonSkippedTests().keys()), | |
| 90 10) | |
| 91 | |
| 92 | |
| 93 if __name__ == '__main__': | |
| 94 unittest.main() | |
| OLD | NEW |