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

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: rename_selftest 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
« no previous file with comments | « gm/rebaseline_server/imagediffdb.py ('k') | gm/rebaseline_server/results.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
10
11 TODO(epoger): Modify to use Python's unittest framework.
12 """
13
14 # System-level imports
15 import logging
16
17 # Local imports
18 import imagediffdb
19
20
21 IMAGE_URL_BASE = 'http://chromium-skia-gm.commondatastorage.googleapis.com/gm/bi tmap-64bitMD5/'
22
23 def main():
24 logging.basicConfig(level=logging.INFO)
25
26 # params for each self-test:
27 # 0. expected image locator
28 # 1. expected image URL
29 # 2. actual image locator
30 # 3. actual image URL
31 # 4. expected percent_pixels_differing (as a string, to 4 decimal places)
32 # 5. expected weighted_diff_measure (as a string, to 4 decimal places)
33 selftests = [
34 ['16206093933823793653',
35 IMAGE_URL_BASE + 'arcofzorro/16206093933823793653.png',
36 '13786535001616823825',
37 IMAGE_URL_BASE + 'arcofzorro/13786535001616823825.png',
38 '0.0653', '0.0113'],
39 ]
40
41 # Add all image pairs to the database
42 db = imagediffdb.ImageDiffDB('/tmp/ImageDiffDB')
43 for selftest in selftests:
44 retval = db.add_image_pair(
45 expected_image_locator=selftest[0], expected_image_url=selftest[1],
46 actual_image_locator=selftest[2], actual_image_url=selftest[3])
47
48 # Fetch each image pair from the database
49 for selftest in selftests:
50 record = db.get_diff_record(expected_image_locator=selftest[0],
51 actual_image_locator=selftest[2])
52 assert (('%.4f' % record.get_percent_pixels_differing()) == selftest[4])
53 assert (('%.4f' % record.get_weighted_diff_measure()) == selftest[5])
54
55 logging.info("Self-test completed successfully!")
56
57
58 if __name__ == '__main__':
59 main()
OLDNEW
« no previous file with comments | « gm/rebaseline_server/imagediffdb.py ('k') | gm/rebaseline_server/results.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698