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

Side by Side Diff: build/android/pylib/results/presentation/test_results_presentation.py

Issue 2799153008: Add back buttons and load new 'pages' by calling javascript. (Closed)
Patch Set: remove obsolete functions Created 3 years, 8 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
OLDNEW
1 #! /usr/bin/env python 1 #! /usr/bin/env python
2 # 2 #
3 # Copyright 2017 The Chromium Authors. All rights reserved. 3 # Copyright 2017 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 import argparse 7 import argparse
8 import collections 8 import collections
9 import json 9 import json
10 import tempfile 10 import tempfile
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 rowspan: Rowspan HTML attribute. 71 rowspan: Rowspan HTML attribute.
72 """ 72 """
73 return { 73 return {
74 'cell_type': 'links', 74 'cell_type': 'links',
75 'class': html_class, 75 'class': html_class,
76 'links': links, 76 'links': links,
77 'rowspan': rowspan, 77 'rowspan': rowspan,
78 } 78 }
79 79
80 80
81 def action_cell(action, data, html_class):
mikecase (-- gone --) 2017/04/07 23:57:20 I do not think we should pass javascript functions
BigBossZhiling 2017/04/10 19:43:51 Acknowledged.
82 """Formats table cell with javascript actions.
83
84 Args:
85 action: Javscript action.
86 data: Data in cell.
87 class: Class for table cell.
88 """
89 return {
90 'cell_type': 'action',
91 'action': action,
92 'data': data,
93 'class': html_class,
94 }
95
96
81 def logs_cell(result): 97 def logs_cell(result):
82 """Formats result logs data for processing in jinja template.""" 98 """Formats result logs data for processing in jinja template."""
83 link_list = [] 99 link_list = []
84 for name, href in result.get('links', {}).iteritems(): 100 for name, href in result.get('links', {}).iteritems():
85 link_list.append(link( 101 link_list.append(link(
86 data=name, 102 data=name,
87 href=href, 103 href=href,
88 target=LinkTarget.NEW_TAB)) 104 target=LinkTarget.NEW_TAB))
89 105
90 if link_list: 106 if link_list:
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 174
159 header_row = [ 175 header_row = [
160 cell(data='suite_name', html_class='text'), 176 cell(data='suite_name', html_class='text'),
161 cell(data='number_success_tests', html_class='number'), 177 cell(data='number_success_tests', html_class='number'),
162 cell(data='number_fail_tests', html_class='number'), 178 cell(data='number_fail_tests', html_class='number'),
163 cell(data='all_tests', html_class='number'), 179 cell(data='all_tests', html_class='number'),
164 cell(data='elapsed_time_ms', html_class='number'), 180 cell(data='elapsed_time_ms', html_class='number'),
165 ] 181 ]
166 182
167 footer_row = [ 183 footer_row = [
168 links_cell( 184 action_cell(
169 links=[ 185 'showTestsOfOneSuiteOnly(\'TOTAL\')',
mikecase (-- gone --) 2017/04/10 17:03:06 nit: use double quotes here instead of \'
BigBossZhiling 2017/04/10 19:43:51 Done.
170 link(href=('?suite=%s' % 'TOTAL'), 186 'TOTAL',
171 target=LinkTarget.CURRENT_TAB, 187 'center'
172 data='TOTAL') 188 ), # TOTAL
173 ],
174 ), # suite_name
175 cell(data=0), # number_success_tests 189 cell(data=0), # number_success_tests
176 cell(data=0), # number_fail_tests 190 cell(data=0), # number_fail_tests
177 cell(data=0), # all_tests 191 cell(data=0), # all_tests
178 cell(data=0), # elapsed_time_ms 192 cell(data=0), # elapsed_time_ms
179 ] 193 ]
180 194
181 suite_row_dict = {} 195 suite_row_dict = {}
182 for test_name, test_results in results_dict.iteritems(): 196 for test_name, test_results in results_dict.iteritems():
183 # TODO(mikecase): This logic doesn't work if there are multiple test runs. 197 # TODO(mikecase): This logic doesn't work if there are multiple test runs.
184 # That is, if 'per_iteration_data' has multiple entries. 198 # That is, if 'per_iteration_data' has multiple entries.
185 # Since we only care about the result of the last test run. 199 # Since we only care about the result of the last test run.
186 result = test_results[-1] 200 result = test_results[-1]
187 201
188 suite_name = (test_name.split('#')[0] if '#' in test_name 202 suite_name = (test_name.split('#')[0] if '#' in test_name
189 else test_name.split('.')[0]) 203 else test_name.split('.')[0])
190 if suite_name in suite_row_dict: 204 if suite_name in suite_row_dict:
191 suite_row = suite_row_dict[suite_name] 205 suite_row = suite_row_dict[suite_name]
192 else: 206 else:
193 suite_row = [ 207 suite_row = [
194 links_cell( 208 action_cell(
195 links=[ 209 'showTestsOfOneSuiteOnly(\'%s\')' % suite_name,
mikecase (-- gone --) 2017/04/10 17:03:06 same here
BigBossZhiling 2017/04/10 19:43:51 Done.
196 link(href=('?suite=%s' % suite_name), 210 suite_name,
197 target=LinkTarget.CURRENT_TAB, 211 'left'
198 data=suite_name)],
199 html_class='left'
200 ), # suite_name 212 ), # suite_name
201 cell(data=0), # number_success_tests 213 cell(data=0), # number_success_tests
202 cell(data=0), # number_fail_tests 214 cell(data=0), # number_fail_tests
203 cell(data=0), # all_tests 215 cell(data=0), # all_tests
204 cell(data=0), # elapsed_time_ms 216 cell(data=0), # elapsed_time_ms
205 ] 217 ]
206 218
207 suite_row_dict[suite_name] = suite_row 219 suite_row_dict[suite_name] = suite_row
208 220
209 suite_row[ALL_COUNT_INDEX]['data'] += 1 221 suite_row[ALL_COUNT_INDEX]['data'] += 1
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 print upload_to_google_bucket(result_html_string.encode('UTF-8'), 332 print upload_to_google_bucket(result_html_string.encode('UTF-8'),
321 args.test_name, args.builder_name, 333 args.test_name, args.builder_name,
322 args.build_number, args.bucket, 334 args.build_number, args.bucket,
323 args.server_url, args.content_type) 335 args.server_url, args.content_type)
324 else: 336 else:
325 raise IOError('--json-file %s not found.' % args.json_file) 337 raise IOError('--json-file %s not found.' % args.json_file)
326 338
327 339
328 if __name__ == '__main__': 340 if __name__ == '__main__':
329 sys.exit(main()) 341 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698