|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /* |
|
5 * These tests make sure that dragging and dropping sites works as expected. |
|
6 * Sites contained in the grid need to shift around to indicate the result |
|
7 * of the drag-and-drop operation. If the grid is full and we're dragging |
|
8 * a new site into it another one gets pushed out. |
|
9 */ |
|
10 function runTests() { |
|
11 requestLongerTimeout(2); |
|
12 |
|
13 // test a simple drag-and-drop scenario |
|
14 yield setLinks("0,1,2,3,4,5,6,7,8"); |
|
15 setPinnedLinks(""); |
|
16 |
|
17 yield addNewTabPageTab(); |
|
18 checkGrid("0,1,2,3,4,5,6,7,8"); |
|
19 |
|
20 yield simulateDrop(0, 1); |
|
21 checkGrid("1,0p,2,3,4,5,6,7,8"); |
|
22 |
|
23 // drag a cell to its current cell and make sure it's not pinned afterwards |
|
24 yield setLinks("0,1,2,3,4,5,6,7,8"); |
|
25 setPinnedLinks(""); |
|
26 |
|
27 yield addNewTabPageTab(); |
|
28 checkGrid("0,1,2,3,4,5,6,7,8"); |
|
29 |
|
30 yield simulateDrop(0, 0); |
|
31 checkGrid("0,1,2,3,4,5,6,7,8"); |
|
32 |
|
33 // ensure that pinned pages aren't moved if that's not necessary |
|
34 yield setLinks("0,1,2,3,4,5,6,7,8"); |
|
35 setPinnedLinks(",1,2"); |
|
36 |
|
37 yield addNewTabPageTab(); |
|
38 checkGrid("0,1p,2p,3,4,5,6,7,8"); |
|
39 |
|
40 yield simulateDrop(0, 3); |
|
41 checkGrid("3,1p,2p,0p,4,5,6,7,8"); |
|
42 |
|
43 // pinned sites should always be moved around as blocks. if a pinned site is |
|
44 // moved around, neighboring pinned are affected as well |
|
45 yield setLinks("0,1,2,3,4,5,6,7,8"); |
|
46 setPinnedLinks("0,1"); |
|
47 |
|
48 yield addNewTabPageTab(); |
|
49 checkGrid("0p,1p,2,3,4,5,6,7,8"); |
|
50 |
|
51 yield simulateDrop(2, 0); |
|
52 checkGrid("2p,0p,1p,3,4,5,6,7,8"); |
|
53 |
|
54 // pinned sites should not be pushed out of the grid (unless there are only |
|
55 // pinned ones left on the grid) |
|
56 yield setLinks("0,1,2,3,4,5,6,7,8"); |
|
57 setPinnedLinks(",,,,,,,7,8"); |
|
58 |
|
59 yield addNewTabPageTab(); |
|
60 checkGrid("0,1,2,3,4,5,6,7p,8p"); |
|
61 |
|
62 yield simulateDrop(2, 8); |
|
63 checkGrid("0,1,3,4,5,6,7p,8p,2p"); |
|
64 |
|
65 // make sure that pinned sites are re-positioned correctly |
|
66 yield setLinks("0,1,2,3,4,5,6,7,8"); |
|
67 setPinnedLinks("0,1,2,,,5"); |
|
68 |
|
69 yield addNewTabPageTab(); |
|
70 checkGrid("0p,1p,2p,3,4,5p,6,7,8"); |
|
71 |
|
72 yield simulateDrop(0, 4); |
|
73 checkGrid("3,1p,2p,4,0p,5p,6,7,8"); |
|
74 } |