Index: chrome/test/data/webui/md_bookmarks/list_test.js |
diff --git a/chrome/test/data/webui/md_bookmarks/list_test.js b/chrome/test/data/webui/md_bookmarks/list_test.js |
index d63ddd95ca8ea50dd311d2c71768b0afb4610707..3c7efa8ea769e9e5b4a762a2198d76b7a7eeeed3 100644 |
--- a/chrome/test/data/webui/md_bookmarks/list_test.js |
+++ b/chrome/test/data/webui/md_bookmarks/list_test.js |
@@ -9,14 +9,14 @@ suite('<bookmarks-list>', function() { |
setup(function() { |
store = new bookmarks.TestStore({ |
nodes: testTree(createFolder( |
- '0', |
+ '10', |
[ |
createItem('1'), |
createFolder('3', []), |
createItem('5'), |
createItem('7'), |
])), |
- selectedFolder: '0', |
+ selectedFolder: '10', |
}); |
bookmarks.Store.instance_ = store; |
@@ -42,7 +42,7 @@ suite('<bookmarks-list>', function() { |
customClick(items[0]); |
assertEquals('select-items', store.lastAction.name); |
- assertFalse(store.lastAction.add); |
+ assertTrue(store.lastAction.clear); |
assertEquals('1', store.lastAction.anchor); |
assertDeepEquals(['1'], store.lastAction.items); |
@@ -50,7 +50,7 @@ suite('<bookmarks-list>', function() { |
customClick(items[2], {shiftKey: true, ctrlKey: true}); |
assertEquals('select-items', store.lastAction.name); |
- assertTrue(store.lastAction.add); |
+ assertFalse(store.lastAction.clear); |
assertEquals('1', store.lastAction.anchor); |
assertDeepEquals(['1', '3', '5'], store.lastAction.items); |
}); |
@@ -71,3 +71,84 @@ suite('<bookmarks-list>', function() { |
assertDeepEquals(list.displayedIds_, list.displayedList_.map(n => n.id)); |
}); |
}); |
+ |
+suite('<bookmarks-list> integration test', function() { |
+ var list; |
+ var store; |
+ var items; |
+ |
+ setup(function() { |
+ store = new bookmarks.TestStore({ |
+ nodes: testTree(createFolder( |
+ '10', |
+ [ |
+ createItem('1'), |
+ createFolder('3', []), |
+ createItem('5'), |
+ createItem('7'), |
+ createItem('9'), |
+ ])), |
+ selectedFolder: '10', |
+ }); |
+ bookmarks.Store.instance_ = store; |
+ store.setReducersEnabled(true); |
+ |
+ list = document.createElement('bookmarks-list'); |
+ list.style.height = '100%'; |
+ list.style.width = '100%'; |
+ list.style.position = 'absolute'; |
+ |
+ replaceBody(list); |
+ Polymer.dom.flush(); |
+ |
+ items = list.root.querySelectorAll('bookmarks-item'); |
+ }); |
+ |
+ test('shift-selects multiple items', function() { |
+ customClick(items[1]); |
+ assertDeepEquals(['3'], normalizeSet(store.data.selection.items)); |
+ assertDeepEquals('3', store.data.selection.anchor); |
+ |
+ customClick(items[3], {shiftKey: true}); |
+ assertDeepEquals(['3', '5', '7'], normalizeSet(store.data.selection.items)); |
+ assertDeepEquals('3', store.data.selection.anchor); |
+ |
+ customClick(items[0], {shiftKey: true}); |
+ assertDeepEquals(['1', '3'], normalizeSet(store.data.selection.items)); |
+ assertDeepEquals('3', store.data.selection.anchor); |
+ }); |
+ |
+ test('ctrl toggles multiple items', function() { |
+ customClick(items[1]); |
+ assertDeepEquals(['3'], normalizeSet(store.data.selection.items)); |
+ assertDeepEquals('3', store.data.selection.anchor); |
+ |
+ customClick(items[3], {ctrlKey: true}); |
+ assertDeepEquals(['3', '7'], normalizeSet(store.data.selection.items)); |
+ assertDeepEquals('7', store.data.selection.anchor); |
+ |
+ customClick(items[1], {ctrlKey: true}); |
+ assertDeepEquals(['7'], normalizeSet(store.data.selection.items)); |
+ assertDeepEquals('3', store.data.selection.anchor); |
+ }); |
+ |
+ test('ctrl+shift adds ranges to selection', function() { |
+ customClick(items[0]); |
+ assertDeepEquals(['1'], normalizeSet(store.data.selection.items)); |
+ assertDeepEquals('1', store.data.selection.anchor); |
+ |
+ customClick(items[2], {ctrlKey: true}); |
+ assertDeepEquals(['1', '5'], normalizeSet(store.data.selection.items)); |
+ assertDeepEquals('5', store.data.selection.anchor); |
+ |
+ customClick(items[4], {ctrlKey: true, shiftKey: true}); |
+ assertDeepEquals( |
+ ['1', '5', '7', '9'], normalizeSet(store.data.selection.items)); |
+ assertDeepEquals('5', store.data.selection.anchor); |
+ |
+ customClick(items[0], {ctrlKey: true, shiftKey: true}); |
+ assertDeepEquals( |
+ ['1', '3', '5', '7', '9'], normalizeSet(store.data.selection.items)); |
+ assertDeepEquals('5', store.data.selection.anchor); |
+ }); |
+}); |