Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: media/tools/layout_tests/layouttest_analyzer_helpers_unittest.py

Issue 7693018: Intial checkin of layout test analyzer. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Minor modification after doublecheck. Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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_helper
dennis_jeffrey 2011/08/26 19:01:26 I think we need an 's' at the end of this line, el
imasaki1 2011/08/26 22:28:44 Done. Also, I also forget to run this unit test. I
12
13
14 class TestLayoutTestAnalyzerHelpers(unittest.TestCase):
15
16 def testFindLatestTime(self):
17 time_list = ['2011-08-18-19', '2011-08-18-22', '2011-08-18-21',
18 '2012-01-11-21']
19 self.assertEquals(layouttest_analyzer_helpers.FindLatestTime(time_list),
20 '2012-01-11-21')
21
22 def GenerateTestDataWholeAndSkip(self):
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):
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.CompareToOtherResultMap(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.CompareToOtherResultMap(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.CompareToOtherResultMap(
83 analyzerResultMapMoreTEInfo)
84 self.assertTrue('NEWADDED' in m['nonskip'][1][0][1][0])
85
86 def testGetListOfBugsForNonSkippedTests(self):
87 file_path = os.path.join('test_data', 'base')
88 analyzerResultMapBase = AnalyzerResultMap.Load(file_path)
89 self.assertEquals(
90 len(analyzerResultMapBase.GetListOfBugsForNonSkippedTests().keys()),
91 10)
92
93
94 if __name__ == '__main__':
95 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698