Chromium Code Reviews| 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 // 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.
| |
| 345 assertDeepEquals( | |
| 346 { | |
| 347 parentId: '1', | |
| 348 index: 0, | |
| 349 }, | |
| 350 dndManager.calculateDropInfo_({ | |
| 351 element: getListItem('11'), | |
| 352 position: DropPosition.ABOVE, | |
| 353 })); | |
| 354 | |
| 355 assertDeepEquals( | |
| 356 { | |
| 357 parentId: '1', | |
| 358 index: 2, | |
| 359 }, | |
| 360 dndManager.calculateDropInfo_({ | |
| 361 element: getListItem('12'), | |
| 362 position: DropPosition.BELOW, | |
| 363 })); | |
| 364 | |
| 365 assertDeepEquals( | |
| 366 { | |
| 367 parentId: '13', | |
| 368 index: -1, | |
| 369 }, | |
| 370 dndManager.calculateDropInfo_({ | |
| 371 element: getListItem('13'), | |
| 372 position: DropPosition.ON, | |
| 373 })); | |
| 374 | |
| 375 // Drops onto the sidebar. | |
| 376 assertDeepEquals( | |
| 377 { | |
| 378 parentId: '1', | |
| 379 index: 4, | |
| 380 }, | |
| 381 dndManager.calculateDropInfo_({ | |
| 382 element: getFolderNode('15'), | |
| 383 position: DropPosition.ABOVE, | |
| 384 })); | |
| 385 | |
| 386 assertDeepEquals( | |
| 387 { | |
| 388 parentId: '1', | |
| 389 index: 5, | |
| 390 }, | |
| 391 dndManager.calculateDropInfo_({ | |
| 392 element: getFolderNode('15'), | |
| 393 position: DropPosition.BELOW, | |
| 394 })); | |
| 395 | |
| 396 assertDeepEquals( | |
| 397 { | |
| 398 parentId: '111', | |
| 399 index: -1, | |
| 400 }, | |
| 401 dndManager.calculateDropInfo_({ | |
| 402 element: getFolderNode('111'), | |
| 403 position: DropPosition.ON, | |
| 404 })); | |
| 405 }); | |
| 406 | |
| 407 test('simple drag and drop end to end', function() { | |
| 408 var dropParentId; | |
| 409 var dropIndex; | |
| 410 chrome.bookmarkManagerPrivate.drop = function(parentId, index) { | |
| 411 dropParentId = parentId; | |
| 412 dropIndex = index; | |
| 413 }; | |
| 414 | |
| 415 var dragElement = getListItem('13'); | |
| 416 var dragTarget = getListItem('12'); | |
| 417 | |
| 418 dispatchDragEvent('dragstart', dragElement); | |
| 419 assertDeepEquals(['13'], draggedIds); | |
| 420 dndManager.dragInfo_.handleChromeDragEnter(createDragData(draggedIds)); | |
| 421 | |
| 422 dispatchDragEvent( | |
| 423 'dragover', dragTarget, MockInteractions.topLeftOfNode(dragTarget)); | |
| 424 assertDragStyle(dragTarget, DRAG_STYLE.ABOVE); | |
| 425 | |
| 426 dispatchDragEvent('drop', dragTarget); | |
| 427 assertEquals('1', dropParentId); | |
| 428 assertEquals(1, dropIndex); | |
| 429 | |
| 430 dispatchDragEvent('dragend', dragTarget); | |
| 431 assertDragStyle(dragTarget, DRAG_STYLE.NONE); | |
| 432 }); | |
| 342 }); | 433 }); |
| OLD | NEW |