michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: newWindowWithTabView(function (win) { michael@0: registerCleanupFunction(function () win.close()); michael@0: waitForFocus(function () testScenarios(win)); michael@0: }); michael@0: } michael@0: michael@0: function testScenarios(win) { michael@0: let simulateDragDrop = function (target) { michael@0: EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw); michael@0: EventUtils.synthesizeMouse(target, 40, 20, {type: "mousemove"}, cw); michael@0: EventUtils.synthesizeMouse(target, 80, 20, {type: "mouseup"}, cw); michael@0: } michael@0: michael@0: let dragOutOfGroup = function (target) { michael@0: EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw); michael@0: EventUtils.synthesizeMouse(target, 600, 5, {type: "mousemove"}, cw); michael@0: EventUtils.synthesizeMouse(target, 600, 5, {type: "mouseup"}, cw); michael@0: } michael@0: michael@0: let dragIntoGroup = function (target) { michael@0: EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw); michael@0: EventUtils.synthesizeMouse(target, -200, 5, {type: "mousemove"}, cw); michael@0: EventUtils.synthesizeMouse(target, -200, 5, {type: "mouseup"}, cw); michael@0: } michael@0: michael@0: let assertActiveOrphan = function (tabItem) { michael@0: ok(!cw.GroupItems.getActiveGroupItem(), "no groupItem is active"); michael@0: is(cw.UI.getActiveTab(), tabItem, "orphan tab is active"); michael@0: is(cw.UI.getActiveOrphanTab(), tabItem, "orphan tab is active"); michael@0: } michael@0: michael@0: let cw = win.TabView.getContentWindow(); michael@0: let groupItem = cw.GroupItems.groupItems[0]; michael@0: let groupItem2 = createGroupItemWithBlankTabs(win, 400, 300, 20, 4); michael@0: michael@0: // move group michael@0: cw.UI.setActive(groupItem); michael@0: simulateDragDrop(groupItem2.container); michael@0: is(cw.GroupItems.getActiveGroupItem(), groupItem2, "second groupItem is active"); michael@0: is(cw.UI.getActiveTab(), groupItem2.getChild(0), "second groupItem's first tab is active"); michael@0: michael@0: // resize group michael@0: cw.UI.setActive(groupItem); michael@0: let tabItem = groupItem2.getChild(2); michael@0: groupItem2.setActiveTab(tabItem); michael@0: simulateDragDrop(groupItem2.$resizer[0]); michael@0: is(cw.GroupItems.getActiveGroupItem(), groupItem2, "second groupItem is active"); michael@0: is(cw.UI.getActiveTab(), tabItem, "second groupItem's third tab is active"); michael@0: michael@0: // drag tab out of group michael@0: tabItem = groupItem2.getChild(0); michael@0: dragOutOfGroup(tabItem.container); michael@0: is(cw.UI.getActiveTab(), tabItem, "the dragged tab is active"); michael@0: michael@0: // drag back into group michael@0: dragIntoGroup(tabItem.container); michael@0: cw.UI.setActive(groupItem); michael@0: cw.UI.setActive(groupItem2); michael@0: is(cw.UI.getActiveTab(), tabItem, "the dropped tab is active"); michael@0: michael@0: // hide + unhide groupItem michael@0: hideGroupItem(groupItem2, function () { michael@0: is(cw.GroupItems.getActiveGroupItem(), groupItem, "first groupItem is active"); michael@0: michael@0: unhideGroupItem(groupItem2, function () { michael@0: is(cw.GroupItems.getActiveGroupItem(), groupItem2, "second groupItem is active"); michael@0: is(cw.UI.getActiveTab(), tabItem, "the dropped tab is active"); michael@0: michael@0: finish(); michael@0: }); michael@0: }); michael@0: }