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

Side by Side Diff: tests/selenium/pdiff_test.py

Issue 235041: Modified output format to be accepted by Pulse. Updated DEPS to include newer... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 11 years, 2 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
« no previous file with comments | « tests/selenium/main.py ('k') | tests/selenium/test_runner.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import os 1 import os
2 import re 2 import re
3 import subprocess 3 import subprocess
4 import unittest 4 import unittest
5 import sys 5 import sys
6 6
7 import selenium_utilities 7 import selenium_utilities
8 import selenium_constants 8 import selenium_constants
9 9
10 class PDiffTest(unittest.TestCase): 10 class PDiffTest(unittest.TestCase):
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 use_downsample = True 56 use_downsample = True
57 elif (opt.startswith("pdiff_edge_ignore_off")): 57 elif (opt.startswith("pdiff_edge_ignore_off")):
58 use_edge = False 58 use_edge = False
59 elif (opt.startswith("pdiff_edge_threshold")): 59 elif (opt.startswith("pdiff_edge_threshold")):
60 edge_threshold = selenium_utilities.GetArgument(opt) 60 edge_threshold = selenium_utilities.GetArgument(opt)
61 61
62 results = [] 62 results = []
63 # Loop over number of screenshots. 63 # Loop over number of screenshots.
64 for screenshot_no in range(self.num_screenshots): 64 for screenshot_no in range(self.num_screenshots):
65 # Find reference image. 65 # Find reference image.
66 shotname = self.screenshot_name + str(screenshot_no + 1)
66 J = os.path.join 67 J = os.path.join
67 platform_img_path = J(self.ref_dir, 68 platform_img_path = J(self.ref_dir,
68 selenium_constants.PLATFORM_SCREENSHOT_DIR, 69 selenium_constants.PLATFORM_SCREENSHOT_DIR,
69 self.screenshot_name + str(screenshot_no + 1) + 70 shotname + '_reference.png')
70 '_reference.png')
71 reg_img_path = J(self.ref_dir, 71 reg_img_path = J(self.ref_dir,
72 selenium_constants.DEFAULT_SCREENSHOT_DIR, 72 selenium_constants.DEFAULT_SCREENSHOT_DIR,
73 self.screenshot_name + str(screenshot_no + 1) + 73 shotname + '_reference.png')
74 '_reference.png')
75 74
76 if os.path.exists(platform_img_path): 75 if os.path.exists(platform_img_path):
77 ref_img_path = platform_img_path 76 ref_img_path = platform_img_path
78 elif os.path.exists(reg_img_path): 77 elif os.path.exists(reg_img_path):
79 ref_img_path = reg_img_path 78 ref_img_path = reg_img_path
80 else: 79 else:
81 self.fail('Reference image for ' + self.screenshot_name + ' not found.' 80 self.fail('Reference image for ' + shotname + ' not found.')
82 + '\nNeither file exists %s NOR %s' %
83 (reg_img_path, platform_img_path))
84 81
85 # Find generated image. 82 # Find generated image.
86 gen_img_path = J(self.gen_dir, self.screenshot_name + 83 gen_img_path = J(self.gen_dir, shotname + '.png')
87 str(screenshot_no + 1) + '.png') 84 diff_img_path = J(self.gen_dir, 'cmp_' + shotname + '.png')
88 diff_img_path = J(self.gen_dir, 'cmp_' + self.screenshot_name +
89 str(screenshot_no + 1) + '.png')
90 85
91 self.assertTrue(os.path.exists(gen_img_path), 86 self.assertTrue(os.path.exists(gen_img_path),
92 'Generated screenshot for ' + self.screenshot_name + 87 'Generated screenshot for ' + shotname + ' not found.\n')
93 ' not found.\nFile does not exist: %s' % gen_img_path)
94 88
95 # Run perceptual diff 89 # Run perceptual diff
96 arguments = [self.pdiff_path, 90 arguments = [self.pdiff_path,
97 ref_img_path, 91 ref_img_path,
98 gen_img_path, 92 gen_img_path,
99 "-output", diff_img_path, 93 "-output", diff_img_path,
100 "-fov", "45", 94 "-fov", "45",
101 "-alphaThreshold", alpha_threshold, 95 "-alphaThreshold", alpha_threshold,
102 # Turn on verbose output for the percetual diff so we 96 # Turn on verbose output for the percetual diff so we
103 # can see how far off we are on the threshold. 97 # can see how far off we are on the threshold.
(...skipping 15 matching lines...) Expand all
119 stderr=subprocess.PIPE) 113 stderr=subprocess.PIPE)
120 (pdiff_stdout, pdiff_stderr) = pdiff_pipe.communicate() 114 (pdiff_stdout, pdiff_stderr) = pdiff_pipe.communicate()
121 result = pdiff_pipe.returncode 115 result = pdiff_pipe.returncode
122 # Find out how many pixels were different by looking at the output. 116 # Find out how many pixels were different by looking at the output.
123 pixel_re = re.compile("(\d+) pixels are different", re.DOTALL) 117 pixel_re = re.compile("(\d+) pixels are different", re.DOTALL)
124 pixel_match = pixel_re.search(pdiff_stdout) 118 pixel_match = pixel_re.search(pdiff_stdout)
125 different_pixels = "0" 119 different_pixels = "0"
126 if pixel_match: 120 if pixel_match:
127 different_pixels = pixel_match.group(1) 121 different_pixels = pixel_match.group(1)
128 122
129 results += [(gen_img_path, int(different_pixels))] 123 results += [(shotname, int(different_pixels))]
130 124
131 all_tests_passed = True 125 all_tests_passed = True
132 msg = "Pixel Threshold is %s. Failing screenshots:\n" % pixel_threshold 126 msg = "Pixel threshold is %s. Failing screenshots:\n" % pixel_threshold
133 for path, pixels in results: 127 for name, pixels in results:
134 if pixels >= pixel_threshold: 128 if pixels >= pixel_threshold:
135 all_tests_passed = False 129 all_tests_passed = False
136 msg += " %s, differing by %s\n" % (path, str(pixels)) 130 msg += " %s, differing by %s\n" % (name, str(pixels))
137 131
138 if not all_tests_passed: 132 self.assertTrue(all_tests_passed, msg)
139 self.assertTrue(all_tests_passed, msg)
OLDNEW
« no previous file with comments | « tests/selenium/main.py ('k') | tests/selenium/test_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698