2011-02-27 17:36:36 -08:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
2011-01-21 07:21:30 -08:00
|
|
|
|
|
|
|
function test() {
|
|
|
|
waitForExplicitFinish();
|
2013-08-16 11:03:43 -07:00
|
|
|
newWindowWithTabView(onTabViewShown, null, 850);
|
2011-01-21 07:21:30 -08:00
|
|
|
}
|
|
|
|
|
2011-08-02 22:38:07 -07:00
|
|
|
function onTabViewShown(win) {
|
|
|
|
registerCleanupFunction(function () win.close());
|
2011-01-21 07:21:30 -08:00
|
|
|
|
2011-08-02 22:38:07 -07:00
|
|
|
let contentWindow = win.TabView.getContentWindow();
|
|
|
|
let currentGroup = contentWindow.GroupItems.getActiveGroupItem();
|
2011-01-21 07:21:30 -08:00
|
|
|
|
2011-08-02 22:38:07 -07:00
|
|
|
function checkResized(diffX, diffY, shouldResize, text, callback) {
|
|
|
|
let {width: origWidth, height: origHeight} = currentGroup.getBounds();
|
2011-01-21 07:21:30 -08:00
|
|
|
|
2011-08-02 22:38:07 -07:00
|
|
|
resizeWindow(win, diffX, diffY, function () {
|
|
|
|
let {width: newWidth, height: newHeight} = currentGroup.getBounds();
|
|
|
|
let resized = (origWidth != newWidth || origHeight != newHeight);
|
2011-01-21 07:21:30 -08:00
|
|
|
|
2011-08-02 22:38:07 -07:00
|
|
|
is(resized, shouldResize, text + ": The group should " +
|
|
|
|
(shouldResize ? "" : "not ") + "have been resized");
|
2011-01-21 07:21:30 -08:00
|
|
|
|
2011-08-02 22:38:07 -07:00
|
|
|
callback();
|
|
|
|
});
|
2011-01-21 07:21:30 -08:00
|
|
|
}
|
|
|
|
|
2011-08-02 22:38:07 -07:00
|
|
|
function next() {
|
|
|
|
let test = tests.shift();
|
|
|
|
|
|
|
|
if (test)
|
|
|
|
checkResized.apply(this, test.concat([next]));
|
|
|
|
else
|
|
|
|
finishTest();
|
2011-01-21 07:21:30 -08:00
|
|
|
}
|
|
|
|
|
2011-08-02 22:38:07 -07:00
|
|
|
function finishTest() {
|
2011-01-21 07:21:30 -08:00
|
|
|
// reset the usersize of the group, so this should clear the "cramped" feeling.
|
2011-08-02 22:38:07 -07:00
|
|
|
currentGroup.setSize(100, 100, true);
|
2011-01-21 07:21:30 -08:00
|
|
|
currentGroup.setUserSize();
|
2011-08-02 22:38:07 -07:00
|
|
|
checkResized(400, 400, false, "After clearing the cramp", finish);
|
2011-01-21 07:21:30 -08:00
|
|
|
}
|
|
|
|
|
2011-08-02 22:38:07 -07:00
|
|
|
let tests = [
|
|
|
|
// 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"]
|
|
|
|
];
|
2011-01-21 07:21:30 -08:00
|
|
|
|
2011-08-02 22:38:07 -07:00
|
|
|
// setup
|
|
|
|
currentGroup.setSize(600, 600, true);
|
|
|
|
currentGroup.setUserSize();
|
2011-01-21 07:21:30 -08:00
|
|
|
|
2011-08-02 22:38:07 -07:00
|
|
|
// run the tests
|
|
|
|
next();
|
2011-01-21 07:21:30 -08:00
|
|
|
}
|
|
|
|
|
2011-08-02 22:38:07 -07:00
|
|
|
// ----------
|
|
|
|
function resizeWindow(win, diffX, diffY, callback) {
|
|
|
|
let targetWidth = win.outerWidth + diffX;
|
|
|
|
let targetHeight = win.outerHeight + diffY;
|
|
|
|
|
2014-01-16 05:37:16 -08:00
|
|
|
(function tryResize() {
|
2011-08-02 22:38:07 -07:00
|
|
|
let {outerWidth: width, outerHeight: height} = win;
|
2014-01-16 05:37:16 -08:00
|
|
|
if (width != targetWidth || height != targetHeight) {
|
|
|
|
win.resizeTo(targetWidth, targetHeight);
|
|
|
|
executeSoon(tryResize);
|
|
|
|
} else {
|
|
|
|
callback();
|
|
|
|
}
|
|
|
|
})();
|
2011-01-21 07:21:30 -08:00
|
|
|
}
|