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;
|
2012-06-03 10:15:41 -07:00
|
|
|
let tiltOpened = false;
|
2011-12-21 04:39:29 -08:00
|
|
|
|
|
|
|
function test() {
|
|
|
|
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() {
|
2012-11-30 00:07:59 -08:00
|
|
|
TiltUtils.setDocumentZoom(window, ZOOM);
|
|
|
|
|
2011-12-21 04:39:29 -08:00
|
|
|
createTilt({
|
|
|
|
onTiltOpen: function(instance)
|
|
|
|
{
|
2012-06-03 10:15:41 -07:00
|
|
|
tiltOpened = true;
|
|
|
|
|
2012-11-30 00:07:59 -08:00
|
|
|
ok(isApprox(instance.presenter._getPageZoom(), ZOOM),
|
2012-01-20 11:05:00 -08:00
|
|
|
"The Highlighter zoom doesn't have the expected results.");
|
|
|
|
|
2011-12-21 04:39:29 -08:00
|
|
|
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;
|
|
|
|
|
2012-02-07 01:44:55 -08:00
|
|
|
let renderer = instance.presenter._renderer;
|
2011-12-21 04:39:29 -08:00
|
|
|
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-20 11:05:00 -08:00
|
|
|
|
2012-01-19 07:48:22 -08:00
|
|
|
Services.obs.addObserver(cleanup, DESTROYED, false);
|
2012-11-30 00:07:59 -08:00
|
|
|
Tilt.destroy(Tilt.currentWindowId);
|
2011-12-21 04:39:29 -08:00
|
|
|
});
|
2012-01-20 11:05:00 -08:00
|
|
|
}
|
2012-06-03 10:15:41 -07:00
|
|
|
}, false, function suddenDeath()
|
|
|
|
{
|
|
|
|
info("Tilt could not be initialized properly.");
|
|
|
|
cleanup();
|
2011-12-21 04:39:29 -08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function cleanup() {
|
2012-06-03 10:15:41 -07:00
|
|
|
if (tiltOpened) { Services.obs.removeObserver(cleanup, DESTROYED); }
|
2011-12-21 04:39:29 -08:00
|
|
|
gBrowser.removeCurrentTab();
|
|
|
|
finish();
|
|
|
|
}
|