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

Side by Side Diff: gm/rebaseline_server/imagediffdb-test.py

Issue 59283006: rebaseline_server: add pixel diffs, and sorting by diff metrics (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: lots_of_fixes Created 7 years, 1 month 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
Property Changes:
Added: svn:executable
+ *
OLDNEW
(Empty)
1 #!/usr/bin/python
2
3 """
4 Copyright 2013 Google Inc.
5
6 Use of this source code is governed by a BSD-style license that can be
7 found in the LICENSE file.
8
9 Test imagediffdb.py
epoger 2013/11/07 21:11:54 Moved the self-test code into this new file.
jcgregorio 2013/11/08 02:02:29 Please rename to imagediffdb_test.py. A file image
epoger 2013/11/08 16:11:28 Done.
10 """
11
12 # System-level imports
13 import logging
14
15 # Local imports
16 import imagediffdb
17
18
19 IMAGE_URL_BASE = 'http://chromium-skia-gm.commondatastorage.googleapis.com/gm/bi tmap-64bitMD5/'
20
21 def main():
22 logging.basicConfig(level=logging.INFO)
23
24 # params for each self-test:
25 # 0. expected image locator
26 # 1. expected image URL
27 # 2. actual image locator
28 # 3. actual image URL
29 # 4. expected percent_pixels_differing (as a string, to 4 decimal places)
30 # 5. expected weighted_diff_measure (as a string, to 4 decimal places)
31 selftests = [
32 ['16206093933823793653',
33 IMAGE_URL_BASE + 'arcofzorro/16206093933823793653.png',
34 '13786535001616823825',
35 IMAGE_URL_BASE + 'arcofzorro/13786535001616823825.png',
36 '0.0653', '0.0113'],
37 ]
38
39 # Add all image pairs to the database
40 db = imagediffdb.ImageDiffDB('/tmp/ImageDiffDB')
41 for selftest in selftests:
42 retval = db.add_image_pair(
43 expected_image_locator=selftest[0], expected_image_url=selftest[1],
44 actual_image_locator=selftest[2], actual_image_url=selftest[3])
45
46 # Fetch each image pair from the database
47 for selftest in selftests:
jcgregorio 2013/11/08 02:02:29 Either convert tests to use Python's unittest fram
epoger 2013/11/08 16:11:28 Added a TODO at the top of the renamed file.
48 record = db.get_diff_record(expected_image_locator=selftest[0],
49 actual_image_locator=selftest[2])
50 assert (('%.4f' % record.get_percent_pixels_differing()) == selftest[4])
51 assert (('%.4f' % record.get_weighted_diff_measure()) == selftest[5])
52
53 logging.info("Self-test completed successfully!")
54
55
56 if __name__ == '__main__':
57 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698