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

Unified Diff: chrome/test/data/webui/history_browsertest.js

Issue 12217015: History: Fix selecting multiple visits. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 10 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 | « chrome/browser/resources/history/history.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/history_browsertest.js
diff --git a/chrome/test/data/webui/history_browsertest.js b/chrome/test/data/webui/history_browsertest.js
index 4455ccefacb77abf0688fd734ca4f9d2fa85f907..c2dc3089ead2d21beb12b19764df4f02f3e5cf79 100644
--- a/chrome/test/data/webui/history_browsertest.js
+++ b/chrome/test/data/webui/history_browsertest.js
@@ -50,6 +50,20 @@ function callFrontendAsync(functionName) {
}
/**
+ * Checks that all the checkboxes in the [|start|, |end|] interval are checked
+ * and that their IDs are properly set. Does that against the checkboxes in
+ * |checked|, starting from the |startInChecked| position.
+ * @param {Array} checked An array of all the relevant checked checkboxes
+ * on this page.
+ * @param {Number} start The starting checkbox id.
+ * @param {Number} end The ending checkbox id.
+ */
+function checkInterval(checked, start, end) {
+ for (var i = start; i <= end; i++)
+ expectEquals('checkbox-' + i, checked[i - start].id);
+}
+
+/**
* Base fixture for History WebUI testing.
* @extends {testing.Test}
* @constructor
@@ -316,3 +330,66 @@ TEST_F('HistoryWebUITest', 'deletion', function() {
});
});
});
+
+/**
+ * Test selecting multiple entries using shift click.
+ */
+TEST_F('HistoryWebUITest', 'multipleSelect', function() {
+ var checkboxes = document.querySelectorAll(
+ '#results-display input[type=checkbox]');
+
+ var getAllChecked = function () {
+ return Array.prototype.slice.call(document.querySelectorAll(
+ '#results-display input[type=checkbox]:checked'));
+ }
+
+ // Make sure that nothing is checked.
+ expectEquals(0, getAllChecked().length);
+
+ var shiftClick = function(el) {
+ el.dispatchEvent(new MouseEvent('click', { shiftKey: true }));
+ };
+
+ // Check the start.
+ shiftClick($('checkbox-4'));
+ // And the end.
+ shiftClick($('checkbox-9'));
+
+ // See if they are checked.
+ var checked = getAllChecked();
+ expectEquals(6, checked.length);
+ checkInterval(checked, 4, 9);
+
+ // Extend the selection.
+ shiftClick($('checkbox-14'));
+
+ checked = getAllChecked();
+ expectEquals(11, checked.length);
+ checkInterval(checked, 4, 14);
+
+ // Now do a normal click on a higher ID box and a shift click on a lower ID
+ // one (test the other way around).
+ $('checkbox-24').click();
+ shiftClick($('checkbox-19'));
+
+ checked = getAllChecked();
+ expectEquals(17, checked.length);
+ // First set of checkboxes (11).
+ checkInterval(checked, 4, 14);
+ // Second set (6).
+ checkInterval(checked.slice(11), 19, 24);
+
+ // Test deselection.
+ $('checkbox-26').click();
+ shiftClick($('checkbox-20'));
+
+ checked = getAllChecked();
+ // checkbox-20 to checkbox-24 should be deselected now.
+ expectEquals(12, checked.length);
+ // First set of checkboxes (11).
+ checkInterval(checked, 4, 14);
+ // Only checkbox-19 should still be selected.
+ expectEquals('checkbox-19', checked[11].id);
+
+ testDone();
+});
« no previous file with comments | « chrome/browser/resources/history/history.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698