Commit b1d98d23 authored by Tim Taubert's avatar Tim Taubert
Browse files

Bug 625668 - Resizes for single groups don't stick correctly, returning them...

Bug 625668 - Resizes for single groups don't stick correctly, returning them to their userSize values; r=dietrich
parent adfa8285
Loading
Loading
Loading
Loading
+6 −1
Original line number Original line Diff line number Diff line
@@ -310,9 +310,14 @@ Item.prototype = {
  // Parameters:
  // Parameters:
  //  immediately - boolean for doing the pushAway without animation
  //  immediately - boolean for doing the pushAway without animation
  pushAway: function Item_pushAway(immediately) {
  pushAway: function Item_pushAway(immediately) {
    var items = Items.getTopLevelItems();

    // we need at least two top-level items to push something away
    if (items.length < 2)
      return;

    var buffer = Math.floor(Items.defaultGutter / 2);
    var buffer = Math.floor(Items.defaultGutter / 2);


    var items = Items.getTopLevelItems();
    // setup each Item's pushAwayData attribute:
    // setup each Item's pushAwayData attribute:
    items.forEach(function pushAway_setupPushAwayData(item) {
    items.forEach(function pushAway_setupPushAwayData(item) {
      var data = {};
      var data = {};
+51 −51
Original line number Original line Diff line number Diff line
@@ -3,75 +3,75 @@


function test() {
function test() {
  waitForExplicitFinish();
  waitForExplicitFinish();

  newWindowWithTabView(onTabViewShown);
  newWindowWithTabView(onTabViewWindowLoaded);
}
}


function onTabViewWindowLoaded(win) {
function onTabViewShown(win) {
  win.removeEventListener("tabviewshown", onTabViewWindowLoaded, false);
  registerCleanupFunction(function () win.close());

  ok(win.TabView.isVisible(), "Tab View is visible");

  let contentWindow = win.document.getElementById("tab-view").contentWindow;
  let [originalTab] = win.gBrowser.visibleTabs;


  let contentWindow = win.TabView.getContentWindow();
  let currentGroup = contentWindow.GroupItems.getActiveGroupItem();
  let currentGroup = contentWindow.GroupItems.getActiveGroupItem();


  currentGroup.setSize(600, 600, true);
  function checkResized(diffX, diffY, shouldResize, text, callback) {
  currentGroup.setUserSize();
    let {width: origWidth, height: origHeight} = currentGroup.getBounds();

    resizeWindow(win, diffX, diffY, function () {
      let {width: newWidth, height: newHeight} = currentGroup.getBounds();
      let resized = (origWidth != newWidth || origHeight != newHeight);


  let down1 = function down1(resized) {
      is(resized, shouldResize, text + ": The group should " +
    checkResized(currentGroup, 50, 50, false, "A little bigger", up1, contentWindow, win);
         (shouldResize ? "" : "not ") + "have been resized");
  };


  let up1 = function up1(resized) {
      callback();
    checkResized(currentGroup, -400, -400, true, "Much smaller", down2, contentWindow, win);    
    });
  }
  }


  let down2 = function down2(resized) {
  function next() {
    checkResized(currentGroup, 400, 400, undefined,
    let test = tests.shift();
      "Bigger after much smaller: TODO (bug 625668): the group should be resized!",
      up2, contentWindow, win);
  };


  let up2 = function up2(resized) {
    if (test)
    checkResized(currentGroup, -400, -400, undefined,
      checkResized.apply(this, test.concat([next]));
      "Much smaller: TODO (bug 625668): the group should be resized!",
    else
      down3, contentWindow, win);    
      finishTest();
  }
  }


  let down3 = function down3(resized) {
  function finishTest() {
    // reset the usersize of the group, so this should clear the "cramped" feeling.
    // reset the usersize of the group, so this should clear the "cramped" feeling.
    currentGroup.setSize(100, 100, true);
    currentGroup.setSize(100, 100, true);
    currentGroup.setUserSize();
    currentGroup.setUserSize();
    checkResized(currentGroup, 400, 400, false,
    checkResized(400, 400, false, "After clearing the cramp", finish);
      "After clearing the cramp",
      up3, contentWindow, win);
  };
  
  let up3 = function up3(resized) {
    win.close();
    finish();
  }
  }


  // start by making it a little smaller.
  let tests = [
  checkResized(currentGroup, -50, -50, false, "A little smaller", down1, contentWindow, win);
    // diffX, diffY, shouldResize, text
}
    [ -50,  -50, false, "A little smaller"],
    [  50,   50, false, "A little bigger"],
    [-400, -400, true,  "Much smaller"],
    [ 400,  400, true,  "Bigger after much smaller"],
    [-400, -400, true,  "Much smaller"]
  ];


function simulateResizeBy(xDiff, yDiff, win) {
  // setup
  win = win || window;
  currentGroup.setSize(600, 600, true);
  currentGroup.setUserSize();


  win.resizeBy(xDiff, yDiff);
  // run the tests
  next();
}
}


function checkResized(item, xDiff, yDiff, expectResized, note, callback, contentWindow, win) {
// ----------
  let originalBounds = new contentWindow.Rect(item.getBounds());
function resizeWindow(win, diffX, diffY, callback) {
  simulateResizeBy(xDiff, yDiff, win);
  let targetWidth = win.outerWidth + diffX;
  let targetHeight = win.outerHeight + diffY;

  win.addEventListener("resize", function onResize() {
    let {outerWidth: width, outerHeight: height} = win;
    if (width != targetWidth || height != targetHeight)
      return;

    win.removeEventListener("resize", onResize, false);
    executeSoon(callback);
  }, false);


  let newBounds = item.getBounds();
  win.resizeBy(diffX, diffY);
  let resized = !newBounds.equals(originalBounds);
  if (expectResized !== undefined)
    is(resized, expectResized, note + ": The group should " + 
      (expectResized ? "" : "not ") + "be resized");
  callback(resized);
}
}