|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 function test() { |
|
5 waitForExplicitFinish(); |
|
6 |
|
7 newWindowWithTabView(function (win) { |
|
8 registerCleanupFunction(function () win.close()); |
|
9 waitForFocus(function () testScenarios(win)); |
|
10 }); |
|
11 } |
|
12 |
|
13 function testScenarios(win) { |
|
14 let simulateDragDrop = function (target) { |
|
15 EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw); |
|
16 EventUtils.synthesizeMouse(target, 40, 20, {type: "mousemove"}, cw); |
|
17 EventUtils.synthesizeMouse(target, 80, 20, {type: "mouseup"}, cw); |
|
18 } |
|
19 |
|
20 let dragOutOfGroup = function (target) { |
|
21 EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw); |
|
22 EventUtils.synthesizeMouse(target, 600, 5, {type: "mousemove"}, cw); |
|
23 EventUtils.synthesizeMouse(target, 600, 5, {type: "mouseup"}, cw); |
|
24 } |
|
25 |
|
26 let dragIntoGroup = function (target) { |
|
27 EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw); |
|
28 EventUtils.synthesizeMouse(target, -200, 5, {type: "mousemove"}, cw); |
|
29 EventUtils.synthesizeMouse(target, -200, 5, {type: "mouseup"}, cw); |
|
30 } |
|
31 |
|
32 let assertActiveOrphan = function (tabItem) { |
|
33 ok(!cw.GroupItems.getActiveGroupItem(), "no groupItem is active"); |
|
34 is(cw.UI.getActiveTab(), tabItem, "orphan tab is active"); |
|
35 is(cw.UI.getActiveOrphanTab(), tabItem, "orphan tab is active"); |
|
36 } |
|
37 |
|
38 let cw = win.TabView.getContentWindow(); |
|
39 let groupItem = cw.GroupItems.groupItems[0]; |
|
40 let groupItem2 = createGroupItemWithBlankTabs(win, 400, 300, 20, 4); |
|
41 |
|
42 // move group |
|
43 cw.UI.setActive(groupItem); |
|
44 simulateDragDrop(groupItem2.container); |
|
45 is(cw.GroupItems.getActiveGroupItem(), groupItem2, "second groupItem is active"); |
|
46 is(cw.UI.getActiveTab(), groupItem2.getChild(0), "second groupItem's first tab is active"); |
|
47 |
|
48 // resize group |
|
49 cw.UI.setActive(groupItem); |
|
50 let tabItem = groupItem2.getChild(2); |
|
51 groupItem2.setActiveTab(tabItem); |
|
52 simulateDragDrop(groupItem2.$resizer[0]); |
|
53 is(cw.GroupItems.getActiveGroupItem(), groupItem2, "second groupItem is active"); |
|
54 is(cw.UI.getActiveTab(), tabItem, "second groupItem's third tab is active"); |
|
55 |
|
56 // drag tab out of group |
|
57 tabItem = groupItem2.getChild(0); |
|
58 dragOutOfGroup(tabItem.container); |
|
59 is(cw.UI.getActiveTab(), tabItem, "the dragged tab is active"); |
|
60 |
|
61 // drag back into group |
|
62 dragIntoGroup(tabItem.container); |
|
63 cw.UI.setActive(groupItem); |
|
64 cw.UI.setActive(groupItem2); |
|
65 is(cw.UI.getActiveTab(), tabItem, "the dropped tab is active"); |
|
66 |
|
67 // hide + unhide groupItem |
|
68 hideGroupItem(groupItem2, function () { |
|
69 is(cw.GroupItems.getActiveGroupItem(), groupItem, "first groupItem is active"); |
|
70 |
|
71 unhideGroupItem(groupItem2, function () { |
|
72 is(cw.GroupItems.getActiveGroupItem(), groupItem2, "second groupItem is active"); |
|
73 is(cw.UI.getActiveTab(), tabItem, "the dropped tab is active"); |
|
74 |
|
75 finish(); |
|
76 }); |
|
77 }); |
|
78 } |