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

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: add console.error 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('ct-results-comparison');
62 comparison.setAttribute('type', resultType);
63
64 if (results.kActualKind in resultsURLsByKind)
65 comparison.setAttribute('actualUrl', resultsURLsByKind[results.k ActualKind]);
esprehn 2014/06/23 05:25:05 Polymer is going to create properties for you, you
ojan 2014/06/23 05:43:32 I was picturing after ResultsGrid was converted to
66 if (results.kExpectedKind in resultsURLsByKind)
67 comparison.setAttribute('expectedUrl', resultsURLsByKind[results .kExpectedKind]);
68 if (results.kDiffKind in resultsURLsByKind)
69 comparison.setAttribute('diffUrl', resultsURLsByKind[results.kDi ffKind]);
70
71 this.appendChild(comparison);
151 }.bind(this)); 72 }.bind(this));
73
152 if (!this.children.length) 74 if (!this.children.length)
153 this.textContent = 'No results to display.' 75 this.textContent = 'No results to display.'
154 } 76 }
155 }); 77 });
156 78
157 ui.results.ResultsDetails = base.extends('div', { 79 ui.results.ResultsDetails = base.extends('div', {
158 init: function(delegate, failureInfo) 80 init: function(delegate, failureInfo)
159 { 81 {
160 this.className = 'results-detail'; 82 this.className = 'results-detail';
161 this._delegate = delegate; 83 this._delegate = delegate;
162 this._failureInfo = failureInfo; 84 this._failureInfo = failureInfo;
163 this._haveShownOnce = false; 85 this._haveShownOnce = false;
164 }, 86 },
165 show: function() { 87 show: function() {
166 if (this._haveShownOnce) 88 if (this._haveShownOnce)
167 return; 89 return;
168 this._haveShownOnce = true; 90 this._haveShownOnce = true;
169 this._delegate.fetchResultsURLs(this._failureInfo).then(function(results URLs) { 91 this._delegate.fetchResultsURLs(this._failureInfo).then(function(results URLs) {
170 var resultsGrid = new ui.results.ResultsGrid(); 92 var resultsGrid = new ui.results.ResultsGrid();
171 resultsGrid.addResults(resultsURLs); 93 resultsGrid.addResults(resultsURLs);
172 94
173 $(this).empty().append( 95 $(this).empty().append(
174 new ui.actions.List([ 96 new ui.actions.List([
175 new ui.actions.Previous(), 97 new ui.actions.Previous(),
176 new ui.actions.Next() 98 new ui.actions.Next()
177 ])).append(resultsGrid); 99 ])).append(resultsGrid);
178
179
180 }.bind(this)); 100 }.bind(this));
181 }, 101 },
182 }); 102 });
183 103
184 function isAnyReftest(testName, resultsByTest) 104 function isAnyReftest(testName, resultsByTest)
185 { 105 {
186 return Object.keys(resultsByTest[testName]).map(function(builder) { 106 return Object.keys(resultsByTest[testName]).map(function(builder) {
187 return resultsByTest[testName][builder]; 107 return resultsByTest[testName][builder];
188 }).some(function(resultNode) { 108 }).some(function(resultNode) {
189 return resultNode.reftest_type && resultNode.reftest_type.length; 109 return resultNode.reftest_type && resultNode.reftest_type.length;
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 { 376 {
457 this._testSelector.firstResult() 377 this._testSelector.firstResult()
458 }, 378 },
459 currentTestName: function() 379 currentTestName: function()
460 { 380 {
461 return this._testSelector.currentTestName() 381 return this._testSelector.currentTestName()
462 } 382 }
463 }); 383 });
464 384
465 })(); 385 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698