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

Unified Diff: dashboard/dashboard/elements/test-picker.html

Issue 2750313003: Revert of [Dashboard] Start using /list_tests's test_path_dict mode in test-picker (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dashboard/dashboard/elements/report-page.html ('k') | dashboard/dashboard/elements/test-picker-test.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dashboard/dashboard/elements/test-picker.html
diff --git a/dashboard/dashboard/elements/test-picker.html b/dashboard/dashboard/elements/test-picker.html
index ad80c3685487dbca6e4033f841af04d3f017536a..68495461505c96428351c22ac83892edb9a83538 100644
--- a/dashboard/dashboard/elements/test-picker.html
+++ b/dashboard/dashboard/elements/test-picker.html
@@ -12,6 +12,7 @@
<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>
@@ -384,7 +385,8 @@
},
updateAddButtonState: function() {
- this.enableAddSeries = this.getCurrentSelection() instanceof Array;
+ var selection = this.getCurrentSelection();
+ this.enableAddSeries = selection != null && selection.isValid();
},
getSubtestAtIndex: function(index) {
@@ -436,13 +438,11 @@
* 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({
- mainPath: this.getCurrentSelectedPath(),
- selectedPaths: this.getCurrentSelection(),
- unselectedPaths: this.getCurrentUnselected()
- }));
+ 'data', JSON.stringify(testPathAndSelected));
event.dataTransfer.effectAllowed = 'copy';
},
@@ -455,92 +455,72 @@
/**
* Gets the current selection from the menus. Returns null unless there
- * is a valid selection.
+ * are valid test selection.
*/
getCurrentSelection: function() {
- var level = 0;
- var parts = [];
- while (true) {
- var menu = this.getSelectionMenu(level);
+ // Up to subtest menu.
+ for (var i = 0; i < 3; i++) {
+ var menu = this.getSelectionMenu(i);
if (!menu || !menu.selectedItem) {
- // A selection is only valid if it specifies at least one subtest
- // component, which is the third level.
- if (level <= 2) return null;
- break;
+ return null;
+ }
+ }
+
+ var suite = this.getSelectionMenu(0).selectedItem;
+ var selection = new testselection.TestSelection(this.testSuites);
+ var testPathAndSelected = this.addTestPathFromSubtestDict(
+ this.subtestDict, suite.name, 2);
+ var bot = this.getCheckedBot();
+ for (var j = 0; j < testPathAndSelected.length; j++) {
+ var fullTestPath = bot + '/' + testPathAndSelected[j][0];
+ selection.addTestPath(fullTestPath, testPathAndSelected[j][1]);
+ }
+
+ return selection;
+ },
+
+ /**
+ * 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 [];
+ }
+ 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 {
- // 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.name;
- var bot = this.getCheckedBot();
- parts.unshift(suite);
- parts.unshift(bot);
-
- var path = parts.join('/');
-
- if (this.currentSelectedPath_ === path)
- return this.currentSelectedTests_;
- this.sendListTestsRequest(path);
- return null;
- },
-
- 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;
- }
-
- 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;
- }
-
- 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)
- );
+ var results = this.addTestPathFromSubtestDict(
+ subtestDict[name]['sub_tests'], nextTestPath, level + 1);
+ testPathAndSelected.push.apply(testPathAndSelected, results);
+ }
+ }
+ return testPathAndSelected;
},
/**
« no previous file with comments | « dashboard/dashboard/elements/report-page.html ('k') | dashboard/dashboard/elements/test-picker-test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698