OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 suite('drag and drop', function() { | 5 suite('drag and drop', function() { |
6 var app; | 6 var app; |
7 var list; | 7 var list; |
8 var sidebar; | 8 var sidebar; |
9 var store; | 9 var store; |
10 var dndManager; | 10 var dndManager; |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 dndManager.dragInfo_.handleChromeDragEnter(createDragData(['2'])); | 332 dndManager.dragInfo_.handleChromeDragEnter(createDragData(['2'])); |
333 assertEquals( | 333 assertEquals( |
334 DropPosition.NONE, | 334 DropPosition.NONE, |
335 dndManager.calculateValidDropPositions_(getListItem('13'))); | 335 dndManager.calculateValidDropPositions_(getListItem('13'))); |
336 | 336 |
337 // Drags onto folders should work as per usual. | 337 // Drags onto folders should work as per usual. |
338 assertEquals( | 338 assertEquals( |
339 DropPosition.ON | DropPosition.ABOVE | DropPosition.BELOW, | 339 DropPosition.ON | DropPosition.ABOVE | DropPosition.BELOW, |
340 dndManager.calculateValidDropPositions_(getFolderNode('112'))); | 340 dndManager.calculateValidDropPositions_(getFolderNode('112'))); |
341 }); | 341 }); |
| 342 |
| 343 test('calculateDropInfo_', function() { |
| 344 function assertDropInfo(parentId, index, element, position) { |
| 345 assertDeepEquals( |
| 346 {parentId: parentId, index: index}, |
| 347 dndManager.calculateDropInfo_( |
| 348 {element: element, position: position})); |
| 349 } |
| 350 |
| 351 |
| 352 // Drops onto the list. |
| 353 assertDropInfo('1', 0, getListItem('11'), DropPosition.ABOVE); |
| 354 assertDropInfo('1', 2, getListItem('12'), DropPosition.BELOW); |
| 355 assertDropInfo('13', -1, getListItem('13'), DropPosition.ON); |
| 356 |
| 357 // Drops onto the sidebar. |
| 358 assertDropInfo('1', 4, getFolderNode('15'), DropPosition.ABOVE); |
| 359 assertDropInfo('1', 5, getFolderNode('15'), DropPosition.BELOW); |
| 360 assertDropInfo('111', -1, getFolderNode('111'), DropPosition.ON); |
| 361 }); |
| 362 |
| 363 test('simple drag and drop end to end', function() { |
| 364 var dropParentId; |
| 365 var dropIndex; |
| 366 chrome.bookmarkManagerPrivate.drop = function(parentId, index) { |
| 367 dropParentId = parentId; |
| 368 dropIndex = index; |
| 369 }; |
| 370 |
| 371 var dragElement = getListItem('13'); |
| 372 var dragTarget = getListItem('12'); |
| 373 |
| 374 dispatchDragEvent('dragstart', dragElement); |
| 375 assertDeepEquals(['13'], draggedIds); |
| 376 dndManager.dragInfo_.handleChromeDragEnter(createDragData(draggedIds)); |
| 377 |
| 378 dispatchDragEvent( |
| 379 'dragover', dragTarget, MockInteractions.topLeftOfNode(dragTarget)); |
| 380 assertDragStyle(dragTarget, DRAG_STYLE.ABOVE); |
| 381 |
| 382 dispatchDragEvent('drop', dragTarget); |
| 383 assertEquals('1', dropParentId); |
| 384 assertEquals(1, dropIndex); |
| 385 |
| 386 dispatchDragEvent('dragend', dragTarget); |
| 387 assertDragStyle(dragTarget, DRAG_STYLE.NONE); |
| 388 }); |
342 }); | 389 }); |
OLD | NEW |