Chromium Code Reviews| Index: chrome/test/data/webui/md_bookmarks/dnd_manager_test.js |
| diff --git a/chrome/test/data/webui/md_bookmarks/dnd_manager_test.js b/chrome/test/data/webui/md_bookmarks/dnd_manager_test.js |
| index 2984f47e9cd14ed1aafb78f28163609bac50b6b2..9e445ccc3866b93b8a5034e9c338d00e3bc10119 100644 |
| --- a/chrome/test/data/webui/md_bookmarks/dnd_manager_test.js |
| +++ b/chrome/test/data/webui/md_bookmarks/dnd_manager_test.js |
| @@ -339,4 +339,95 @@ suite('drag and drop', function() { |
| DropPosition.ON | DropPosition.ABOVE | DropPosition.BELOW, |
| dndManager.calculateValidDropPositions_(getFolderNode('112'))); |
| }); |
| + |
| + test('calculateDropInfo_', function() { |
| + // Drops onto the list. |
|
tsergeant
2017/03/29 00:32:48
You could use a helper function here to shorten th
calamity
2017/03/29 03:35:37
Done.
|
| + assertDeepEquals( |
| + { |
| + parentId: '1', |
| + index: 0, |
| + }, |
| + dndManager.calculateDropInfo_({ |
| + element: getListItem('11'), |
| + position: DropPosition.ABOVE, |
| + })); |
| + |
| + assertDeepEquals( |
| + { |
| + parentId: '1', |
| + index: 2, |
| + }, |
| + dndManager.calculateDropInfo_({ |
| + element: getListItem('12'), |
| + position: DropPosition.BELOW, |
| + })); |
| + |
| + assertDeepEquals( |
| + { |
| + parentId: '13', |
| + index: -1, |
| + }, |
| + dndManager.calculateDropInfo_({ |
| + element: getListItem('13'), |
| + position: DropPosition.ON, |
| + })); |
| + |
| + // Drops onto the sidebar. |
| + assertDeepEquals( |
| + { |
| + parentId: '1', |
| + index: 4, |
| + }, |
| + dndManager.calculateDropInfo_({ |
| + element: getFolderNode('15'), |
| + position: DropPosition.ABOVE, |
| + })); |
| + |
| + assertDeepEquals( |
| + { |
| + parentId: '1', |
| + index: 5, |
| + }, |
| + dndManager.calculateDropInfo_({ |
| + element: getFolderNode('15'), |
| + position: DropPosition.BELOW, |
| + })); |
| + |
| + assertDeepEquals( |
| + { |
| + parentId: '111', |
| + index: -1, |
| + }, |
| + dndManager.calculateDropInfo_({ |
| + element: getFolderNode('111'), |
| + position: DropPosition.ON, |
| + })); |
| + }); |
| + |
| + test('simple drag and drop end to end', function() { |
| + var dropParentId; |
| + var dropIndex; |
| + chrome.bookmarkManagerPrivate.drop = function(parentId, index) { |
| + dropParentId = parentId; |
| + dropIndex = index; |
| + }; |
| + |
| + var dragElement = getListItem('13'); |
| + var dragTarget = getListItem('12'); |
| + |
| + dispatchDragEvent('dragstart', dragElement); |
| + assertDeepEquals(['13'], draggedIds); |
| + dndManager.dragInfo_.handleChromeDragEnter(createDragData(draggedIds)); |
| + |
| + dispatchDragEvent( |
| + 'dragover', dragTarget, MockInteractions.topLeftOfNode(dragTarget)); |
| + assertDragStyle(dragTarget, DRAG_STYLE.ABOVE); |
| + |
| + dispatchDragEvent('drop', dragTarget); |
| + assertEquals('1', dropParentId); |
| + assertEquals(1, dropIndex); |
| + |
| + dispatchDragEvent('dragend', dragTarget); |
| + assertDragStyle(dragTarget, DRAG_STYLE.NONE); |
| + }); |
| }); |