Chromium Code Reviews| 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..88b1222c5563dbac1dd57261bfb815877942b2c3 100644 |
| --- a/chrome/test/data/webui/history_browsertest.js |
| +++ b/chrome/test/data/webui/history_browsertest.js |
| @@ -316,3 +316,56 @@ 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. |
| + for (var i = 0; i < checkboxes.length; i++) |
| + expectFalse(checkboxes[i].checked); |
|
Patrick Dubroy
2013/02/05 20:43:14
You could also do this with:
expectEqual(docume
Sergiu
2013/02/06 10:52:34
Done, expectFalse doesn't actually work as it seem
|
| + |
| + var getNewEvent = function() { |
|
Patrick Dubroy
2013/02/05 20:43:14
Nit: maybe name this getClickEvent?
Sergiu
2013/02/06 10:52:34
Made it getShiftClickEvent to make it clearer.
|
| + return new MouseEvent('click', { shiftKey: true }); |
| + }; |
| + |
| + // Check the start. |
| + $('checkbox-4').dispatchEvent(getNewEvent()); |
| + // And the end. |
| + $('checkbox-9').dispatchEvent(getNewEvent()); |
| + |
| + // See if they are checked. |
| + for (var i = 0; i < checkboxes.length; i++) { |
| + if (i >= 4 && i <= 9) |
|
Patrick Dubroy
2013/02/05 20:43:14
Again, you could use querySelectorAll('input[type=
Sergiu
2013/02/06 10:52:34
Just for thoroughness I would like to check the id
|
| + expectTrue(checkboxes[i].checked); |
| + else |
| + expectFalse(checkboxes[i].checked); |
| + } |
| + |
| + // Extend the selection. |
| + $('checkbox-14').dispatchEvent(getNewEvent()); |
| + |
| + for (var i = 0; i < checkboxes.length; i++) { |
|
Patrick Dubroy
2013/02/05 20:43:14
Same here.
Sergiu
2013/02/06 10:52:34
Done.
|
| + if (i >= 4 && i <= 14) |
| + expectTrue(checkboxes[i].checked); |
| + else |
| + expectFalse(checkboxes[i].checked); |
| + } |
| + |
| + // 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(getNewEvent()); |
| + |
| + for (var i = 0; i < checkboxes.length; i++) { |
| + if ((i >= 4 && i <= 14) || (i >= 19 && i <=24)) |
| + expectTrue(checkboxes[i].checked); |
| + else |
| + expectFalse(checkboxes[i].checked); |
| + } |
| + |
|
Patrick Dubroy
2013/02/05 20:43:14
One more test I would add:
$('checkbox-26').cli
Sergiu
2013/02/06 10:52:34
Done.
|
| + testDone(); |
| +}); |