Index: dashboard/dashboard/elements/test-picker.html |
diff --git a/dashboard/dashboard/elements/test-picker.html b/dashboard/dashboard/elements/test-picker.html |
index 68495461505c96428351c22ac83892edb9a83538..ad80c3685487dbca6e4033f841af04d3f017536a 100644 |
--- a/dashboard/dashboard/elements/test-picker.html |
+++ b/dashboard/dashboard/elements/test-picker.html |
@@ -12,7 +12,6 @@ found in the LICENSE file. |
<link rel="import" href="/dashboard/elements/autocomplete-box.html"> |
<link rel="import" href="/dashboard/static/simple_xhr.html"> |
-<link rel="import" href="/dashboard/static/testselection.html"> |
<dom-module id="test-picker"> |
<template> |
@@ -385,8 +384,7 @@ found in the LICENSE file. |
}, |
updateAddButtonState: function() { |
- var selection = this.getCurrentSelection(); |
- this.enableAddSeries = selection != null && selection.isValid(); |
+ this.enableAddSeries = this.getCurrentSelection() instanceof Array; |
}, |
getSubtestAtIndex: function(index) { |
@@ -438,11 +436,13 @@ found in the LICENSE file. |
* Handler for drag start event for series drag button. |
*/ |
onSeriesButtonDragStart: function(event, detail) { |
- var selection = this.getCurrentSelection(); |
- var testPathAndSelected = selection.getTestPathAndSelectedSeries(); |
event.dataTransfer.setData('type', 'seriesdnd'); |
event.dataTransfer.setData( |
- 'data', JSON.stringify(testPathAndSelected)); |
+ 'data', JSON.stringify({ |
+ mainPath: this.getCurrentSelectedPath(), |
+ selectedPaths: this.getCurrentSelection(), |
+ unselectedPaths: this.getCurrentUnselected() |
+ })); |
event.dataTransfer.effectAllowed = 'copy'; |
}, |
@@ -455,72 +455,92 @@ found in the LICENSE file. |
/** |
* Gets the current selection from the menus. Returns null unless there |
- * are valid test selection. |
+ * is a valid selection. |
*/ |
getCurrentSelection: function() { |
- // Up to subtest menu. |
- for (var i = 0; i < 3; i++) { |
- var menu = this.getSelectionMenu(i); |
+ var level = 0; |
+ var parts = []; |
+ while (true) { |
+ var menu = this.getSelectionMenu(level); |
if (!menu || !menu.selectedItem) { |
- return null; |
+ // A selection is only valid if it specifies at least one subtest |
+ // component, which is the third level. |
+ if (level <= 2) return null; |
+ break; |
+ } else { |
+ // We want to collect all the subtest components so we can form |
+ // the full test path after this loop is done. |
+ if (level >= 2) parts.push(menu.selectedItem.name); |
} |
+ level += 1; |
} |
- var suite = this.getSelectionMenu(0).selectedItem; |
- var selection = new testselection.TestSelection(this.testSuites); |
- var testPathAndSelected = this.addTestPathFromSubtestDict( |
- this.subtestDict, suite.name, 2); |
+ var suite = this.getSelectionMenu(0).selectedItem.name; |
var bot = this.getCheckedBot(); |
- for (var j = 0; j < testPathAndSelected.length; j++) { |
- var fullTestPath = bot + '/' + testPathAndSelected[j][0]; |
- selection.addTestPath(fullTestPath, testPathAndSelected[j][1]); |
- } |
+ parts.unshift(suite); |
+ parts.unshift(bot); |
+ |
+ var path = parts.join('/'); |
- return selection; |
+ if (this.currentSelectedPath_ === path) |
+ return this.currentSelectedTests_; |
+ this.sendListTestsRequest(path); |
+ return null; |
}, |
- /** |
- * This method recursively add test path from a subtestDict. Selected |
- * series are added at the last level of the menu. |
- * @return {Array} List of pair of test path to list of selected series |
- * name. |
- */ |
- addTestPathFromSubtestDict: function(subtestDict, testPath, level) { |
- if (!subtestDict) { |
- return []; |
+ getCurrentSelectedPath: function() { |
+ return this.currentSelectedPath_; |
+ }, |
+ |
+ getCurrentUnselected: function() { |
+ return this.currentUnselectedTests_; |
+ }, |
+ |
+ sendListTestsRequest: function(path) { |
+ var params = { |
+ type: 'test_path_dict' |
+ }; |
+ |
+ params.test_path_dict = {}; |
+ params.test_path_dict[path] = 'core'; |
+ params.test_path_dict = JSON.stringify(params.test_path_dict); |
+ |
+ if (this.listTestsUnselectedXhr) { |
+ this.listTestsUnselectedXhr.abort(); |
+ this.listTestsUnselectedXhr = null; |
} |
- var testPathAndSelected = []; |
- var nextMenu = this.getSelectionMenu(level + 1); |
- // If this is the last menu with selection. |
- var isLastLevel = (level == this.selectionModels.length - 1 || |
- !nextMenu || |
- !nextMenu.selectedItem); |
- |
- var item = this.getSelectionMenu(level).selectedItem; |
- if (item) { |
- var name = item.name; |
- var nextTestPath = testPath + '/' + name; |
- var selectedSeries = []; |
- if (isLastLevel) { |
- if (subtestDict[name]['has_rows']) { |
- selectedSeries.push(name); |
- } |
- // Select important traces by default. |
- var nextSubtestDict = subtestDict[name]['sub_tests']; |
- for (var subName in nextSubtestDict) { |
- if (nextSubtestDict[subName]['has_rows'] && |
- testselection.isImportant(nextTestPath + '/' + subName)) { |
- selectedSeries.push(subName); |
- } |
- } |
- testPathAndSelected.push([nextTestPath, selectedSeries]); |
- } else { |
- var results = this.addTestPathFromSubtestDict( |
- subtestDict[name]['sub_tests'], nextTestPath, level + 1); |
- testPathAndSelected.push.apply(testPathAndSelected, results); |
- } |
+ |
+ this.listTestsUnselectedXhr = simple_xhr.send( |
+ '/list_tests', |
+ params, |
+ function(response) { |
+ this.currentUnselectedTests_ = response; |
+ }.bind(this), |
+ function(error) { |
+ if (error) console.log('Error from retCurrentSelection.'); |
+ }.bind(this) |
+ ); |
+ |
+ params.return_selected = '1'; |
+ |
+ if (this.listTestsXhr) { |
+ this.listTestsXhr.abort(); |
+ this.listTestsXhr = null; |
} |
- return testPathAndSelected; |
+ |
+ this.listTestsXhr = simple_xhr.send( |
+ '/list_tests', |
+ params, |
+ function(response) { |
+ this.currentSelectedPath_ = path; |
+ this.currentSelectedTests_ = response; |
+ this.updateSubtestMenus(2); |
+ }.bind(this), |
+ function(error) { |
+ if (error) console.log('Error from retCurrentSelection.'); |
+ this.loading = false; |
+ }.bind(this) |
+ ); |
}, |
/** |