michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /* michael@0: * These tests make sure that dragging and dropping sites works as expected. michael@0: * Sites contained in the grid need to shift around to indicate the result michael@0: * of the drag-and-drop operation. If the grid is full and we're dragging michael@0: * a new site into it another one gets pushed out. michael@0: */ michael@0: function runTests() { michael@0: requestLongerTimeout(2); michael@0: michael@0: // test a simple drag-and-drop scenario michael@0: yield setLinks("0,1,2,3,4,5,6,7,8"); michael@0: setPinnedLinks(""); michael@0: michael@0: yield addNewTabPageTab(); michael@0: checkGrid("0,1,2,3,4,5,6,7,8"); michael@0: michael@0: yield simulateDrop(0, 1); michael@0: checkGrid("1,0p,2,3,4,5,6,7,8"); michael@0: michael@0: // drag a cell to its current cell and make sure it's not pinned afterwards michael@0: yield setLinks("0,1,2,3,4,5,6,7,8"); michael@0: setPinnedLinks(""); michael@0: michael@0: yield addNewTabPageTab(); michael@0: checkGrid("0,1,2,3,4,5,6,7,8"); michael@0: michael@0: yield simulateDrop(0, 0); michael@0: checkGrid("0,1,2,3,4,5,6,7,8"); michael@0: michael@0: // ensure that pinned pages aren't moved if that's not necessary michael@0: yield setLinks("0,1,2,3,4,5,6,7,8"); michael@0: setPinnedLinks(",1,2"); michael@0: michael@0: yield addNewTabPageTab(); michael@0: checkGrid("0,1p,2p,3,4,5,6,7,8"); michael@0: michael@0: yield simulateDrop(0, 3); michael@0: checkGrid("3,1p,2p,0p,4,5,6,7,8"); michael@0: michael@0: // pinned sites should always be moved around as blocks. if a pinned site is michael@0: // moved around, neighboring pinned are affected as well michael@0: yield setLinks("0,1,2,3,4,5,6,7,8"); michael@0: setPinnedLinks("0,1"); michael@0: michael@0: yield addNewTabPageTab(); michael@0: checkGrid("0p,1p,2,3,4,5,6,7,8"); michael@0: michael@0: yield simulateDrop(2, 0); michael@0: checkGrid("2p,0p,1p,3,4,5,6,7,8"); michael@0: michael@0: // pinned sites should not be pushed out of the grid (unless there are only michael@0: // pinned ones left on the grid) michael@0: yield setLinks("0,1,2,3,4,5,6,7,8"); michael@0: setPinnedLinks(",,,,,,,7,8"); michael@0: michael@0: yield addNewTabPageTab(); michael@0: checkGrid("0,1,2,3,4,5,6,7p,8p"); michael@0: michael@0: yield simulateDrop(2, 8); michael@0: checkGrid("0,1,3,4,5,6,7p,8p,2p"); michael@0: michael@0: // make sure that pinned sites are re-positioned correctly michael@0: yield setLinks("0,1,2,3,4,5,6,7,8"); michael@0: setPinnedLinks("0,1,2,,,5"); michael@0: michael@0: yield addNewTabPageTab(); michael@0: checkGrid("0p,1p,2p,3,4,5p,6,7,8"); michael@0: michael@0: yield simulateDrop(0, 4); michael@0: checkGrid("3,1p,2p,4,0p,5p,6,7,8"); michael@0: }