2011-12-21 04:39:29 -08:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const ZOOM = 2;
|
|
|
|
const RESIZE = 50;
|
|
|
|
|
|
|
|
function test() {
|
2012-01-20 03:36:48 -08:00
|
|
|
let random = Math.random() * 10;
|
|
|
|
|
|
|
|
TiltUtils.setDocumentZoom(window, random);
|
|
|
|
ok(isApprox(TiltUtils.getDocumentZoom(window), random),
|
2011-12-21 04:39:29 -08:00
|
|
|
"The getDocumentZoom utility function didn't return the expected results.");
|
|
|
|
|
2012-01-15 23:00:57 -08:00
|
|
|
|
2011-12-21 04:39:29 -08:00
|
|
|
if (!isTiltEnabled()) {
|
|
|
|
info("Skipping controller test because Tilt isn't enabled.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!isWebGLSupported()) {
|
|
|
|
info("Skipping controller test because WebGL isn't supported.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
waitForExplicitFinish();
|
|
|
|
|
|
|
|
createTab(function() {
|
|
|
|
createTilt({
|
|
|
|
onInspectorOpen: function()
|
|
|
|
{
|
2012-01-20 03:36:48 -08:00
|
|
|
TiltUtils.setDocumentZoom(window, ZOOM);
|
2011-12-21 04:39:29 -08:00
|
|
|
},
|
|
|
|
onTiltOpen: function(instance)
|
|
|
|
{
|
|
|
|
ok(isApprox(instance.presenter.transforms.zoom, ZOOM),
|
|
|
|
"The presenter transforms zoom wasn't initially set correctly.");
|
|
|
|
|
|
|
|
let contentWindow = gBrowser.selectedBrowser.contentWindow;
|
|
|
|
let initialWidth = contentWindow.innerWidth;
|
|
|
|
let initialHeight = contentWindow.innerHeight;
|
|
|
|
|
|
|
|
let renderer = instance.presenter.renderer;
|
|
|
|
let arcball = instance.controller.arcball;
|
|
|
|
|
|
|
|
ok(isApprox(contentWindow.innerWidth * ZOOM, renderer.width, 1),
|
2012-01-20 03:36:48 -08:00
|
|
|
"The renderer width wasn't set correctly before the resize.");
|
2011-12-21 04:39:29 -08:00
|
|
|
ok(isApprox(contentWindow.innerHeight * ZOOM, renderer.height, 1),
|
2012-01-20 03:36:48 -08:00
|
|
|
"The renderer height wasn't set correctly before the resize.");
|
2011-12-21 04:39:29 -08:00
|
|
|
|
|
|
|
ok(isApprox(contentWindow.innerWidth * ZOOM, arcball.width, 1),
|
2012-01-20 03:36:48 -08:00
|
|
|
"The arcball width wasn't set correctly before the resize.");
|
2011-12-21 04:39:29 -08:00
|
|
|
ok(isApprox(contentWindow.innerHeight * ZOOM, arcball.height, 1),
|
2012-01-20 03:36:48 -08:00
|
|
|
"The arcball height wasn't set correctly before the resize.");
|
2011-12-21 04:39:29 -08:00
|
|
|
|
|
|
|
|
|
|
|
window.resizeBy(-RESIZE * ZOOM, -RESIZE * ZOOM);
|
|
|
|
|
|
|
|
executeSoon(function() {
|
|
|
|
ok(isApprox(contentWindow.innerWidth + RESIZE, initialWidth, 1),
|
2012-01-20 03:36:48 -08:00
|
|
|
"The content window width wasn't set correctly after the resize.");
|
2011-12-21 04:39:29 -08:00
|
|
|
ok(isApprox(contentWindow.innerHeight + RESIZE, initialHeight, 1),
|
2012-01-20 03:36:48 -08:00
|
|
|
"The content window height wasn't set correctly after the resize.");
|
2011-12-21 04:39:29 -08:00
|
|
|
|
|
|
|
ok(isApprox(contentWindow.innerWidth * ZOOM, renderer.width, 1),
|
2012-01-20 03:36:48 -08:00
|
|
|
"The renderer width wasn't set correctly after the resize.");
|
2011-12-21 04:39:29 -08:00
|
|
|
ok(isApprox(contentWindow.innerHeight * ZOOM, renderer.height, 1),
|
2012-01-20 03:36:48 -08:00
|
|
|
"The renderer height wasn't set correctly after the resize.");
|
2011-12-21 04:39:29 -08:00
|
|
|
|
|
|
|
ok(isApprox(contentWindow.innerWidth * ZOOM, arcball.width, 1),
|
2012-01-20 03:36:48 -08:00
|
|
|
"The arcball width wasn't set correctly after the resize.");
|
2011-12-21 04:39:29 -08:00
|
|
|
ok(isApprox(contentWindow.innerHeight * ZOOM, arcball.height, 1),
|
2012-01-20 03:36:48 -08:00
|
|
|
"The arcball height wasn't set correctly after the resize.");
|
2011-12-21 04:39:29 -08:00
|
|
|
|
|
|
|
|
|
|
|
window.resizeBy(RESIZE * ZOOM, RESIZE * ZOOM);
|
|
|
|
|
2012-01-19 07:48:22 -08:00
|
|
|
Services.obs.addObserver(cleanup, DESTROYED, false);
|
2011-12-21 04:39:29 -08:00
|
|
|
InspectorUI.closeInspectorUI();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function cleanup() {
|
2012-01-19 07:48:22 -08:00
|
|
|
Services.obs.removeObserver(cleanup, DESTROYED);
|
2011-12-21 04:39:29 -08:00
|
|
|
gBrowser.removeCurrentTab();
|
|
|
|
finish();
|
|
|
|
}
|