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

Unified Diff: chrome/test/data/webui/md_bookmarks/dnd_manager_test.js

Issue 2772003002: [MD Bookmarks] Make drag and drop update data model. (Closed)
Patch Set: address_comments Created 3 years, 9 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
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 faefc8260b67903a0105cccdd66f53d4f6d5c6a5..9e6d6ef2fa3827328d0150b1459e01f67b3294ad 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,51 @@ suite('drag and drop', function() {
DropPosition.ON | DropPosition.ABOVE | DropPosition.BELOW,
dndManager.calculateValidDropPositions_(getFolderNode('112')));
});
+
+ test('calculateDropInfo_', function() {
+ function assertDropInfo(parentId, index, element, position) {
+ assertDeepEquals(
+ {parentId: parentId, index: index},
+ dndManager.calculateDropInfo_(
+ {element: element, position: position}));
+ }
+
+
+ // Drops onto the list.
+ assertDropInfo('1', 0, getListItem('11'), DropPosition.ABOVE);
+ assertDropInfo('1', 2, getListItem('12'), DropPosition.BELOW);
+ assertDropInfo('13', -1, getListItem('13'), DropPosition.ON);
+
+ // Drops onto the sidebar.
+ assertDropInfo('1', 4, getFolderNode('15'), DropPosition.ABOVE);
+ assertDropInfo('1', 5, getFolderNode('15'), DropPosition.BELOW);
+ assertDropInfo('111', -1, getFolderNode('111'), 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);
+ });
});

Powered by Google App Engine
This is Rietveld 408576698