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

Side by Side Diff: gm/rebaseline_server/imagepair_test.py

Issue 479613002: Add ability to output ImageBaseGSUrl to render_picture and use in rebaseline server (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update remaining ImagePair callers Created 6 years, 4 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
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 """ 3 """
4 Copyright 2014 Google Inc. 4 Copyright 2014 Google Inc.
5 5
6 Use of this source code is governed by a BSD-style license that can be 6 Use of this source code is governed by a BSD-style license that can be
7 found in the LICENSE file. 7 found in the LICENSE file.
8 8
9 Test imagepair.py 9 Test imagepair.py
10 """ 10 """
11 11
12 # System-level imports 12 # System-level imports
13 import shutil 13 import shutil
14 import tempfile 14 import tempfile
15 import unittest 15 import unittest
16 16
17 # Local imports 17 # Local imports
18 import imagediffdb 18 import imagediffdb
19 import imagepair 19 import imagepair
20 20
21 21
22 IMG_URL_BASE = ('http://chromium-skia-gm.commondatastorage.googleapis.com/' 22 IMG_URL_BASE = ('http://chromium-skia-gm.commondatastorage.googleapis.com/'
23 'gm/bitmap-64bitMD5/') 23 'gm/bitmap-64bitMD5/')
24 ALT_IMG_URL_BASE = ('http://chromium-skia-gm.commondatastorage.googleapis.com/'
25 'test/gm/bitmap-64bitMD5/')
24 26
25 27
26 class ImagePairTest(unittest.TestCase): 28 class ImagePairTest(unittest.TestCase):
27 29
28 def setUp(self): 30 def setUp(self):
29 self.temp_dir = tempfile.mkdtemp() 31 self.temp_dir = tempfile.mkdtemp()
30 self.maxDiff = None 32 self.maxDiff = None
31 33
32 def tearDown(self): 34 def tearDown(self):
33 shutil.rmtree(self.temp_dir) 35 shutil.rmtree(self.temp_dir)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 # expected output: 69 # expected output:
68 { 70 {
69 'extraColumns': { 71 'extraColumns': {
70 'builder': 'MyBuilder', 72 'builder': 'MyBuilder',
71 'test': 'MyTest', 73 'test': 'MyTest',
72 }, 74 },
73 'imageAUrl': 'arcofzorro/16206093933823793653.png', 75 'imageAUrl': 'arcofzorro/16206093933823793653.png',
74 'imageBUrl': 'arcofzorro/16206093933823793653.png', 76 'imageBUrl': 'arcofzorro/16206093933823793653.png',
75 'isDifferent': False, 77 'isDifferent': False,
76 }, 78 },
79 # use alternate imageB base url:
epoger 2014/08/21 16:15:22 AFAICT, the different settings for this parameter
rmistry 2014/08/21 18:15:06 This parameter was read and exercised at line 209.
epoger 2014/08/21 18:25:06 I see that the parameter was read, but the paramet
rmistry 2014/08/21 19:07:01 The parameter's value did modify the results of th
epoger 2014/08/21 19:20:30 Ah, so you added a new file to GS ( gs://chromium-
80 True,
epoger 2014/08/21 16:15:22 Assuming that this parameter is really being exerc
rmistry 2014/08/21 18:15:06 Used the tuple suggestion. Done.
77 ], 81 ],
78 82
79 [ 83 [
80 # inputs: 84 # inputs:
81 'arcofzorro/16206093933823793653.png', 85 'arcofzorro/16206093933823793653.png',
82 'arcofzorro/13786535001616823825.png', 86 'arcofzorro/13786535001616823825.png',
83 None, 87 None,
84 None, 88 None,
85 # expected output: 89 # expected output:
86 { 90 {
87 'differenceData': { 91 'differenceData': {
88 'maxDiffPerChannel': [255, 255, 247], 92 'maxDiffPerChannel': [255, 255, 247],
89 'numDifferingPixels': 662, 93 'numDifferingPixels': 662,
90 'percentDifferingPixels': 0.0662, 94 'percentDifferingPixels': 0.0662,
91 'perceptualDifference': 0.06620300000000157, 95 'perceptualDifference': 0.06620300000000157,
92 'diffUrl': 'arcofzorro_16206093933823793653_png_png-vs-' + 96 'diffUrl': 'arcofzorro_16206093933823793653_png_png-vs-' +
93 'arcofzorro_13786535001616823825_png_png.png', 97 'arcofzorro_13786535001616823825_png_png.png',
94 'whiteDiffUrl': 'arcofzorro_16206093933823793653_png_png' + 98 'whiteDiffUrl': 'arcofzorro_16206093933823793653_png_png' +
95 '-vs-arcofzorro_13786535001616823825_png_png.png', 99 '-vs-arcofzorro_13786535001616823825_png_png.png',
96 }, 100 },
97 'imageAUrl': 'arcofzorro/16206093933823793653.png', 101 'imageAUrl': 'arcofzorro/16206093933823793653.png',
98 'imageBUrl': 'arcofzorro/13786535001616823825.png', 102 'imageBUrl': 'arcofzorro/13786535001616823825.png',
99 'isDifferent': True, 103 'isDifferent': True,
100 }, 104 },
105 # use alternate imageB base url:
106 False,
101 ], 107 ],
102 108
103 [ 109 [
104 # inputs: 110 # inputs:
105 'gradients_degenerate_2pt/10552995703607727960.png', 111 'gradients_degenerate_2pt/10552995703607727960.png',
106 'gradients_degenerate_2pt/11198253335583713230.png', 112 'gradients_degenerate_2pt/11198253335583713230.png',
107 { 113 {
108 'ignoreFailure': True, 114 'ignoreFailure': True,
109 'bugs': [1001, 1002], 115 'bugs': [1001, 1002],
110 }, 116 },
(...skipping 23 matching lines...) Expand all
134 'extraColumns': { 140 'extraColumns': {
135 'builder': 'MyBuilder', 141 'builder': 'MyBuilder',
136 'test': 'MyTest', 142 'test': 'MyTest',
137 }, 143 },
138 'imageAUrl': 144 'imageAUrl':
139 'gradients_degenerate_2pt/10552995703607727960.png', 145 'gradients_degenerate_2pt/10552995703607727960.png',
140 'imageBUrl': 146 'imageBUrl':
141 'gradients_degenerate_2pt/11198253335583713230.png', 147 'gradients_degenerate_2pt/11198253335583713230.png',
142 'isDifferent': True, 148 'isDifferent': True,
143 }, 149 },
150 # use alternate imageB base url:
151 False,
144 ], 152 ],
145 153
146 # Test fix for http://skbug.com/2368 -- how do we handle an ImagePair 154 # Test fix for http://skbug.com/2368 -- how do we handle an ImagePair
147 # missing one of its images? 155 # missing one of its images?
148 [ 156 [
149 # inputs: 157 # inputs:
150 'arcofzorro/16206093933823793653.png', 158 'arcofzorro/16206093933823793653.png',
151 'nonexistentDir/111111.png', 159 'nonexistentDir/111111.png',
152 { 160 {
153 'ignoreFailure': True, 161 'ignoreFailure': True,
(...skipping 10 matching lines...) Expand all
164 'ignoreFailure': True, 172 'ignoreFailure': True,
165 }, 173 },
166 'extraColumns': { 174 'extraColumns': {
167 'builder': 'MyBuilder', 175 'builder': 'MyBuilder',
168 'test': 'MyTest', 176 'test': 'MyTest',
169 }, 177 },
170 'imageAUrl': 'arcofzorro/16206093933823793653.png', 178 'imageAUrl': 'arcofzorro/16206093933823793653.png',
171 'imageBUrl': 'nonexistentDir/111111.png', 179 'imageBUrl': 'nonexistentDir/111111.png',
172 'isDifferent': True, 180 'isDifferent': True,
173 }, 181 },
182 # use alternate imageB base url:
183 False,
174 ], 184 ],
175 185
176 # One of the two images is missing, but download_all_images=True so we 186 # One of the two images is missing, but download_all_images=True so we
177 # should download it anyway. 187 # should download it anyway.
178 [ 188 [
179 # inputs: 189 # inputs:
180 None, 190 None,
181 'arcofzorro/13786535001616823825.png', 191 'arcofzorro/13786535001616823825.png',
182 None, 192 None,
183 None, 193 None,
184 # expected output: 194 # expected output:
185 { 195 {
186 'imageAUrl': None, 196 'imageAUrl': None,
187 'imageBUrl': 'arcofzorro/13786535001616823825.png', 197 'imageBUrl': 'arcofzorro/13786535001616823825.png',
188 'isDifferent': True, 198 'isDifferent': True,
189 }, 199 },
200 # use alternate imageB base url:
201 False,
190 ], 202 ],
191 203
192 ] 204 ]
193 205
194 db = imagediffdb.ImageDiffDB(self.temp_dir) 206 db = imagediffdb.ImageDiffDB(self.temp_dir)
195 for selftest in selftests: 207 for selftest in selftests:
208 imageA_base_url = IMG_URL_BASE
209 if selftest[5]:
210 imageB_base_url = ALT_IMG_URL_BASE
211 else:
212 imageB_base_url = IMG_URL_BASE
196 image_pair = imagepair.ImagePair( 213 image_pair = imagepair.ImagePair(
197 image_diff_db=db, 214 image_diff_db=db,
198 base_url=IMG_URL_BASE, 215 imageA_base_url=imageA_base_url,
216 imageB_base_url=imageB_base_url,
199 imageA_relative_url=selftest[0], 217 imageA_relative_url=selftest[0],
200 imageB_relative_url=selftest[1], 218 imageB_relative_url=selftest[1],
201 expectations=selftest[2], 219 expectations=selftest[2],
202 extra_columns=selftest[3], 220 extra_columns=selftest[3],
203 download_all_images=True) 221 download_all_images=True)
204 self.assertEqual(image_pair.as_dict(), selftest[4]) 222 self.assertEqual(image_pair.as_dict(), selftest[4])
205 223
206 224
207 def main(): 225 def main():
208 suite = unittest.TestLoader().loadTestsFromTestCase(ImagePairTest) 226 suite = unittest.TestLoader().loadTestsFromTestCase(ImagePairTest)
209 unittest.TextTestRunner(verbosity=2).run(suite) 227 unittest.TextTestRunner(verbosity=2).run(suite)
210 228
211 229
212 if __name__ == '__main__': 230 if __name__ == '__main__':
213 main() 231 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698