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

Side by Side Diff: Tools/GardeningServer/scripts/ui/results.js

Issue 350563002: Port first garden-o-matic component over to polymer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove CSP Created 6 years, 6 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 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 12 matching lines...) Expand all
23 * THE POSSIBILITY OF SUCH DAMAGE. 23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 var ui = ui || {}; 26 var ui = ui || {};
27 ui.results = ui.results || {}; 27 ui.results = ui.results || {};
28 28
29 (function(){ 29 (function(){
30 30
31 var kResultsPrefetchDelayMS = 500; 31 var kResultsPrefetchDelayMS = 500;
32 32
33 ui.results.Comparison = base.extends('div', {
34 init: function()
35 {
36 this.className = 'comparison';
37 this.innerHTML = '<div><h2>Expected</h2><div class="results-container ex pected"></div></div>' +
38 '<div><h2>Actual</h2><div class="results-container actu al"></div></div>' +
39 '<div><h2>Diff</h2><div class="results-container diff"> </div></div>';
40 },
41 _selectorForKind: function(kind)
42 {
43 switch (kind) {
44 case results.kExpectedKind:
45 return '.expected';
46 case results.kActualKind:
47 return '.actual';
48 case results.kDiffKind:
49 return '.diff';
50 }
51 return '.unknown';
52 },
53 update: function(kind, result)
54 {
55 var selector = this._selectorForKind(kind);
56 $(selector, this).empty().append(result);
57 return result;
58 },
59 });
60
61 // We'd really like TextResult and ImageResult to extend a common Result base
62 // class, but we can't seem to do that because they inherit from different
63 // HTMLElements. We could have them inherit from <div>, but that seems lame.
64
65 ui.results.TextResult = base.extends('iframe', {
66 init: function(url)
67 {
68 this.className = 'text-result';
69 this.src = url;
70 }
71 });
72
73 ui.results.ImageResult = base.extends('img', {
74 init: function(url)
75 {
76 this.className = 'image-result';
77 this.src = url;
78 }
79 });
80
81 ui.results.AudioResult = base.extends('audio', {
82 init: function(url)
83 {
84 this.className = 'audio-result';
85 this.src = url;
86 this.controls = 'controls';
87 }
88 });
89
90 function constructorForResultType(type)
91 {
92 if (type == results.kImageType)
93 return ui.results.ImageResult;
94 if (type == results.kAudioType)
95 return ui.results.AudioResult;
96 return ui.results.TextResult;
97 }
98
99 ui.results.ResultsGrid = base.extends('div', { 33 ui.results.ResultsGrid = base.extends('div', {
100 init: function() 34 init: function()
101 { 35 {
102 this.className = 'results-grid'; 36 this.className = 'results-grid';
103 }, 37 },
104 _addResult: function(comparison, constructor, resultsURLsByKind, kind)
105 {
106 var url = resultsURLsByKind[kind];
107 if (!url)
108 return;
109 comparison.update(kind, new constructor(url));
110 },
111 addComparison: function(resultType, resultsURLsByKind)
112 {
113 var comparison = new ui.results.Comparison();
114 var constructor = constructorForResultType(resultType);
115
116 this._addResult(comparison, constructor, resultsURLsByKind, results.kExp ectedKind);
117 this._addResult(comparison, constructor, resultsURLsByKind, results.kAct ualKind);
118 this._addResult(comparison, constructor, resultsURLsByKind, results.kDif fKind);
119
120 this.appendChild(comparison);
121 return comparison;
122 },
123 addRow: function(resultType, url)
124 {
125 var constructor = constructorForResultType(resultType);
126 var view = new constructor(url);
127 this.appendChild(view);
128 return view;
129 },
130 addResults: function(resultsURLs) 38 addResults: function(resultsURLs)
131 { 39 {
132 var resultsURLsByTypeAndKind = {}; 40 var resultsURLsByTypeAndKind = {};
133
134 resultsURLsByTypeAndKind[results.kImageType] = {};
135 resultsURLsByTypeAndKind[results.kAudioType] = {};
136 resultsURLsByTypeAndKind[results.kTextType] = {};
137
138 resultsURLs.forEach(function(url) { 41 resultsURLs.forEach(function(url) {
139 resultsURLsByTypeAndKind[results.resultType(url)][results.resultKind (url)] = url; 42 var resultType = results.resultType(url);
43 if (!resultsURLsByTypeAndKind[resultType])
44 resultsURLsByTypeAndKind[resultType] = {};
45 resultsURLsByTypeAndKind[resultType][results.resultKind(url)] = url;
140 }); 46 });
141 47
142 $.each(resultsURLsByTypeAndKind, function(resultType, resultsURLsByKind) { 48 $.each(resultsURLsByTypeAndKind, function(resultType, resultsURLsByKind) {
143 if ($.isEmptyObject(resultsURLsByKind))
144 return;
145 if (results.kUnknownKind in resultsURLsByKind) { 49 if (results.kUnknownKind in resultsURLsByKind) {
146 // This is something like "crash" that isn't a comparison. 50 // This is something like "crash" that isn't a comparison.
147 this.addRow(resultType, resultsURLsByKind[results.kUnknownKind]) ; 51 var result = document.createElement('iframe');
52 result.src = resultsURLsByKind[results.kUnknownKind];
53 // FIXME: Move this to a stylesheet when we polymerize this comp onent.
54 result.style.border = 0;
55 result.style.width = '100%';
56 result.style.height = '400px';
57 this.appendChild(result);
148 return; 58 return;
149 } 59 }
150 this.addComparison(resultType, resultsURLsByKind); 60
61 var comparison = document.createElement('results-comparison');
62 comparison.type = resultType;
63 comparison.urlsByKind = resultsURLsByKind;
64 this.appendChild(comparison);
151 }.bind(this)); 65 }.bind(this));
66
152 if (!this.children.length) 67 if (!this.children.length)
153 this.textContent = 'No results to display.' 68 this.textContent = 'No results to display.'
154 } 69 }
155 }); 70 });
156 71
157 ui.results.ResultsDetails = base.extends('div', { 72 ui.results.ResultsDetails = base.extends('div', {
158 init: function(delegate, failureInfo) 73 init: function(delegate, failureInfo)
159 { 74 {
160 this.className = 'results-detail'; 75 this.className = 'results-detail';
161 this._delegate = delegate; 76 this._delegate = delegate;
162 this._failureInfo = failureInfo; 77 this._failureInfo = failureInfo;
163 this._haveShownOnce = false; 78 this._haveShownOnce = false;
164 }, 79 },
165 show: function() { 80 show: function() {
166 if (this._haveShownOnce) 81 if (this._haveShownOnce)
167 return; 82 return;
168 this._haveShownOnce = true; 83 this._haveShownOnce = true;
169 this._delegate.fetchResultsURLs(this._failureInfo).then(function(results URLs) { 84 this._delegate.fetchResultsURLs(this._failureInfo).then(function(results URLs) {
170 var resultsGrid = new ui.results.ResultsGrid(); 85 var resultsGrid = new ui.results.ResultsGrid();
171 resultsGrid.addResults(resultsURLs); 86 resultsGrid.addResults(resultsURLs);
172 87
173 $(this).empty().append( 88 $(this).empty().append(
174 new ui.actions.List([ 89 new ui.actions.List([
175 new ui.actions.Previous(), 90 new ui.actions.Previous(),
176 new ui.actions.Next() 91 new ui.actions.Next()
177 ])).append(resultsGrid); 92 ])).append(resultsGrid);
178
179
180 }.bind(this)); 93 }.bind(this));
181 }, 94 },
182 }); 95 });
183 96
184 function isAnyReftest(testName, resultsByTest) 97 function isAnyReftest(testName, resultsByTest)
185 { 98 {
186 return Object.keys(resultsByTest[testName]).map(function(builder) { 99 return Object.keys(resultsByTest[testName]).map(function(builder) {
187 return resultsByTest[testName][builder]; 100 return resultsByTest[testName][builder];
188 }).some(function(resultNode) { 101 }).some(function(resultNode) {
189 return resultNode.reftest_type && resultNode.reftest_type.length; 102 return resultNode.reftest_type && resultNode.reftest_type.length;
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 { 369 {
457 this._testSelector.firstResult() 370 this._testSelector.firstResult()
458 }, 371 },
459 currentTestName: function() 372 currentTestName: function()
460 { 373 {
461 return this._testSelector.currentTestName() 374 return this._testSelector.currentTestName()
462 } 375 }
463 }); 376 });
464 377
465 })(); 378 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698