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

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

Issue 334533003: rebaseline_server: delete no-longer-used weightedDiffMeasure (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 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 2013 Google Inc. 4 Copyright 2013 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 imagediffdb.py 9 Test imagediffdb.py
10 """ 10 """
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 TODO(epoger): Instead of hitting Google Storage, we should read image 50 TODO(epoger): Instead of hitting Google Storage, we should read image
51 files from local disk using a file:// IMG_URL_BASE. 51 files from local disk using a file:// IMG_URL_BASE.
52 """ 52 """
53 # params for each self-test: 53 # params for each self-test:
54 # 0. expected image locator 54 # 0. expected image locator
55 # 1. expected image URL 55 # 1. expected image URL
56 # 2. actual image locator 56 # 2. actual image locator
57 # 3. actual image URL 57 # 3. actual image URL
58 # 4. expected percent_pixels_differing (as a string, to 4 decimal places) 58 # 4. expected percent_pixels_differing (as a string, to 4 decimal places)
59 # 5. expected weighted_diff_measure (as a string, to 4 decimal places) 59 # 5. expected perceptual difference (as a string, to 4 decimal places)
60 # 6. expected perceptual difference (as a string, to 4 decimal places) 60 # 6. expected max_diff_per_channel
61 # 7. expected max_diff_per_channel
62 selftests = [ 61 selftests = [
63 [ 62 [
64 'arcofzorro/16206093933823793653', 63 'arcofzorro/16206093933823793653',
65 IMG_URL_BASE + 'arcofzorro/16206093933823793653.png', 64 IMG_URL_BASE + 'arcofzorro/16206093933823793653.png',
66 'arcofzorro/13786535001616823825', 65 'arcofzorro/13786535001616823825',
67 IMG_URL_BASE + 'arcofzorro/13786535001616823825.png', 66 IMG_URL_BASE + 'arcofzorro/13786535001616823825.png',
68 '0.0662', '0.0113', '0.0662', [255, 255, 247], 67 '0.0662', '0.0662', [255, 255, 247],
69 ], 68 ],
70 [ 69 [
71 'gradients_degenerate_2pt/10552995703607727960', 70 'gradients_degenerate_2pt/10552995703607727960',
72 IMG_URL_BASE + 'gradients_degenerate_2pt/10552995703607727960.png', 71 IMG_URL_BASE + 'gradients_degenerate_2pt/10552995703607727960.png',
73 'gradients_degenerate_2pt/11198253335583713230', 72 'gradients_degenerate_2pt/11198253335583713230',
74 IMG_URL_BASE + 'gradients_degenerate_2pt/11198253335583713230.png', 73 IMG_URL_BASE + 'gradients_degenerate_2pt/11198253335583713230.png',
75 '100.0000', '66.6667', '100.0000', [255, 0, 255], 74 '100.0000', '100.0000', [255, 0, 255],
76 ], 75 ],
77 ] 76 ]
78 77
79 # Add all image pairs to the database 78 # Add all image pairs to the database
80 db = imagediffdb.ImageDiffDB(self._temp_dir) 79 db = imagediffdb.ImageDiffDB(self._temp_dir)
81 for selftest in selftests: 80 for selftest in selftests:
82 retval = db.add_image_pair( 81 retval = db.add_image_pair(
83 expected_image_locator=selftest[0], expected_image_url=selftest[1], 82 expected_image_locator=selftest[0], expected_image_url=selftest[1],
84 actual_image_locator=selftest[2], actual_image_url=selftest[3]) 83 actual_image_locator=selftest[2], actual_image_url=selftest[3])
85 84
86 # Fetch each image pair from the database 85 # Fetch each image pair from the database
87 for selftest in selftests: 86 for selftest in selftests:
88 record = db.get_diff_record(expected_image_locator=selftest[0], 87 record = db.get_diff_record(expected_image_locator=selftest[0],
89 actual_image_locator=selftest[2]) 88 actual_image_locator=selftest[2])
90 self.assertEqual('%.4f' % record.get_percent_pixels_differing(), 89 self.assertEqual('%.4f' % record.get_percent_pixels_differing(),
91 selftest[4]) 90 selftest[4])
92 self.assertEqual('%.4f' % record.get_weighted_diff_measure(), selftest[5]) 91 self.assertEqual('%.4f' % record.get_perceptual_difference(), selftest[5])
93 self.assertEqual('%.4f' % record.get_perceptual_difference(), selftest[6]) 92 self.assertEqual(record.get_max_diff_per_channel(), selftest[6])
94 self.assertEqual(record.get_max_diff_per_channel(), selftest[7])
95 93
96 94
97 def main(): 95 def main():
98 suite = unittest.TestLoader().loadTestsFromTestCase(ImageDiffDbTest) 96 suite = unittest.TestLoader().loadTestsFromTestCase(ImageDiffDbTest)
99 unittest.TextTestRunner(verbosity=2).run(suite) 97 unittest.TextTestRunner(verbosity=2).run(suite)
100 98
101 99
102 if __name__ == '__main__': 100 if __name__ == '__main__':
103 main() 101 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698