browser/components/tabview/test/browser_tabview_click_group.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/components/tabview/test/browser_tabview_click_group.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,68 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +let contentWindow;
     1.8 +let groupItem;
     1.9 +let groupItemId;
    1.10 +
    1.11 +function test() {
    1.12 +  waitForExplicitFinish();
    1.13 +
    1.14 +  registerCleanupFunction(function() {
    1.15 +    contentWindow.gPrefBranch.clearUserPref("animate_zoom");
    1.16 +    let createdGroupItem = contentWindow.GroupItems.groupItem(groupItemId)
    1.17 +    if (createdGroupItem)
    1.18 +      closeGroupItem(createdGroupItem);
    1.19 +    hideTabView();
    1.20 +  });
    1.21 +
    1.22 +  showTabView(function() {
    1.23 +    contentWindow = TabView.getContentWindow();
    1.24 +    groupItem = createEmptyGroupItem(contentWindow, 300, 300, 200);
    1.25 +    groupItemId = groupItem.id;
    1.26 +    testMouseClickOnEmptyGroupItem();
    1.27 +  });
    1.28 +}
    1.29 +
    1.30 +function testMouseClickOnEmptyGroupItem() {
    1.31 +  whenTabViewIsHidden(function() {
    1.32 +    is(groupItem.getChildren().length, 1, "The group item contains one tab item now");
    1.33 +    showTabView(testDraggingWithinGroupItem);
    1.34 +  });
    1.35 +  is(groupItem.getChildren().length, 0, "The group item doesn't contain any tab items");
    1.36 +  EventUtils.sendMouseEvent({ type: "mousedown" }, groupItem.container, contentWindow);
    1.37 +  EventUtils.sendMouseEvent({ type: "mouseup" }, groupItem.container, contentWindow);
    1.38 +}
    1.39 +
    1.40 +function testDraggingWithinGroupItem() {
    1.41 +  let target = groupItem.container;
    1.42 +  contentWindow.gPrefBranch.setBoolPref("animate_zoom", false);
    1.43 +
    1.44 +  // stimulate drag and drop
    1.45 +  EventUtils.sendMouseEvent( {type: "mousedown" }, target, contentWindow);
    1.46 +  EventUtils.synthesizeMouse(target, 10, 10, { type: "mousemove" }, contentWindow);
    1.47 +  ok(groupItem.isDragging, "The group item is being dragged")
    1.48 +
    1.49 +  EventUtils.sendMouseEvent({ type: "mouseup" }, target, contentWindow);
    1.50 +  ok(!groupItem.isDragging, "The dragging is competely");
    1.51 +
    1.52 +  executeSoon(function() {
    1.53 +    ok(TabView.isVisible(), "The tab view is still visible after dragging");
    1.54 +    contentWindow.gPrefBranch.clearUserPref("animate_zoom");
    1.55 +
    1.56 +    testMouseClickOnGroupItem();
    1.57 +  });
    1.58 +}
    1.59 +
    1.60 +function testMouseClickOnGroupItem() {
    1.61 +  whenTabViewIsHidden(function() {
    1.62 +    is(groupItem.getChildren().length, 1, "The group item still contains one tab item");
    1.63 +
    1.64 +    closeGroupItem(groupItem, function() {
    1.65 +      hideTabView(finish);
    1.66 +    });
    1.67 +  });
    1.68 +  EventUtils.sendMouseEvent({ type: "mousedown" }, groupItem.container, contentWindow);
    1.69 +  EventUtils.sendMouseEvent({ type: "mouseup" }, groupItem.container, contentWindow);
    1.70 +}
    1.71 +

mercurial