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

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

Issue 106523003: [I-Spy] Add support for rebaselining expectations from the web UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add missing dom.py Created 6 years, 11 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
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 constants 14 from common import chrome_utils
15 from ..common import ispy_utils 15 from common import constants
16 from common import ispy_utils
16 17
17 import gs_bucket 18 import gs_bucket
18 import views 19 import views
19 20
20 JINJA = jinja2.Environment( 21 JINJA = jinja2.Environment(
21 loader=jinja2.FileSystemLoader(os.path.dirname(views.__file__)), 22 loader=jinja2.FileSystemLoader(os.path.dirname(views.__file__)),
22 extensions=['jinja2.ext.autoescape']) 23 extensions=['jinja2.ext.autoescape'])
23 24
24 25
25 class MainViewHandler(webapp2.RequestHandler): 26 class MainViewHandler(webapp2.RequestHandler):
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 61
61 This method will produce a list of failure-rows that are sorted 62 This method will produce a list of failure-rows that are sorted
62 in descending order by number of different pixels. 63 in descending order by number of different pixels.
63 64
64 Args: 65 Args:
65 test_run: The name of the test_run to render failure rows from. 66 test_run: The name of the test_run to render failure rows from.
66 ispy: An instance of ispy_utils.ISpyUtils. 67 ispy: An instance of ispy_utils.ISpyUtils.
67 """ 68 """
68 paths = set([path for path in ispy.GetAllPaths('failures/' + test_run) 69 paths = set([path for path in ispy.GetAllPaths('failures/' + test_run)
69 if path.endswith('actual.png')]) 70 if path.endswith('actual.png')])
71 can_rebaseline = chrome_utils.ChromeUtils(
72 ispy.cloud_bucket).CanRebaselineToTestRun(test_run)
70 rows = [self._CreateRow(test_run, path, ispy) for path in paths] 73 rows = [self._CreateRow(test_run, path, ispy) for path in paths]
71 if rows: 74
72 # Function that sorts by the different_pixels field in the failure-info. 75 # Function that sorts by the different_pixels field in the failure-info.
73 def _Sorter(a, b): 76 def _Sorter(a, b):
74 return cmp(b['percent_different'], 77 return cmp(b['percent_different'],
75 a['percent_different']) 78 a['percent_different'])
76 template = JINJA.get_template('main_view.html') 79 template = JINJA.get_template('main_view.html')
77 self.response.write( 80 self.response.write(
78 template.render({'comparisons': sorted(rows, _Sorter), 81 template.render({'comparisons': sorted(rows, _Sorter),
79 'test_run': test_run})) 82 'test_run': test_run,
80 else: 83 'can_rebaseline': can_rebaseline}))
81 template = JINJA.get_template('empty_view.html')
82 self.response.write(template.render())
83 84
84 def _CreateRow(self, test_run, path, ispy): 85 def _CreateRow(self, test_run, path, ispy):
85 """Creates one failure-row. 86 """Creates one failure-row.
86 87
87 This method builds a dictionary with the data necessary to display a 88 This method builds a dictionary with the data necessary to display a
88 failure in the main_view html template. 89 failure in the main_view html template.
89 90
90 Args: 91 Args:
91 test_run: The name of the test_run the failure is in. 92 test_run: The name of the test_run the failure is in.
92 path: A path to the failure's actual.png file. 93 path: A path to the failure's actual.png file.
(...skipping 13 matching lines...) Expand all
106 res['expectation'], 'expected.png') 107 res['expectation'], 'expected.png')
107 diff = ispy_utils.GetFailurePath(test_run, res['expectation'], 'diff.png') 108 diff = ispy_utils.GetFailurePath(test_run, res['expectation'], 'diff.png')
108 res['percent_different'] = res['info']['fraction_different'] * 100 109 res['percent_different'] = res['info']['fraction_different'] * 100
109 res['expected_path'] = expected 110 res['expected_path'] = expected
110 res['diff_path'] = diff 111 res['diff_path'] = diff
111 res['actual_path'] = path 112 res['actual_path'] = path
112 res['expected'] = ispy.cloud_bucket.GetImageURL(expected) 113 res['expected'] = ispy.cloud_bucket.GetImageURL(expected)
113 res['diff'] = ispy.cloud_bucket.GetImageURL(diff) 114 res['diff'] = ispy.cloud_bucket.GetImageURL(diff)
114 res['actual'] = ispy.cloud_bucket.GetImageURL(path) 115 res['actual'] = ispy.cloud_bucket.GetImageURL(path)
115 return res 116 return res
OLDNEW
« no previous file with comments | « chrome/test/functional/ispy/server/image_handler.py ('k') | chrome/test/functional/ispy/server/rebaseline_handler.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698