| 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 // from. | 331 // from. |
| 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 |
| 342 // Drags onto an empty search list do nothing. |
| 343 store.data.search.results = []; |
| 344 store.notifyObservers(); |
| 345 assertEquals( |
| 346 DropPosition.NONE, dndManager.calculateValidDropPositions_(list)); |
| 341 }); | 347 }); |
| 342 | 348 |
| 343 test('calculateDropInfo_', function() { | 349 test('calculateDropInfo_', function() { |
| 344 function assertDropInfo(parentId, index, element, position) { | 350 function assertDropInfo(parentId, index, element, position) { |
| 345 assertDeepEquals( | 351 assertDeepEquals( |
| 346 {parentId: parentId, index: index}, | 352 {parentId: parentId, index: index}, |
| 347 dndManager.calculateDropInfo_( | 353 dndManager.calculateDropInfo_( |
| 348 {element: element, position: position})); | 354 {element: element, position: position})); |
| 349 } | 355 } |
| 350 | 356 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 dispatchDragEvent('dragover', dragTarget); | 442 dispatchDragEvent('dragover', dragTarget); |
| 437 assertEquals(700, autoExpander.lastTimestamp_); | 443 assertEquals(700, autoExpander.lastTimestamp_); |
| 438 | 444 |
| 439 autoExpander.testTimestamp_ += autoExpander.EXPAND_FOLDER_DELAY; | 445 autoExpander.testTimestamp_ += autoExpander.EXPAND_FOLDER_DELAY; |
| 440 dispatchDragEvent('dragover', dragTarget); | 446 dispatchDragEvent('dragover', dragTarget); |
| 441 assertDeepEquals( | 447 assertDeepEquals( |
| 442 bookmarks.actions.changeFolderOpen('11', true), store.lastAction); | 448 bookmarks.actions.changeFolderOpen('11', true), store.lastAction); |
| 443 assertEquals(0, autoExpander.lastTimestamp_); | 449 assertEquals(0, autoExpander.lastTimestamp_); |
| 444 assertEquals(null, autoExpander.lastElement_); | 450 assertEquals(null, autoExpander.lastElement_); |
| 445 }); | 451 }); |
| 452 |
| 453 test('drag onto empty list', function() { |
| 454 store.data.selectedFolder = '14'; |
| 455 store.notifyObservers(); |
| 456 |
| 457 var dragElement = getFolderNode('15'); |
| 458 var dragTarget = list; |
| 459 |
| 460 // Dragging onto an empty list. |
| 461 dispatchDragEvent('dragstart', dragElement); |
| 462 dndManager.dragInfo_.handleChromeDragEnter(createDragData(draggedIds)); |
| 463 |
| 464 dispatchDragEvent('dragover', dragTarget); |
| 465 assertEquals( |
| 466 DropPosition.ON, dndManager.calculateValidDropPositions_(dragTarget)); |
| 467 assertDragStyle(dragTarget, DRAG_STYLE.ON); |
| 468 |
| 469 dispatchDragEvent('dragend', dragTarget); |
| 470 |
| 471 // Dragging onto a non-empty list. |
| 472 store.data.selectedFolder = '11'; |
| 473 store.notifyObservers(); |
| 474 |
| 475 dispatchDragEvent('dragstart', dragElement); |
| 476 dndManager.dragInfo_.handleChromeDragEnter(createDragData(draggedIds)); |
| 477 |
| 478 dispatchDragEvent('dragover', dragTarget); |
| 479 assertEquals( |
| 480 DropPosition.NONE, dndManager.calculateValidDropPositions_(dragTarget)); |
| 481 assertDragStyle(dragTarget, DRAG_STYLE.NONE); |
| 482 }); |
| 446 }); | 483 }); |
| OLD | NEW |