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

Side by Side Diff: trunk/src/chrome/test/functional/ispy/server/main_view_handler.py

Issue 104793008: Revert 240226 "[I-Spy] Add support for rebaselining expectations..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years 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
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Request handler to serve the main_view page.""" 5 """Request handler to serve the main_view page."""
6 6
7 import jinja2 7 import jinja2
8 import json 8 import json
9 import os 9 import os
10 import re 10 import re
11 import sys 11 import sys
12 import webapp2 12 import webapp2
13 13
14 from common import chrome_utils 14 from ..common import constants
15 from common import constants 15 from ..common import ispy_utils
16 from common import ispy_utils
17 16
18 import gs_bucket 17 import gs_bucket
19 import views 18 import views
20 19
21 JINJA = jinja2.Environment( 20 JINJA = jinja2.Environment(
22 loader=jinja2.FileSystemLoader(os.path.dirname(views.__file__)), 21 loader=jinja2.FileSystemLoader(os.path.dirname(views.__file__)),
23 extensions=['jinja2.ext.autoescape']) 22 extensions=['jinja2.ext.autoescape'])
24 23
25 24
26 class MainViewHandler(webapp2.RequestHandler): 25 class MainViewHandler(webapp2.RequestHandler):
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 60
62 This method will produce a list of failure-rows that are sorted 61 This method will produce a list of failure-rows that are sorted
63 in descending order by number of different pixels. 62 in descending order by number of different pixels.
64 63
65 Args: 64 Args:
66 test_run: The name of the test_run to render failure rows from. 65 test_run: The name of the test_run to render failure rows from.
67 ispy: An instance of ispy_utils.ISpyUtils. 66 ispy: An instance of ispy_utils.ISpyUtils.
68 """ 67 """
69 paths = set([path for path in ispy.GetAllPaths('failures/' + test_run) 68 paths = set([path for path in ispy.GetAllPaths('failures/' + test_run)
70 if path.endswith('actual.png')]) 69 if path.endswith('actual.png')])
71 can_rebaseline = chrome_utils.ChromeUtils(
72 ispy.cloud_bucket).CanRebaselineToTestRun(test_run)
73 rows = [self._CreateRow(test_run, path, ispy) for path in paths] 70 rows = [self._CreateRow(test_run, path, ispy) for path in paths]
74 71 if rows:
75 # Function that sorts by the different_pixels field in the failure-info. 72 # Function that sorts by the different_pixels field in the failure-info.
76 def _Sorter(a, b): 73 def _Sorter(a, b):
77 return cmp(b['percent_different'], 74 return cmp(b['percent_different'],
78 a['percent_different']) 75 a['percent_different'])
79 template = JINJA.get_template('main_view.html') 76 template = JINJA.get_template('main_view.html')
80 self.response.write( 77 self.response.write(
81 template.render({'comparisons': sorted(rows, _Sorter), 78 template.render({'comparisons': sorted(rows, _Sorter),
82 'test_run': test_run, 79 'test_run': test_run}))
83 'can_rebaseline': can_rebaseline})) 80 else:
81 template = JINJA.get_template('empty_view.html')
82 self.response.write(template.render())
84 83
85 def _CreateRow(self, test_run, path, ispy): 84 def _CreateRow(self, test_run, path, ispy):
86 """Creates one failure-row. 85 """Creates one failure-row.
87 86
88 This method builds a dictionary with the data necessary to display a 87 This method builds a dictionary with the data necessary to display a
89 failure in the main_view html template. 88 failure in the main_view html template.
90 89
91 Args: 90 Args:
92 test_run: The name of the test_run the failure is in. 91 test_run: The name of the test_run the failure is in.
93 path: A path to the failure's actual.png file. 92 path: A path to the failure's actual.png file.
(...skipping 13 matching lines...) Expand all
107 res['expectation'], 'expected.png') 106 res['expectation'], 'expected.png')
108 diff = ispy_utils.GetFailurePath(test_run, res['expectation'], 'diff.png') 107 diff = ispy_utils.GetFailurePath(test_run, res['expectation'], 'diff.png')
109 res['percent_different'] = res['info']['fraction_different'] * 100 108 res['percent_different'] = res['info']['fraction_different'] * 100
110 res['expected_path'] = expected 109 res['expected_path'] = expected
111 res['diff_path'] = diff 110 res['diff_path'] = diff
112 res['actual_path'] = path 111 res['actual_path'] = path
113 res['expected'] = ispy.cloud_bucket.GetImageURL(expected) 112 res['expected'] = ispy.cloud_bucket.GetImageURL(expected)
114 res['diff'] = ispy.cloud_bucket.GetImageURL(diff) 113 res['diff'] = ispy.cloud_bucket.GetImageURL(diff)
115 res['actual'] = ispy.cloud_bucket.GetImageURL(path) 114 res['actual'] = ispy.cloud_bucket.GetImageURL(path)
116 return res 115 return res
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698