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

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: Refactor 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..8893fe96e0daa56fbd13a5af697edef9079c1fa4 100644
--- a/chrome/test/data/webui/history_browsertest.js
+++ b/chrome/test/data/webui/history_browsertest.js
@@ -50,6 +50,22 @@ 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.
+ * @param {Number} startInChecked The first position in the |checked| array
+ * to check.
+ */
+function checkInterval(checked, start, end, startInChecked) {
+ for (var i = start; i <= end; i++)
+ expectEquals('checkbox-' + i, checked[i - start + startInChecked].id);
+}
+
+/**
* Base fixture for History WebUI testing.
* @extends {testing.Test}
* @constructor
@@ -316,3 +332,67 @@ 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]');
+
+ // Make sure that nothing is checked.
+ expectEquals(0,
+ document.querySelectorAll(
+ '#results-display input[type=checkbox]:checked').length);
Patrick Dubroy 2013/02/06 18:53:07 All of the duplicated querySelectorAll stuff clutt
Sergiu 2013/02/07 10:18:18 Done.
+
+ var getShiftClickEvent = function() {
+ return new MouseEvent('click', { shiftKey: true });
+ };
+
+ // Check the start.
+ $('checkbox-4').dispatchEvent(getShiftClickEvent());
Patrick Dubroy 2013/02/06 18:53:07 Maybe factor the dispatchEvent out too? Something
Sergiu 2013/02/07 10:18:18 Done.
+ // And the end.
+ $('checkbox-9').dispatchEvent(getShiftClickEvent());
+
+ // See if they are checked.
+ var checked = document.querySelectorAll(
+ '#results-display input[type=checkbox]:checked');
+ expectEquals(6, checked.length);
+ checkInterval(checked, 4, 9, 0);
+
+ // Extend the selection.
+ $('checkbox-14').dispatchEvent(getShiftClickEvent());
+
+ checked = document.querySelectorAll(
+ '#results-display input[type=checkbox]:checked');
+ expectEquals(11, checked.length);
+ checkInterval(checked, 4, 14, 0);
+
+ // 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();
+ $('checkbox-19').dispatchEvent(getShiftClickEvent());
+
+ checked = document.querySelectorAll(
+ '#results-display input[type=checkbox]:checked');
+ expectEquals(17, checked.length);
+ // First set of checkboxes (11).
+ checkInterval(checked, 4, 14, 0);
+ // Second set (6).
+ checkInterval(checked, 19, 24, 11);
Patrick Dubroy 2013/02/06 18:53:07 It might be more clear if you eliminated the last
Sergiu 2013/02/07 10:18:18 Heh, actually it seems like querySelectorAll retur
+
+ // Test deselection.
+ $('checkbox-26').click();
+ $('checkbox-20').dispatchEvent(getShiftClickEvent());
+
+ checked = document.querySelectorAll(
+ '#results-display input[type=checkbox]:checked');
+ // checkbox-20 to checkbox-24 should be deselected now.
+ expectEquals(12, checked.length);
+ // First set of checkboxes (11).
+ checkInterval(checked, 4, 14, 0);
+ // 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