mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 22:56:11 +03:00
commit
01408a4744
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,7 +3,7 @@ node_modules
|
|||||||
build/
|
build/
|
||||||
sftp-config.json
|
sftp-config.json
|
||||||
coverage/
|
coverage/
|
||||||
temp/
|
instrumented/
|
||||||
.idea
|
.idea
|
||||||
/nbproject/private/
|
/nbproject/private/
|
||||||
.directory
|
.directory
|
||||||
|
53
Gruntfile.js
53
Gruntfile.js
@ -1,18 +1,20 @@
|
|||||||
/* global module */
|
/* global module */
|
||||||
|
|
||||||
module.exports = function(grunt) {
|
module.exports = function(grunt) {
|
||||||
|
var dateFormat = require('dateformat');
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
grunt.loadNpmTasks("grunt-contrib-compress");
|
grunt.loadNpmTasks("grunt-contrib-compress");
|
||||||
grunt.loadNpmTasks("grunt-contrib-concat");
|
grunt.loadNpmTasks("grunt-contrib-concat");
|
||||||
grunt.loadNpmTasks("grunt-contrib-uglify");
|
grunt.loadNpmTasks("grunt-contrib-uglify");
|
||||||
grunt.loadNpmTasks("grunt-qunit-istanbul");
|
grunt.loadNpmTasks("grunt-contrib-qunit");
|
||||||
grunt.loadNpmTasks("grunt-contrib-connect");
|
grunt.loadNpmTasks("grunt-contrib-connect");
|
||||||
grunt.loadNpmTasks("grunt-contrib-watch");
|
grunt.loadNpmTasks("grunt-contrib-watch");
|
||||||
grunt.loadNpmTasks("grunt-contrib-clean");
|
grunt.loadNpmTasks("grunt-contrib-clean");
|
||||||
grunt.loadNpmTasks("grunt-eslint");
|
grunt.loadNpmTasks("grunt-eslint");
|
||||||
grunt.loadNpmTasks("grunt-git-describe");
|
grunt.loadNpmTasks("grunt-git-describe");
|
||||||
grunt.loadNpmTasks('grunt-text-replace');
|
grunt.loadNpmTasks('grunt-text-replace');
|
||||||
|
grunt.loadNpmTasks('grunt-istanbul');
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
var packageJson = grunt.file.readJSON("package.json"),
|
var packageJson = grunt.file.readJSON("package.json"),
|
||||||
@ -21,6 +23,7 @@ module.exports = function(grunt) {
|
|||||||
packageDirName = "openseadragon-bin-" + packageJson.version,
|
packageDirName = "openseadragon-bin-" + packageJson.version,
|
||||||
packageDir = "build/" + packageDirName + "/",
|
packageDir = "build/" + packageDirName + "/",
|
||||||
releaseRoot = "../site-build/built-openseadragon/",
|
releaseRoot = "../site-build/built-openseadragon/",
|
||||||
|
coverageDir = 'coverage/' + dateFormat(new Date(), 'yyyymmdd-HHMMss'),
|
||||||
sources = [
|
sources = [
|
||||||
"src/openseadragon.js",
|
"src/openseadragon.js",
|
||||||
"src/fullscreen.js",
|
"src/fullscreen.js",
|
||||||
@ -83,7 +86,7 @@ module.exports = function(grunt) {
|
|||||||
clean: {
|
clean: {
|
||||||
build: ["build"],
|
build: ["build"],
|
||||||
package: [packageDir],
|
package: [packageDir],
|
||||||
coverage: ["coverage"],
|
coverage: ["instrumented"],
|
||||||
release: {
|
release: {
|
||||||
src: [releaseRoot],
|
src: [releaseRoot],
|
||||||
options: {
|
options: {
|
||||||
@ -154,7 +157,8 @@ module.exports = function(grunt) {
|
|||||||
qunit: {
|
qunit: {
|
||||||
normal: {
|
normal: {
|
||||||
options: {
|
options: {
|
||||||
urls: [ "http://localhost:8000/test/test.html" ]
|
urls: [ "http://localhost:8000/test/test.html" ],
|
||||||
|
timeout: 10000
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
coverage: {
|
coverage: {
|
||||||
@ -162,11 +166,13 @@ module.exports = function(grunt) {
|
|||||||
urls: [ "http://localhost:8000/test/coverage.html" ],
|
urls: [ "http://localhost:8000/test/coverage.html" ],
|
||||||
coverage: {
|
coverage: {
|
||||||
src: ['src/*.js'],
|
src: ['src/*.js'],
|
||||||
htmlReport: 'coverage/html/',
|
htmlReport: coverageDir + '/html/',
|
||||||
instrumentedFiles: 'temp/',
|
instrumentedFiles: 'instrumented/src/',
|
||||||
baseUrl: '.',
|
baseUrl: '.',
|
||||||
disposeCollector: true
|
disposeCollector: true
|
||||||
}
|
},
|
||||||
|
inject: 'test/helpers/phantom-bridge.js',
|
||||||
|
timeout: 10000
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
all: {
|
all: {
|
||||||
@ -199,7 +205,38 @@ module.exports = function(grunt) {
|
|||||||
},
|
},
|
||||||
build: {}
|
build: {}
|
||||||
},
|
},
|
||||||
gitInfo: "unknown"
|
gitInfo: "unknown",
|
||||||
|
instrument: {
|
||||||
|
files: sources,
|
||||||
|
options: {
|
||||||
|
lazy: false,
|
||||||
|
basePath: 'instrumented/'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
reloadTasks: {
|
||||||
|
rootPath: "instrumented/src/"
|
||||||
|
},
|
||||||
|
storeCoverage: {
|
||||||
|
options: {
|
||||||
|
dir: coverageDir,
|
||||||
|
'include-all-sources': true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
makeReport: {
|
||||||
|
src: "coverage/**/*.json",
|
||||||
|
options: {
|
||||||
|
type: [ "lcov", "html" ],
|
||||||
|
dir: coverageDir,
|
||||||
|
print: "detail"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
grunt.event.on("qunit.coverage", function(coverage) {
|
||||||
|
var reportPath = coverageDir + "/coverage.json";
|
||||||
|
|
||||||
|
// Create the coverage file
|
||||||
|
grunt.file.write(reportPath, JSON.stringify(coverage));
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
@ -287,7 +324,7 @@ module.exports = function(grunt) {
|
|||||||
// ----------
|
// ----------
|
||||||
// Coverage task.
|
// Coverage task.
|
||||||
// Outputs unit test code coverage report.
|
// Outputs unit test code coverage report.
|
||||||
grunt.registerTask("coverage", ["clean:coverage", "connect", "qunit:coverage"]);
|
grunt.registerTask("coverage", ["clean:coverage", "instrument", "connect", "qunit:coverage", "makeReport"]);
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Package task.
|
// Package task.
|
||||||
|
34
package.json
34
package.json
@ -2,31 +2,45 @@
|
|||||||
"name": "openseadragon",
|
"name": "openseadragon",
|
||||||
"version": "2.3.1",
|
"version": "2.3.1",
|
||||||
"description": "Provides a smooth, zoomable user interface for HTML/Javascript.",
|
"description": "Provides a smooth, zoomable user interface for HTML/Javascript.",
|
||||||
"keywords": ["image", "zoom", "pan", "openseadragon", "seadragon", "deepzoom", "dzi", "iiif", "osm", "tms"],
|
"keywords": [
|
||||||
|
"image",
|
||||||
|
"zoom",
|
||||||
|
"pan",
|
||||||
|
"openseadragon",
|
||||||
|
"seadragon",
|
||||||
|
"deepzoom",
|
||||||
|
"dzi",
|
||||||
|
"iiif",
|
||||||
|
"osm",
|
||||||
|
"tms"
|
||||||
|
],
|
||||||
"homepage": "http://openseadragon.github.io/",
|
"homepage": "http://openseadragon.github.io/",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/openseadragon/openseadragon/issues"
|
"url": "https://github.com/openseadragon/openseadragon/issues"
|
||||||
},
|
},
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"files": ["build/openseadragon/"],
|
"files": [
|
||||||
|
"build/openseadragon/"
|
||||||
|
],
|
||||||
"main": "build/openseadragon/openseadragon.js",
|
"main": "build/openseadragon/openseadragon.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/openseadragon/openseadragon.git"
|
"url": "https://github.com/openseadragon/openseadragon.git"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"grunt": "^0.4.5",
|
"grunt": "^1.0.1",
|
||||||
"grunt-contrib-clean": "^0.7.0",
|
"grunt-contrib-clean": "^1.1.0",
|
||||||
"grunt-contrib-compress": "^1.4.3",
|
"grunt-contrib-compress": "^1.4.3",
|
||||||
"grunt-contrib-concat": "^1.0.1",
|
"grunt-contrib-concat": "^1.0.1",
|
||||||
"grunt-contrib-connect": "^0.11.2",
|
"grunt-contrib-connect": "^1.0.2",
|
||||||
"grunt-contrib-uglify": "^2.0.0",
|
"grunt-contrib-qunit": "^2.0.0",
|
||||||
"grunt-contrib-watch": "^0.6.1",
|
"grunt-contrib-uglify": "^3.2.1",
|
||||||
"grunt-git-describe": "^2.3.2",
|
"grunt-contrib-watch": "^1.0.0",
|
||||||
"grunt-eslint": "^19.0.0",
|
"grunt-eslint": "^19.0.0",
|
||||||
"grunt-qunit-istanbul": "^0.6.0",
|
"grunt-git-describe": "^2.3.2",
|
||||||
|
"grunt-istanbul": "^0.8.0",
|
||||||
"grunt-text-replace": "^0.4.0",
|
"grunt-text-replace": "^0.4.0",
|
||||||
"qunitjs": "^1.20.0"
|
"qunitjs": "2.4.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "grunt test",
|
"test": "grunt test",
|
||||||
|
@ -21,40 +21,40 @@
|
|||||||
<script src="/test/lib/jquery.simulate.js"></script>
|
<script src="/test/lib/jquery.simulate.js"></script>
|
||||||
|
|
||||||
<!-- OpenSeadragon sources -->
|
<!-- OpenSeadragon sources -->
|
||||||
<script src="/src/openseadragon.js"></script>
|
<script src="/instrumented/src/openseadragon.js"></script>
|
||||||
<script src="/src/fullscreen.js"></script>
|
<script src="/instrumented/src/fullscreen.js"></script>
|
||||||
<script src="/src/eventsource.js"></script>
|
<script src="/instrumented/src/eventsource.js"></script>
|
||||||
<script src="/src/mousetracker.js"></script>
|
<script src="/instrumented/src/mousetracker.js"></script>
|
||||||
<script src="/src/control.js"></script>
|
<script src="/instrumented/src/control.js"></script>
|
||||||
<script src="/src/controldock.js"></script>
|
<script src="/instrumented/src/controldock.js"></script>
|
||||||
<script src="/src/placement.js"></script>
|
<script src="/instrumented/src/placement.js"></script>
|
||||||
<script src="/src/viewer.js"></script>
|
<script src="/instrumented/src/viewer.js"></script>
|
||||||
<script src="/src/navigator.js"></script>
|
<script src="/instrumented/src/navigator.js"></script>
|
||||||
<script src="/src/strings.js"></script>
|
<script src="/instrumented/src/strings.js"></script>
|
||||||
<script src="/src/point.js"></script>
|
<script src="/instrumented/src/point.js"></script>
|
||||||
<script src="/src/tilesource.js"></script>
|
<script src="/instrumented/src/tilesource.js"></script>
|
||||||
<script src="/src/dzitilesource.js"></script>
|
<script src="/instrumented/src/dzitilesource.js"></script>
|
||||||
<script src="/src/iiiftilesource.js"></script>
|
<script src="/instrumented/src/iiiftilesource.js"></script>
|
||||||
<script src="/src/osmtilesource.js"></script>
|
<script src="/instrumented/src/osmtilesource.js"></script>
|
||||||
<script src="/src/tmstilesource.js"></script>
|
<script src="/instrumented/src/tmstilesource.js"></script>
|
||||||
<script src="/src/zoomifytilesource.js"></script>
|
<script src="/instrumented/src/zoomifytilesource.js"></script>
|
||||||
<script src="/src/legacytilesource.js"></script>
|
<script src="/instrumented/src/legacytilesource.js"></script>
|
||||||
<script src="/src/imagetilesource.js"></script>
|
<script src="/instrumented/src/imagetilesource.js"></script>
|
||||||
<script src="/src/tilesourcecollection.js"></script>
|
<script src="/instrumented/src/tilesourcecollection.js"></script>
|
||||||
<script src="/src/button.js"></script>
|
<script src="/instrumented/src/button.js"></script>
|
||||||
<script src="/src/buttongroup.js"></script>
|
<script src="/instrumented/src/buttongroup.js"></script>
|
||||||
<script src="/src/rectangle.js"></script>
|
<script src="/instrumented/src/rectangle.js"></script>
|
||||||
<script src="/src/referencestrip.js"></script>
|
<script src="/instrumented/src/referencestrip.js"></script>
|
||||||
<script src="/src/displayrectangle.js"></script>
|
<script src="/instrumented/src/displayrectangle.js"></script>
|
||||||
<script src="/src/spring.js"></script>
|
<script src="/instrumented/src/spring.js"></script>
|
||||||
<script src="/src/imageloader.js"></script>
|
<script src="/instrumented/src/imageloader.js"></script>
|
||||||
<script src="/src/tile.js"></script>
|
<script src="/instrumented/src/tile.js"></script>
|
||||||
<script src="/src/overlay.js"></script>
|
<script src="/instrumented/src/overlay.js"></script>
|
||||||
<script src="/src/drawer.js"></script>
|
<script src="/instrumented/src/drawer.js"></script>
|
||||||
<script src="/src/viewport.js"></script>
|
<script src="/instrumented/src/viewport.js"></script>
|
||||||
<script src="/src/tiledimage.js"></script>
|
<script src="/instrumented/src/tiledimage.js"></script>
|
||||||
<script src="/src/tilecache.js"></script>
|
<script src="/instrumented/src/tilecache.js"></script>
|
||||||
<script src="/src/world.js"></script>
|
<script src="/instrumented/src/world.js"></script>
|
||||||
|
|
||||||
<!-- Helpers -->
|
<!-- Helpers -->
|
||||||
<script src="/test/helpers/legacy.mouse.shim.js"></script>
|
<script src="/test/helpers/legacy.mouse.shim.js"></script>
|
||||||
|
73
test/helpers/phantom-bridge.js
Normal file
73
test/helpers/phantom-bridge.js
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* grunt-contrib-qunit
|
||||||
|
* http://gruntjs.com/
|
||||||
|
*
|
||||||
|
* Copyright (c) 2016 "Cowboy" Ben Alman, contributors
|
||||||
|
* Licensed under the MIT license.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*global QUnit:true, alert:true*/
|
||||||
|
(function (factory) {
|
||||||
|
if (typeof define === 'function' && define.amd) {
|
||||||
|
require(['qunit'], factory);
|
||||||
|
} else {
|
||||||
|
factory(QUnit);
|
||||||
|
}
|
||||||
|
}(function(QUnit) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
// Don't re-order tests.
|
||||||
|
QUnit.config.reorder = false;
|
||||||
|
|
||||||
|
// Send messages to the parent PhantomJS process via alert! Good times!!
|
||||||
|
function sendMessage() {
|
||||||
|
var args = [].slice.call(arguments);
|
||||||
|
alert(JSON.stringify(args));
|
||||||
|
}
|
||||||
|
|
||||||
|
// These methods connect QUnit to PhantomJS.
|
||||||
|
QUnit.log(function(obj) {
|
||||||
|
// What is this I don’t even
|
||||||
|
if (obj.message === '[object Object], undefined:undefined') { return; }
|
||||||
|
|
||||||
|
// Parse some stuff before sending it.
|
||||||
|
var actual, expected;
|
||||||
|
if (!obj.result) {
|
||||||
|
// Dumping large objects can be very slow, and the dump isn't used for
|
||||||
|
// passing tests, so only dump if the test failed.
|
||||||
|
actual = QUnit.dump.parse(obj.actual);
|
||||||
|
expected = QUnit.dump.parse(obj.expected);
|
||||||
|
}
|
||||||
|
// Send it.
|
||||||
|
sendMessage('qunit.log', obj.result, actual, expected, obj.message, obj.source, obj.todo);
|
||||||
|
});
|
||||||
|
|
||||||
|
QUnit.testStart(function(obj) {
|
||||||
|
sendMessage('qunit.testStart', obj.name);
|
||||||
|
});
|
||||||
|
|
||||||
|
QUnit.testDone(function(obj) {
|
||||||
|
sendMessage('qunit.testDone', obj.name, obj.failed, obj.passed, obj.total, obj.runtime, obj.skipped, obj.todo);
|
||||||
|
});
|
||||||
|
|
||||||
|
QUnit.moduleStart(function(obj) {
|
||||||
|
sendMessage('qunit.moduleStart', obj.name);
|
||||||
|
});
|
||||||
|
|
||||||
|
QUnit.moduleDone(function(obj) {
|
||||||
|
sendMessage('qunit.moduleDone', obj.name, obj.failed, obj.passed, obj.total);
|
||||||
|
});
|
||||||
|
|
||||||
|
QUnit.begin(function() {
|
||||||
|
sendMessage('qunit.begin');
|
||||||
|
});
|
||||||
|
|
||||||
|
QUnit.done(function(obj) {
|
||||||
|
// send coverage data if available
|
||||||
|
if ( window.__coverage__ ) {
|
||||||
|
sendMessage( "qunit.coverage", window.__coverage__ );
|
||||||
|
}
|
||||||
|
|
||||||
|
sendMessage('qunit.done', obj.failed, obj.passed, obj.total, obj.runtime);
|
||||||
|
});
|
||||||
|
}));
|
@ -1,4 +1,4 @@
|
|||||||
/* global module, asyncTest, $, ok, equal, notEqual, start, test, Util */
|
/* global $, Util */
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
|
|
||||||
@ -64,38 +64,39 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
assessNumericValue: function ( value1, value2, variance, message ) {
|
assessNumericValue: function ( assert, value1, value2, variance, message ) {
|
||||||
ok( Util.equalsWithVariance( value1, value2, variance ), message + " Expected:" + value1 + " Found: " + value2 + " Variance: " + variance );
|
assert.ok( Util.equalsWithVariance( value1, value2, variance ), message + " Expected:" + value1 + " Found: " + value2 + " Variance: " + variance );
|
||||||
},
|
},
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
assertPointsEquals: function (pointA, pointB, precision, message) {
|
assertPointsEquals: function (assert, pointA, pointB, precision, message) {
|
||||||
Util.assessNumericValue(pointA.x, pointB.x, precision, message + " x: ");
|
Util.assessNumericValue(assert, pointA.x, pointB.x, precision, message + " x: ");
|
||||||
Util.assessNumericValue(pointA.y, pointB.y, precision, message + " y: ");
|
Util.assessNumericValue(assert, pointA.y, pointB.y, precision, message + " y: ");
|
||||||
},
|
},
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
assertRectangleEquals: function (rectA, rectB, precision, message) {
|
assertRectangleEquals: function (assert, rectA, rectB, precision, message) {
|
||||||
Util.assessNumericValue(rectA.x, rectB.x, precision, message + " x: ");
|
Util.assessNumericValue(assert, rectA.x, rectB.x, precision, message + " x: ");
|
||||||
Util.assessNumericValue(rectA.y, rectB.y, precision, message + " y: ");
|
Util.assessNumericValue(assert, rectA.y, rectB.y, precision, message + " y: ");
|
||||||
Util.assessNumericValue(rectA.width, rectB.width, precision,
|
Util.assessNumericValue(assert, rectA.width, rectB.width, precision,
|
||||||
message + " width: ");
|
message + " width: ");
|
||||||
Util.assessNumericValue(rectA.height, rectB.height, precision,
|
Util.assessNumericValue(assert, rectA.height, rectB.height, precision,
|
||||||
message + " height: ");
|
message + " height: ");
|
||||||
Util.assessNumericValue(rectA.degrees, rectB.degrees, precision,
|
Util.assessNumericValue(assert, rectA.degrees, rectB.degrees, precision,
|
||||||
message + " degrees: ");
|
message + " degrees: ");
|
||||||
},
|
},
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
timeWatcher: function ( time ) {
|
timeWatcher: function ( assert, time ) {
|
||||||
|
var done = assert.async();
|
||||||
time = time || 2000;
|
time = time || 2000;
|
||||||
var finished = false;
|
var finished = false;
|
||||||
|
|
||||||
setTimeout( function () {
|
setTimeout( function () {
|
||||||
if ( !finished ) {
|
if ( !finished ) {
|
||||||
finished = true;
|
finished = true;
|
||||||
ok( false, 'finishes in ' + time + 'ms' );
|
assert.ok( false, 'finishes in ' + time + 'ms' );
|
||||||
start();
|
done();
|
||||||
}
|
}
|
||||||
}, time );
|
}, time );
|
||||||
|
|
||||||
@ -103,7 +104,7 @@
|
|||||||
done: function () {
|
done: function () {
|
||||||
if ( !finished ) {
|
if ( !finished ) {
|
||||||
finished = true;
|
finished = true;
|
||||||
start();
|
done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -118,13 +119,12 @@
|
|||||||
if (result === undefined) {
|
if (result === undefined) {
|
||||||
result = original.apply(this, arguments);
|
result = original.apply(this, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
testDeprecation: function(obj0, member0, obj1, member1) {
|
testDeprecation: function(assert, obj0, member0, obj1, member1) {
|
||||||
var called = false;
|
var called = false;
|
||||||
var errored = false;
|
var errored = false;
|
||||||
|
|
||||||
@ -144,8 +144,8 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
obj0[member0]();
|
obj0[member0]();
|
||||||
equal(called, true, 'called through for ' + member0);
|
assert.equal(called, true, 'called through for ' + member0);
|
||||||
equal(errored, true, 'errored for ' + member0);
|
assert.equal(errored, true, 'errored for ' + member0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* global module, asyncTest, start, $, ok, equal, deepEqual, testLog */
|
/* global QUnit, $, testLog */
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var viewer;
|
var viewer;
|
||||||
@ -36,8 +36,8 @@
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
module('AJAX-Tiles', {
|
QUnit.module('AJAX-Tiles', {
|
||||||
setup: function() {
|
beforeEach: function() {
|
||||||
$('<div id="example"></div>').appendTo('#qunit-fixture');
|
$('<div id="example"></div>').appendTo('#qunit-fixture');
|
||||||
|
|
||||||
testLog.reset();
|
testLog.reset();
|
||||||
@ -52,7 +52,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
teardown: function() {
|
afterEach: function() {
|
||||||
if (viewer && viewer.close) {
|
if (viewer && viewer.close) {
|
||||||
viewer.close();
|
viewer.close();
|
||||||
}
|
}
|
||||||
@ -61,25 +61,27 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('tile-loaded event includes AJAX request object', function() {
|
QUnit.test('tile-loaded event includes AJAX request object', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var tileLoaded = function tileLoaded(evt) {
|
var tileLoaded = function tileLoaded(evt) {
|
||||||
viewer.removeHandler('tile-loaded', tileLoaded);
|
viewer.removeHandler('tile-loaded', tileLoaded);
|
||||||
ok(evt.tileRequest, 'Event includes tileRequest property');
|
assert.ok(evt.tileRequest, 'Event includes tileRequest property');
|
||||||
equal(evt.tileRequest.readyState, XMLHttpRequest.DONE, 'tileRequest is in completed state');
|
assert.equal(evt.tileRequest.readyState, XMLHttpRequest.DONE, 'tileRequest is in completed state');
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler('tile-loaded', tileLoaded);
|
viewer.addHandler('tile-loaded', tileLoaded);
|
||||||
viewer.open(customTileSource);
|
viewer.open(customTileSource);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('withCredentials is set in tile AJAX requests', function() {
|
QUnit.test('withCredentials is set in tile AJAX requests', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var tileLoaded = function tileLoaded(evt) {
|
var tileLoaded = function tileLoaded(evt) {
|
||||||
viewer.removeHandler('tile-loaded', tileLoaded);
|
viewer.removeHandler('tile-loaded', tileLoaded);
|
||||||
ok(evt.tileRequest, 'Event includes tileRequest property');
|
assert.ok(evt.tileRequest, 'Event includes tileRequest property');
|
||||||
equal(evt.tileRequest.readyState, XMLHttpRequest.DONE, 'tileRequest is in completed state');
|
assert.equal(evt.tileRequest.readyState, XMLHttpRequest.DONE, 'tileRequest is in completed state');
|
||||||
equal(evt.tileRequest.withCredentials, true, 'withCredentials is set in tile request');
|
assert.equal(evt.tileRequest.withCredentials, true, 'withCredentials is set in tile request');
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler('tile-loaded', tileLoaded);
|
viewer.addHandler('tile-loaded', tileLoaded);
|
||||||
@ -89,7 +91,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('tile-load-failed event includes AJAX request object', function() {
|
QUnit.test('tile-load-failed event includes AJAX request object', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
// Create a tile source that points to a broken URL
|
// Create a tile source that points to a broken URL
|
||||||
var brokenTileSource = OpenSeadragon.extend({}, customTileSource, {
|
var brokenTileSource = OpenSeadragon.extend({}, customTileSource, {
|
||||||
getTileUrl: function () {
|
getTileUrl: function () {
|
||||||
@ -99,31 +102,32 @@
|
|||||||
|
|
||||||
var tileLoadFailed = function tileLoadFailed(evt) {
|
var tileLoadFailed = function tileLoadFailed(evt) {
|
||||||
viewer.removeHandler('tile-load-failed', tileLoadFailed);
|
viewer.removeHandler('tile-load-failed', tileLoadFailed);
|
||||||
ok(evt.tileRequest, 'Event includes tileRequest property');
|
assert.ok(evt.tileRequest, 'Event includes tileRequest property');
|
||||||
equal(evt.tileRequest.readyState, XMLHttpRequest.DONE, 'tileRequest is in completed state');
|
assert.equal(evt.tileRequest.readyState, XMLHttpRequest.DONE, 'tileRequest is in completed state');
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler('tile-load-failed', tileLoadFailed);
|
viewer.addHandler('tile-load-failed', tileLoadFailed);
|
||||||
viewer.open(brokenTileSource);
|
viewer.open(brokenTileSource);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Headers can be set per-tile', function() {
|
QUnit.test('Headers can be set per-tile', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var tileLoaded = function tileLoaded(evt) {
|
var tileLoaded = function tileLoaded(evt) {
|
||||||
viewer.removeHandler('tile-loaded', tileLoaded);
|
viewer.removeHandler('tile-loaded', tileLoaded);
|
||||||
var tile = evt.tile;
|
var tile = evt.tile;
|
||||||
ok(tile, 'tile property exists on event');
|
assert.ok(tile, 'tile property exists on event');
|
||||||
ok(tile.ajaxHeaders, 'Tile has ajaxHeaders property');
|
assert.ok(tile.ajaxHeaders, 'Tile has ajaxHeaders property');
|
||||||
equal(tile.ajaxHeaders.Range, getTileRangeHeader(tile.level, tile.x, tile.y), 'Tile has correct range header.');
|
assert.equal(tile.ajaxHeaders.Range, getTileRangeHeader(tile.level, tile.x, tile.y), 'Tile has correct range header.');
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler('tile-loaded', tileLoaded);
|
viewer.addHandler('tile-loaded', tileLoaded);
|
||||||
|
|
||||||
viewer.open(customTileSource);
|
viewer.open(customTileSource);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Headers are propagated correctly', function() {
|
QUnit.test('Headers are propagated correctly', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
// Create a tile source that sets a static header for tiles
|
// Create a tile source that sets a static header for tiles
|
||||||
var staticHeaderTileSource = OpenSeadragon.extend({}, customTileSource, {
|
var staticHeaderTileSource = OpenSeadragon.extend({}, customTileSource, {
|
||||||
getTileAjaxHeaders: function() {
|
getTileAjaxHeaders: function() {
|
||||||
@ -142,13 +146,13 @@
|
|||||||
var tileLoaded = function tileLoaded(evt) {
|
var tileLoaded = function tileLoaded(evt) {
|
||||||
viewer.removeHandler('tile-loaded', tileLoaded);
|
viewer.removeHandler('tile-loaded', tileLoaded);
|
||||||
var tile = evt.tile;
|
var tile = evt.tile;
|
||||||
ok(tile, 'tile property exists on event');
|
assert.ok(tile, 'tile property exists on event');
|
||||||
ok(tile.ajaxHeaders, 'Tile has ajaxHeaders property');
|
assert.ok(tile.ajaxHeaders, 'Tile has ajaxHeaders property');
|
||||||
deepEqual(
|
assert.deepEqual(
|
||||||
tile.ajaxHeaders, expectedHeaders,
|
tile.ajaxHeaders, expectedHeaders,
|
||||||
'Tile headers include headers set on Viewer and TiledImage'
|
'Tile headers include headers set on Viewer and TiledImage'
|
||||||
);
|
);
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler('tile-loaded', tileLoaded);
|
viewer.addHandler('tile-loaded', tileLoaded);
|
||||||
@ -161,7 +165,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Viewer headers are overwritten by TiledImage', function() {
|
QUnit.test('Viewer headers are overwritten by TiledImage', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
// Create a tile source that sets a static header for tiles
|
// Create a tile source that sets a static header for tiles
|
||||||
var staticHeaderTileSource = OpenSeadragon.extend({}, customTileSource, {
|
var staticHeaderTileSource = OpenSeadragon.extend({}, customTileSource, {
|
||||||
getTileAjaxHeaders: function() {
|
getTileAjaxHeaders: function() {
|
||||||
@ -180,13 +185,13 @@
|
|||||||
var tileLoaded = function tileLoaded(evt) {
|
var tileLoaded = function tileLoaded(evt) {
|
||||||
viewer.removeHandler('tile-loaded', tileLoaded);
|
viewer.removeHandler('tile-loaded', tileLoaded);
|
||||||
var tile = evt.tile;
|
var tile = evt.tile;
|
||||||
ok(tile, 'tile property exists on event');
|
assert.ok(tile, 'tile property exists on event');
|
||||||
ok(tile.ajaxHeaders, 'Tile has ajaxHeaders property');
|
assert.ok(tile.ajaxHeaders, 'Tile has ajaxHeaders property');
|
||||||
deepEqual(
|
assert.deepEqual(
|
||||||
tile.ajaxHeaders, expectedHeaders,
|
tile.ajaxHeaders, expectedHeaders,
|
||||||
'TiledImage header overwrites viewer header'
|
'TiledImage header overwrites viewer header'
|
||||||
);
|
);
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler('tile-loaded', tileLoaded);
|
viewer.addHandler('tile-loaded', tileLoaded);
|
||||||
@ -200,7 +205,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('TiledImage headers are overwritten by Tile', function() {
|
QUnit.test('TiledImage headers are overwritten by Tile', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
|
|
||||||
var expectedHeaders = {
|
var expectedHeaders = {
|
||||||
'X-Viewer-Header': 'ViewerHeaderValue',
|
'X-Viewer-Header': 'ViewerHeaderValue',
|
||||||
@ -211,13 +217,13 @@
|
|||||||
var tileLoaded = function tileLoaded(evt) {
|
var tileLoaded = function tileLoaded(evt) {
|
||||||
viewer.removeHandler('tile-loaded', tileLoaded);
|
viewer.removeHandler('tile-loaded', tileLoaded);
|
||||||
var tile = evt.tile;
|
var tile = evt.tile;
|
||||||
ok(tile, 'tile property exists on event');
|
assert.ok(tile, 'tile property exists on event');
|
||||||
ok(tile.ajaxHeaders, 'Tile has ajaxHeaders property');
|
assert.ok(tile.ajaxHeaders, 'Tile has ajaxHeaders property');
|
||||||
deepEqual(
|
assert.deepEqual(
|
||||||
tile.ajaxHeaders, expectedHeaders,
|
tile.ajaxHeaders, expectedHeaders,
|
||||||
'Tile header overwrites TiledImage header'
|
'Tile header overwrites TiledImage header'
|
||||||
);
|
);
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler('tile-loaded', tileLoaded);
|
viewer.addHandler('tile-loaded', tileLoaded);
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
/* global module, asyncTest, $, ok, equal, notEqual, start, test, Util, testLog */
|
/* global QUnit, $, Util, testLog */
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var viewer;
|
var viewer;
|
||||||
|
|
||||||
module('Basic', {
|
QUnit.module('Basic', {
|
||||||
setup: function () {
|
beforeEach: function () {
|
||||||
var example = $('<div id="example"></div>').appendTo("#qunit-fixture");
|
$('<div id="example"></div>').appendTo("#qunit-fixture");
|
||||||
|
|
||||||
testLog.reset();
|
testLog.reset();
|
||||||
|
|
||||||
@ -15,7 +15,7 @@
|
|||||||
springStiffness: 100 // Faster animation = faster tests
|
springStiffness: 100 // Faster animation = faster tests
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
teardown: function () {
|
afterEach: function () {
|
||||||
if (viewer && viewer.close) {
|
if (viewer && viewer.close) {
|
||||||
viewer.close();
|
viewer.close();
|
||||||
}
|
}
|
||||||
@ -25,57 +25,59 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('Open', function() {
|
QUnit.test('Open', function(assert) {
|
||||||
ok(viewer, 'Viewer exists');
|
var done = assert.async();
|
||||||
|
assert.ok(viewer, 'Viewer exists');
|
||||||
|
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(true, 'Open event was sent');
|
assert.ok(true, 'Open event was sent');
|
||||||
ok(event, 'Handler received event data');
|
assert.ok(event, 'Handler received event data');
|
||||||
equal(event.eventSource, viewer, 'Sender of open event was viewer');
|
assert.equal(event.eventSource, viewer, 'Sender of open event was viewer');
|
||||||
ok(viewer.viewport, 'Viewport exists');
|
assert.ok(viewer.viewport, 'Viewport exists');
|
||||||
ok(viewer.source, 'source exists');
|
assert.ok(viewer.source, 'source exists');
|
||||||
ok(viewer._updateRequestId, 'timer is on');
|
assert.ok(viewer._updateRequestId, 'timer is on');
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Open Error Handling', function() {
|
QUnit.test('Open Error Handling', function(assert) {
|
||||||
ok(viewer, 'Viewer exists');
|
var done = assert.async();
|
||||||
|
assert.ok(viewer, 'Viewer exists');
|
||||||
|
|
||||||
viewer.addHandler('open', function(event) {
|
viewer.addHandler('open', function(event) {
|
||||||
ok(false, "The open event should not fire for failed opens");
|
assert.ok(false, "The open event should not fire for failed opens");
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
viewer.addHandler('open-failed', function(event) {
|
viewer.addHandler('open-failed', function(event) {
|
||||||
ok(true, "The open-failed event should be fired when the source 404s");
|
assert.ok(true, "The open-failed event should be fired when the source 404s");
|
||||||
|
|
||||||
equal($(".openseadragon-message").length, 1, "Open failures should display a message");
|
assert.equal($(".openseadragon-message").length, 1, "Open failures should display a message");
|
||||||
|
|
||||||
ok(testLog.log.contains('["AJAX request returned %d: %s",404,"/test/data/not-a-real-file"]'),
|
assert.ok(testLog.log.contains('["AJAX request returned %d: %s",404,"/test/data/not-a-real-file"]'),
|
||||||
"AJAX failures should be logged to the console");
|
"AJAX failures should be logged to the console");
|
||||||
|
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
viewer.open('/test/data/not-a-real-file');
|
viewer.open('/test/data/not-a-real-file');
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
QUnit.test('Zoom', function(assert) {
|
||||||
asyncTest('Zoom', function() {
|
var done = assert.async();
|
||||||
viewer.addHandler("open", function () {
|
viewer.addHandler("open", function () {
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
equal(viewport.getZoom(), 1, 'We start out unzoomed');
|
assert.equal(viewport.getZoom(), 1, 'We start out unzoomed');
|
||||||
|
|
||||||
var zoomHandler = function() {
|
var zoomHandler = function() {
|
||||||
viewer.removeHandler('animation-finish', zoomHandler);
|
viewer.removeHandler('animation-finish', zoomHandler);
|
||||||
equal(viewport.getZoom(), 2, 'Zoomed correctly');
|
assert.equal(viewport.getZoom(), 2, 'Zoomed correctly');
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler('animation-finish', zoomHandler);
|
viewer.addHandler('animation-finish', zoomHandler);
|
||||||
@ -84,20 +86,20 @@
|
|||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
QUnit.test('Pan', function(assert) {
|
||||||
asyncTest('Pan', function() {
|
var done = assert.async();
|
||||||
viewer.addHandler("open", function () {
|
viewer.addHandler("open", function () {
|
||||||
var viewport = viewer.viewport,
|
var viewport = viewer.viewport,
|
||||||
center = viewport.getCenter();
|
center = viewport.getCenter();
|
||||||
|
|
||||||
ok(center.x === 0.5 && center.y === 0.5, 'We start out unpanned');
|
assert.ok(center.x === 0.5 && center.y === 0.5, 'We start out unpanned');
|
||||||
|
|
||||||
var panHandler = function() {
|
var panHandler = function() {
|
||||||
viewer.removeHandler('animation-finish', panHandler);
|
viewer.removeHandler('animation-finish', panHandler);
|
||||||
center = viewport.getCenter();
|
center = viewport.getCenter();
|
||||||
Util.assessNumericValue(center.x, 0.1, 0.00001, 'panned horizontally');
|
Util.assessNumericValue(assert, center.x, 0.1, 0.00001, 'panned horizontally');
|
||||||
Util.assessNumericValue(center.y, 0.1, 0.00001, 'panned vertically');
|
Util.assessNumericValue(assert, center.y, 0.1, 0.00001, 'panned vertically');
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler('animation-finish', panHandler);
|
viewer.addHandler('animation-finish', panHandler);
|
||||||
@ -107,9 +109,9 @@
|
|||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
QUnit.test('Home', function(assert) {
|
||||||
asyncTest('Home', function() {
|
var done = assert.async();
|
||||||
// Test setup:
|
// Test beforeEach:
|
||||||
function opener() {
|
function opener() {
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
viewport.panTo(new OpenSeadragon.Point(0.1, 0.1));
|
viewport.panTo(new OpenSeadragon.Point(0.1, 0.1));
|
||||||
@ -122,15 +124,15 @@
|
|||||||
|
|
||||||
viewer.removeHandler('animation-finish', stage1);
|
viewer.removeHandler('animation-finish', stage1);
|
||||||
|
|
||||||
ok(center.x !== 0.5 && center.y !== 0.5, 'We start out panned');
|
assert.ok(center.x !== 0.5 && center.y !== 0.5, 'We start out panned');
|
||||||
notEqual(viewport.getZoom(), 1, 'We start out zoomed');
|
assert.notEqual(viewport.getZoom(), 1, 'We start out zoomed');
|
||||||
|
|
||||||
var homeHandler = function() {
|
var homeHandler = function() {
|
||||||
viewer.removeHandler('animation-finish', homeHandler);
|
viewer.removeHandler('animation-finish', homeHandler);
|
||||||
center = viewport.getCenter();
|
center = viewport.getCenter();
|
||||||
ok(center.x === 0.5 && center.y === 0.5, 'We end up unpanned');
|
assert.ok(center.x === 0.5 && center.y === 0.5, 'We end up unpanned');
|
||||||
equal(viewport.getZoom(), 1, 'We end up unzoomed');
|
assert.equal(viewport.getZoom(), 1, 'We end up unzoomed');
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler('animation-finish', homeHandler);
|
viewer.addHandler('animation-finish', homeHandler);
|
||||||
@ -143,21 +145,21 @@
|
|||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
QUnit.test('Click', function(assert) {
|
||||||
asyncTest('Click', function() {
|
var done = assert.async();
|
||||||
viewer.addHandler("open", function () {
|
viewer.addHandler("open", function () {
|
||||||
var viewport = viewer.viewport,
|
var viewport = viewer.viewport,
|
||||||
center = viewport.getCenter();
|
center = viewport.getCenter();
|
||||||
|
|
||||||
ok(center.x === 0.5 && center.y === 0.5, 'We start out unpanned');
|
assert.ok(center.x === 0.5 && center.y === 0.5, 'We start out unpanned');
|
||||||
equal(viewport.getZoom(), 1, 'We start out unzoomed');
|
assert.equal(viewport.getZoom(), 1, 'We start out unzoomed');
|
||||||
|
|
||||||
var clickHandler = function() {
|
var clickHandler = function() {
|
||||||
viewer.removeHandler('animation-finish', clickHandler);
|
viewer.removeHandler('animation-finish', clickHandler);
|
||||||
center = viewport.getCenter();
|
center = viewport.getCenter();
|
||||||
ok(center.x > 0.37 && center.x < 0.38 && center.y > 0.37 && center.y < 0.38, 'Panned correctly');
|
assert.ok(center.x > 0.37 && center.x < 0.38 && center.y > 0.37 && center.y < 0.38, 'Panned correctly');
|
||||||
equal(viewport.getZoom(), 2, 'Zoomed correctly');
|
assert.equal(viewport.getZoom(), 2, 'Zoomed correctly');
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler('animation-finish', clickHandler);
|
viewer.addHandler('animation-finish', clickHandler);
|
||||||
@ -174,39 +176,39 @@
|
|||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
QUnit.test('FullPage', function(assert) {
|
||||||
asyncTest('FullPage', function() {
|
var done = assert.async();
|
||||||
viewer.addHandler("open", function () {
|
viewer.addHandler("open", function () {
|
||||||
ok(!viewer.isFullPage(), 'Started out not fullpage');
|
assert.ok(!viewer.isFullPage(), 'Started out not fullpage');
|
||||||
ok(!$(viewer.element).hasClass('fullpage'),
|
assert.ok(!$(viewer.element).hasClass('fullpage'),
|
||||||
'No fullpage class on div');
|
'No fullpage class on div');
|
||||||
|
|
||||||
var checkEnteringPreFullPage = function(event) {
|
var checkEnteringPreFullPage = function(event) {
|
||||||
viewer.removeHandler('pre-full-page', checkEnteringPreFullPage);
|
viewer.removeHandler('pre-full-page', checkEnteringPreFullPage);
|
||||||
ok(event.fullPage, 'Switching to fullpage');
|
assert.ok(event.fullPage, 'Switching to fullpage');
|
||||||
ok(!viewer.isFullPage(), 'Not yet fullpage');
|
assert.ok(!viewer.isFullPage(), 'Not yet fullpage');
|
||||||
};
|
};
|
||||||
|
|
||||||
var checkEnteringFullPage = function(event) {
|
var checkEnteringFullPage = function(event) {
|
||||||
viewer.removeHandler('full-page', checkEnteringFullPage);
|
viewer.removeHandler('full-page', checkEnteringFullPage);
|
||||||
ok(event.fullPage, 'Switched to fullpage');
|
assert.ok(event.fullPage, 'Switched to fullpage');
|
||||||
ok(viewer.isFullPage(), 'Enabled fullpage');
|
assert.ok(viewer.isFullPage(), 'Enabled fullpage');
|
||||||
ok($(viewer.element).hasClass('fullpage'),
|
assert.ok($(viewer.element).hasClass('fullpage'),
|
||||||
'Fullpage class added to div');
|
'Fullpage class added to div');
|
||||||
|
|
||||||
var checkExitingPreFullPage = function(event) {
|
var checkExitingPreFullPage = function(event) {
|
||||||
viewer.removeHandler('pre-full-page', checkExitingPreFullPage);
|
viewer.removeHandler('pre-full-page', checkExitingPreFullPage);
|
||||||
ok(!event.fullPage, 'Exiting fullpage');
|
assert.ok(!event.fullPage, 'Exiting fullpage');
|
||||||
ok(viewer.isFullPage(), 'Still fullpage');
|
assert.ok(viewer.isFullPage(), 'Still fullpage');
|
||||||
};
|
};
|
||||||
|
|
||||||
var checkExitingFullPage = function(event) {
|
var checkExitingFullPage = function(event) {
|
||||||
viewer.removeHandler('full-page', checkExitingFullPage);
|
viewer.removeHandler('full-page', checkExitingFullPage);
|
||||||
ok(!event.fullPage, 'Exiting fullpage');
|
assert.ok(!event.fullPage, 'Exiting fullpage');
|
||||||
ok(!viewer.isFullPage(), 'Disabled fullpage');
|
assert.ok(!viewer.isFullPage(), 'Disabled fullpage');
|
||||||
ok(!$(viewer.element).hasClass('fullpage'),
|
assert.ok(!$(viewer.element).hasClass('fullpage'),
|
||||||
'Fullpage class removed from div');
|
'Fullpage class removed from div');
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler("pre-full-page", checkExitingPreFullPage);
|
viewer.addHandler("pre-full-page", checkExitingPreFullPage);
|
||||||
@ -221,30 +223,30 @@
|
|||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('FullScreen', function() {
|
QUnit.test('FullScreen', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
if (!OpenSeadragon.supportsFullScreen) {
|
if (!OpenSeadragon.supportsFullScreen) {
|
||||||
expect(0);
|
assert.expect(0);
|
||||||
start();
|
done();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
viewer.addHandler("open", function () {
|
viewer.addHandler("open", function () {
|
||||||
ok(!OpenSeadragon.isFullScreen(), 'Started out not fullscreen');
|
assert.ok(!OpenSeadragon.isFullScreen(), 'Started out not fullscreen');
|
||||||
|
|
||||||
var checkEnteringPreFullScreen = function(event) {
|
var checkEnteringPreFullScreen = function(event) {
|
||||||
viewer.removeHandler('pre-full-screen', checkEnteringPreFullScreen);
|
viewer.removeHandler('pre-full-screen', checkEnteringPreFullScreen);
|
||||||
ok(event.fullScreen, 'Switching to fullscreen');
|
assert.ok(event.fullScreen, 'Switching to fullscreen');
|
||||||
ok(!OpenSeadragon.isFullScreen(), 'Not yet fullscreen');
|
assert.ok(!OpenSeadragon.isFullScreen(), 'Not yet fullscreen');
|
||||||
};
|
};
|
||||||
|
|
||||||
// The fullscreen mode is always denied during tests so we are
|
// The fullscreen mode is always denied during tests so we are
|
||||||
// exiting directly.
|
// exiting directly.
|
||||||
var checkExitingFullScreen = function(event) {
|
var checkExitingFullScreen = function(event) {
|
||||||
viewer.removeHandler('full-screen', checkExitingFullScreen);
|
viewer.removeHandler('full-screen', checkExitingFullScreen);
|
||||||
ok(!event.fullScreen, 'Exiting fullscreen');
|
assert.ok(!event.fullScreen, 'Exiting fullscreen');
|
||||||
ok(!OpenSeadragon.isFullScreen(), 'Disabled fullscreen');
|
assert.ok(!OpenSeadragon.isFullScreen(), 'Disabled fullscreen');
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler("pre-full-screen", checkEnteringPreFullScreen);
|
viewer.addHandler("pre-full-screen", checkEnteringPreFullScreen);
|
||||||
viewer.addHandler("full-screen", checkExitingFullScreen);
|
viewer.addHandler("full-screen", checkExitingFullScreen);
|
||||||
@ -254,16 +256,16 @@
|
|||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
QUnit.test('Close', function(assert) {
|
||||||
asyncTest('Close', function() {
|
var done = assert.async();
|
||||||
viewer.addHandler("open", function () {
|
viewer.addHandler("open", function () {
|
||||||
var closeHandler = function() {
|
var closeHandler = function() {
|
||||||
viewer.removeHandler('close', closeHandler);
|
viewer.removeHandler('close', closeHandler);
|
||||||
ok(!viewer.source, 'no source');
|
assert.ok(!viewer.source, 'no source');
|
||||||
ok(true, 'Close event was sent');
|
assert.ok(true, 'Close event was sent');
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
ok(!viewer._updateRequestId, 'timer is off');
|
assert.ok(!viewer._updateRequestId, 'timer is off');
|
||||||
start();
|
done();
|
||||||
}, 100);
|
}, 100);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -273,11 +275,11 @@
|
|||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
QUnit.test('Destroy', function(assert) {
|
||||||
asyncTest('Destroy', function() {
|
var done = assert.async();
|
||||||
viewer.addHandler("open", function () {
|
viewer.addHandler("open", function () {
|
||||||
// Check that the DOM has been modified
|
// Check that the DOM has been modified
|
||||||
notEqual(0, $('#example').children().length);
|
assert.notEqual(0, $('#example').children().length);
|
||||||
|
|
||||||
var closeCalled = false;
|
var closeCalled = false;
|
||||||
var closeHandler = function() {
|
var closeHandler = function() {
|
||||||
@ -289,14 +291,14 @@
|
|||||||
viewer.destroy();
|
viewer.destroy();
|
||||||
|
|
||||||
// Check that the DOM has been cleaned up
|
// Check that the DOM has been cleaned up
|
||||||
equal(0, $('#example').children().length);
|
assert.equal(0, $('#example').children().length);
|
||||||
equal(null, viewer.canvas);
|
assert.equal(null, viewer.canvas);
|
||||||
equal(null, viewer.keyboardCommandArea);
|
assert.equal(null, viewer.keyboardCommandArea);
|
||||||
equal(null, viewer.container);
|
assert.equal(null, viewer.container);
|
||||||
equal(null, viewer.element);
|
assert.equal(null, viewer.element);
|
||||||
equal(true, closeCalled);
|
assert.equal(true, closeCalled);
|
||||||
viewer = null;
|
viewer = null;
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
@ -319,8 +321,8 @@
|
|||||||
img.src = corsImg;
|
img.src = corsImg;
|
||||||
}
|
}
|
||||||
|
|
||||||
asyncTest( 'CrossOriginPolicyMissing', function () {
|
QUnit.test( 'CrossOriginPolicyMissing', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer.crossOriginPolicy = false;
|
viewer.crossOriginPolicy = false;
|
||||||
viewer.smoothTileEdgesMinZoom = Infinity;
|
viewer.smoothTileEdgesMinZoom = Infinity;
|
||||||
viewer.open( {
|
viewer.open( {
|
||||||
@ -332,19 +334,19 @@
|
|||||||
} ]
|
} ]
|
||||||
} );
|
} );
|
||||||
viewer.addOnceHandler('tile-drawn', function() {
|
viewer.addOnceHandler('tile-drawn', function() {
|
||||||
ok(OpenSeadragon.isCanvasTainted(viewer.drawer.context.canvas),
|
assert.ok(OpenSeadragon.isCanvasTainted(viewer.drawer.context.canvas),
|
||||||
"Canvas should be tainted.");
|
"Canvas should be tainted.");
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
asyncTest( 'CrossOriginPolicyAnonymous', function () {
|
QUnit.test( 'CrossOriginPolicyAnonymous', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
browserSupportsImgCrossOrigin(function(supported) {
|
browserSupportsImgCrossOrigin(function(supported) {
|
||||||
if (!supported) {
|
if (!supported) {
|
||||||
expect(0);
|
assert.expect(0);
|
||||||
start();
|
done();
|
||||||
} else {
|
} else {
|
||||||
viewer.crossOriginPolicy = 'Anonymous';
|
viewer.crossOriginPolicy = 'Anonymous';
|
||||||
viewer.open( {
|
viewer.open( {
|
||||||
@ -356,21 +358,21 @@
|
|||||||
} ]
|
} ]
|
||||||
} );
|
} );
|
||||||
viewer.addOnceHandler('tile-drawn', function() {
|
viewer.addOnceHandler('tile-drawn', function() {
|
||||||
ok(!OpenSeadragon.isCanvasTainted(viewer.drawer.context.canvas),
|
assert.ok(!OpenSeadragon.isCanvasTainted(viewer.drawer.context.canvas),
|
||||||
"Canvas should not be tainted.");
|
"Canvas should not be tainted.");
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
asyncTest( 'CrossOriginPolicyOption', function () {
|
QUnit.test( 'CrossOriginPolicyOption', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
browserSupportsImgCrossOrigin(function(supported) {
|
browserSupportsImgCrossOrigin(function(supported) {
|
||||||
if (!supported) {
|
if (!supported) {
|
||||||
expect(0);
|
assert.expect(0);
|
||||||
start();
|
done();
|
||||||
} else {
|
} else {
|
||||||
viewer.crossOriginPolicy = "Anonymous";
|
viewer.crossOriginPolicy = "Anonymous";
|
||||||
viewer.smoothTileEdgesMinZoom = Infinity;
|
viewer.smoothTileEdgesMinZoom = Infinity;
|
||||||
@ -386,20 +388,21 @@
|
|||||||
crossOriginPolicy : false
|
crossOriginPolicy : false
|
||||||
} );
|
} );
|
||||||
viewer.addOnceHandler('tile-drawn', function() {
|
viewer.addOnceHandler('tile-drawn', function() {
|
||||||
ok(OpenSeadragon.isCanvasTainted(viewer.drawer.context.canvas),
|
assert.ok(OpenSeadragon.isCanvasTainted(viewer.drawer.context.canvas),
|
||||||
"Canvas should be tainted.");
|
"Canvas should be tainted.");
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
} );
|
} );
|
||||||
asyncTest( 'CrossOriginPolicyTileSource', function () {
|
|
||||||
|
|
||||||
|
QUnit.test( 'CrossOriginPolicyTileSource', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
browserSupportsImgCrossOrigin(function(supported) {
|
browserSupportsImgCrossOrigin(function(supported) {
|
||||||
if (!supported) {
|
if (!supported) {
|
||||||
expect(0);
|
assert.expect(0);
|
||||||
start();
|
done();
|
||||||
} else {
|
} else {
|
||||||
viewer.crossOriginPolicy = false;
|
viewer.crossOriginPolicy = false;
|
||||||
viewer.smoothTileEdgesMinZoom = Infinity;
|
viewer.smoothTileEdgesMinZoom = Infinity;
|
||||||
@ -415,9 +418,9 @@
|
|||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
viewer.addOnceHandler('tile-drawn', function() {
|
viewer.addOnceHandler('tile-drawn', function() {
|
||||||
ok(!OpenSeadragon.isCanvasTainted(viewer.drawer.context.canvas),
|
assert.ok(!OpenSeadragon.isCanvasTainted(viewer.drawer.context.canvas),
|
||||||
"Canvas should not be tainted.");
|
"Canvas should not be tainted.");
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -425,8 +428,9 @@
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
asyncTest('SetDebugMode', function() {
|
QUnit.test('SetDebugMode', function(assert) {
|
||||||
ok(viewer, 'Viewer exists');
|
var done = assert.async();
|
||||||
|
assert.ok(viewer, 'Viewer exists');
|
||||||
|
|
||||||
var checkImageTilesDebugState = function (expectedState) {
|
var checkImageTilesDebugState = function (expectedState) {
|
||||||
|
|
||||||
@ -443,15 +447,15 @@
|
|||||||
|
|
||||||
//Ensure we start with debug mode turned off
|
//Ensure we start with debug mode turned off
|
||||||
viewer.setDebugMode(false);
|
viewer.setDebugMode(false);
|
||||||
ok(checkImageTilesDebugState(false), "All image tiles have debug mode turned off.");
|
assert.ok(checkImageTilesDebugState(false), "All image tiles have debug mode turned off.");
|
||||||
ok(!viewer.debugMode, "Viewer debug mode is turned off.");
|
assert.ok(!viewer.debugMode, "Viewer debug mode is turned off.");
|
||||||
|
|
||||||
//Turn debug mode on and check that the Viewer and all tiled images are in debug mode.
|
//Turn debug mode on and check that the Viewer and all tiled images are in debug mode.
|
||||||
viewer.setDebugMode(true);
|
viewer.setDebugMode(true);
|
||||||
ok(checkImageTilesDebugState(true), "All image tiles have debug mode turned on.");
|
assert.ok(checkImageTilesDebugState(true), "All image tiles have debug mode turned on.");
|
||||||
ok(viewer.debugMode, "Viewer debug mode is turned on.");
|
assert.ok(viewer.debugMode, "Viewer debug mode is turned on.");
|
||||||
|
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
@ -460,11 +464,11 @@
|
|||||||
|
|
||||||
//Version numbers are injected by the build process, so skip version tests if we are only running code coverage
|
//Version numbers are injected by the build process, so skip version tests if we are only running code coverage
|
||||||
if(!window.isCoverageTest ){
|
if(!window.isCoverageTest ){
|
||||||
test('version object', function() {
|
QUnit.test('version object', function(assert) {
|
||||||
equal(typeof OpenSeadragon.version.versionStr, "string", "versionStr should be a string");
|
assert.equal(typeof OpenSeadragon.version.versionStr, "string", "versionStr should be a string");
|
||||||
ok(OpenSeadragon.version.major >= 0, "major should be a positive number");
|
assert.ok(OpenSeadragon.version.major >= 0, "major should be a positive number");
|
||||||
ok(OpenSeadragon.version.minor >= 0, "minor should be a positive number");
|
assert.ok(OpenSeadragon.version.minor >= 0, "minor should be a positive number");
|
||||||
ok(OpenSeadragon.version.revision >= 0, "revision should be a positive number");
|
assert.ok(OpenSeadragon.version.revision >= 0, "revision should be a positive number");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
224
test/modules/controls.js
vendored
224
test/modules/controls.js
vendored
@ -1,11 +1,11 @@
|
|||||||
/* global module, asyncTest, $, ok, equal, notEqual, start, test, Util, testLog */
|
/* global QUnit, $, testLog */
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
var viewer;
|
var viewer;
|
||||||
|
|
||||||
module('Controls', {
|
QUnit.module('Controls', {
|
||||||
setup: function () {
|
beforeEach: function () {
|
||||||
var example = $('<div id="controlsTests"></div>')
|
$('<div id="controlsTests"></div>')
|
||||||
.css({
|
.css({
|
||||||
width: 1000,
|
width: 1000,
|
||||||
height: 1000
|
height: 1000
|
||||||
@ -15,7 +15,7 @@
|
|||||||
testLog.reset();
|
testLog.reset();
|
||||||
|
|
||||||
},
|
},
|
||||||
teardown: function () {
|
afterEach: function () {
|
||||||
if (viewer && viewer.close) {
|
if (viewer && viewer.close) {
|
||||||
viewer.close();
|
viewer.close();
|
||||||
}
|
}
|
||||||
@ -24,16 +24,16 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('ZoomControlOff', function () {
|
QUnit.test('ZoomControlOff', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function () {
|
var openHandler = function () {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(!viewer.showZoomControl, 'showZoomControl should be off');
|
assert.ok(!viewer.showZoomControl, 'showZoomControl should be off');
|
||||||
ok(!viewer.zoomInButton, "zoomIn button should be null");
|
assert.ok(!viewer.zoomInButton, "zoomIn button should be null");
|
||||||
ok(!viewer.zoomOutButton, "zoomOut button should be null");
|
assert.ok(!viewer.zoomOutButton, "zoomOut button should be null");
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
@ -46,29 +46,29 @@
|
|||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('ZoomControlOn', function () {
|
QUnit.test('ZoomControlOn', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function () {
|
var openHandler = function () {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(viewer.showZoomControl, 'showZoomControl should be on');
|
assert.ok(viewer.showZoomControl, 'showZoomControl should be on');
|
||||||
ok(!!viewer.zoomInButton, "zoomIn button should not be null");
|
assert.ok(!!viewer.zoomInButton, "zoomIn button should not be null");
|
||||||
ok(!!viewer.zoomOutButton, "zoomOut button should not be null");
|
assert.ok(!!viewer.zoomOutButton, "zoomOut button should not be null");
|
||||||
notEqual(viewer.buttons.buttons.indexOf(viewer.zoomInButton), -1,
|
assert.notEqual(viewer.buttons.buttons.indexOf(viewer.zoomInButton), -1,
|
||||||
"The zoomIn button should be present");
|
"The zoomIn button should be present");
|
||||||
notEqual(viewer.buttons.buttons.indexOf(viewer.zoomOutButton), -1,
|
assert.notEqual(viewer.buttons.buttons.indexOf(viewer.zoomOutButton), -1,
|
||||||
"The zoomOut button should be present");
|
"The zoomOut button should be present");
|
||||||
|
|
||||||
var oldZoom = viewer.viewport.getZoom();
|
var oldZoom = viewer.viewport.getZoom();
|
||||||
viewer.zoomInButton.onClick();
|
viewer.zoomInButton.onClick();
|
||||||
var newZoom = viewer.viewport.getZoom();
|
var newZoom = viewer.viewport.getZoom();
|
||||||
ok(oldZoom < newZoom, "OSD should have zoomed in.");
|
assert.ok(oldZoom < newZoom, "OSD should have zoomed in.");
|
||||||
oldZoom = newZoom;
|
oldZoom = newZoom;
|
||||||
viewer.zoomOutButton.onClick();
|
viewer.zoomOutButton.onClick();
|
||||||
newZoom = viewer.viewport.getZoom();
|
newZoom = viewer.viewport.getZoom();
|
||||||
ok(oldZoom > newZoom, "OSD should have zoomed out.");
|
assert.ok(oldZoom > newZoom, "OSD should have zoomed out.");
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
@ -81,15 +81,15 @@
|
|||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('HomeControlOff', function () {
|
QUnit.test('HomeControlOff', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function () {
|
var openHandler = function () {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(!viewer.showHomeControl, 'showHomeControl should be off');
|
assert.ok(!viewer.showHomeControl, 'showHomeControl should be off');
|
||||||
ok(!viewer.homeButton, "Home button should be null");
|
assert.ok(!viewer.homeButton, "Home button should be null");
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
@ -102,32 +102,32 @@
|
|||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('HomeControlOn', function () {
|
QUnit.test('HomeControlOn', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function () {
|
var openHandler = function () {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(viewer.showHomeControl, 'showHomeControl should be on');
|
assert.ok(viewer.showHomeControl, 'showHomeControl should be on');
|
||||||
ok(!!viewer.homeButton, "Home button should not be null");
|
assert.ok(!!viewer.homeButton, "Home button should not be null");
|
||||||
notEqual(viewer.buttons.buttons.indexOf(viewer.homeButton), -1,
|
assert.notEqual(viewer.buttons.buttons.indexOf(viewer.homeButton), -1,
|
||||||
"The home button should be present");
|
"The home button should be present");
|
||||||
|
|
||||||
viewer.viewport.zoomBy(1.1);
|
viewer.viewport.zoomBy(1.1);
|
||||||
var bounds = viewer.viewport.getBounds();
|
var bounds = viewer.viewport.getBounds();
|
||||||
var homeBounds = viewer.viewport.getHomeBounds();
|
var homeBounds = viewer.viewport.getHomeBounds();
|
||||||
ok(bounds.x !== homeBounds.x ||
|
assert.ok(bounds.x !== homeBounds.x ||
|
||||||
bounds.y !== homeBounds.y ||
|
bounds.y !== homeBounds.y ||
|
||||||
bounds.width !== homeBounds.width ||
|
bounds.width !== homeBounds.width ||
|
||||||
bounds.height !== homeBounds.height,
|
bounds.height !== homeBounds.height,
|
||||||
"OSD should not be at home.");
|
"OSD should not be at home.");
|
||||||
viewer.homeButton.onRelease();
|
viewer.homeButton.onRelease();
|
||||||
bounds = viewer.viewport.getBounds();
|
bounds = viewer.viewport.getBounds();
|
||||||
ok(bounds.x === homeBounds.x &&
|
assert.ok(bounds.x === homeBounds.x &&
|
||||||
bounds.y === homeBounds.y &&
|
bounds.y === homeBounds.y &&
|
||||||
bounds.width === homeBounds.width &&
|
bounds.width === homeBounds.width &&
|
||||||
bounds.height === homeBounds.height, "OSD should have get home.");
|
bounds.height === homeBounds.height, "OSD should have get home.");
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
@ -140,15 +140,15 @@
|
|||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('FullPageControlOff', function () {
|
QUnit.test('FullPageControlOff', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function () {
|
var openHandler = function () {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(!viewer.showFullPageControl, 'showFullPageControl should be off');
|
assert.ok(!viewer.showFullPageControl, 'showFullPageControl should be off');
|
||||||
ok(!viewer.fullPageButton, "FullPage button should be null");
|
assert.ok(!viewer.fullPageButton, "FullPage button should be null");
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
@ -161,23 +161,23 @@
|
|||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('FullPageControlOn', function () {
|
QUnit.test('FullPageControlOn', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function () {
|
var openHandler = function () {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(viewer.showHomeControl, 'showFullPageControl should be on');
|
assert.ok(viewer.showHomeControl, 'showFullPageControl should be on');
|
||||||
ok(!!viewer.fullPageButton, "FullPage button should not be null");
|
assert.ok(!!viewer.fullPageButton, "FullPage button should not be null");
|
||||||
notEqual(viewer.buttons.buttons.indexOf(viewer.fullPageButton), -1,
|
assert.notEqual(viewer.buttons.buttons.indexOf(viewer.fullPageButton), -1,
|
||||||
"The full page button should be present");
|
"The full page button should be present");
|
||||||
|
|
||||||
ok(!viewer.isFullPage(), "OSD should not be in full page.");
|
assert.ok(!viewer.isFullPage(), "OSD should not be in full page.");
|
||||||
viewer.fullPageButton.onRelease();
|
viewer.fullPageButton.onRelease();
|
||||||
ok(viewer.isFullPage(), "OSD should be in full page.");
|
assert.ok(viewer.isFullPage(), "OSD should be in full page.");
|
||||||
viewer.fullPageButton.onRelease();
|
viewer.fullPageButton.onRelease();
|
||||||
ok(!viewer.isFullPage(), "OSD should not be in full page.");
|
assert.ok(!viewer.isFullPage(), "OSD should not be in full page.");
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
@ -190,19 +190,19 @@
|
|||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('RotateControlOff', function () {
|
QUnit.test('RotateControlOff', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function (event) {
|
var openHandler = function (event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(true, 'Open event was sent');
|
assert.ok(true, 'Open event was sent');
|
||||||
ok(viewer.drawer, 'Drawer exists');
|
assert.ok(viewer.drawer, 'Drawer exists');
|
||||||
ok(viewer.drawer.canRotate(), 'drawer.canRotate needs to be true');
|
assert.ok(viewer.drawer.canRotate(), 'drawer.canRotate needs to be true');
|
||||||
ok(!viewer.showRotationControl, 'showRotationControl should be off');
|
assert.ok(!viewer.showRotationControl, 'showRotationControl should be off');
|
||||||
ok(!viewer.rotateLeftButton, "rotateLeft button should be null");
|
assert.ok(!viewer.rotateLeftButton, "rotateLeft button should be null");
|
||||||
ok(!viewer.rotateRightButton, "rotateRight button should be null");
|
assert.ok(!viewer.rotateRightButton, "rotateRight button should be null");
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
@ -215,29 +215,29 @@
|
|||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('RotateControlOn', function () {
|
QUnit.test('RotateControlOn', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function (event) {
|
var openHandler = function (event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(true, 'Open event was sent');
|
assert.ok(true, 'Open event was sent');
|
||||||
ok(viewer.drawer, 'Drawer exists');
|
assert.ok(viewer.drawer, 'Drawer exists');
|
||||||
ok(viewer.drawer.canRotate(), 'drawer.canRotate needs to be true');
|
assert.ok(viewer.drawer.canRotate(), 'drawer.canRotate needs to be true');
|
||||||
ok(viewer.showRotationControl, 'showRotationControl should be true');
|
assert.ok(viewer.showRotationControl, 'showRotationControl should be true');
|
||||||
notEqual(viewer.buttons.buttons.indexOf(viewer.rotateLeftButton), -1,
|
assert.notEqual(viewer.buttons.buttons.indexOf(viewer.rotateLeftButton), -1,
|
||||||
"rotateLeft should be found");
|
"rotateLeft should be found");
|
||||||
notEqual(viewer.buttons.buttons.indexOf(viewer.rotateRightButton), -1,
|
assert.notEqual(viewer.buttons.buttons.indexOf(viewer.rotateRightButton), -1,
|
||||||
"rotateRight should be found");
|
"rotateRight should be found");
|
||||||
|
|
||||||
// Now simulate the left/right button clicks.
|
// Now simulate the left/right button clicks.
|
||||||
// TODO: re-factor simulateViewerClickWithDrag so it'll accept any element, and use that.
|
// TODO: re-factor simulateViewerClickWithDrag so it'll accept any element, and use that.
|
||||||
equal(viewer.viewport.degrees, 0, "Image should start at 0 degrees rotation");
|
assert.equal(viewer.viewport.degrees, 0, "Image should start at 0 degrees rotation");
|
||||||
viewer.rotateLeftButton.onRelease();
|
viewer.rotateLeftButton.onRelease();
|
||||||
equal(viewer.viewport.degrees, 270, "Image should be 270 degrees rotation (left)");
|
assert.equal(viewer.viewport.degrees, 270, "Image should be 270 degrees rotation (left)");
|
||||||
viewer.rotateRightButton.onRelease();
|
viewer.rotateRightButton.onRelease();
|
||||||
equal(viewer.viewport.degrees, 0, "Image should be 270 degrees rotation (right)");
|
assert.equal(viewer.viewport.degrees, 0, "Image should be 270 degrees rotation (right)");
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
@ -250,16 +250,16 @@
|
|||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('SequenceControlOff', function () {
|
QUnit.test('SequenceControlOff', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function () {
|
var openHandler = function () {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(!viewer.showSequenceControl, 'showSequenceControl should be off');
|
assert.ok(!viewer.showSequenceControl, 'showSequenceControl should be off');
|
||||||
ok(!viewer.previousButton, "Previous button should be null");
|
assert.ok(!viewer.previousButton, "Previous button should be null");
|
||||||
ok(!viewer.nextButton, "Next button should be null");
|
assert.ok(!viewer.nextButton, "Next button should be null");
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
@ -276,47 +276,47 @@
|
|||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('SequenceControlOnPrevNextWrapOff', function () {
|
QUnit.test('SequenceControlOnPrevNextWrapOff', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function () {
|
var openHandler = function () {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(viewer.showSequenceControl, 'showSequenceControl should be on');
|
assert.ok(viewer.showSequenceControl, 'showSequenceControl should be on');
|
||||||
ok(!!viewer.previousButton, "Previous button should not be null");
|
assert.ok(!!viewer.previousButton, "Previous button should not be null");
|
||||||
ok(!!viewer.nextButton, "Next button should not be null");
|
assert.ok(!!viewer.nextButton, "Next button should not be null");
|
||||||
notEqual(viewer.paging.buttons.indexOf(viewer.previousButton), -1,
|
assert.notEqual(viewer.paging.buttons.indexOf(viewer.previousButton), -1,
|
||||||
"The previous button should be present");
|
"The previous button should be present");
|
||||||
notEqual(viewer.paging.buttons.indexOf(viewer.nextButton), -1,
|
assert.notEqual(viewer.paging.buttons.indexOf(viewer.nextButton), -1,
|
||||||
"The next button should be present");
|
"The next button should be present");
|
||||||
|
|
||||||
equal(viewer.currentPage(), 0, "OSD should open on first page.");
|
assert.equal(viewer.currentPage(), 0, "OSD should open on first page.");
|
||||||
ok(viewer.previousButton.element.disabled,
|
assert.ok(viewer.previousButton.element.disabled,
|
||||||
"Previous should be disabled on first page.");
|
"Previous should be disabled on first page.");
|
||||||
ok(!viewer.nextButton.element.disabled,
|
assert.ok(!viewer.nextButton.element.disabled,
|
||||||
"Next should be enabled on first page.");
|
"Next should be enabled on first page.");
|
||||||
|
|
||||||
viewer.nextButton.onRelease();
|
viewer.nextButton.onRelease();
|
||||||
equal(viewer.currentPage(), 1, "OSD should be on second page.");
|
assert.equal(viewer.currentPage(), 1, "OSD should be on second page.");
|
||||||
ok(!viewer.previousButton.element.disabled,
|
assert.ok(!viewer.previousButton.element.disabled,
|
||||||
"Previous should be enabled on second page.");
|
"Previous should be enabled on second page.");
|
||||||
ok(!viewer.nextButton.element.disabled,
|
assert.ok(!viewer.nextButton.element.disabled,
|
||||||
"Next should be enabled on second page.");
|
"Next should be enabled on second page.");
|
||||||
|
|
||||||
viewer.nextButton.onRelease();
|
viewer.nextButton.onRelease();
|
||||||
equal(viewer.currentPage(), 2, "OSD should be on third page.");
|
assert.equal(viewer.currentPage(), 2, "OSD should be on third page.");
|
||||||
ok(!viewer.previousButton.element.disabled,
|
assert.ok(!viewer.previousButton.element.disabled,
|
||||||
"Previous should be enabled on third page.");
|
"Previous should be enabled on third page.");
|
||||||
ok(viewer.nextButton.element.disabled,
|
assert.ok(viewer.nextButton.element.disabled,
|
||||||
"Next should be disabled on third page.");
|
"Next should be disabled on third page.");
|
||||||
|
|
||||||
viewer.previousButton.onRelease();
|
viewer.previousButton.onRelease();
|
||||||
equal(viewer.currentPage(), 1, "OSD should be on second page.");
|
assert.equal(viewer.currentPage(), 1, "OSD should be on second page.");
|
||||||
ok(!viewer.previousButton.element.disabled,
|
assert.ok(!viewer.previousButton.element.disabled,
|
||||||
"Previous should be enabled on second page.");
|
"Previous should be enabled on second page.");
|
||||||
ok(!viewer.nextButton.element.disabled,
|
assert.ok(!viewer.nextButton.element.disabled,
|
||||||
"Next should be enabled on second page.");
|
"Next should be enabled on second page.");
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
@ -335,40 +335,40 @@
|
|||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('SequenceControlOnPrevNextWrapOn', function () {
|
QUnit.test('SequenceControlOnPrevNextWrapOn', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function () {
|
var openHandler = function () {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(viewer.showSequenceControl, 'showSequenceControl should be on');
|
assert.ok(viewer.showSequenceControl, 'showSequenceControl should be on');
|
||||||
ok(!!viewer.previousButton, "Previous button should not be null");
|
assert.ok(!!viewer.previousButton, "Previous button should not be null");
|
||||||
ok(!!viewer.nextButton, "Next button should not be null");
|
assert.ok(!!viewer.nextButton, "Next button should not be null");
|
||||||
notEqual(viewer.paging.buttons.indexOf(viewer.previousButton), -1,
|
assert.notEqual(viewer.paging.buttons.indexOf(viewer.previousButton), -1,
|
||||||
"The previous button should be present");
|
"The previous button should be present");
|
||||||
notEqual(viewer.paging.buttons.indexOf(viewer.nextButton), -1,
|
assert.notEqual(viewer.paging.buttons.indexOf(viewer.nextButton), -1,
|
||||||
"The next button should be present");
|
"The next button should be present");
|
||||||
|
|
||||||
equal(viewer.currentPage(), 0, "OSD should open on first page.");
|
assert.equal(viewer.currentPage(), 0, "OSD should open on first page.");
|
||||||
ok(!viewer.previousButton.element.disabled,
|
assert.ok(!viewer.previousButton.element.disabled,
|
||||||
"Previous should be enabled on first page.");
|
"Previous should be enabled on first page.");
|
||||||
ok(!viewer.nextButton.element.disabled,
|
assert.ok(!viewer.nextButton.element.disabled,
|
||||||
"Next should be enabled on first page.");
|
"Next should be enabled on first page.");
|
||||||
|
|
||||||
viewer.previousButton.onRelease();
|
viewer.previousButton.onRelease();
|
||||||
equal(viewer.currentPage(), 2, "OSD should be on third page.");
|
assert.equal(viewer.currentPage(), 2, "OSD should be on third page.");
|
||||||
ok(!viewer.previousButton.element.disabled,
|
assert.ok(!viewer.previousButton.element.disabled,
|
||||||
"Previous should be enabled on third page.");
|
"Previous should be enabled on third page.");
|
||||||
ok(!viewer.nextButton.element.disabled,
|
assert.ok(!viewer.nextButton.element.disabled,
|
||||||
"Next should be enabled on third page.");
|
"Next should be enabled on third page.");
|
||||||
|
|
||||||
viewer.nextButton.onRelease();
|
viewer.nextButton.onRelease();
|
||||||
equal(viewer.currentPage(), 0, "OSD should be on first page.");
|
assert.equal(viewer.currentPage(), 0, "OSD should be on first page.");
|
||||||
ok(!viewer.previousButton.element.disabled,
|
assert.ok(!viewer.previousButton.element.disabled,
|
||||||
"Previous should be enabled on first page.");
|
"Previous should be enabled on first page.");
|
||||||
ok(!viewer.nextButton.element.disabled,
|
assert.ok(!viewer.nextButton.element.disabled,
|
||||||
"Next should be enabled on first page.");
|
"Next should be enabled on first page.");
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
/* global module, asyncTest, $, ok, equal, notEqual, start, test, Util, testLog */
|
/* global QUnit, $, Util, testLog */
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var viewer;
|
var viewer;
|
||||||
|
|
||||||
module('Drawer', {
|
QUnit.module('Drawer', {
|
||||||
setup: function () {
|
beforeEach: function () {
|
||||||
var example = $('<div id="example"></div>').appendTo("#qunit-fixture");
|
$('<div id="example"></div>').appendTo("#qunit-fixture");
|
||||||
|
|
||||||
testLog.reset();
|
testLog.reset();
|
||||||
},
|
},
|
||||||
teardown: function () {
|
afterEach: function () {
|
||||||
if (viewer && viewer.close) {
|
if (viewer && viewer.close) {
|
||||||
viewer.close();
|
viewer.close();
|
||||||
}
|
}
|
||||||
@ -29,15 +29,17 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('basics', function() {
|
QUnit.test('basics', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
createViewer();
|
createViewer();
|
||||||
ok(viewer.drawer, 'Drawer exists');
|
assert.ok(viewer.drawer, 'Drawer exists');
|
||||||
equal(viewer.drawer.canRotate(), OpenSeadragon.supportsCanvas, 'we can rotate if we have canvas');
|
assert.equal(viewer.drawer.canRotate(), OpenSeadragon.supportsCanvas, 'we can rotate if we have canvas');
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('rotation', function() {
|
QUnit.test('rotation', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
createViewer({
|
createViewer({
|
||||||
tileSources: '/test/data/testpattern.dzi'
|
tileSources: '/test/data/testpattern.dzi'
|
||||||
});
|
});
|
||||||
@ -45,27 +47,29 @@
|
|||||||
viewer.addHandler('open', function handler(event) {
|
viewer.addHandler('open', function handler(event) {
|
||||||
viewer.viewport.setRotation(30);
|
viewer.viewport.setRotation(30);
|
||||||
Util.spyOnce(viewer.drawer.context, 'rotate', function() {
|
Util.spyOnce(viewer.drawer.context, 'rotate', function() {
|
||||||
ok(true, 'drawing with new rotation');
|
assert.ok(true, 'drawing with new rotation');
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('debug', function() {
|
QUnit.test('debug', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
createViewer({
|
createViewer({
|
||||||
tileSources: '/test/data/testpattern.dzi',
|
tileSources: '/test/data/testpattern.dzi',
|
||||||
debugMode: true
|
debugMode: true
|
||||||
});
|
});
|
||||||
|
|
||||||
Util.spyOnce(viewer.drawer, 'drawDebugInfo', function() {
|
Util.spyOnce(viewer.drawer, 'drawDebugInfo', function() {
|
||||||
ok(true, 'drawDebugInfo is called');
|
assert.ok(true, 'drawDebugInfo is called');
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('sketchCanvas', function() {
|
QUnit.test('sketchCanvas', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
createViewer({
|
createViewer({
|
||||||
tileSources: '/test/data/testpattern.dzi'
|
tileSources: '/test/data/testpattern.dzi'
|
||||||
});
|
});
|
||||||
@ -73,9 +77,9 @@
|
|||||||
|
|
||||||
viewer.addHandler('tile-drawn', function noOpacityHandler() {
|
viewer.addHandler('tile-drawn', function noOpacityHandler() {
|
||||||
viewer.removeHandler('tile-drawn', noOpacityHandler);
|
viewer.removeHandler('tile-drawn', noOpacityHandler);
|
||||||
equal(drawer.sketchCanvas, null,
|
assert.equal(drawer.sketchCanvas, null,
|
||||||
'The sketch canvas should be null if no decimal opacity is used.');
|
'The sketch canvas should be null if no decimal opacity is used.');
|
||||||
equal(drawer.sketchContext, null,
|
assert.equal(drawer.sketchContext, null,
|
||||||
'The sketch context should be null if no decimal opacity is used.');
|
'The sketch context should be null if no decimal opacity is used.');
|
||||||
testOpacityDecimal();
|
testOpacityDecimal();
|
||||||
});
|
});
|
||||||
@ -95,32 +99,34 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
viewer.removeHandler('tile-drawn', opacityDecimalHandler);
|
viewer.removeHandler('tile-drawn', opacityDecimalHandler);
|
||||||
notEqual(drawer.sketchCanvas, null,
|
assert.notEqual(drawer.sketchCanvas, null,
|
||||||
'The sketch canvas should not be null once a decimal opacity has been used.');
|
'The sketch canvas should not be null once a decimal opacity has been used.');
|
||||||
notEqual(drawer.sketchContext, null,
|
assert.notEqual(drawer.sketchContext, null,
|
||||||
'The sketch context should not be null once a decimal opacity has been used.');
|
'The sketch context should not be null once a decimal opacity has been used.');
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('deprecations', function() {
|
QUnit.test('deprecations', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
|
|
||||||
createViewer({
|
createViewer({
|
||||||
tileSources: '/test/data/testpattern.dzi'
|
tileSources: '/test/data/testpattern.dzi'
|
||||||
});
|
});
|
||||||
viewer.world.addHandler('add-item', function() {
|
viewer.world.addHandler('add-item', function() {
|
||||||
Util.testDeprecation(viewer.drawer, 'addOverlay', viewer, 'addOverlay');
|
Util.testDeprecation(assert, viewer.drawer, 'addOverlay', viewer, 'addOverlay');
|
||||||
Util.testDeprecation(viewer.drawer, 'updateOverlay', viewer, 'updateOverlay');
|
Util.testDeprecation(assert, viewer.drawer, 'updateOverlay', viewer, 'updateOverlay');
|
||||||
Util.testDeprecation(viewer.drawer, 'removeOverlay', viewer, 'removeOverlay');
|
Util.testDeprecation(assert, viewer.drawer, 'removeOverlay', viewer, 'removeOverlay');
|
||||||
Util.testDeprecation(viewer.drawer, 'clearOverlays', viewer, 'clearOverlays');
|
Util.testDeprecation(assert, viewer.drawer, 'clearOverlays', viewer, 'clearOverlays');
|
||||||
Util.testDeprecation(viewer.drawer, 'needsUpdate', viewer.world, 'needsDraw');
|
Util.testDeprecation(assert, viewer.drawer, 'needsUpdate', viewer.world, 'needsDraw');
|
||||||
Util.testDeprecation(viewer.drawer, 'numTilesLoaded', viewer.tileCache, 'numTilesLoaded');
|
Util.testDeprecation(assert, viewer.drawer, 'numTilesLoaded', viewer.tileCache, 'numTilesLoaded');
|
||||||
Util.testDeprecation(viewer.drawer, 'reset', viewer.world, 'resetItems');
|
Util.testDeprecation(assert, viewer.drawer, 'reset', viewer.world, 'resetItems');
|
||||||
Util.testDeprecation(viewer.drawer, 'update', viewer.world, 'draw');
|
Util.testDeprecation(assert, viewer.drawer, 'update', viewer.world, 'draw');
|
||||||
Util.testDeprecation(viewer.drawer, 'setOpacity', viewer.world.getItemAt(0), 'setOpacity');
|
Util.testDeprecation(assert, viewer.drawer, 'setOpacity', viewer.world.getItemAt(0), 'setOpacity');
|
||||||
Util.testDeprecation(viewer.drawer, 'getOpacity', viewer.world.getItemAt(0), 'getOpacity');
|
Util.testDeprecation(assert, viewer.drawer, 'getOpacity', viewer.world.getItemAt(0), 'getOpacity');
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,42 +1,48 @@
|
|||||||
|
/* global QUnit, testLog */
|
||||||
/*global module:true, test:true, equal:true, OpenSeadragon:true*/
|
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
module('DziTileSource', {
|
QUnit.module('DziTileSource', {
|
||||||
setup: function() {
|
beforeEach: function() {
|
||||||
testLog.reset();
|
testLog.reset();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function testImplicitTilesUrl(dziUrl, expected, msg) {
|
function testImplicitTilesUrl(assert, dziUrl, expected, msg) {
|
||||||
var source = new OpenSeadragon.DziTileSource();
|
var source = new OpenSeadragon.DziTileSource();
|
||||||
var options = source.configure({
|
var options = source.configure({
|
||||||
Image: {Size: {Width:0, Height: 0}}
|
Image: {Size: {Width:0, Height: 0}}
|
||||||
}, dziUrl);
|
}, dziUrl);
|
||||||
equal(options.tilesUrl, expected, msg);
|
assert.equal(options.tilesUrl, expected, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
test('test implicit tilesUrl guessed from dzi url', function() {
|
QUnit.test('test implicit tilesUrl guessed from dzi url', function(assert) {
|
||||||
testImplicitTilesUrl(
|
testImplicitTilesUrl(
|
||||||
|
assert,
|
||||||
'/path/my.dzi', '/path/my_files/',
|
'/path/my.dzi', '/path/my_files/',
|
||||||
'dzi extension should be stripped');
|
'dzi extension should be stripped');
|
||||||
testImplicitTilesUrl(
|
testImplicitTilesUrl(
|
||||||
|
assert,
|
||||||
'/path/my', '/path/my_files/',
|
'/path/my', '/path/my_files/',
|
||||||
'no extension should still produce _files path');
|
'no extension should still produce _files path');
|
||||||
testImplicitTilesUrl(
|
testImplicitTilesUrl(
|
||||||
|
assert,
|
||||||
'/my/', '/my_files/',
|
'/my/', '/my_files/',
|
||||||
'no extension with trailing slash should preserve slash');
|
'no extension with trailing slash should preserve slash');
|
||||||
testImplicitTilesUrl(
|
testImplicitTilesUrl(
|
||||||
|
assert,
|
||||||
'my.xml', 'my_files/',
|
'my.xml', 'my_files/',
|
||||||
'relative link should stay the same');
|
'relative link should stay the same');
|
||||||
testImplicitTilesUrl(
|
testImplicitTilesUrl(
|
||||||
|
assert,
|
||||||
'/p/foo.dzi?a=1&b=2', '/p/foo_files/',
|
'/p/foo.dzi?a=1&b=2', '/p/foo_files/',
|
||||||
'querystring in dzi url should be ignored after slashes');
|
'querystring in dzi url should be ignored after slashes');
|
||||||
testImplicitTilesUrl(
|
testImplicitTilesUrl(
|
||||||
|
assert,
|
||||||
'/iiipsrv?DeepZoom=/path/my.dzi', '/iiipsrv?DeepZoom=/path/my_files/',
|
'/iiipsrv?DeepZoom=/path/my.dzi', '/iiipsrv?DeepZoom=/path/my_files/',
|
||||||
'querystring in dzi url should not be ignored before slashes');
|
'querystring in dzi url should not be ignored before slashes');
|
||||||
testImplicitTilesUrl(
|
testImplicitTilesUrl(
|
||||||
|
assert,
|
||||||
'/fcg-bin/iipsrv.fcgi?Deepzoom=123test.tif.dzi', '/fcg-bin/iipsrv.fcgi?Deepzoom=123test.tif_files/',
|
'/fcg-bin/iipsrv.fcgi?Deepzoom=123test.tif.dzi', '/fcg-bin/iipsrv.fcgi?Deepzoom=123test.tif_files/',
|
||||||
'filename in querystring does not have to contain slash');
|
'filename in querystring does not have to contain slash');
|
||||||
});
|
});
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
/* global module, asyncTest, $, ok, equal, notEqual, start, test, TouchUtil, Util, testLog */
|
/* global QUnit, $, TouchUtil, Util, testLog */
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
var viewer;
|
var viewer;
|
||||||
|
|
||||||
module( 'Events', {
|
QUnit.module( 'Events', {
|
||||||
setup: function () {
|
beforeEach: function () {
|
||||||
var example = $( '<div id="eventsexample"></div>' ).appendTo( "#qunit-fixture" );
|
$( '<div id="eventsexample"></div>' ).appendTo( "#qunit-fixture" );
|
||||||
|
|
||||||
testLog.reset();
|
testLog.reset();
|
||||||
|
|
||||||
@ -15,7 +15,7 @@
|
|||||||
springStiffness: 100 // Faster animation = faster tests
|
springStiffness: 100 // Faster animation = faster tests
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
teardown: function () {
|
afterEach: function () {
|
||||||
if ( viewer && viewer.close ) {
|
if ( viewer && viewer.close ) {
|
||||||
viewer.close();
|
viewer.close();
|
||||||
}
|
}
|
||||||
@ -25,12 +25,12 @@
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest( 'MouseTracker: mouse gestures', function () {
|
QUnit.test( 'MouseTracker: mouse gestures', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var $canvas = $( viewer.element ).find( '.openseadragon-canvas' ).not( '.navigator .openseadragon-canvas' ),
|
var $canvas = $( viewer.element ).find( '.openseadragon-canvas' ).not( '.navigator .openseadragon-canvas' ),
|
||||||
simEvent = {},
|
simEvent = {},
|
||||||
offset = $canvas.offset(),
|
offset = $canvas.offset(),
|
||||||
tracker = viewer.innerTracker,
|
tracker = viewer.innerTracker,
|
||||||
intervalId,
|
|
||||||
origEnterHandler,
|
origEnterHandler,
|
||||||
origExitHandler,
|
origExitHandler,
|
||||||
origPressHandler,
|
origPressHandler,
|
||||||
@ -278,58 +278,58 @@
|
|||||||
var assessGestureExpectations = function (expected) {
|
var assessGestureExpectations = function (expected) {
|
||||||
var pointersList = tracker.getActivePointersListByType('mouse');
|
var pointersList = tracker.getActivePointersListByType('mouse');
|
||||||
if ('enterCount' in expected) {
|
if ('enterCount' in expected) {
|
||||||
equal( enterCount, expected.enterCount, expected.description + 'enterHandler event count matches expected (' + expected.enterCount + ')' );
|
assert.equal( enterCount, expected.enterCount, expected.description + 'enterHandler event count matches expected (' + expected.enterCount + ')' );
|
||||||
}
|
}
|
||||||
if ('exitCount' in expected) {
|
if ('exitCount' in expected) {
|
||||||
equal( exitCount, expected.exitCount, expected.description + 'exitHandler event count matches expected (' + expected.exitCount + ')' );
|
assert.equal( exitCount, expected.exitCount, expected.description + 'exitHandler event count matches expected (' + expected.exitCount + ')' );
|
||||||
}
|
}
|
||||||
if ('pressCount' in expected) {
|
if ('pressCount' in expected) {
|
||||||
equal( pressCount, expected.pressCount, expected.description + 'pressHandler event count matches expected (' + expected.pressCount + ')' );
|
assert.equal( pressCount, expected.pressCount, expected.description + 'pressHandler event count matches expected (' + expected.pressCount + ')' );
|
||||||
}
|
}
|
||||||
if ('releaseCount' in expected) {
|
if ('releaseCount' in expected) {
|
||||||
equal( releaseCount, expected.releaseCount, expected.description + 'releaseHandler event count matches expected (' + expected.releaseCount + ')' );
|
assert.equal( releaseCount, expected.releaseCount, expected.description + 'releaseHandler event count matches expected (' + expected.releaseCount + ')' );
|
||||||
}
|
}
|
||||||
if ('rightPressCount' in expected) {
|
if ('rightPressCount' in expected) {
|
||||||
equal( rightPressCount, expected.rightPressCount, expected.description + 'nonPrimaryPressHandler event count (secondary/right button) matches expected (' + expected.rightPressCount + ')' );
|
assert.equal( rightPressCount, expected.rightPressCount, expected.description + 'nonPrimaryPressHandler event count (secondary/right button) matches expected (' + expected.rightPressCount + ')' );
|
||||||
}
|
}
|
||||||
if ('rightReleaseCount' in expected) {
|
if ('rightReleaseCount' in expected) {
|
||||||
equal( rightReleaseCount, expected.rightReleaseCount, expected.description + 'nonPrimaryReleaseHandler event count (secondary/right button) matches expected (' + expected.rightReleaseCount + ')' );
|
assert.equal( rightReleaseCount, expected.rightReleaseCount, expected.description + 'nonPrimaryReleaseHandler event count (secondary/right button) matches expected (' + expected.rightReleaseCount + ')' );
|
||||||
}
|
}
|
||||||
if ('middlePressCount' in expected) {
|
if ('middlePressCount' in expected) {
|
||||||
equal( middlePressCount, expected.middlePressCount, expected.description + 'nonPrimaryPressHandler event count (aux/middle button) matches expected (' + expected.middlePressCount + ')' );
|
assert.equal( middlePressCount, expected.middlePressCount, expected.description + 'nonPrimaryPressHandler event count (aux/middle button) matches expected (' + expected.middlePressCount + ')' );
|
||||||
}
|
}
|
||||||
if ('middleReleaseCount' in expected) {
|
if ('middleReleaseCount' in expected) {
|
||||||
equal( middleReleaseCount, expected.middleReleaseCount, expected.description + 'nonPrimaryReleaseHandler event count (aux/middle button) matches expected (' + expected.middleReleaseCount + ')' );
|
assert.equal( middleReleaseCount, expected.middleReleaseCount, expected.description + 'nonPrimaryReleaseHandler event count (aux/middle button) matches expected (' + expected.middleReleaseCount + ')' );
|
||||||
}
|
}
|
||||||
if ('moveCount' in expected) {
|
if ('moveCount' in expected) {
|
||||||
equal( moveCount, expected.moveCount, expected.description + 'moveHandler event count matches expected (' + expected.moveCount + ')' );
|
assert.equal( moveCount, expected.moveCount, expected.description + 'moveHandler event count matches expected (' + expected.moveCount + ')' );
|
||||||
}
|
}
|
||||||
if ('clickCount' in expected) {
|
if ('clickCount' in expected) {
|
||||||
equal( clickCount, expected.clickCount, expected.description + 'clickHandler event count matches expected (' + expected.clickCount + ')' );
|
assert.equal( clickCount, expected.clickCount, expected.description + 'clickHandler event count matches expected (' + expected.clickCount + ')' );
|
||||||
}
|
}
|
||||||
if ('dblClickCount' in expected) {
|
if ('dblClickCount' in expected) {
|
||||||
equal( dblClickCount, expected.dblClickCount, expected.description + 'dblClickHandler event count matches expected (' + expected.dblClickCount + ')' );
|
assert.equal( dblClickCount, expected.dblClickCount, expected.description + 'dblClickHandler event count matches expected (' + expected.dblClickCount + ')' );
|
||||||
}
|
}
|
||||||
if ('dragCount' in expected) {
|
if ('dragCount' in expected) {
|
||||||
equal( dragCount, expected.dragCount, expected.description + 'dragHandler event count matches expected (' + expected.dragCount + ')' );
|
assert.equal( dragCount, expected.dragCount, expected.description + 'dragHandler event count matches expected (' + expected.dragCount + ')' );
|
||||||
}
|
}
|
||||||
if ('dragEndCount' in expected) {
|
if ('dragEndCount' in expected) {
|
||||||
equal( dragEndCount, expected.dragEndCount, expected.description + 'dragEndHandler event count matches expected (' + expected.dragEndCount + ')' );
|
assert.equal( dragEndCount, expected.dragEndCount, expected.description + 'dragEndHandler event count matches expected (' + expected.dragEndCount + ')' );
|
||||||
}
|
}
|
||||||
if ('insideElementPressed' in expected) {
|
if ('insideElementPressed' in expected) {
|
||||||
equal( insideElementPressed, expected.insideElementPressed, expected.description + 'releaseHandler event.insideElementPressed matches expected (' + expected.insideElementPressed + ')' );
|
assert.equal( insideElementPressed, expected.insideElementPressed, expected.description + 'releaseHandler event.insideElementPressed matches expected (' + expected.insideElementPressed + ')' );
|
||||||
}
|
}
|
||||||
if ('insideElementReleased' in expected) {
|
if ('insideElementReleased' in expected) {
|
||||||
equal( insideElementReleased, expected.insideElementReleased, expected.description + 'releaseHandler event.insideElementReleased matches expected (' + expected.insideElementReleased + ')' );
|
assert.equal( insideElementReleased, expected.insideElementReleased, expected.description + 'releaseHandler event.insideElementReleased matches expected (' + expected.insideElementReleased + ')' );
|
||||||
}
|
}
|
||||||
if ('contacts' in expected) {
|
if ('contacts' in expected) {
|
||||||
equal( pointersList.contacts, expected.contacts, expected.description + 'Remaining pointer contact count matches expected (' + expected.contacts + ')' );
|
assert.equal( pointersList.contacts, expected.contacts, expected.description + 'Remaining pointer contact count matches expected (' + expected.contacts + ')' );
|
||||||
}
|
}
|
||||||
if ('trackedPointers' in expected) {
|
if ('trackedPointers' in expected) {
|
||||||
equal( pointersList.getLength(), expected.trackedPointers, expected.description + 'Remaining tracked pointer count matches expected (' + expected.trackedPointers + ')' );
|
assert.equal( pointersList.getLength(), expected.trackedPointers, expected.description + 'Remaining tracked pointer count matches expected (' + expected.trackedPointers + ')' );
|
||||||
}
|
}
|
||||||
if ('quickClick' in expected) {
|
if ('quickClick' in expected) {
|
||||||
equal( quickClick, expected.quickClick, expected.description + 'clickHandler event.quick matches expected (' + expected.quickClick + ')' );
|
assert.equal( quickClick, expected.quickClick, expected.description + 'clickHandler event.quick matches expected (' + expected.quickClick + ')' );
|
||||||
}
|
}
|
||||||
if ('speed' in expected) {
|
if ('speed' in expected) {
|
||||||
Util.assessNumericValue(expected.speed, speed, 1.0, expected.description + 'Drag speed ');
|
Util.assessNumericValue(expected.speed, speed, 1.0, expected.description + 'Drag speed ');
|
||||||
@ -340,8 +340,6 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
var onOpen = function ( event ) {
|
var onOpen = function ( event ) {
|
||||||
var timeStart,
|
|
||||||
timeElapsed;
|
|
||||||
|
|
||||||
viewer.removeHandler( 'open', onOpen );
|
viewer.removeHandler( 'open', onOpen );
|
||||||
|
|
||||||
@ -670,7 +668,7 @@
|
|||||||
unhookViewerHandlers();
|
unhookViewerHandlers();
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler( 'open', onOpen );
|
viewer.addHandler( 'open', onOpen );
|
||||||
@ -679,7 +677,8 @@
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
if ('TouchEvent' in window) {
|
if ('TouchEvent' in window) {
|
||||||
asyncTest( 'MouseTracker: touch events', function () {
|
QUnit.test( 'MouseTracker: touch events', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var $canvas = $( viewer.element ).find( '.openseadragon-canvas' ).not( '.navigator .openseadragon-canvas' ),
|
var $canvas = $( viewer.element ).find( '.openseadragon-canvas' ).not( '.navigator .openseadragon-canvas' ),
|
||||||
tracker = viewer.innerTracker,
|
tracker = viewer.innerTracker,
|
||||||
touches;
|
touches;
|
||||||
@ -692,13 +691,13 @@
|
|||||||
var assessTouchExpectations = function ( expected ) {
|
var assessTouchExpectations = function ( expected ) {
|
||||||
var pointersList = tracker.getActivePointersListByType( 'touch' );
|
var pointersList = tracker.getActivePointersListByType( 'touch' );
|
||||||
if ('captureCount' in expected) {
|
if ('captureCount' in expected) {
|
||||||
equal( pointersList.captureCount, expected.captureCount, expected.description + 'Pointer capture count matches expected (' + expected.captureCount + ')' );
|
assert.equal( pointersList.captureCount, expected.captureCount, expected.description + 'Pointer capture count matches expected (' + expected.captureCount + ')' );
|
||||||
}
|
}
|
||||||
if ('contacts' in expected) {
|
if ('contacts' in expected) {
|
||||||
equal( pointersList.contacts, expected.contacts, expected.description + 'Pointer contact count matches expected (' + expected.contacts + ')' );
|
assert.equal( pointersList.contacts, expected.contacts, expected.description + 'Pointer contact count matches expected (' + expected.contacts + ')' );
|
||||||
}
|
}
|
||||||
if ('trackedPointers' in expected) {
|
if ('trackedPointers' in expected) {
|
||||||
equal( pointersList.getLength(), expected.trackedPointers, expected.description + 'Tracked pointer count matches expected (' + expected.trackedPointers + ')' );
|
assert.equal( pointersList.getLength(), expected.trackedPointers, expected.description + 'Tracked pointer count matches expected (' + expected.trackedPointers + ')' );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -745,7 +744,7 @@
|
|||||||
|
|
||||||
TouchUtil.resetTracker( tracker );
|
TouchUtil.resetTracker( tracker );
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler( 'open', onOpen );
|
viewer.addHandler( 'open', onOpen );
|
||||||
@ -754,7 +753,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('Viewer: preventDefaultAction', function() {
|
QUnit.test('Viewer: preventDefaultAction', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var $canvas = $(viewer.element).find('.openseadragon-canvas')
|
var $canvas = $(viewer.element).find('.openseadragon-canvas')
|
||||||
.not('.navigator .openseadragon-canvas');
|
.not('.navigator .openseadragon-canvas');
|
||||||
var tracker = viewer.innerTracker;
|
var tracker = viewer.innerTracker;
|
||||||
@ -805,9 +805,9 @@
|
|||||||
|
|
||||||
var zoom = viewer.viewport.getZoom();
|
var zoom = viewer.viewport.getZoom();
|
||||||
var bounds = viewer.viewport.getBounds();
|
var bounds = viewer.viewport.getBounds();
|
||||||
Util.assessNumericValue(zoom, originalZoom, epsilon,
|
Util.assessNumericValue(assert, zoom, originalZoom, epsilon,
|
||||||
"Zoom should be prevented");
|
"Zoom should be prevented");
|
||||||
Util.assertRectangleEquals(bounds, originalBounds, epsilon,
|
Util.assertRectangleEquals(assert, bounds, originalBounds, epsilon,
|
||||||
'Pan should be prevented');
|
'Pan should be prevented');
|
||||||
|
|
||||||
tracker.clickHandler = origClickHandler;
|
tracker.clickHandler = origClickHandler;
|
||||||
@ -815,18 +815,19 @@
|
|||||||
|
|
||||||
simulateClickAndDrag();
|
simulateClickAndDrag();
|
||||||
|
|
||||||
var zoom = viewer.viewport.getZoom();
|
zoom = viewer.viewport.getZoom();
|
||||||
var bounds = viewer.viewport.getBounds();
|
bounds = viewer.viewport.getBounds();
|
||||||
Util.assessNumericValue(zoom, 0.002, epsilon,
|
Util.assessNumericValue(assert, zoom, 0.002, epsilon,
|
||||||
"Zoom should not be prevented");
|
"Zoom should not be prevented");
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
|
assert,
|
||||||
new OpenSeadragon.Rect(-249.5, -0.25, 500, 0.5),
|
new OpenSeadragon.Rect(-249.5, -0.25, 500, 0.5),
|
||||||
bounds,
|
bounds,
|
||||||
epsilon,
|
epsilon,
|
||||||
'Pan should not be prevented');
|
'Pan should not be prevented');
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler('open', onOpen);
|
viewer.addHandler('open', onOpen);
|
||||||
@ -834,7 +835,8 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('Viewer: preventDefaultAction in dblClickHandler', function() {
|
QUnit.test('Viewer: preventDefaultAction in dblClickHandler', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var tracker = viewer.innerTracker;
|
var tracker = viewer.innerTracker;
|
||||||
var epsilon = 0.0000001;
|
var epsilon = 0.0000001;
|
||||||
|
|
||||||
@ -863,7 +865,7 @@
|
|||||||
simulateDblTap();
|
simulateDblTap();
|
||||||
|
|
||||||
var zoom = viewer.viewport.getZoom();
|
var zoom = viewer.viewport.getZoom();
|
||||||
Util.assessNumericValue(originalZoom, zoom, epsilon,
|
Util.assessNumericValue(assert, originalZoom, zoom, epsilon,
|
||||||
"Zoom on double tap should be prevented");
|
"Zoom on double tap should be prevented");
|
||||||
|
|
||||||
// Reset event handler to original
|
// Reset event handler to original
|
||||||
@ -872,19 +874,19 @@
|
|||||||
simulateDblTap();
|
simulateDblTap();
|
||||||
originalZoom = originalZoom * viewer.zoomPerClick;
|
originalZoom = originalZoom * viewer.zoomPerClick;
|
||||||
|
|
||||||
var zoom = viewer.viewport.getZoom();
|
zoom = viewer.viewport.getZoom();
|
||||||
Util.assessNumericValue(originalZoom, zoom, epsilon,
|
Util.assessNumericValue(assert, originalZoom, zoom, epsilon,
|
||||||
"Zoom on double tap should not be prevented");
|
"Zoom on double tap should not be prevented");
|
||||||
|
|
||||||
|
|
||||||
var dblClickHandler = function(event) {
|
var dblClickHandler = function(event) {
|
||||||
event.preventDefaultAction = true;
|
event.preventDefaultAction = true;
|
||||||
}
|
};
|
||||||
|
|
||||||
viewer.addHandler('canvas-double-click', dblClickHandler);
|
viewer.addHandler('canvas-double-click', dblClickHandler);
|
||||||
|
|
||||||
var zoom = viewer.viewport.getZoom();
|
zoom = viewer.viewport.getZoom();
|
||||||
Util.assessNumericValue(originalZoom, zoom, epsilon,
|
Util.assessNumericValue(assert, originalZoom, zoom, epsilon,
|
||||||
"Zoom on double tap should be prevented");
|
"Zoom on double tap should be prevented");
|
||||||
|
|
||||||
// Remove custom event handler
|
// Remove custom event handler
|
||||||
@ -893,13 +895,13 @@
|
|||||||
simulateDblTap();
|
simulateDblTap();
|
||||||
originalZoom = originalZoom * viewer.zoomPerClick;
|
originalZoom = originalZoom * viewer.zoomPerClick;
|
||||||
|
|
||||||
var zoom = viewer.viewport.getZoom();
|
zoom = viewer.viewport.getZoom();
|
||||||
Util.assessNumericValue(originalZoom, zoom, epsilon,
|
Util.assessNumericValue(assert, originalZoom, zoom, epsilon,
|
||||||
"Zoom on double tap should not be prevented");
|
"Zoom on double tap should not be prevented");
|
||||||
|
|
||||||
TouchUtil.resetTracker(tracker);
|
TouchUtil.resetTracker(tracker);
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler('open', onOpen);
|
viewer.addHandler('open', onOpen);
|
||||||
@ -907,7 +909,8 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest( 'EventSource/MouseTracker/Viewer: event.originalEvent event.userData canvas-drag canvas-drag-end canvas-release canvas-click', function () {
|
QUnit.test( 'EventSource/MouseTracker/Viewer: event.originalEvent event.userData canvas-drag canvas-drag-end canvas-release canvas-click', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var $canvas = $( viewer.element ).find( '.openseadragon-canvas' ).not( '.navigator .openseadragon-canvas' ),
|
var $canvas = $( viewer.element ).find( '.openseadragon-canvas' ).not( '.navigator .openseadragon-canvas' ),
|
||||||
mouseTracker = null,
|
mouseTracker = null,
|
||||||
userData = { item1: 'Test user data', item2: Math.random() },
|
userData = { item1: 'Test user data', item2: Math.random() },
|
||||||
@ -1055,18 +1058,18 @@
|
|||||||
viewer.removeHandler( 'canvas-release', onEventSourceRelease );
|
viewer.removeHandler( 'canvas-release', onEventSourceRelease );
|
||||||
viewer.removeHandler( 'canvas-click', onEventSourceClick );
|
viewer.removeHandler( 'canvas-click', onEventSourceClick );
|
||||||
|
|
||||||
equal( dragsHandledEventSource, dragCount, "'canvas-drag' event count matches 'mousemove' event count (" + dragCount + ")" );
|
assert.equal( dragsHandledEventSource, dragCount, "'canvas-drag' event count matches 'mousemove' event count (" + dragCount + ")" );
|
||||||
equal( dragEndsHandledEventSource, dragEndsExpected, "'canvas-drag-end' event count matches expected (" + dragEndsExpected + ")" );
|
assert.equal( dragEndsHandledEventSource, dragEndsExpected, "'canvas-drag-end' event count matches expected (" + dragEndsExpected + ")" );
|
||||||
equal( releasesHandledEventSource, releasesExpected, "'canvas-release' event count matches expected (" + releasesExpected + ")" );
|
assert.equal( releasesHandledEventSource, releasesExpected, "'canvas-release' event count matches expected (" + releasesExpected + ")" );
|
||||||
equal( clicksHandledEventSource, releasesExpected, "'canvas-click' event count matches expected (" + releasesExpected + ")" );
|
assert.equal( clicksHandledEventSource, releasesExpected, "'canvas-click' event count matches expected (" + releasesExpected + ")" );
|
||||||
equal( originalEventsPassedViewer, eventsHandledViewer, "Original event received count matches expected (" + eventsHandledViewer + ")" );
|
assert.equal( originalEventsPassedViewer, eventsHandledViewer, "Original event received count matches expected (" + eventsHandledViewer + ")" );
|
||||||
|
|
||||||
equal( eventSourcePassedMouseTracker, eventsHandledMouseTracker, "Event source received count matches expected (" + eventsHandledMouseTracker + ")" );
|
assert.equal( eventSourcePassedMouseTracker, eventsHandledMouseTracker, "Event source received count matches expected (" + eventsHandledMouseTracker + ")" );
|
||||||
equal( originalEventsPassedMouseTracker, eventsHandledMouseTracker, "Original event received count matches expected (" + eventsHandledMouseTracker + ")" );
|
assert.equal( originalEventsPassedMouseTracker, eventsHandledMouseTracker, "Original event received count matches expected (" + eventsHandledMouseTracker + ")" );
|
||||||
deepEqual( event.userData, originalUserData, 'MouseTracker userData was untouched' );
|
assert.deepEqual( event.userData, originalUserData, 'MouseTracker userData was untouched' );
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler( 'open', onOpen );
|
viewer.addHandler( 'open', onOpen );
|
||||||
@ -1074,16 +1077,17 @@
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest( 'EventSource: addHandler without userData', function () {
|
QUnit.test( 'EventSource: addHandler without userData', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function ( event ) {
|
var openHandler = function ( event ) {
|
||||||
viewer.removeHandler( 'open', openHandler );
|
viewer.removeHandler( 'open', openHandler );
|
||||||
ok( event, 'Event handler received event data' );
|
assert.ok( event, 'Event handler received event data' );
|
||||||
if ( event ) {
|
if ( event ) {
|
||||||
strictEqual( event.eventSource, viewer, 'eventSource sent, eventSource is viewer' );
|
assert.strictEqual( event.eventSource, viewer, 'eventSource sent, eventSource is viewer' );
|
||||||
strictEqual( event.userData, null, 'User data defaulted to null' );
|
assert.strictEqual( event.userData, null, 'User data defaulted to null' );
|
||||||
}
|
}
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler( 'open', openHandler );
|
viewer.addHandler( 'open', openHandler );
|
||||||
@ -1091,19 +1095,20 @@
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest( 'EventSource: addHandler with userData', function () {
|
QUnit.test( 'EventSource: addHandler with userData', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var userData = { item1: 'Test user data', item2: Math.random() },
|
var userData = { item1: 'Test user data', item2: Math.random() },
|
||||||
originalUserData = { item1: userData.item1, item2: userData.item2 };
|
originalUserData = { item1: userData.item1, item2: userData.item2 };
|
||||||
|
|
||||||
var openHandler = function ( event ) {
|
var openHandler = function ( event ) {
|
||||||
viewer.removeHandler( 'open', openHandler );
|
viewer.removeHandler( 'open', openHandler );
|
||||||
ok( event, 'Event handler received event data' );
|
assert.ok( event, 'Event handler received event data' );
|
||||||
ok( event && event.userData, 'Event handler received user data' );
|
assert.ok( event && event.userData, 'Event handler received user data' );
|
||||||
if ( event && event.userData ) {
|
if ( event && event.userData ) {
|
||||||
deepEqual( event.userData, originalUserData, 'User data was untouched' );
|
assert.deepEqual( event.userData, originalUserData, 'User data was untouched' );
|
||||||
}
|
}
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler( 'open', openHandler, userData );
|
viewer.addHandler( 'open', openHandler, userData );
|
||||||
@ -1111,7 +1116,7 @@
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
test('EventSource: addOnceHandler', function() {
|
QUnit.test('EventSource: addOnceHandler', function(assert) {
|
||||||
var eventSource = new OpenSeadragon.EventSource();
|
var eventSource = new OpenSeadragon.EventSource();
|
||||||
var userData = 'data';
|
var userData = 'data';
|
||||||
var eventData = {
|
var eventData = {
|
||||||
@ -1120,23 +1125,23 @@
|
|||||||
var handlerCalledCount = 0;
|
var handlerCalledCount = 0;
|
||||||
eventSource.addOnceHandler('test-event', function(event) {
|
eventSource.addOnceHandler('test-event', function(event) {
|
||||||
handlerCalledCount++;
|
handlerCalledCount++;
|
||||||
strictEqual(event.foo, eventData.foo,
|
assert.strictEqual(event.foo, eventData.foo,
|
||||||
'Event data should be transmitted to the event.');
|
'Event data should be transmitted to the event.');
|
||||||
strictEqual(event.userData, userData,
|
assert.strictEqual(event.userData, userData,
|
||||||
'User data should be transmitted to the event.');
|
'User data should be transmitted to the event.');
|
||||||
}, userData);
|
}, userData);
|
||||||
strictEqual(0, handlerCalledCount,
|
assert.strictEqual(0, handlerCalledCount,
|
||||||
'Handler should not have been called yet.');
|
'Handler should not have been called yet.');
|
||||||
eventSource.raiseEvent('test-event', eventData);
|
eventSource.raiseEvent('test-event', eventData);
|
||||||
strictEqual(1, handlerCalledCount,
|
assert.strictEqual(1, handlerCalledCount,
|
||||||
'Handler should have been called once.');
|
'Handler should have been called once.');
|
||||||
eventSource.raiseEvent('test-event', eventData);
|
eventSource.raiseEvent('test-event', eventData);
|
||||||
strictEqual(1, handlerCalledCount,
|
assert.strictEqual(1, handlerCalledCount,
|
||||||
'Handler should still have been called once.');
|
'Handler should still have been called once.');
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
test('EventSource: addOnceHandler 2 times', function() {
|
QUnit.test('EventSource: addOnceHandler 2 times', function(assert) {
|
||||||
var eventSource = new OpenSeadragon.EventSource();
|
var eventSource = new OpenSeadragon.EventSource();
|
||||||
var userData = 'data';
|
var userData = 'data';
|
||||||
var eventData = {
|
var eventData = {
|
||||||
@ -1145,37 +1150,38 @@
|
|||||||
var handlerCalledCount = 0;
|
var handlerCalledCount = 0;
|
||||||
eventSource.addOnceHandler('test-event', function(event) {
|
eventSource.addOnceHandler('test-event', function(event) {
|
||||||
handlerCalledCount++;
|
handlerCalledCount++;
|
||||||
strictEqual(event.foo, eventData.foo,
|
assert.strictEqual(event.foo, eventData.foo,
|
||||||
'Event data should be transmitted to the event.');
|
'Event data should be transmitted to the event.');
|
||||||
strictEqual(event.userData, userData,
|
assert.strictEqual(event.userData, userData,
|
||||||
'User data should be transmitted to the event.');
|
'User data should be transmitted to the event.');
|
||||||
}, userData, 2);
|
}, userData, 2);
|
||||||
strictEqual(0, handlerCalledCount,
|
assert.strictEqual(0, handlerCalledCount,
|
||||||
'Handler should not have been called yet.');
|
'Handler should not have been called yet.');
|
||||||
eventSource.raiseEvent('test-event', eventData);
|
eventSource.raiseEvent('test-event', eventData);
|
||||||
strictEqual(1, handlerCalledCount,
|
assert.strictEqual(1, handlerCalledCount,
|
||||||
'Handler should have been called once.');
|
'Handler should have been called once.');
|
||||||
eventSource.raiseEvent('test-event', eventData);
|
eventSource.raiseEvent('test-event', eventData);
|
||||||
strictEqual(2, handlerCalledCount,
|
assert.strictEqual(2, handlerCalledCount,
|
||||||
'Handler should have been called twice.');
|
'Handler should have been called twice.');
|
||||||
eventSource.raiseEvent('test-event', eventData);
|
eventSource.raiseEvent('test-event', eventData);
|
||||||
strictEqual(2, handlerCalledCount,
|
assert.strictEqual(2, handlerCalledCount,
|
||||||
'Handler should still have been called twice.');
|
'Handler should still have been called twice.');
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest( 'Viewer: tile-drawing event', function () {
|
QUnit.test( 'Viewer: tile-drawing event', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
var tileDrawing = function ( event ) {
|
var tileDrawing = function ( event ) {
|
||||||
viewer.removeHandler( 'tile-drawing', tileDrawing );
|
viewer.removeHandler( 'tile-drawing', tileDrawing );
|
||||||
ok( event, 'Event handler should be invoked' );
|
assert.ok( event, 'Event handler should be invoked' );
|
||||||
if ( event ) {
|
if ( event ) {
|
||||||
// Make sure we have the expected elements set
|
// Make sure we have the expected elements set
|
||||||
ok(event.context, "Context should be set");
|
assert.ok(event.context, "Context should be set");
|
||||||
ok(event.tile, "Tile should be set");
|
assert.ok(event.tile, "Tile should be set");
|
||||||
ok(event.rendered, "Rendered should be set");
|
assert.ok(event.rendered, "Rendered should be set");
|
||||||
}
|
}
|
||||||
viewer.close();
|
viewer.close();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler( 'tile-drawing', tileDrawing );
|
viewer.addHandler( 'tile-drawing', tileDrawing );
|
||||||
@ -1183,17 +1189,17 @@
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
// tile-loaded event tests
|
// tile-loaded event tests
|
||||||
asyncTest( 'Viewer: tile-loaded event without callback.', function () {
|
QUnit.test( 'Viewer: tile-loaded event without callback.', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
function tileLoaded ( event ) {
|
function tileLoaded ( event ) {
|
||||||
viewer.removeHandler( 'tile-loaded', tileLoaded);
|
viewer.removeHandler( 'tile-loaded', tileLoaded);
|
||||||
var tile = event.tile;
|
var tile = event.tile;
|
||||||
ok( tile.loading, "The tile should be marked as loading.");
|
assert.ok( tile.loading, "The tile should be marked as loading.");
|
||||||
notOk( tile.loaded, "The tile should not be marked as loaded.");
|
assert.notOk( tile.loaded, "The tile should not be marked as loaded.");
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
notOk( tile.loading, "The tile should not be marked as loading.");
|
assert.notOk( tile.loading, "The tile should not be marked as loading.");
|
||||||
ok( tile.loaded, "The tile should be marked as loaded.");
|
assert.ok( tile.loaded, "The tile should be marked as loaded.");
|
||||||
start();
|
done();
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1201,22 +1207,22 @@
|
|||||||
viewer.open( '/test/data/testpattern.dzi' );
|
viewer.open( '/test/data/testpattern.dzi' );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
asyncTest( 'Viewer: tile-loaded event with 1 callback.', function () {
|
QUnit.test( 'Viewer: tile-loaded event with 1 callback.', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
function tileLoaded ( event ) {
|
function tileLoaded ( event ) {
|
||||||
viewer.removeHandler( 'tile-loaded', tileLoaded);
|
viewer.removeHandler( 'tile-loaded', tileLoaded);
|
||||||
var tile = event.tile;
|
var tile = event.tile;
|
||||||
var callback = event.getCompletionCallback();
|
var callback = event.getCompletionCallback();
|
||||||
ok( tile.loading, "The tile should be marked as loading.");
|
assert.ok( tile.loading, "The tile should be marked as loading.");
|
||||||
notOk( tile.loaded, "The tile should not be marked as loaded.");
|
assert.notOk( tile.loaded, "The tile should not be marked as loaded.");
|
||||||
ok( callback, "The event should have a callback.");
|
assert.ok( callback, "The event should have a callback.");
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
ok( tile.loading, "The tile should be marked as loading.");
|
assert.ok( tile.loading, "The tile should be marked as loading.");
|
||||||
notOk( tile.loaded, "The tile should not be marked as loaded.");
|
assert.notOk( tile.loaded, "The tile should not be marked as loaded.");
|
||||||
callback();
|
callback();
|
||||||
notOk( tile.loading, "The tile should not be marked as loading.");
|
assert.notOk( tile.loading, "The tile should not be marked as loading.");
|
||||||
ok( tile.loaded, "The tile should be marked as loaded.");
|
assert.ok( tile.loaded, "The tile should be marked as loaded.");
|
||||||
start();
|
done();
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1224,28 +1230,28 @@
|
|||||||
viewer.open( '/test/data/testpattern.dzi' );
|
viewer.open( '/test/data/testpattern.dzi' );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
asyncTest( 'Viewer: tile-loaded event with 2 callbacks.', function () {
|
QUnit.test( 'Viewer: tile-loaded event with 2 callbacks.', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
function tileLoaded ( event ) {
|
function tileLoaded ( event ) {
|
||||||
viewer.removeHandler( 'tile-loaded', tileLoaded);
|
viewer.removeHandler( 'tile-loaded', tileLoaded);
|
||||||
var tile = event.tile;
|
var tile = event.tile;
|
||||||
var callback1 = event.getCompletionCallback();
|
var callback1 = event.getCompletionCallback();
|
||||||
var callback2 = event.getCompletionCallback();
|
var callback2 = event.getCompletionCallback();
|
||||||
ok( tile.loading, "The tile should be marked as loading.");
|
assert.ok( tile.loading, "The tile should be marked as loading.");
|
||||||
notOk( tile.loaded, "The tile should not be marked as loaded.");
|
assert.notOk( tile.loaded, "The tile should not be marked as loaded.");
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
ok( tile.loading, "The tile should be marked as loading.");
|
assert.ok( tile.loading, "The tile should be marked as loading.");
|
||||||
notOk( tile.loaded, "The tile should not be marked as loaded.");
|
assert.notOk( tile.loaded, "The tile should not be marked as loaded.");
|
||||||
callback1();
|
callback1();
|
||||||
ok( tile.loading, "The tile should be marked as loading.");
|
assert.ok( tile.loading, "The tile should be marked as loading.");
|
||||||
notOk( tile.loaded, "The tile should not be marked as loaded.");
|
assert.notOk( tile.loaded, "The tile should not be marked as loaded.");
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
ok( tile.loading, "The tile should be marked as loading.");
|
assert.ok( tile.loading, "The tile should be marked as loading.");
|
||||||
notOk( tile.loaded, "The tile should not be marked as loaded.");
|
assert.notOk( tile.loaded, "The tile should not be marked as loaded.");
|
||||||
callback2();
|
callback2();
|
||||||
notOk( tile.loading, "The tile should not be marked as loading.");
|
assert.notOk( tile.loading, "The tile should not be marked as loading.");
|
||||||
ok( tile.loaded, "The tile should be marked as loaded.");
|
assert.ok( tile.loaded, "The tile should be marked as loaded.");
|
||||||
start();
|
done();
|
||||||
}, 0);
|
}, 0);
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
@ -1254,9 +1260,10 @@
|
|||||||
viewer.open( '/test/data/testpattern.dzi' );
|
viewer.open( '/test/data/testpattern.dzi' );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
asyncTest( 'Viewer: tile-unloaded event.', function() {
|
QUnit.test( 'Viewer: tile-unloaded event.', function(assert) {
|
||||||
var tiledImage;
|
var tiledImage;
|
||||||
var tile;
|
var tile;
|
||||||
|
var done = assert.async();
|
||||||
|
|
||||||
function tileLoaded( event ) {
|
function tileLoaded( event ) {
|
||||||
viewer.removeHandler( 'tile-loaded', tileLoaded);
|
viewer.removeHandler( 'tile-loaded', tileLoaded);
|
||||||
@ -1269,11 +1276,11 @@
|
|||||||
|
|
||||||
function tileUnloaded( event ) {
|
function tileUnloaded( event ) {
|
||||||
viewer.removeHandler( 'tile-unloaded', tileUnloaded );
|
viewer.removeHandler( 'tile-unloaded', tileUnloaded );
|
||||||
equal( tile, event.tile,
|
assert.equal( tile, event.tile,
|
||||||
"The unloaded tile should be the same than the loaded one." );
|
"The unloaded tile should be the same than the loaded one." );
|
||||||
equal( tiledImage, event.tiledImage,
|
assert.equal( tiledImage, event.tiledImage,
|
||||||
"The tiledImage of the unloaded tile should be the same than the one of the loaded one." );
|
"The tiledImage of the unloaded tile should be the same than the one of the loaded one." );
|
||||||
start();
|
done();
|
||||||
}
|
}
|
||||||
|
|
||||||
viewer.addHandler( 'tile-loaded', tileLoaded );
|
viewer.addHandler( 'tile-loaded', tileLoaded );
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
|
/* global QUnit, Util */
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
// This module tests whether our various file formats can be opened.
|
// This module tests whether our various file formats can be opened.
|
||||||
// TODO: Add more file formats (with corresponding test data).
|
// TODO: Add more file formats (with corresponding test data).
|
||||||
|
|
||||||
module('Formats', {
|
QUnit.module('Formats', {
|
||||||
setup: function () {
|
beforeEach: function () {
|
||||||
var example = document.createElement("div");
|
var example = document.createElement("div");
|
||||||
example.id = "example";
|
example.id = "example";
|
||||||
document.getElementById("qunit-fixture").appendChild(example);
|
document.getElementById("qunit-fixture").appendChild(example);
|
||||||
@ -14,13 +16,12 @@
|
|||||||
var viewer = null;
|
var viewer = null;
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
var testOpenUrl = function(relativeUrl) {
|
var testOpenUrl = function(relativeUrl, assert) {
|
||||||
testOpen('/test/data/' + relativeUrl);
|
testOpen('/test/data/' + relativeUrl, assert);
|
||||||
};
|
};
|
||||||
|
|
||||||
var testOpen = function(tileSource) {
|
var testOpen = function(tileSource, assert) {
|
||||||
$(document).ready(function() {
|
var timeWatcher = Util.timeWatcher(assert, 7000);
|
||||||
var timeWatcher = Util.timeWatcher(7000);
|
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
id: 'example',
|
id: 'example',
|
||||||
@ -28,17 +29,17 @@
|
|||||||
tileSources: tileSource
|
tileSources: tileSource
|
||||||
});
|
});
|
||||||
|
|
||||||
ok(viewer, 'Viewer exists');
|
assert.ok(viewer, 'Viewer exists');
|
||||||
|
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
ok(true, 'Open event was sent');
|
assert.ok(true, 'Open event was sent');
|
||||||
viewer.addHandler('tile-drawn', tileDrawnHandler);
|
viewer.addHandler('tile-drawn', tileDrawnHandler);
|
||||||
};
|
};
|
||||||
|
|
||||||
var tileDrawnHandler = function(event) {
|
var tileDrawnHandler = function(event) {
|
||||||
viewer.removeHandler('tile-drawn', tileDrawnHandler);
|
viewer.removeHandler('tile-drawn', tileDrawnHandler);
|
||||||
ok(true, 'A tile has been drawn');
|
assert.ok(true, 'A tile has been drawn');
|
||||||
viewer.addHandler('close', closeHandler);
|
viewer.addHandler('close', closeHandler);
|
||||||
viewer.close();
|
viewer.close();
|
||||||
};
|
};
|
||||||
@ -46,81 +47,79 @@
|
|||||||
var closeHandler = function(event) {
|
var closeHandler = function(event) {
|
||||||
viewer.removeHandler('close', closeHandler);
|
viewer.removeHandler('close', closeHandler);
|
||||||
$('#example').empty();
|
$('#example').empty();
|
||||||
ok(true, 'Close event was sent');
|
assert.ok(true, 'Close event was sent');
|
||||||
timeWatcher.done();
|
timeWatcher.done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('DZI', function() {
|
QUnit.test('DZI', function(assert) {
|
||||||
testOpenUrl('testpattern.dzi');
|
testOpenUrl('testpattern.dzi', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('DZI JSONp', function() {
|
QUnit.test('DZI JSONp', function(assert) {
|
||||||
testOpenUrl('testpattern.js');
|
testOpenUrl('testpattern.js', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('DZI XML', function() {
|
QUnit.test('DZI XML', function(assert) {
|
||||||
testOpenUrl('testpattern.xml');
|
testOpenUrl('testpattern.xml', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('DZI XML with query parameter', function() {
|
QUnit.test('DZI XML with query parameter', function(assert) {
|
||||||
testOpenUrl('testpattern.xml?param=value');
|
testOpenUrl('testpattern.xml?param=value', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF 1.0 JSON', function() {
|
QUnit.test('IIIF 1.0 JSON', function(assert) {
|
||||||
testOpenUrl('iiif_1_0_files/info.json');
|
testOpenUrl('iiif_1_0_files/info.json', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF 1.0 XML', function() {
|
QUnit.test('IIIF 1.0 XML', function(assert) {
|
||||||
testOpenUrl('iiif_1_0_files/info.xml');
|
testOpenUrl('iiif_1_0_files/info.xml', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF 1.1 JSON', function() {
|
QUnit.test('IIIF 1.1 JSON', function(assert) {
|
||||||
testOpenUrl('iiif_1_1_tiled/info.json');
|
testOpenUrl('iiif_1_1_tiled/info.json', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF No Tiles, Less than 256', function() {
|
QUnit.test('IIIF No Tiles, Less than 256', function(assert) {
|
||||||
testOpenUrl('iiif_1_1_no_tiles_255/info.json');
|
testOpenUrl('iiif_1_1_no_tiles_255/info.json', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF No Tiles, Bet. 256 and 512', function() {
|
QUnit.test('IIIF No Tiles, Bet. 256 and 512', function(assert) {
|
||||||
testOpenUrl('iiif_1_1_no_tiles_384/info.json');
|
testOpenUrl('iiif_1_1_no_tiles_384/info.json', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF No Tiles, Bet. 512 and 1024', function() {
|
QUnit.test('IIIF No Tiles, Bet. 512 and 1024', function(assert) {
|
||||||
testOpenUrl('iiif_1_1_no_tiles_768/info.json');
|
testOpenUrl('iiif_1_1_no_tiles_768/info.json', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF No Tiles, Larger than 1024', function() {
|
QUnit.test('IIIF No Tiles, Larger than 1024', function(assert) {
|
||||||
testOpenUrl('iiif_1_1_no_tiles_1048/info.json');
|
testOpenUrl('iiif_1_1_no_tiles_1048/info.json', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF 2.0 JSON', function() {
|
QUnit.test('IIIF 2.0 JSON', function(assert) {
|
||||||
testOpenUrl('iiif_2_0_tiled/info.json');
|
testOpenUrl('iiif_2_0_tiled/info.json', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF 2.0 JSON, sizes array only', function() {
|
QUnit.test('IIIF 2.0 JSON, sizes array only', function(assert) {
|
||||||
testOpenUrl('iiif_2_0_sizes/info.json');
|
testOpenUrl('iiif_2_0_sizes/info.json', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('IIIF 2.0 JSON String', function() {
|
QUnit.test('IIIF 2.0 JSON String', function(assert) {
|
||||||
testOpen(
|
testOpen(
|
||||||
'{' +
|
'{' +
|
||||||
' "@context": "http://iiif.io/api/image/2/context.json",' +
|
' "@context": "http://iiif.io/api/image/2/context.json",' +
|
||||||
@ -144,30 +143,30 @@
|
|||||||
' ]' +
|
' ]' +
|
||||||
' }' +
|
' }' +
|
||||||
' ]' +
|
' ]' +
|
||||||
'}');
|
'}', assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('ImageTileSource', function () {
|
QUnit.test('ImageTileSource', function(assert) {
|
||||||
testOpen({
|
testOpen({
|
||||||
type: "image",
|
type: "image",
|
||||||
url: "/test/data/A.png"
|
url: "/test/data/A.png"
|
||||||
});
|
}, assert);
|
||||||
});
|
});
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('Zoomify', function () {
|
QUnit.test('Zoomify', function(assert) {
|
||||||
testOpen({
|
testOpen({
|
||||||
type: "zoomifytileservice",
|
type: "zoomifytileservice",
|
||||||
tileSize: 256,
|
tileSize: 256,
|
||||||
width: 1000,
|
width: 1000,
|
||||||
height: 1000,
|
height: 1000,
|
||||||
tilesUrl: "/test/data/zoomify/"
|
tilesUrl: "/test/data/zoomify/"
|
||||||
});
|
}, assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('Legacy Image Pyramid', function() {
|
QUnit.test('Legacy Image Pyramid', function(assert) {
|
||||||
// Although it is using image paths that happen to be in IIIF format, this is not a IIIFTileSource.
|
// Although it is using image paths that happen to be in IIIF format, this is not a IIIFTileSource.
|
||||||
// The url values are opaque, just image locations.
|
// The url values are opaque, just image locations.
|
||||||
// When emulating a legacy pyramid, IIIFTileSource calls functions from LegacyTileSource, so this
|
// When emulating a legacy pyramid, IIIFTileSource calls functions from LegacyTileSource, so this
|
||||||
@ -195,7 +194,7 @@
|
|||||||
height: 5074,
|
height: 5074,
|
||||||
width: 6976
|
width: 6976
|
||||||
}]
|
}]
|
||||||
});
|
}, assert);
|
||||||
});
|
});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* global module, asyncTest, $, ok, equal, notEqual, start, test, Util, testLog */
|
/* global QUnit, $, testLog */
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var viewer,
|
var viewer,
|
||||||
@ -8,13 +8,13 @@
|
|||||||
springStiffness: 100 // Faster animation = faster tests
|
springStiffness: 100 // Faster animation = faster tests
|
||||||
};
|
};
|
||||||
|
|
||||||
module('ImageLoader', {
|
QUnit.module('ImageLoader', {
|
||||||
setup: function () {
|
beforeEach: function () {
|
||||||
var example = $('<div id="example"></div>').appendTo("#qunit-fixture");
|
$('<div id="example"></div>').appendTo("#qunit-fixture");
|
||||||
|
|
||||||
testLog.reset();
|
testLog.reset();
|
||||||
},
|
},
|
||||||
teardown: function () {
|
afterEach: function () {
|
||||||
if (viewer && viewer.close) {
|
if (viewer && viewer.close) {
|
||||||
viewer.close();
|
viewer.close();
|
||||||
}
|
}
|
||||||
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
|
|
||||||
test('Default timeout', function() {
|
QUnit.test('Default timeout', function(assert) {
|
||||||
var actual,
|
var actual,
|
||||||
expected = OpenSeadragon.DEFAULT_SETTINGS.timeout,
|
expected = OpenSeadragon.DEFAULT_SETTINGS.timeout,
|
||||||
message,
|
message,
|
||||||
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
message = 'ImageLoader timeout should be set to the default value of ' + expected + ' when none is specified';
|
message = 'ImageLoader timeout should be set to the default value of ' + expected + ' when none is specified';
|
||||||
actual = imageLoader.timeout;
|
actual = imageLoader.timeout;
|
||||||
equal(actual, expected, message);
|
assert.equal(actual, expected, message);
|
||||||
|
|
||||||
// Manually seize the ImageLoader
|
// Manually seize the ImageLoader
|
||||||
imageLoader.jobsInProgress = imageLoader.jobLimit;
|
imageLoader.jobsInProgress = imageLoader.jobLimit;
|
||||||
@ -51,12 +51,12 @@
|
|||||||
|
|
||||||
message = 'ImageJob should inherit the ImageLoader timeout value';
|
message = 'ImageJob should inherit the ImageLoader timeout value';
|
||||||
actual = imageLoader.jobQueue.shift().timeout;
|
actual = imageLoader.jobQueue.shift().timeout;
|
||||||
equal(actual, expected, message);
|
assert.equal(actual, expected, message);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
|
|
||||||
test('Configure timeout', function() {
|
QUnit.test('Configure timeout', function(assert) {
|
||||||
var actual,
|
var actual,
|
||||||
expected = 123456,
|
expected = 123456,
|
||||||
message,
|
message,
|
||||||
@ -69,7 +69,7 @@
|
|||||||
|
|
||||||
message = 'ImageLoader timeout should be configurable';
|
message = 'ImageLoader timeout should be configurable';
|
||||||
actual = imageLoader.timeout;
|
actual = imageLoader.timeout;
|
||||||
equal(actual, expected, message);
|
assert.equal(actual, expected, message);
|
||||||
|
|
||||||
imageLoader.jobsInProgress = imageLoader.jobLimit;
|
imageLoader.jobsInProgress = imageLoader.jobLimit;
|
||||||
imageLoader.addJob({
|
imageLoader.addJob({
|
||||||
@ -82,7 +82,7 @@
|
|||||||
|
|
||||||
message = 'ImageJob should inherit the ImageLoader timeout value';
|
message = 'ImageJob should inherit the ImageLoader timeout value';
|
||||||
actual = imageLoader.jobQueue.shift().timeout;
|
actual = imageLoader.jobQueue.shift().timeout;
|
||||||
equal(actual, expected, message);
|
assert.equal(actual, expected, message);
|
||||||
});
|
});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
/* global module, asyncTest, $, ok, equal, notEqual, start, test, Util, testLog, expect */
|
/* global QUnit, $,testLog */
|
||||||
|
|
||||||
( function() {
|
( function() {
|
||||||
var viewer;
|
var viewer;
|
||||||
|
|
||||||
module( 'Multi-Image', {
|
QUnit.module( 'Multi-Image', {
|
||||||
setup: function() {
|
beforeEach: function() {
|
||||||
$( '<div id="example"></div>' ).appendTo( "#qunit-fixture" );
|
$( '<div id="example"></div>' ).appendTo( "#qunit-fixture" );
|
||||||
|
|
||||||
testLog.reset();
|
testLog.reset();
|
||||||
@ -15,7 +15,7 @@
|
|||||||
springStiffness: 100 // Faster animation = faster tests
|
springStiffness: 100 // Faster animation = faster tests
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
teardown: function() {
|
afterEach: function() {
|
||||||
if ( viewer && viewer.close ) {
|
if ( viewer && viewer.close ) {
|
||||||
viewer.close();
|
viewer.close();
|
||||||
}
|
}
|
||||||
@ -26,10 +26,11 @@
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest( 'Multi-image operations', function() {
|
QUnit.test( 'Multi-image operations', function(assert) {
|
||||||
expect( 24 );
|
var done = assert.async();
|
||||||
|
assert.expect( 24 );
|
||||||
viewer.addHandler( "open", function( ) {
|
viewer.addHandler( "open", function( ) {
|
||||||
equal( 1, viewer.world.getItemCount( ),
|
assert.equal( 1, viewer.world.getItemCount( ),
|
||||||
"One item should be present after opening." );
|
"One item should be present after opening." );
|
||||||
var options = {
|
var options = {
|
||||||
tileSource: {
|
tileSource: {
|
||||||
@ -45,41 +46,41 @@
|
|||||||
viewer.world.addHandler( "add-item", function addFirstItemHandler( event ) {
|
viewer.world.addHandler( "add-item", function addFirstItemHandler( event ) {
|
||||||
viewer.world.removeHandler( "add-item", addFirstItemHandler );
|
viewer.world.removeHandler( "add-item", addFirstItemHandler );
|
||||||
var item1 = event.item;
|
var item1 = event.item;
|
||||||
equal( viewer.world.getItemCount( ), 2,
|
assert.equal( viewer.world.getItemCount( ), 2,
|
||||||
"2 items should be present after adding a item." );
|
"2 items should be present after adding a item." );
|
||||||
equal( viewer.world.getIndexOfItem( item1 ), 1,
|
assert.equal( viewer.world.getIndexOfItem( item1 ), 1,
|
||||||
"The first added item should have a index of 1" );
|
"The first added item should have a index of 1" );
|
||||||
equal( viewer.world.getItemAt( 1 ), item1,
|
assert.equal( viewer.world.getItemAt( 1 ), item1,
|
||||||
"The item at index 1 should be the first added item." );
|
"The item at index 1 should be the first added item." );
|
||||||
|
|
||||||
viewer.addTiledImage( options );
|
viewer.addTiledImage( options );
|
||||||
viewer.world.addHandler( "add-item", function addSecondItemHandler( event ) {
|
viewer.world.addHandler( "add-item", function addSecondItemHandler( event ) {
|
||||||
viewer.world.removeHandler( "add-item", addSecondItemHandler );
|
viewer.world.removeHandler( "add-item", addSecondItemHandler );
|
||||||
var item2 = event.item;
|
var item2 = event.item;
|
||||||
equal( viewer.world.getItemCount( ), 3,
|
assert.equal( viewer.world.getItemCount( ), 3,
|
||||||
"3 items should be present after adding a second item." );
|
"3 items should be present after adding a second item." );
|
||||||
equal( viewer.world.getIndexOfItem( item2 ), 2,
|
assert.equal( viewer.world.getIndexOfItem( item2 ), 2,
|
||||||
"If not specified, a item should be added with the highest index." );
|
"If not specified, a item should be added with the highest index." );
|
||||||
equal( viewer.world.getItemAt( 2 ), item2,
|
assert.equal( viewer.world.getItemAt( 2 ), item2,
|
||||||
"The item at index 2 should be the second added item." );
|
"The item at index 2 should be the second added item." );
|
||||||
|
|
||||||
viewer.world.addHandler( "item-index-change",
|
viewer.world.addHandler( "item-index-change",
|
||||||
function itemIndexChangedHandler( event ) {
|
function itemIndexChangedHandler( event ) {
|
||||||
viewer.world.removeHandler( "item-index-change",
|
viewer.world.removeHandler( "item-index-change",
|
||||||
itemIndexChangedHandler );
|
itemIndexChangedHandler );
|
||||||
equal( event.item, item2,
|
assert.equal( event.item, item2,
|
||||||
"The item which changed index should be item2" );
|
"The item which changed index should be item2" );
|
||||||
equal( event.previousIndex, 2, "Previous index should be 2." );
|
assert.equal( event.previousIndex, 2, "Previous index should be 2." );
|
||||||
equal( event.newIndex, 1, "New index should be 1." );
|
assert.equal( event.newIndex, 1, "New index should be 1." );
|
||||||
});
|
});
|
||||||
viewer.world.setItemIndex( item2, 1 );
|
viewer.world.setItemIndex( item2, 1 );
|
||||||
equal( viewer.world.getIndexOfItem( item2 ), 1,
|
assert.equal( viewer.world.getIndexOfItem( item2 ), 1,
|
||||||
"Item2 index should be 1 after setItemIndex." );
|
"Item2 index should be 1 after setItemIndex." );
|
||||||
equal( viewer.world.getIndexOfItem( item1 ), 2,
|
assert.equal( viewer.world.getIndexOfItem( item1 ), 2,
|
||||||
"Item1 index should be 2 after setItemIndex." );
|
"Item1 index should be 2 after setItemIndex." );
|
||||||
equal( viewer.world.getItemAt( 1 ), item2,
|
assert.equal( viewer.world.getItemAt( 1 ), item2,
|
||||||
"The item at index 1 should be item2." );
|
"The item at index 1 should be item2." );
|
||||||
equal( viewer.world.getItemAt( 2 ), item1,
|
assert.equal( viewer.world.getItemAt( 2 ), item1,
|
||||||
"The item at index 2 should be item1." );
|
"The item at index 2 should be item1." );
|
||||||
|
|
||||||
options.index = 2;
|
options.index = 2;
|
||||||
@ -88,11 +89,11 @@
|
|||||||
viewer.world.addHandler( "add-item", function addThirdItemHandler( event ) {
|
viewer.world.addHandler( "add-item", function addThirdItemHandler( event ) {
|
||||||
viewer.world.removeHandler( "add-item", addThirdItemHandler );
|
viewer.world.removeHandler( "add-item", addThirdItemHandler );
|
||||||
var item3 = event.item;
|
var item3 = event.item;
|
||||||
equal( viewer.world.getItemCount( ), 4,
|
assert.equal( viewer.world.getItemCount( ), 4,
|
||||||
"4 items should be present after adding a third item." );
|
"4 items should be present after adding a third item." );
|
||||||
equal( viewer.world.getIndexOfItem( item3 ), 2,
|
assert.equal( viewer.world.getIndexOfItem( item3 ), 2,
|
||||||
"Item 3 should be added with index 2." );
|
"Item 3 should be added with index 2." );
|
||||||
equal( viewer.world.getIndexOfItem( item2 ), 1,
|
assert.equal( viewer.world.getIndexOfItem( item2 ), 1,
|
||||||
"Item 2 should stay at index 1." );
|
"Item 2 should stay at index 1." );
|
||||||
|
|
||||||
options.index = 2;
|
options.index = 2;
|
||||||
@ -101,26 +102,26 @@
|
|||||||
viewer.world.addHandler( "add-item", function replaceAddItemHandler( event ) {
|
viewer.world.addHandler( "add-item", function replaceAddItemHandler( event ) {
|
||||||
viewer.world.removeHandler( "add-item", replaceAddItemHandler );
|
viewer.world.removeHandler( "add-item", replaceAddItemHandler );
|
||||||
var item4 = event.item;
|
var item4 = event.item;
|
||||||
equal( viewer.world.getItemCount( ), 4,
|
assert.equal( viewer.world.getItemCount( ), 4,
|
||||||
"4 items should still be present after replacing the second item." );
|
"4 items should still be present after replacing the second item." );
|
||||||
equal( viewer.world.getIndexOfItem( item4 ), 2,
|
assert.equal( viewer.world.getIndexOfItem( item4 ), 2,
|
||||||
"Item 4 should be added with index 2." );
|
"Item 4 should be added with index 2." );
|
||||||
equal( viewer.world.getIndexOfItem( item3 ), -1,
|
assert.equal( viewer.world.getIndexOfItem( item3 ), -1,
|
||||||
"Item 3 should be at index -1." );
|
"Item 3 should be at index -1." );
|
||||||
|
|
||||||
viewer.world.addHandler( "remove-item", function removeItemHandler( event ) {
|
viewer.world.addHandler( "remove-item", function removeItemHandler( event ) {
|
||||||
viewer.world.removeHandler( "remove-item", removeItemHandler );
|
viewer.world.removeHandler( "remove-item", removeItemHandler );
|
||||||
|
|
||||||
equal( item2, event.item, "Removed item should be item2." );
|
assert.equal( item2, event.item, "Removed item should be item2." );
|
||||||
|
|
||||||
equal( viewer.world.getIndexOfItem( item1 ), 2,
|
assert.equal( viewer.world.getIndexOfItem( item1 ), 2,
|
||||||
"Item 1 should be at index 2." );
|
"Item 1 should be at index 2." );
|
||||||
equal( viewer.world.getIndexOfItem( item2 ), -1,
|
assert.equal( viewer.world.getIndexOfItem( item2 ), -1,
|
||||||
"Item 2 should be at index -1." );
|
"Item 2 should be at index -1." );
|
||||||
equal( viewer.world.getIndexOfItem( item4 ), 1,
|
assert.equal( viewer.world.getIndexOfItem( item4 ), 1,
|
||||||
"Item 4 should be at index 1." );
|
"Item 4 should be at index 1." );
|
||||||
|
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
viewer.world.removeItem( item2 );
|
viewer.world.removeItem( item2 );
|
||||||
@ -133,7 +134,8 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest( 'Sequences as items', function() {
|
QUnit.test( 'Sequences as items', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var options = {
|
var options = {
|
||||||
tileSource: [{
|
tileSource: [{
|
||||||
type: 'legacy-image-pyramid',
|
type: 'legacy-image-pyramid',
|
||||||
@ -158,9 +160,9 @@
|
|||||||
viewer.addHandler( "add-item-failed",
|
viewer.addHandler( "add-item-failed",
|
||||||
function addItemFailedHandler( event ) {
|
function addItemFailedHandler( event ) {
|
||||||
viewer.removeHandler( "add-item-failed", addItemFailedHandler );
|
viewer.removeHandler( "add-item-failed", addItemFailedHandler );
|
||||||
equal( event.message, "[Viewer.addTiledImage] Sequences can not be added; add them one at a time instead." );
|
assert.equal( event.message, "[Viewer.addTiledImage] Sequences can not be added; add them one at a time instead." );
|
||||||
equal( event.options, options, "Item failed event should give the options." );
|
assert.equal( event.options, options, "Item failed event should give the options." );
|
||||||
start();
|
done();
|
||||||
} );
|
} );
|
||||||
viewer.addTiledImage( options );
|
viewer.addTiledImage( options );
|
||||||
|
|
||||||
@ -169,13 +171,14 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('items are added in order', function() {
|
QUnit.test('items are added in order', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer.addHandler('open', function(event) {
|
viewer.addHandler('open', function(event) {
|
||||||
equal(viewer.world.getItemAt(0).getContentSize().y, 2000, 'first image is tall');
|
assert.equal(viewer.world.getItemAt(0).getContentSize().y, 2000, 'first image is tall');
|
||||||
equal(viewer.world.getItemAt(0).getBounds().width, 4, 'first image has 4 width');
|
assert.equal(viewer.world.getItemAt(0).getBounds().width, 4, 'first image has 4 width');
|
||||||
equal(viewer.world.getItemAt(1).getContentSize().x, 2000, 'second image is wide');
|
assert.equal(viewer.world.getItemAt(1).getContentSize().x, 2000, 'second image is wide');
|
||||||
equal(viewer.world.getItemAt(1).getBounds().width, 2, 'second image has 2 width');
|
assert.equal(viewer.world.getItemAt(1).getBounds().width, 2, 'second image has 2 width');
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
viewer.open([
|
viewer.open([
|
||||||
@ -189,15 +192,16 @@
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Viewer.addSimpleImage', function() {
|
QUnit.test('Viewer.addSimpleImage', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer.addHandler("open", function openHandler() {
|
viewer.addHandler("open", function openHandler() {
|
||||||
viewer.removeHandler("open", openHandler);
|
viewer.removeHandler("open", openHandler);
|
||||||
|
|
||||||
viewer.world.addHandler('add-item', function itemAdded(event) {
|
viewer.world.addHandler('add-item', function itemAdded(event) {
|
||||||
viewer.world.removeHandler('add-item', itemAdded);
|
viewer.world.removeHandler('add-item', itemAdded);
|
||||||
equal(event.item.opacity, 0.5,
|
assert.equal(event.item.opacity, 0.5,
|
||||||
'Opacity option should be set when using addSimpleImage');
|
'Opacity option should be set when using addSimpleImage');
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
viewer.addSimpleImage({
|
viewer.addSimpleImage({
|
||||||
@ -208,7 +212,8 @@
|
|||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Transparent image on top of others', function() {
|
QUnit.test('Transparent image on top of others', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
|
|
||||||
var density = OpenSeadragon.pixelDensityRatio;
|
var density = OpenSeadragon.pixelDensityRatio;
|
||||||
@ -222,10 +227,10 @@
|
|||||||
// Pixel 250,250 will be in the hole of the A
|
// Pixel 250,250 will be in the hole of the A
|
||||||
var expectedVal = getPixelValue(imageData, 250 * density, 250 * density);
|
var expectedVal = getPixelValue(imageData, 250 * density, 250 * density);
|
||||||
|
|
||||||
notEqual(expectedVal.r, 0, 'Red channel should not be 0');
|
assert.notEqual(expectedVal.r, 0, 'Red channel should not be 0');
|
||||||
notEqual(expectedVal.g, 0, 'Green channel should not be 0');
|
assert.notEqual(expectedVal.g, 0, 'Green channel should not be 0');
|
||||||
notEqual(expectedVal.b, 0, 'Blue channel should not be 0');
|
assert.notEqual(expectedVal.b, 0, 'Blue channel should not be 0');
|
||||||
notEqual(expectedVal.a, 0, 'Alpha channel should not be 0');
|
assert.notEqual(expectedVal.a, 0, 'Alpha channel should not be 0');
|
||||||
|
|
||||||
viewer.addSimpleImage({
|
viewer.addSimpleImage({
|
||||||
url: '/test/data/A.png',
|
url: '/test/data/A.png',
|
||||||
@ -235,22 +240,22 @@
|
|||||||
var imageData = viewer.drawer.context.getImageData(0, 0, 500 * density, 500 * density);
|
var imageData = viewer.drawer.context.getImageData(0, 0, 500 * density, 500 * density);
|
||||||
var actualVal = getPixelValue(imageData, 250 * density, 250 * density);
|
var actualVal = getPixelValue(imageData, 250 * density, 250 * density);
|
||||||
|
|
||||||
equal(actualVal.r, expectedVal.r,
|
assert.equal(actualVal.r, expectedVal.r,
|
||||||
'Red channel should not change in transparent part of the A');
|
'Red channel should not change in transparent part of the A');
|
||||||
equal(actualVal.g, expectedVal.g,
|
assert.equal(actualVal.g, expectedVal.g,
|
||||||
'Green channel should not change in transparent part of the A');
|
'Green channel should not change in transparent part of the A');
|
||||||
equal(actualVal.b, expectedVal.b,
|
assert.equal(actualVal.b, expectedVal.b,
|
||||||
'Blue channel should not change in transparent part of the A');
|
'Blue channel should not change in transparent part of the A');
|
||||||
equal(actualVal.a, expectedVal.a,
|
assert.equal(actualVal.a, expectedVal.a,
|
||||||
'Alpha channel should not change in transparent part of the A');
|
'Alpha channel should not change in transparent part of the A');
|
||||||
|
|
||||||
var onAVal = getPixelValue(imageData, 333 * density, 250 * density);
|
var onAVal = getPixelValue(imageData, 333 * density, 250 * density);
|
||||||
equal(onAVal.r, 0, 'Red channel should be null on the A');
|
assert.equal(onAVal.r, 0, 'Red channel should be null on the A');
|
||||||
equal(onAVal.g, 0, 'Green channel should be null on the A');
|
assert.equal(onAVal.g, 0, 'Green channel should be null on the A');
|
||||||
equal(onAVal.b, 0, 'Blue channel should be null on the A');
|
assert.equal(onAVal.b, 0, 'Blue channel should be null on the A');
|
||||||
equal(onAVal.a, 255, 'Alpha channel should be 255 on the A');
|
assert.equal(onAVal.a, 255, 'Alpha channel should be 255 on the A');
|
||||||
|
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,12 @@
|
|||||||
/* global QUnit, module, Util, $, console, test, asyncTest, start, ok, equal, testLog */
|
/* global QUnit, Util, $, console, testLog */
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var viewer;
|
var viewer;
|
||||||
// jQuery.position can give results quite different than what set in style.left
|
// jQuery.position can give results quite different than what set in style.left
|
||||||
var epsilon = 1;
|
var epsilon = 1;
|
||||||
|
|
||||||
module("Overlays", {
|
QUnit.module("Overlays", {
|
||||||
setup: function() {
|
beforeEach: function() {
|
||||||
var example = $('<div id="example-overlays"></div>').appendTo("#qunit-fixture");
|
var example = $('<div id="example-overlays"></div>').appendTo("#qunit-fixture");
|
||||||
var fixedOverlay = $('<div id="fixed-overlay"></div>').appendTo(example);
|
var fixedOverlay = $('<div id="fixed-overlay"></div>').appendTo(example);
|
||||||
fixedOverlay.width(70);
|
fixedOverlay.width(70);
|
||||||
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
testLog.reset();
|
testLog.reset();
|
||||||
},
|
},
|
||||||
teardown: function() {
|
afterEach: function() {
|
||||||
resetTestVariables();
|
resetTestVariables();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -53,8 +53,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
asyncTest('Overlays via viewer options', function() {
|
QUnit.test('Overlays via viewer options', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
id: 'example-overlays',
|
id: 'example-overlays',
|
||||||
prefixUrl: '/build/openseadragon/images/',
|
prefixUrl: '/build/openseadragon/images/',
|
||||||
@ -73,8 +73,8 @@
|
|||||||
function openHandler() {
|
function openHandler() {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
|
|
||||||
equal(viewer.overlays.length, 1, "Global overlay should be added.");
|
assert.equal(viewer.overlays.length, 1, "Global overlay should be added.");
|
||||||
equal(viewer.currentOverlays.length, 1, "Global overlay should be open.");
|
assert.equal(viewer.currentOverlays.length, 1, "Global overlay should be open.");
|
||||||
|
|
||||||
viewer.addHandler('open', openPageHandler);
|
viewer.addHandler('open', openPageHandler);
|
||||||
viewer.goToPage(1);
|
viewer.goToPage(1);
|
||||||
@ -83,8 +83,8 @@
|
|||||||
function openPageHandler() {
|
function openPageHandler() {
|
||||||
viewer.removeHandler('open', openPageHandler);
|
viewer.removeHandler('open', openPageHandler);
|
||||||
|
|
||||||
equal(viewer.overlays.length, 1, "Global overlay should stay after page switch.");
|
assert.equal(viewer.overlays.length, 1, "Global overlay should stay after page switch.");
|
||||||
equal(viewer.currentOverlays.length, 1, "Global overlay should re-open after page switch.");
|
assert.equal(viewer.currentOverlays.length, 1, "Global overlay should re-open after page switch.");
|
||||||
|
|
||||||
viewer.addHandler('close', closeHandler);
|
viewer.addHandler('close', closeHandler);
|
||||||
viewer.close();
|
viewer.close();
|
||||||
@ -93,15 +93,15 @@
|
|||||||
function closeHandler() {
|
function closeHandler() {
|
||||||
viewer.removeHandler('close', closeHandler);
|
viewer.removeHandler('close', closeHandler);
|
||||||
|
|
||||||
equal(viewer.overlays.length, 1, "Global overlay should not be removed on close.");
|
assert.equal(viewer.overlays.length, 1, "Global overlay should not be removed on close.");
|
||||||
equal(viewer.currentOverlays.length, 0, "Global overlay should be closed on close.");
|
assert.equal(viewer.currentOverlays.length, 0, "Global overlay should be closed on close.");
|
||||||
|
|
||||||
start();
|
done();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Page Overlays via viewer options', function() {
|
QUnit.test('Page Overlays via viewer options', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
id: 'example-overlays',
|
id: 'example-overlays',
|
||||||
prefixUrl: '/build/openseadragon/images/',
|
prefixUrl: '/build/openseadragon/images/',
|
||||||
@ -144,8 +144,8 @@
|
|||||||
function openHandler() {
|
function openHandler() {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
|
|
||||||
equal(viewer.overlays.length, 0, "No global overlay should be added.");
|
assert.equal(viewer.overlays.length, 0, "No global overlay should be added.");
|
||||||
equal(viewer.currentOverlays.length, 1, "Page overlay should be open.");
|
assert.equal(viewer.currentOverlays.length, 1, "Page overlay should be open.");
|
||||||
|
|
||||||
viewer.addHandler('open', openPageHandler);
|
viewer.addHandler('open', openPageHandler);
|
||||||
viewer.goToPage(1);
|
viewer.goToPage(1);
|
||||||
@ -154,8 +154,8 @@
|
|||||||
function openPageHandler() {
|
function openPageHandler() {
|
||||||
viewer.removeHandler('open', openPageHandler);
|
viewer.removeHandler('open', openPageHandler);
|
||||||
|
|
||||||
equal(viewer.overlays.length, 0, "No global overlay should be added after page switch.");
|
assert.equal(viewer.overlays.length, 0, "No global overlay should be added after page switch.");
|
||||||
equal(viewer.currentOverlays.length, 0, "No page overlay should be opened after page switch.");
|
assert.equal(viewer.currentOverlays.length, 0, "No page overlay should be opened after page switch.");
|
||||||
|
|
||||||
viewer.addHandler('close', closeHandler);
|
viewer.addHandler('close', closeHandler);
|
||||||
viewer.close();
|
viewer.close();
|
||||||
@ -164,15 +164,15 @@
|
|||||||
function closeHandler() {
|
function closeHandler() {
|
||||||
viewer.removeHandler('close', closeHandler);
|
viewer.removeHandler('close', closeHandler);
|
||||||
|
|
||||||
equal(viewer.overlays.length, 0, "No global overlay should be added on close.");
|
assert.equal(viewer.overlays.length, 0, "No global overlay should be added on close.");
|
||||||
equal(viewer.currentOverlays.length, 0, "Page overlay should be closed on close.");
|
assert.equal(viewer.currentOverlays.length, 0, "Page overlay should be closed on close.");
|
||||||
|
|
||||||
start();
|
done();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Overlays via addOverlay method', function() {
|
QUnit.test('Overlays via addOverlay method', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
id: 'example-overlays',
|
id: 'example-overlays',
|
||||||
prefixUrl: '/build/openseadragon/images/',
|
prefixUrl: '/build/openseadragon/images/',
|
||||||
@ -184,14 +184,14 @@
|
|||||||
function openHandler() {
|
function openHandler() {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
|
|
||||||
equal(viewer.overlays.length, 0, "No global overlay should be added.");
|
assert.equal(viewer.overlays.length, 0, "No global overlay should be added.");
|
||||||
equal(viewer.currentOverlays.length, 0, "No overlay should be open.");
|
assert.equal(viewer.currentOverlays.length, 0, "No overlay should be open.");
|
||||||
|
|
||||||
var rect = new OpenSeadragon.Rect(0.1, 0.1, 0.1, 0.1);
|
var rect = new OpenSeadragon.Rect(0.1, 0.1, 0.1, 0.1);
|
||||||
var overlay = $("<div/>").prop("id", "overlay").get(0);
|
var overlay = $("<div/>").prop("id", "overlay").get(0);
|
||||||
viewer.addOverlay(overlay, rect);
|
viewer.addOverlay(overlay, rect);
|
||||||
equal(viewer.overlays.length, 0, "No manual overlay should be added as global overlay.");
|
assert.equal(viewer.overlays.length, 0, "No manual overlay should be added as global overlay.");
|
||||||
equal(viewer.currentOverlays.length, 1, "A manual overlay should be open.");
|
assert.equal(viewer.currentOverlays.length, 1, "A manual overlay should be open.");
|
||||||
|
|
||||||
viewer.addHandler('open', openPageHandler);
|
viewer.addHandler('open', openPageHandler);
|
||||||
viewer.goToPage(1);
|
viewer.goToPage(1);
|
||||||
@ -200,8 +200,8 @@
|
|||||||
function openPageHandler() {
|
function openPageHandler() {
|
||||||
viewer.removeHandler('open', openPageHandler);
|
viewer.removeHandler('open', openPageHandler);
|
||||||
|
|
||||||
equal(viewer.overlays.length, 0, "No global overlay should be added after page switch.");
|
assert.equal(viewer.overlays.length, 0, "No global overlay should be added after page switch.");
|
||||||
equal(viewer.currentOverlays.length, 0, "Manual overlay should be removed after page switch.");
|
assert.equal(viewer.currentOverlays.length, 0, "Manual overlay should be removed after page switch.");
|
||||||
|
|
||||||
viewer.addHandler('close', closeHandler);
|
viewer.addHandler('close', closeHandler);
|
||||||
viewer.close();
|
viewer.close();
|
||||||
@ -210,16 +210,16 @@
|
|||||||
function closeHandler() {
|
function closeHandler() {
|
||||||
viewer.removeHandler('close', closeHandler);
|
viewer.removeHandler('close', closeHandler);
|
||||||
|
|
||||||
equal(viewer.overlays.length, 0, "No global overlay should be added on close.");
|
assert.equal(viewer.overlays.length, 0, "No global overlay should be added on close.");
|
||||||
equal(viewer.currentOverlays.length, 0, "Manual overlay should be removed on close.");
|
assert.equal(viewer.currentOverlays.length, 0, "Manual overlay should be removed on close.");
|
||||||
|
|
||||||
start();
|
done();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Overlays size in pixels', function() {
|
QUnit.test('Overlays size in pixels', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
id: 'example-overlays',
|
id: 'example-overlays',
|
||||||
prefixUrl: '/build/openseadragon/images/',
|
prefixUrl: '/build/openseadragon/images/',
|
||||||
@ -245,31 +245,31 @@
|
|||||||
var expPosition = viewport.imageToViewerElementCoordinates(
|
var expPosition = viewport.imageToViewerElementCoordinates(
|
||||||
new OpenSeadragon.Point(13, 120));
|
new OpenSeadragon.Point(13, 120));
|
||||||
var actPosition = $("#overlay").position();
|
var actPosition = $("#overlay").position();
|
||||||
Util.assessNumericValue(actPosition.left, expPosition.x, epsilon,
|
Util.assessNumericValue(assert, actPosition.left, expPosition.x, epsilon,
|
||||||
"X position mismatch " + contextMessage);
|
"X position mismatch " + contextMessage);
|
||||||
Util.assessNumericValue(actPosition.top, expPosition.y, epsilon,
|
Util.assessNumericValue(assert, actPosition.top, expPosition.y, epsilon,
|
||||||
"Y position mismatch " + contextMessage);
|
"Y position mismatch " + contextMessage);
|
||||||
|
|
||||||
var zoom = viewport.viewportToImageZoom(viewport.getZoom(true));
|
var zoom = viewport.viewportToImageZoom(viewport.getZoom(true));
|
||||||
var expectedWidth = 124 * zoom;
|
var expectedWidth = 124 * zoom;
|
||||||
var expectedHeight = 132 * zoom;
|
var expectedHeight = 132 * zoom;
|
||||||
Util.assessNumericValue($("#overlay").width(), expectedWidth, epsilon,
|
Util.assessNumericValue(assert, $("#overlay").width(), expectedWidth, epsilon,
|
||||||
"Width mismatch " + contextMessage);
|
"Width mismatch " + contextMessage);
|
||||||
Util.assessNumericValue($("#overlay").height(), expectedHeight, epsilon,
|
Util.assessNumericValue(assert, $("#overlay").height(), expectedHeight, epsilon,
|
||||||
"Height mismatch " + contextMessage);
|
"Height mismatch " + contextMessage);
|
||||||
|
|
||||||
|
|
||||||
expPosition = viewport.imageToViewerElementCoordinates(
|
expPosition = viewport.imageToViewerElementCoordinates(
|
||||||
new OpenSeadragon.Point(400, 500));
|
new OpenSeadragon.Point(400, 500));
|
||||||
actPosition = $("#fixed-overlay").position();
|
actPosition = $("#fixed-overlay").position();
|
||||||
Util.assessNumericValue(actPosition.left, expPosition.x, epsilon,
|
Util.assessNumericValue(assert, actPosition.left, expPosition.x, epsilon,
|
||||||
"Fixed overlay X position mismatch " + contextMessage);
|
"Fixed overlay X position mismatch " + contextMessage);
|
||||||
Util.assessNumericValue(actPosition.top, expPosition.y, epsilon,
|
Util.assessNumericValue(assert, actPosition.top, expPosition.y, epsilon,
|
||||||
"Fixed overlay Y position mismatch " + contextMessage);
|
"Fixed overlay Y position mismatch " + contextMessage);
|
||||||
|
|
||||||
Util.assessNumericValue($("#fixed-overlay").width(), 70, epsilon,
|
Util.assessNumericValue(assert, $("#fixed-overlay").width(), 70, epsilon,
|
||||||
"Fixed overlay width mismatch " + contextMessage);
|
"Fixed overlay width mismatch " + contextMessage);
|
||||||
Util.assessNumericValue($("#fixed-overlay").height(), 60, epsilon,
|
Util.assessNumericValue(assert, $("#fixed-overlay").height(), 60, epsilon,
|
||||||
"Fixed overlay height mismatch " + contextMessage);
|
"Fixed overlay height mismatch " + contextMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,15 +283,15 @@
|
|||||||
viewer.viewport.goHome();
|
viewer.viewport.goHome();
|
||||||
waitForViewer(function() {
|
waitForViewer(function() {
|
||||||
checkOverlayPosition("after goHome using image coordinates");
|
checkOverlayPosition("after goHome using image coordinates");
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Overlays size in points', function() {
|
QUnit.test('Overlays size in points', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
id: 'example-overlays',
|
id: 'example-overlays',
|
||||||
prefixUrl: '/build/openseadragon/images/',
|
prefixUrl: '/build/openseadragon/images/',
|
||||||
@ -317,30 +317,30 @@
|
|||||||
var expPosition = viewport.viewportToViewerElementCoordinates(
|
var expPosition = viewport.viewportToViewerElementCoordinates(
|
||||||
new OpenSeadragon.Point(0.2, 0.1));
|
new OpenSeadragon.Point(0.2, 0.1));
|
||||||
var actPosition = $("#overlay").position();
|
var actPosition = $("#overlay").position();
|
||||||
Util.assessNumericValue(actPosition.left, expPosition.x, epsilon,
|
Util.assessNumericValue(assert, actPosition.left, expPosition.x, epsilon,
|
||||||
"X position mismatch " + contextMessage);
|
"X position mismatch " + contextMessage);
|
||||||
Util.assessNumericValue(actPosition.top, expPosition.y, epsilon,
|
Util.assessNumericValue(assert, actPosition.top, expPosition.y, epsilon,
|
||||||
"Y position mismatch " + contextMessage);
|
"Y position mismatch " + contextMessage);
|
||||||
|
|
||||||
var expectedSize = viewport.deltaPixelsFromPoints(
|
var expectedSize = viewport.deltaPixelsFromPoints(
|
||||||
new OpenSeadragon.Point(0.5, 0.1));
|
new OpenSeadragon.Point(0.5, 0.1));
|
||||||
Util.assessNumericValue($("#overlay").width(), expectedSize.x, epsilon,
|
Util.assessNumericValue(assert, $("#overlay").width(), expectedSize.x, epsilon,
|
||||||
"Width mismatch " + contextMessage);
|
"Width mismatch " + contextMessage);
|
||||||
Util.assessNumericValue($("#overlay").height(), expectedSize.y, epsilon,
|
Util.assessNumericValue(assert, $("#overlay").height(), expectedSize.y, epsilon,
|
||||||
"Height mismatch " + contextMessage);
|
"Height mismatch " + contextMessage);
|
||||||
|
|
||||||
|
|
||||||
expPosition = viewport.viewportToViewerElementCoordinates(
|
expPosition = viewport.viewportToViewerElementCoordinates(
|
||||||
new OpenSeadragon.Point(0.5, 0.6));
|
new OpenSeadragon.Point(0.5, 0.6));
|
||||||
actPosition = $("#fixed-overlay").position();
|
actPosition = $("#fixed-overlay").position();
|
||||||
Util.assessNumericValue(actPosition.left, expPosition.x, epsilon,
|
Util.assessNumericValue(assert, actPosition.left, expPosition.x, epsilon,
|
||||||
"Fixed overlay X position mismatch " + contextMessage);
|
"Fixed overlay X position mismatch " + contextMessage);
|
||||||
Util.assessNumericValue(actPosition.top, expPosition.y, epsilon,
|
Util.assessNumericValue(assert, actPosition.top, expPosition.y, epsilon,
|
||||||
"Fixed overlay Y position mismatch " + contextMessage);
|
"Fixed overlay Y position mismatch " + contextMessage);
|
||||||
|
|
||||||
Util.assessNumericValue($("#fixed-overlay").width(), 70, epsilon,
|
Util.assessNumericValue(assert, $("#fixed-overlay").width(), 70, epsilon,
|
||||||
"Fixed overlay width mismatch " + contextMessage);
|
"Fixed overlay width mismatch " + contextMessage);
|
||||||
Util.assessNumericValue($("#fixed-overlay").height(), 60, epsilon,
|
Util.assessNumericValue(assert, $("#fixed-overlay").height(), 60, epsilon,
|
||||||
"Fixed overlay height mismatch " + contextMessage);
|
"Fixed overlay height mismatch " + contextMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,15 +354,15 @@
|
|||||||
viewer.viewport.goHome();
|
viewer.viewport.goHome();
|
||||||
waitForViewer(function() {
|
waitForViewer(function() {
|
||||||
checkOverlayPosition("after goHome using viewport coordinates");
|
checkOverlayPosition("after goHome using viewport coordinates");
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Overlays placement', function() {
|
QUnit.test('Overlays placement', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var scalableOverlayLocation = new OpenSeadragon.Rect(0.2, 0.1, 0.5, 0.1);
|
var scalableOverlayLocation = new OpenSeadragon.Rect(0.2, 0.1, 0.5, 0.1);
|
||||||
var fixedOverlayLocation = new OpenSeadragon.Point(0.5, 0.6);
|
var fixedOverlayLocation = new OpenSeadragon.Point(0.5, 0.6);
|
||||||
|
|
||||||
@ -393,9 +393,9 @@
|
|||||||
var expPosition = viewport.viewportToViewerElementCoordinates(
|
var expPosition = viewport.viewportToViewerElementCoordinates(
|
||||||
new OpenSeadragon.Point(0.2, 0.1));
|
new OpenSeadragon.Point(0.2, 0.1));
|
||||||
var actPosition = $("#overlay").position();
|
var actPosition = $("#overlay").position();
|
||||||
Util.assessNumericValue(actPosition.left, expPosition.x, epsilon,
|
Util.assessNumericValue(assert, actPosition.left, expPosition.x, epsilon,
|
||||||
"X position mismatch " + contextMessage);
|
"X position mismatch " + contextMessage);
|
||||||
Util.assessNumericValue(actPosition.top, expPosition.y, epsilon,
|
Util.assessNumericValue(assert, actPosition.top, expPosition.y, epsilon,
|
||||||
"Y position mismatch " + contextMessage);
|
"Y position mismatch " + contextMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,9 +406,9 @@
|
|||||||
new OpenSeadragon.Point(0.5, 0.6))
|
new OpenSeadragon.Point(0.5, 0.6))
|
||||||
.plus(expectedOffset);
|
.plus(expectedOffset);
|
||||||
var actPosition = $("#fixed-overlay").position();
|
var actPosition = $("#fixed-overlay").position();
|
||||||
Util.assessNumericValue(actPosition.left, expPosition.x, epsilon,
|
Util.assessNumericValue(assert, actPosition.left, expPosition.x, epsilon,
|
||||||
"Fixed overlay X position mismatch " + contextMessage);
|
"Fixed overlay X position mismatch " + contextMessage);
|
||||||
Util.assessNumericValue(actPosition.top, expPosition.y, epsilon,
|
Util.assessNumericValue(assert, actPosition.top, expPosition.y, epsilon,
|
||||||
"Fixed overlay Y position mismatch " + contextMessage);
|
"Fixed overlay Y position mismatch " + contextMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,7 +439,7 @@
|
|||||||
checkFixedOverlayPosition(new OpenSeadragon.Point(-70, -60),
|
checkFixedOverlayPosition(new OpenSeadragon.Point(-70, -60),
|
||||||
"with BOTTOM_RIGHT placement.");
|
"with BOTTOM_RIGHT placement.");
|
||||||
|
|
||||||
start();
|
done();
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
}, 100);
|
}, 100);
|
||||||
@ -447,8 +447,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Overlays placement and resizing check', function() {
|
QUnit.test('Overlays placement and resizing check', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var fixedOverlayLocation = new OpenSeadragon.Point(0.5, 0.6);
|
var fixedOverlayLocation = new OpenSeadragon.Point(0.5, 0.6);
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
@ -472,9 +472,9 @@
|
|||||||
new OpenSeadragon.Point(0.5, 0.6))
|
new OpenSeadragon.Point(0.5, 0.6))
|
||||||
.plus(expectedOffset);
|
.plus(expectedOffset);
|
||||||
var actPosition = $("#fixed-overlay").position();
|
var actPosition = $("#fixed-overlay").position();
|
||||||
Util.assessNumericValue(actPosition.left, expPosition.x, epsilon,
|
Util.assessNumericValue(assert, actPosition.left, expPosition.x, epsilon,
|
||||||
"Fixed overlay X position mismatch " + contextMessage);
|
"Fixed overlay X position mismatch " + contextMessage);
|
||||||
Util.assessNumericValue(actPosition.top, expPosition.y, epsilon,
|
Util.assessNumericValue(assert, actPosition.top, expPosition.y, epsilon,
|
||||||
"Fixed overlay Y position mismatch " + contextMessage);
|
"Fixed overlay Y position mismatch " + contextMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,14 +496,14 @@
|
|||||||
$("#fixed-overlay").width(70);
|
$("#fixed-overlay").width(70);
|
||||||
$("#fixed-overlay").height(60);
|
$("#fixed-overlay").height(60);
|
||||||
|
|
||||||
start();
|
done();
|
||||||
}, 100);
|
}, 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Overlays placement and no resizing check', function() {
|
QUnit.test('Overlays placement and no resizing check', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var fixedOverlayLocation = new OpenSeadragon.Point(0.5, 0.6);
|
var fixedOverlayLocation = new OpenSeadragon.Point(0.5, 0.6);
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
@ -527,9 +527,9 @@
|
|||||||
new OpenSeadragon.Point(0.5, 0.6))
|
new OpenSeadragon.Point(0.5, 0.6))
|
||||||
.plus(expectedOffset);
|
.plus(expectedOffset);
|
||||||
var actPosition = $("#fixed-overlay").position();
|
var actPosition = $("#fixed-overlay").position();
|
||||||
Util.assessNumericValue(actPosition.left, expPosition.x, epsilon,
|
Util.assessNumericValue(assert, actPosition.left, expPosition.x, epsilon,
|
||||||
"Fixed overlay X position mismatch " + contextMessage);
|
"Fixed overlay X position mismatch " + contextMessage);
|
||||||
Util.assessNumericValue(actPosition.top, expPosition.y, epsilon,
|
Util.assessNumericValue(assert, actPosition.top, expPosition.y, epsilon,
|
||||||
"Fixed overlay Y position mismatch " + contextMessage);
|
"Fixed overlay Y position mismatch " + contextMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -551,16 +551,17 @@
|
|||||||
$("#fixed-overlay").width(70);
|
$("#fixed-overlay").width(70);
|
||||||
$("#fixed-overlay").height(60);
|
$("#fixed-overlay").height(60);
|
||||||
|
|
||||||
start();
|
done();
|
||||||
}, 100);
|
}, 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('overlays appear immediately', function() {
|
QUnit.test('overlays appear immediately', function(assert) {
|
||||||
equal($('#immediate-overlay0').length, 0, 'overlay 0 does not exist');
|
var done = assert.async();
|
||||||
equal($('#immediate-overlay1').length, 0, 'overlay 1 does not exist');
|
assert.equal($('#immediate-overlay0').length, 0, 'overlay 0 does not exist');
|
||||||
|
assert.equal($('#immediate-overlay1').length, 0, 'overlay 1 does not exist');
|
||||||
|
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
id: 'example-overlays',
|
id: 'example-overlays',
|
||||||
@ -575,7 +576,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
viewer.addHandler('open', function() {
|
viewer.addHandler('open', function() {
|
||||||
equal($('#immediate-overlay0').length, 1, 'overlay 0 exists');
|
assert.equal($('#immediate-overlay0').length, 1, 'overlay 0 exists');
|
||||||
|
|
||||||
viewer.addOverlay({
|
viewer.addOverlay({
|
||||||
x: 0,
|
x: 0,
|
||||||
@ -583,13 +584,14 @@
|
|||||||
id: "immediate-overlay1"
|
id: "immediate-overlay1"
|
||||||
});
|
});
|
||||||
|
|
||||||
equal($('#immediate-overlay1').length, 1, 'overlay 1 exists');
|
assert.equal($('#immediate-overlay1').length, 1, 'overlay 1 exists');
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('Overlay scaled horizontally only', function() {
|
QUnit.test('Overlay scaled horizontally only', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
id: 'example-overlays',
|
id: 'example-overlays',
|
||||||
prefixUrl: '/build/openseadragon/images/',
|
prefixUrl: '/build/openseadragon/images/',
|
||||||
@ -615,16 +617,17 @@
|
|||||||
waitForViewer(function() {
|
waitForViewer(function() {
|
||||||
var newWidth = $("#horizontally-scaled-overlay").width();
|
var newWidth = $("#horizontally-scaled-overlay").width();
|
||||||
var newHeight = $("#horizontally-scaled-overlay").height();
|
var newHeight = $("#horizontally-scaled-overlay").height();
|
||||||
equal(newWidth, width * zoom, "Width should be scaled.");
|
assert.equal(newWidth, width * zoom, "Width should be scaled.");
|
||||||
equal(newHeight, height, "Height should not be scaled.");
|
assert.equal(newHeight, height, "Height should not be scaled.");
|
||||||
|
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('Overlay scaled vertically only', function() {
|
QUnit.test('Overlay scaled vertically only', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
id: 'example-overlays',
|
id: 'example-overlays',
|
||||||
prefixUrl: '/build/openseadragon/images/',
|
prefixUrl: '/build/openseadragon/images/',
|
||||||
@ -650,16 +653,17 @@
|
|||||||
waitForViewer(function() {
|
waitForViewer(function() {
|
||||||
var newWidth = $("#vertically-scaled-overlay").width();
|
var newWidth = $("#vertically-scaled-overlay").width();
|
||||||
var newHeight = $("#vertically-scaled-overlay").height();
|
var newHeight = $("#vertically-scaled-overlay").height();
|
||||||
equal(newWidth, width, "Width should not be scaled.");
|
assert.equal(newWidth, width, "Width should not be scaled.");
|
||||||
equal(newHeight, height * zoom, "Height should be scaled.");
|
assert.equal(newHeight, height * zoom, "Height should be scaled.");
|
||||||
|
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('Overlay.getBounds', function() {
|
QUnit.test('Overlay.getBounds', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
id: 'example-overlays',
|
id: 'example-overlays',
|
||||||
prefixUrl: '/build/openseadragon/images/',
|
prefixUrl: '/build/openseadragon/images/',
|
||||||
@ -713,7 +717,7 @@
|
|||||||
var actualBounds = viewer.getOverlayById("fully-scaled-overlay")
|
var actualBounds = viewer.getOverlayById("fully-scaled-overlay")
|
||||||
.getBounds(viewer.viewport);
|
.getBounds(viewer.viewport);
|
||||||
var expectedBounds = new OpenSeadragon.Rect(0, 0, 1, 1);
|
var expectedBounds = new OpenSeadragon.Rect(0, 0, 1, 1);
|
||||||
ok(expectedBounds.equals(actualBounds),
|
assert.ok(expectedBounds.equals(actualBounds),
|
||||||
"The fully scaled overlay should have bounds " +
|
"The fully scaled overlay should have bounds " +
|
||||||
expectedBounds + " but found " + actualBounds);
|
expectedBounds + " but found " + actualBounds);
|
||||||
|
|
||||||
@ -722,7 +726,7 @@
|
|||||||
.getBounds(viewer.viewport);
|
.getBounds(viewer.viewport);
|
||||||
expectedBounds = new OpenSeadragon.Rect(
|
expectedBounds = new OpenSeadragon.Rect(
|
||||||
0, 0.5 - notScaledSize.y / 2, 1, notScaledSize.y);
|
0, 0.5 - notScaledSize.y / 2, 1, notScaledSize.y);
|
||||||
ok(expectedBounds.equals(actualBounds),
|
assert.ok(expectedBounds.equals(actualBounds),
|
||||||
"The horizontally scaled overlay should have bounds " +
|
"The horizontally scaled overlay should have bounds " +
|
||||||
expectedBounds + " but found " + actualBounds);
|
expectedBounds + " but found " + actualBounds);
|
||||||
|
|
||||||
@ -730,7 +734,7 @@
|
|||||||
.getBounds(viewer.viewport);
|
.getBounds(viewer.viewport);
|
||||||
expectedBounds = new OpenSeadragon.Rect(
|
expectedBounds = new OpenSeadragon.Rect(
|
||||||
0, 0, notScaledSize.x, 1);
|
0, 0, notScaledSize.x, 1);
|
||||||
ok(expectedBounds.equals(actualBounds),
|
assert.ok(expectedBounds.equals(actualBounds),
|
||||||
"The vertically scaled overlay should have bounds " +
|
"The vertically scaled overlay should have bounds " +
|
||||||
expectedBounds + " but found " + actualBounds);
|
expectedBounds + " but found " + actualBounds);
|
||||||
|
|
||||||
@ -738,16 +742,17 @@
|
|||||||
.getBounds(viewer.viewport);
|
.getBounds(viewer.viewport);
|
||||||
expectedBounds = new OpenSeadragon.Rect(
|
expectedBounds = new OpenSeadragon.Rect(
|
||||||
1 - notScaledSize.x, 0, notScaledSize.x, notScaledSize.y);
|
1 - notScaledSize.x, 0, notScaledSize.x, notScaledSize.y);
|
||||||
ok(expectedBounds.equals(actualBounds),
|
assert.ok(expectedBounds.equals(actualBounds),
|
||||||
"The not scaled overlay should have bounds " +
|
"The not scaled overlay should have bounds " +
|
||||||
expectedBounds + " but found " + actualBounds);
|
expectedBounds + " but found " + actualBounds);
|
||||||
|
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('Fully scaled overlay rotation mode NO_ROTATION', function() {
|
QUnit.test('Fully scaled overlay rotation mode NO_ROTATION', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
id: 'example-overlays',
|
id: 'example-overlays',
|
||||||
prefixUrl: '/build/openseadragon/images/',
|
prefixUrl: '/build/openseadragon/images/',
|
||||||
@ -775,32 +780,33 @@
|
|||||||
new OpenSeadragon.Point(1, 1))
|
new OpenSeadragon.Point(1, 1))
|
||||||
.minus(expectedSize);
|
.minus(expectedSize);
|
||||||
var actualPosition = $overlay.position();
|
var actualPosition = $overlay.position();
|
||||||
Util.assessNumericValue(actualPosition.left, expectedPosition.x, epsilon,
|
Util.assessNumericValue(assert, actualPosition.left, expectedPosition.x, epsilon,
|
||||||
"Scaled overlay position.x should adjust to rotation.");
|
"Scaled overlay position.x should adjust to rotation.");
|
||||||
Util.assessNumericValue(actualPosition.top, expectedPosition.y, epsilon,
|
Util.assessNumericValue(assert, actualPosition.top, expectedPosition.y, epsilon,
|
||||||
"Scaled overlay position.y should adjust to rotation.");
|
"Scaled overlay position.y should adjust to rotation.");
|
||||||
|
|
||||||
var actualWidth = $overlay.width();
|
var actualWidth = $overlay.width();
|
||||||
var actualHeight = $overlay.height();
|
var actualHeight = $overlay.height();
|
||||||
Util.assessNumericValue(actualWidth, expectedSize.x, epsilon,
|
Util.assessNumericValue(assert, actualWidth, expectedSize.x, epsilon,
|
||||||
"Scaled overlay width should not adjust to rotation.");
|
"Scaled overlay width should not adjust to rotation.");
|
||||||
Util.assessNumericValue(actualHeight, expectedSize.y, epsilon,
|
Util.assessNumericValue(assert, actualHeight, expectedSize.y, epsilon,
|
||||||
"Scaled overlay height should not adjust to rotation.");
|
"Scaled overlay height should not adjust to rotation.");
|
||||||
|
|
||||||
var actualBounds = viewer.getOverlayById("fully-scaled-overlay")
|
var actualBounds = viewer.getOverlayById("fully-scaled-overlay")
|
||||||
.getBounds(viewport);
|
.getBounds(viewport);
|
||||||
var expectedBounds = new OpenSeadragon.Rect(0, 0, 1, 1)
|
var expectedBounds = new OpenSeadragon.Rect(0, 0, 1, 1)
|
||||||
.rotate(-45, new OpenSeadragon.Point(1, 1));
|
.rotate(-45, new OpenSeadragon.Point(1, 1));
|
||||||
ok(expectedBounds.equals(actualBounds),
|
assert.ok(expectedBounds.equals(actualBounds),
|
||||||
"The fully scaled overlay should have bounds " +
|
"The fully scaled overlay should have bounds " +
|
||||||
expectedBounds + " but found " + actualBounds);
|
expectedBounds + " but found " + actualBounds);
|
||||||
|
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('Horizontally scaled overlay rotation mode NO_ROTATION', function() {
|
QUnit.test('Horizontally scaled overlay rotation mode NO_ROTATION', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
id: 'example-overlays',
|
id: 'example-overlays',
|
||||||
prefixUrl: '/build/openseadragon/images/',
|
prefixUrl: '/build/openseadragon/images/',
|
||||||
@ -836,16 +842,16 @@
|
|||||||
new OpenSeadragon.Point(0.5, 0.5))
|
new OpenSeadragon.Point(0.5, 0.5))
|
||||||
.minus(new OpenSeadragon.Point(expectedWidth / 2, notScaledHeight / 2));
|
.minus(new OpenSeadragon.Point(expectedWidth / 2, notScaledHeight / 2));
|
||||||
var actualPosition = $overlay.position();
|
var actualPosition = $overlay.position();
|
||||||
Util.assessNumericValue(actualPosition.left, expectedPosition.x, epsilon,
|
Util.assessNumericValue(assert, actualPosition.left, expectedPosition.x, epsilon,
|
||||||
"Horizontally scaled overlay position.x should adjust to rotation.");
|
"Horizontally scaled overlay position.x should adjust to rotation.");
|
||||||
Util.assessNumericValue(actualPosition.top, expectedPosition.y, epsilon,
|
Util.assessNumericValue(assert, actualPosition.top, expectedPosition.y, epsilon,
|
||||||
"Horizontally scaled overlay position.y should adjust to rotation.");
|
"Horizontally scaled overlay position.y should adjust to rotation.");
|
||||||
|
|
||||||
var actualWidth = $overlay.width();
|
var actualWidth = $overlay.width();
|
||||||
var actualHeight = $overlay.height();
|
var actualHeight = $overlay.height();
|
||||||
Util.assessNumericValue(actualWidth, expectedWidth, epsilon,
|
Util.assessNumericValue(assert, actualWidth, expectedWidth, epsilon,
|
||||||
"Horizontally scaled overlay width should not adjust to rotation.");
|
"Horizontally scaled overlay width should not adjust to rotation.");
|
||||||
Util.assessNumericValue(actualHeight, notScaledHeight, epsilon,
|
Util.assessNumericValue(assert, actualHeight, notScaledHeight, epsilon,
|
||||||
"Horizontally scaled overlay height should not adjust to rotation.");
|
"Horizontally scaled overlay height should not adjust to rotation.");
|
||||||
|
|
||||||
var actualBounds = viewer.getOverlayById("horizontally-scaled-overlay")
|
var actualBounds = viewer.getOverlayById("horizontally-scaled-overlay")
|
||||||
@ -853,16 +859,17 @@
|
|||||||
var expectedBounds = new OpenSeadragon.Rect(
|
var expectedBounds = new OpenSeadragon.Rect(
|
||||||
0, 0.5 - notScaledSize.y / 2, 1, notScaledSize.y)
|
0, 0.5 - notScaledSize.y / 2, 1, notScaledSize.y)
|
||||||
.rotate(-45, new OpenSeadragon.Point(0.5, 0.5));
|
.rotate(-45, new OpenSeadragon.Point(0.5, 0.5));
|
||||||
ok(expectedBounds.equals(actualBounds),
|
assert.ok(expectedBounds.equals(actualBounds),
|
||||||
"The horizontally scaled overlay should have bounds " +
|
"The horizontally scaled overlay should have bounds " +
|
||||||
expectedBounds + " but found " + actualBounds);
|
expectedBounds + " but found " + actualBounds);
|
||||||
|
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('Vertically scaled overlay rotation mode NO_ROTATION', function() {
|
QUnit.test('Vertically scaled overlay rotation mode NO_ROTATION', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
id: 'example-overlays',
|
id: 'example-overlays',
|
||||||
prefixUrl: '/build/openseadragon/images/',
|
prefixUrl: '/build/openseadragon/images/',
|
||||||
@ -898,16 +905,16 @@
|
|||||||
new OpenSeadragon.Point(0, 0.5))
|
new OpenSeadragon.Point(0, 0.5))
|
||||||
.minus(new OpenSeadragon.Point(0, expectedHeight / 2));
|
.minus(new OpenSeadragon.Point(0, expectedHeight / 2));
|
||||||
var actualPosition = $overlay.position();
|
var actualPosition = $overlay.position();
|
||||||
Util.assessNumericValue(actualPosition.left, expectedPosition.x, epsilon,
|
Util.assessNumericValue(assert, actualPosition.left, expectedPosition.x, epsilon,
|
||||||
"Vertically scaled overlay position.x should adjust to rotation.");
|
"Vertically scaled overlay position.x should adjust to rotation.");
|
||||||
Util.assessNumericValue(actualPosition.top, expectedPosition.y, epsilon,
|
Util.assessNumericValue(assert, actualPosition.top, expectedPosition.y, epsilon,
|
||||||
"Vertically scaled overlay position.y should adjust to rotation.");
|
"Vertically scaled overlay position.y should adjust to rotation.");
|
||||||
|
|
||||||
var actualWidth = $overlay.width();
|
var actualWidth = $overlay.width();
|
||||||
var actualHeight = $overlay.height();
|
var actualHeight = $overlay.height();
|
||||||
Util.assessNumericValue(actualWidth, notScaledWidth, epsilon,
|
Util.assessNumericValue(assert, actualWidth, notScaledWidth, epsilon,
|
||||||
"Vertically scaled overlay width should not adjust to rotation.");
|
"Vertically scaled overlay width should not adjust to rotation.");
|
||||||
Util.assessNumericValue(actualHeight, expectedHeight, epsilon,
|
Util.assessNumericValue(assert, actualHeight, expectedHeight, epsilon,
|
||||||
"Vertically scaled overlay height should not adjust to rotation.");
|
"Vertically scaled overlay height should not adjust to rotation.");
|
||||||
|
|
||||||
var actualBounds = viewer.getOverlayById("vertically-scaled-overlay")
|
var actualBounds = viewer.getOverlayById("vertically-scaled-overlay")
|
||||||
@ -915,16 +922,17 @@
|
|||||||
var expectedBounds = new OpenSeadragon.Rect(
|
var expectedBounds = new OpenSeadragon.Rect(
|
||||||
0, 0, notScaledSize.x, 1)
|
0, 0, notScaledSize.x, 1)
|
||||||
.rotate(-45, new OpenSeadragon.Point(0, 0.5));
|
.rotate(-45, new OpenSeadragon.Point(0, 0.5));
|
||||||
ok(expectedBounds.equals(actualBounds),
|
assert.ok(expectedBounds.equals(actualBounds),
|
||||||
"The vertically scaled overlay should have bounds " +
|
"The vertically scaled overlay should have bounds " +
|
||||||
expectedBounds + " but found " + actualBounds);
|
expectedBounds + " but found " + actualBounds);
|
||||||
|
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('Not scaled overlay rotation mode NO_ROTATION', function() {
|
QUnit.test('Not scaled overlay rotation mode NO_ROTATION', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
id: 'example-overlays',
|
id: 'example-overlays',
|
||||||
prefixUrl: '/build/openseadragon/images/',
|
prefixUrl: '/build/openseadragon/images/',
|
||||||
@ -958,16 +966,16 @@
|
|||||||
new OpenSeadragon.Point(1, 0))
|
new OpenSeadragon.Point(1, 0))
|
||||||
.minus(new OpenSeadragon.Point(notScaledWidth, 0));
|
.minus(new OpenSeadragon.Point(notScaledWidth, 0));
|
||||||
var actualPosition = $overlay.position();
|
var actualPosition = $overlay.position();
|
||||||
Util.assessNumericValue(actualPosition.left, expectedPosition.x, epsilon,
|
Util.assessNumericValue(assert, actualPosition.left, expectedPosition.x, epsilon,
|
||||||
"Not scaled overlay position.x should adjust to rotation.");
|
"Not scaled overlay position.x should adjust to rotation.");
|
||||||
Util.assessNumericValue(actualPosition.top, expectedPosition.y, epsilon,
|
Util.assessNumericValue(assert, actualPosition.top, expectedPosition.y, epsilon,
|
||||||
"Not scaled overlay position.y should adjust to rotation.");
|
"Not scaled overlay position.y should adjust to rotation.");
|
||||||
|
|
||||||
var actualWidth = $overlay.width();
|
var actualWidth = $overlay.width();
|
||||||
var actualHeight = $overlay.height();
|
var actualHeight = $overlay.height();
|
||||||
Util.assessNumericValue(actualWidth, notScaledWidth, epsilon,
|
Util.assessNumericValue(assert, actualWidth, notScaledWidth, epsilon,
|
||||||
"Not scaled overlay width should not adjust to rotation.");
|
"Not scaled overlay width should not adjust to rotation.");
|
||||||
Util.assessNumericValue(actualHeight, notScaledHeight, epsilon,
|
Util.assessNumericValue(assert, actualHeight, notScaledHeight, epsilon,
|
||||||
"Not scaled overlay height should not adjust to rotation.");
|
"Not scaled overlay height should not adjust to rotation.");
|
||||||
|
|
||||||
var actualBounds = viewer.getOverlayById("not-scaled-overlay")
|
var actualBounds = viewer.getOverlayById("not-scaled-overlay")
|
||||||
@ -975,16 +983,17 @@
|
|||||||
var expectedBounds = new OpenSeadragon.Rect(
|
var expectedBounds = new OpenSeadragon.Rect(
|
||||||
1 - notScaledSize.x, 0, notScaledSize.x, notScaledSize.y)
|
1 - notScaledSize.x, 0, notScaledSize.x, notScaledSize.y)
|
||||||
.rotate(-45, new OpenSeadragon.Point(1, 0));
|
.rotate(-45, new OpenSeadragon.Point(1, 0));
|
||||||
ok(expectedBounds.equals(actualBounds),
|
assert.ok(expectedBounds.equals(actualBounds),
|
||||||
"Not scaled overlay should have bounds " +
|
"Not scaled overlay should have bounds " +
|
||||||
expectedBounds + " but found " + actualBounds);
|
expectedBounds + " but found " + actualBounds);
|
||||||
|
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('Fully scaled overlay rotation mode BOUNDING_BOX', function() {
|
QUnit.test('Fully scaled overlay rotation mode BOUNDING_BOX', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
id: 'example-overlays',
|
id: 'example-overlays',
|
||||||
prefixUrl: '/build/openseadragon/images/',
|
prefixUrl: '/build/openseadragon/images/',
|
||||||
@ -1009,16 +1018,16 @@
|
|||||||
var expectedRect = viewport.viewportToViewerElementRectangle(
|
var expectedRect = viewport.viewportToViewerElementRectangle(
|
||||||
new OpenSeadragon.Rect(0, 0, 1, 1)).getBoundingBox();
|
new OpenSeadragon.Rect(0, 0, 1, 1)).getBoundingBox();
|
||||||
var actualPosition = $overlay.position();
|
var actualPosition = $overlay.position();
|
||||||
Util.assessNumericValue(actualPosition.left, expectedRect.x, epsilon,
|
Util.assessNumericValue(assert, actualPosition.left, expectedRect.x, epsilon,
|
||||||
"Scaled overlay position.x should adjust to rotation.");
|
"Scaled overlay position.x should adjust to rotation.");
|
||||||
Util.assessNumericValue(actualPosition.top, expectedRect.y, epsilon,
|
Util.assessNumericValue(assert, actualPosition.top, expectedRect.y, epsilon,
|
||||||
"Scaled overlay position.y should adjust to rotation.");
|
"Scaled overlay position.y should adjust to rotation.");
|
||||||
|
|
||||||
var actualWidth = $overlay.width();
|
var actualWidth = $overlay.width();
|
||||||
var actualHeight = $overlay.height();
|
var actualHeight = $overlay.height();
|
||||||
Util.assessNumericValue(actualWidth, expectedRect.width, epsilon,
|
Util.assessNumericValue(assert, actualWidth, expectedRect.width, epsilon,
|
||||||
"Scaled overlay width should not adjust to rotation.");
|
"Scaled overlay width should not adjust to rotation.");
|
||||||
Util.assessNumericValue(actualHeight, expectedRect.height, epsilon,
|
Util.assessNumericValue(assert, actualHeight, expectedRect.height, epsilon,
|
||||||
"Scaled overlay height should not adjust to rotation.");
|
"Scaled overlay height should not adjust to rotation.");
|
||||||
|
|
||||||
var actualBounds = viewer.getOverlayById("fully-scaled-overlay")
|
var actualBounds = viewer.getOverlayById("fully-scaled-overlay")
|
||||||
@ -1026,23 +1035,24 @@
|
|||||||
var expectedBounds = new OpenSeadragon.Rect(
|
var expectedBounds = new OpenSeadragon.Rect(
|
||||||
0.5, -0.5, Math.sqrt(2), Math.sqrt(2), 45);
|
0.5, -0.5, Math.sqrt(2), Math.sqrt(2), 45);
|
||||||
var boundsEpsilon = 0.000001;
|
var boundsEpsilon = 0.000001;
|
||||||
Util.assessNumericValue(actualBounds.x, expectedBounds.x, boundsEpsilon,
|
Util.assessNumericValue(assert, actualBounds.x, expectedBounds.x, boundsEpsilon,
|
||||||
"The fully scaled overlay should have adjusted bounds.x");
|
"The fully scaled overlay should have adjusted bounds.x");
|
||||||
Util.assessNumericValue(actualBounds.y, expectedBounds.y, boundsEpsilon,
|
Util.assessNumericValue(assert, actualBounds.y, expectedBounds.y, boundsEpsilon,
|
||||||
"The fully scaled overlay should have adjusted bounds.y");
|
"The fully scaled overlay should have adjusted bounds.y");
|
||||||
Util.assessNumericValue(actualBounds.width, expectedBounds.width, boundsEpsilon,
|
Util.assessNumericValue(assert, actualBounds.width, expectedBounds.width, boundsEpsilon,
|
||||||
"The fully scaled overlay should have adjusted bounds.width");
|
"The fully scaled overlay should have adjusted bounds.width");
|
||||||
Util.assessNumericValue(actualBounds.height, expectedBounds.height, boundsEpsilon,
|
Util.assessNumericValue(assert, actualBounds.height, expectedBounds.height, boundsEpsilon,
|
||||||
"The fully scaled overlay should have adjusted bounds.height");
|
"The fully scaled overlay should have adjusted bounds.height");
|
||||||
Util.assessNumericValue(actualBounds.degrees, expectedBounds.degrees, boundsEpsilon,
|
Util.assessNumericValue(assert, actualBounds.degrees, expectedBounds.degrees, boundsEpsilon,
|
||||||
"The fully scaled overlay should have adjusted bounds.degrees");
|
"The fully scaled overlay should have adjusted bounds.degrees");
|
||||||
|
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('Fully scaled overlay rotation mode EXACT', function() {
|
QUnit.test('Fully scaled overlay rotation mode EXACT', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
id: 'example-overlays',
|
id: 'example-overlays',
|
||||||
prefixUrl: '/build/openseadragon/images/',
|
prefixUrl: '/build/openseadragon/images/',
|
||||||
@ -1073,16 +1083,16 @@
|
|||||||
var actualStyle = $overlay.get(0).style;
|
var actualStyle = $overlay.get(0).style;
|
||||||
var left = Number(actualStyle.left.replace("px", ""));
|
var left = Number(actualStyle.left.replace("px", ""));
|
||||||
var top = Number(actualStyle.top.replace("px", ""));
|
var top = Number(actualStyle.top.replace("px", ""));
|
||||||
Util.assessNumericValue(left, expectedPosition.x, epsilon,
|
Util.assessNumericValue(assert, left, expectedPosition.x, epsilon,
|
||||||
"Scaled overlay position.x should adjust to rotation.");
|
"Scaled overlay position.x should adjust to rotation.");
|
||||||
Util.assessNumericValue(top, expectedPosition.y, epsilon,
|
Util.assessNumericValue(assert, top, expectedPosition.y, epsilon,
|
||||||
"Scaled overlay position.y should adjust to rotation.");
|
"Scaled overlay position.y should adjust to rotation.");
|
||||||
|
|
||||||
var actualWidth = $overlay.width();
|
var actualWidth = $overlay.width();
|
||||||
var actualHeight = $overlay.height();
|
var actualHeight = $overlay.height();
|
||||||
Util.assessNumericValue(actualWidth, expectedSize.x, epsilon,
|
Util.assessNumericValue(assert, actualWidth, expectedSize.x, epsilon,
|
||||||
"Scaled overlay width should not adjust to rotation.");
|
"Scaled overlay width should not adjust to rotation.");
|
||||||
Util.assessNumericValue(actualHeight, expectedSize.y, epsilon,
|
Util.assessNumericValue(assert, actualHeight, expectedSize.y, epsilon,
|
||||||
"Scaled overlay height should not adjust to rotation.");
|
"Scaled overlay height should not adjust to rotation.");
|
||||||
|
|
||||||
var transformOriginProp = OpenSeadragon.getCssPropertyWithVendorPrefix(
|
var transformOriginProp = OpenSeadragon.getCssPropertyWithVendorPrefix(
|
||||||
@ -1091,19 +1101,19 @@
|
|||||||
'transform');
|
'transform');
|
||||||
var transformOrigin = actualStyle[transformOriginProp];
|
var transformOrigin = actualStyle[transformOriginProp];
|
||||||
// Some browsers replace "right bottom" by "100% 100%"
|
// Some browsers replace "right bottom" by "100% 100%"
|
||||||
ok(transformOrigin.match(/(100% 100%)|(right bottom)/),
|
assert.ok(transformOrigin.match(/(100% 100%)|(right bottom)/),
|
||||||
"Transform origin should be right bottom. Got: " + transformOrigin);
|
"Transform origin should be right bottom. Got: " + transformOrigin);
|
||||||
equal(actualStyle[transformProp], "rotate(45deg)",
|
assert.equal(actualStyle[transformProp], "rotate(45deg)",
|
||||||
"Transform should be rotate(45deg).");
|
"Transform should be rotate(45deg).");
|
||||||
|
|
||||||
var actualBounds = viewer.getOverlayById("fully-scaled-overlay")
|
var actualBounds = viewer.getOverlayById("fully-scaled-overlay")
|
||||||
.getBounds(viewport);
|
.getBounds(viewport);
|
||||||
var expectedBounds = new OpenSeadragon.Rect(0, 0, 1, 1);
|
var expectedBounds = new OpenSeadragon.Rect(0, 0, 1, 1);
|
||||||
ok(expectedBounds.equals(actualBounds),
|
assert.ok(expectedBounds.equals(actualBounds),
|
||||||
"The fully scaled overlay should have bounds " +
|
"The fully scaled overlay should have bounds " +
|
||||||
expectedBounds + " but found " + actualBounds);
|
expectedBounds + " but found " + actualBounds);
|
||||||
|
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
/* global module, asyncTest, $, ok, equal, notEqual, start, test, Util, testLog */
|
/* global QUnit, $, testLog */
|
||||||
|
|
||||||
( function() {
|
( function() {
|
||||||
|
|
||||||
module( 'Polyfills', {
|
QUnit.module( 'Polyfills', {
|
||||||
setup: function() {
|
beforeEach: function() {
|
||||||
testLog.reset();
|
testLog.reset();
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
test( 'pageScroll', function() {
|
QUnit.test( 'pageScroll', function(assert) {
|
||||||
// Setup
|
// Setup
|
||||||
var origWidth = $( "body" ).width(),
|
var origWidth = $( "body" ).width(),
|
||||||
origHeight = $( "body" ).height();
|
origHeight = $( "body" ).height();
|
||||||
@ -23,17 +23,17 @@
|
|||||||
var originalGetPageScroll = OpenSeadragon.getPageScroll;
|
var originalGetPageScroll = OpenSeadragon.getPageScroll;
|
||||||
|
|
||||||
var scroll = OpenSeadragon.getPageScroll();
|
var scroll = OpenSeadragon.getPageScroll();
|
||||||
equal( scroll.x, 0, "Scroll should be 0 at beginning." );
|
assert.equal( scroll.x, 0, "Scroll should be 0 at beginning." );
|
||||||
equal( scroll.y, 0, "Scroll should be 0 at beginning." );
|
assert.equal( scroll.y, 0, "Scroll should be 0 at beginning." );
|
||||||
|
|
||||||
// If window.pageXOffset is not supported, the getPageScroll method should
|
// If window.pageXOffset is not supported, the getPageScroll method should
|
||||||
// not have been redefined
|
// not have been redefined
|
||||||
if ( typeof ( window.pageXOffset ) != "number" ) {
|
if ( typeof ( window.pageXOffset ) != "number" ) {
|
||||||
equal( originalGetPageScroll, OpenSeadragon.getPageScroll,
|
assert.equal( originalGetPageScroll, OpenSeadragon.getPageScroll,
|
||||||
"OpenSeadragon.getPageScroll must not be redefined when on 0,0" +
|
"OpenSeadragon.getPageScroll must not be redefined when on 0,0" +
|
||||||
" and window API is not supported." );
|
" and window API is not supported." );
|
||||||
} else {
|
} else {
|
||||||
notEqual( originalGetPageScroll, OpenSeadragon.getPageScroll,
|
assert.notEqual( originalGetPageScroll, OpenSeadragon.getPageScroll,
|
||||||
"OpenSeadragon.getPageScroll must be redefined when window API " +
|
"OpenSeadragon.getPageScroll must be redefined when window API " +
|
||||||
"is supported." );
|
"is supported." );
|
||||||
}
|
}
|
||||||
@ -41,14 +41,14 @@
|
|||||||
$( document ).scrollLeft( 200 );
|
$( document ).scrollLeft( 200 );
|
||||||
$( document ).scrollTop( 100 );
|
$( document ).scrollTop( 100 );
|
||||||
scroll = originalGetPageScroll();
|
scroll = originalGetPageScroll();
|
||||||
equal( scroll.x, 200, "First call to getScroll." );
|
assert.equal( scroll.x, 200, "First call to getScroll." );
|
||||||
equal( scroll.y, 100, "First call to getScroll." );
|
assert.equal( scroll.y, 100, "First call to getScroll." );
|
||||||
|
|
||||||
$( document ).scrollLeft( 500 );
|
$( document ).scrollLeft( 500 );
|
||||||
$( document ).scrollTop( 600 );
|
$( document ).scrollTop( 600 );
|
||||||
scroll = OpenSeadragon.getPageScroll();
|
scroll = OpenSeadragon.getPageScroll();
|
||||||
equal( scroll.x, 500, "Second call to getScroll." );
|
assert.equal( scroll.x, 500, "Second call to getScroll." );
|
||||||
equal( scroll.y, 600, "Second call to getScroll." );
|
assert.equal( scroll.y, 600, "Second call to getScroll." );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -60,16 +60,16 @@
|
|||||||
$( document ).scrollTop( 0 );
|
$( document ).scrollTop( 0 );
|
||||||
var scroll = new OpenSeadragon.Point( 0, 0 );
|
var scroll = new OpenSeadragon.Point( 0, 0 );
|
||||||
OpenSeadragon.setPageScroll( scroll );
|
OpenSeadragon.setPageScroll( scroll );
|
||||||
equal( $( document ).scrollLeft(), 0, "First call to 0,0 while already on 0,0." );
|
assert.equal( $( document ).scrollLeft(), 0, "First call to 0,0 while already on 0,0." );
|
||||||
equal( $( document ).scrollTop(), 0, "First call to 0,0 while already on 0,0." );
|
assert.equal( $( document ).scrollTop(), 0, "First call to 0,0 while already on 0,0." );
|
||||||
|
|
||||||
// If window.pageXOffset is not supported, the getPageScroll method should
|
// If window.pageXOffset is not supported, the getPageScroll method should
|
||||||
// not have been redefined
|
// not have been redefined
|
||||||
if ( typeof ( window.scrollTo ) === "undefined" ) {
|
if ( typeof ( window.scrollTo ) === "undefined" ) {
|
||||||
equal( originalSetPageScroll, OpenSeadragon.setPageScroll,
|
assert.equal( originalSetPageScroll, OpenSeadragon.setPageScroll,
|
||||||
"OpenSeadragon.setPageScroll must not be redefined when not moving." );
|
"OpenSeadragon.setPageScroll must not be redefined when not moving." );
|
||||||
} else {
|
} else {
|
||||||
notEqual( originalSetPageScroll, OpenSeadragon.setPageScroll,
|
assert.notEqual( originalSetPageScroll, OpenSeadragon.setPageScroll,
|
||||||
"OpenSeadragon.setPageScroll must be redefined when window API is supported." );
|
"OpenSeadragon.setPageScroll must be redefined when window API is supported." );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,16 +79,16 @@
|
|||||||
$( document ).scrollTop( 200 );
|
$( document ).scrollTop( 200 );
|
||||||
var scroll = new OpenSeadragon.Point( 100, 200 );
|
var scroll = new OpenSeadragon.Point( 100, 200 );
|
||||||
OpenSeadragon.setPageScroll( scroll );
|
OpenSeadragon.setPageScroll( scroll );
|
||||||
equal( $( document ).scrollLeft(), 100, "First call to 100,200 while already on 100,200." );
|
assert.equal( $( document ).scrollLeft(), 100, "First call to 100,200 while already on 100,200." );
|
||||||
equal( $( document ).scrollTop(), 200, "First call to 100,200 while already on 100,200." );
|
assert.equal( $( document ).scrollTop(), 200, "First call to 100,200 while already on 100,200." );
|
||||||
|
|
||||||
// If window.pageXOffset is not supported, the getPageScroll method should
|
// If window.pageXOffset is not supported, the getPageScroll method should
|
||||||
// not have been redefined
|
// not have been redefined
|
||||||
if ( typeof ( window.scrollTo ) === "undefined" ) {
|
if ( typeof ( window.scrollTo ) === "undefined" ) {
|
||||||
equal( originalSetPageScroll, OpenSeadragon.setPageScroll,
|
assert.equal( originalSetPageScroll, OpenSeadragon.setPageScroll,
|
||||||
"OpenSeadragon.setPageScroll must not be redefined when not moving." );
|
"OpenSeadragon.setPageScroll must not be redefined when not moving." );
|
||||||
} else {
|
} else {
|
||||||
notEqual( originalSetPageScroll, OpenSeadragon.setPageScroll,
|
assert.notEqual( originalSetPageScroll, OpenSeadragon.setPageScroll,
|
||||||
"OpenSeadragon.setPageScroll must be redefined when window API is supported." );
|
"OpenSeadragon.setPageScroll must be redefined when window API is supported." );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,9 +102,9 @@
|
|||||||
$( document ).scrollTop( 0 );
|
$( document ).scrollTop( 0 );
|
||||||
var scroll = new OpenSeadragon.Point( 20000, 20000 );
|
var scroll = new OpenSeadragon.Point( 20000, 20000 );
|
||||||
OpenSeadragon.setPageScroll( scroll );
|
OpenSeadragon.setPageScroll( scroll );
|
||||||
equal( $( document ).scrollLeft(), actualScrollLeft, "First call to position above limits." );
|
assert.equal( $( document ).scrollLeft(), actualScrollLeft, "First call to position above limits." );
|
||||||
equal( $( document ).scrollTop(), actualScrollTop, "First call to position above limits." );
|
assert.equal( $( document ).scrollTop(), actualScrollTop, "First call to position above limits." );
|
||||||
notEqual( originalSetPageScroll, OpenSeadragon.setPageScroll,
|
assert.notEqual( originalSetPageScroll, OpenSeadragon.setPageScroll,
|
||||||
"Even if outside scroll limits, OpenSeadragon.setPageScroll can be " +
|
"Even if outside scroll limits, OpenSeadragon.setPageScroll can be " +
|
||||||
"reassigned on first call." );
|
"reassigned on first call." );
|
||||||
|
|
||||||
@ -112,9 +112,9 @@
|
|||||||
var currentSetPageScroll = OpenSeadragon.setPageScroll;
|
var currentSetPageScroll = OpenSeadragon.setPageScroll;
|
||||||
var scroll = new OpenSeadragon.Point( 200, 200 );
|
var scroll = new OpenSeadragon.Point( 200, 200 );
|
||||||
OpenSeadragon.setPageScroll( scroll );
|
OpenSeadragon.setPageScroll( scroll );
|
||||||
equal( $( document ).scrollLeft(), 200, "Second call." );
|
assert.equal( $( document ).scrollLeft(), 200, "Second call." );
|
||||||
equal( $( document ).scrollTop(), 200, "Second call." );
|
assert.equal( $( document ).scrollTop(), 200, "Second call." );
|
||||||
equal( currentSetPageScroll, OpenSeadragon.setPageScroll,
|
assert.equal( currentSetPageScroll, OpenSeadragon.setPageScroll,
|
||||||
"OpenSeadragon.setPageScroll must not be reassigned after first call." );
|
"OpenSeadragon.setPageScroll must not be reassigned after first call." );
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,152 +1,152 @@
|
|||||||
/* global module, asyncTest, $, ok, equal, notEqual, start, test, Util, testLog */
|
/* global QUnit, Util */
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
module('Rectangle', {});
|
QUnit.module('Rectangle', {});
|
||||||
|
|
||||||
var precision = 0.000000001;
|
var precision = 0.000000001;
|
||||||
|
|
||||||
test('Constructor', function() {
|
QUnit.test('Constructor', function(assert) {
|
||||||
var rect = new OpenSeadragon.Rect(1, 2, 3, 4, 5);
|
var rect = new OpenSeadragon.Rect(1, 2, 3, 4, 5);
|
||||||
strictEqual(rect.x, 1, 'rect.x should be 1');
|
assert.strictEqual(rect.x, 1, 'rect.x should be 1');
|
||||||
strictEqual(rect.y, 2, 'rect.y should be 2');
|
assert.strictEqual(rect.y, 2, 'rect.y should be 2');
|
||||||
strictEqual(rect.width, 3, 'rect.width should be 3');
|
assert.strictEqual(rect.width, 3, 'rect.width should be 3');
|
||||||
strictEqual(rect.height, 4, 'rect.height should be 4');
|
assert.strictEqual(rect.height, 4, 'rect.height should be 4');
|
||||||
strictEqual(rect.degrees, 5, 'rect.degrees should be 5');
|
assert.strictEqual(rect.degrees, 5, 'rect.degrees should be 5');
|
||||||
|
|
||||||
rect = new OpenSeadragon.Rect();
|
rect = new OpenSeadragon.Rect();
|
||||||
strictEqual(rect.x, 0, 'rect.x should be 0');
|
assert.strictEqual(rect.x, 0, 'rect.x should be 0');
|
||||||
strictEqual(rect.y, 0, 'rect.y should be 0');
|
assert.strictEqual(rect.y, 0, 'rect.y should be 0');
|
||||||
strictEqual(rect.width, 0, 'rect.width should be 0');
|
assert.strictEqual(rect.width, 0, 'rect.width should be 0');
|
||||||
strictEqual(rect.height, 0, 'rect.height should be 0');
|
assert.strictEqual(rect.height, 0, 'rect.height should be 0');
|
||||||
strictEqual(rect.degrees, 0, 'rect.degrees should be 0');
|
assert.strictEqual(rect.degrees, 0, 'rect.degrees should be 0');
|
||||||
|
|
||||||
rect = new OpenSeadragon.Rect(0, 0, 1, 2, -405);
|
rect = new OpenSeadragon.Rect(0, 0, 1, 2, -405);
|
||||||
Util.assessNumericValue(Math.sqrt(2) / 2, rect.x, precision,
|
Util.assessNumericValue(assert, Math.sqrt(2) / 2, rect.x, precision,
|
||||||
'rect.x should be sqrt(2)/2');
|
'rect.x should be sqrt(2)/2');
|
||||||
Util.assessNumericValue(-Math.sqrt(2) / 2, rect.y, precision,
|
Util.assessNumericValue(assert, -Math.sqrt(2) / 2, rect.y, precision,
|
||||||
'rect.y should be -sqrt(2)/2');
|
'rect.y should be -sqrt(2)/2');
|
||||||
Util.assessNumericValue(2, rect.width, precision,
|
Util.assessNumericValue(assert, 2, rect.width, precision,
|
||||||
'rect.width should be 2');
|
'rect.width should be 2');
|
||||||
Util.assessNumericValue(1, rect.height, precision,
|
Util.assessNumericValue(assert, 1, rect.height, precision,
|
||||||
'rect.height should be 1');
|
'rect.height should be 1');
|
||||||
strictEqual(45, rect.degrees, 'rect.degrees should be 45');
|
assert.strictEqual(45, rect.degrees, 'rect.degrees should be 45');
|
||||||
|
|
||||||
rect = new OpenSeadragon.Rect(0, 0, 1, 2, 135);
|
rect = new OpenSeadragon.Rect(0, 0, 1, 2, 135);
|
||||||
Util.assessNumericValue(-Math.sqrt(2), rect.x, precision,
|
Util.assessNumericValue(assert, -Math.sqrt(2), rect.x, precision,
|
||||||
'rect.x should be -sqrt(2)');
|
'rect.x should be -sqrt(2)');
|
||||||
Util.assessNumericValue(-Math.sqrt(2), rect.y, precision,
|
Util.assessNumericValue(assert, -Math.sqrt(2), rect.y, precision,
|
||||||
'rect.y should be -sqrt(2)');
|
'rect.y should be -sqrt(2)');
|
||||||
Util.assessNumericValue(2, rect.width, precision,
|
Util.assessNumericValue(assert, 2, rect.width, precision,
|
||||||
'rect.width should be 2');
|
'rect.width should be 2');
|
||||||
Util.assessNumericValue(1, rect.height, precision,
|
Util.assessNumericValue(assert, 1, rect.height, precision,
|
||||||
'rect.height should be 1');
|
'rect.height should be 1');
|
||||||
strictEqual(45, rect.degrees, 'rect.degrees should be 45');
|
assert.strictEqual(45, rect.degrees, 'rect.degrees should be 45');
|
||||||
|
|
||||||
rect = new OpenSeadragon.Rect(0, 0, 1, 1, 585);
|
rect = new OpenSeadragon.Rect(0, 0, 1, 1, 585);
|
||||||
Util.assessNumericValue(0, rect.x, precision,
|
Util.assessNumericValue(assert, 0, rect.x, precision,
|
||||||
'rect.x should be 0');
|
'rect.x should be 0');
|
||||||
Util.assessNumericValue(-Math.sqrt(2), rect.y, precision,
|
Util.assessNumericValue(assert, -Math.sqrt(2), rect.y, precision,
|
||||||
'rect.y should be -sqrt(2)');
|
'rect.y should be -sqrt(2)');
|
||||||
Util.assessNumericValue(1, rect.width, precision,
|
Util.assessNumericValue(assert, 1, rect.width, precision,
|
||||||
'rect.width should be 1');
|
'rect.width should be 1');
|
||||||
Util.assessNumericValue(1, rect.height, precision,
|
Util.assessNumericValue(assert, 1, rect.height, precision,
|
||||||
'rect.height should be 1');
|
'rect.height should be 1');
|
||||||
strictEqual(45, rect.degrees, 'rect.degrees should be 45');
|
assert.strictEqual(45, rect.degrees, 'rect.degrees should be 45');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getTopLeft', function() {
|
QUnit.test('getTopLeft', function(assert) {
|
||||||
var rect = new OpenSeadragon.Rect(1, 2, 3, 4, 5);
|
var rect = new OpenSeadragon.Rect(1, 2, 3, 4, 5);
|
||||||
var expected = new OpenSeadragon.Point(1, 2);
|
var expected = new OpenSeadragon.Point(1, 2);
|
||||||
ok(expected.equals(rect.getTopLeft()), "Incorrect top left point.");
|
assert.ok(expected.equals(rect.getTopLeft()), "Incorrect top left point.");
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getTopRight', function() {
|
QUnit.test('getTopRight', function(assert) {
|
||||||
var rect = new OpenSeadragon.Rect(0, 0, 1, 3);
|
var rect = new OpenSeadragon.Rect(0, 0, 1, 3);
|
||||||
var expected = new OpenSeadragon.Point(1, 0);
|
var expected = new OpenSeadragon.Point(1, 0);
|
||||||
ok(expected.equals(rect.getTopRight()), "Incorrect top right point.");
|
assert.ok(expected.equals(rect.getTopRight()), "Incorrect top right point.");
|
||||||
|
|
||||||
rect.degrees = 45;
|
rect.degrees = 45;
|
||||||
expected = new OpenSeadragon.Point(1 / Math.sqrt(2), 1 / Math.sqrt(2));
|
expected = new OpenSeadragon.Point(1 / Math.sqrt(2), 1 / Math.sqrt(2));
|
||||||
Util.assertPointsEquals(expected, rect.getTopRight(), precision,
|
Util.assertPointsEquals(assert, expected, rect.getTopRight(), precision,
|
||||||
"Incorrect top right point with rotation.");
|
"Incorrect top right point with rotation.");
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getBottomLeft', function() {
|
QUnit.test('getBottomLeft', function(assert) {
|
||||||
var rect = new OpenSeadragon.Rect(0, 0, 3, 1);
|
var rect = new OpenSeadragon.Rect(0, 0, 3, 1);
|
||||||
var expected = new OpenSeadragon.Point(0, 1);
|
var expected = new OpenSeadragon.Point(0, 1);
|
||||||
ok(expected.equals(rect.getBottomLeft()), "Incorrect bottom left point.");
|
assert.ok(expected.equals(rect.getBottomLeft()), "Incorrect bottom left point.");
|
||||||
|
|
||||||
rect.degrees = 45;
|
rect.degrees = 45;
|
||||||
expected = new OpenSeadragon.Point(-1 / Math.sqrt(2), 1 / Math.sqrt(2));
|
expected = new OpenSeadragon.Point(-1 / Math.sqrt(2), 1 / Math.sqrt(2));
|
||||||
Util.assertPointsEquals(expected, rect.getBottomLeft(), precision,
|
Util.assertPointsEquals(assert, expected, rect.getBottomLeft(), precision,
|
||||||
"Incorrect bottom left point with rotation.");
|
"Incorrect bottom left point with rotation.");
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getBottomRight', function() {
|
QUnit.test('getBottomRight', function(assert) {
|
||||||
var rect = new OpenSeadragon.Rect(0, 0, 1, 1);
|
var rect = new OpenSeadragon.Rect(0, 0, 1, 1);
|
||||||
var expected = new OpenSeadragon.Point(1, 1);
|
var expected = new OpenSeadragon.Point(1, 1);
|
||||||
ok(expected.equals(rect.getBottomRight()), "Incorrect bottom right point.");
|
assert.ok(expected.equals(rect.getBottomRight()), "Incorrect bottom right point.");
|
||||||
|
|
||||||
rect.degrees = 45;
|
rect.degrees = 45;
|
||||||
expected = new OpenSeadragon.Point(0, Math.sqrt(2));
|
expected = new OpenSeadragon.Point(0, Math.sqrt(2));
|
||||||
Util.assertPointsEquals(expected, rect.getBottomRight(), precision,
|
Util.assertPointsEquals(assert, expected, rect.getBottomRight(), precision,
|
||||||
"Incorrect bottom right point with 45 rotation.");
|
"Incorrect bottom right point with 45 rotation.");
|
||||||
|
|
||||||
rect.degrees = 90;
|
rect.degrees = 90;
|
||||||
expected = new OpenSeadragon.Point(-1, 1);
|
expected = new OpenSeadragon.Point(-1, 1);
|
||||||
Util.assertPointsEquals(expected, rect.getBottomRight(), precision,
|
Util.assertPointsEquals(assert, expected, rect.getBottomRight(), precision,
|
||||||
"Incorrect bottom right point with 90 rotation.");
|
"Incorrect bottom right point with 90 rotation.");
|
||||||
|
|
||||||
rect.degrees = 135;
|
rect.degrees = 135;
|
||||||
expected = new OpenSeadragon.Point(-Math.sqrt(2), 0);
|
expected = new OpenSeadragon.Point(-Math.sqrt(2), 0);
|
||||||
Util.assertPointsEquals(expected, rect.getBottomRight(), precision,
|
Util.assertPointsEquals(assert, expected, rect.getBottomRight(), precision,
|
||||||
"Incorrect bottom right point with 135 rotation.");
|
"Incorrect bottom right point with 135 rotation.");
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getCenter', function() {
|
QUnit.test('getCenter', function(assert) {
|
||||||
var rect = new OpenSeadragon.Rect(0, 0, 1, 1);
|
var rect = new OpenSeadragon.Rect(0, 0, 1, 1);
|
||||||
var expected = new OpenSeadragon.Point(0.5, 0.5);
|
var expected = new OpenSeadragon.Point(0.5, 0.5);
|
||||||
ok(expected.equals(rect.getCenter()), "Incorrect center point.");
|
assert.ok(expected.equals(rect.getCenter()), "Incorrect center point.");
|
||||||
|
|
||||||
rect.degrees = 45;
|
rect.degrees = 45;
|
||||||
expected = new OpenSeadragon.Point(0, 0.5 * Math.sqrt(2));
|
expected = new OpenSeadragon.Point(0, 0.5 * Math.sqrt(2));
|
||||||
Util.assertPointsEquals(expected, rect.getCenter(), precision,
|
Util.assertPointsEquals(assert, expected, rect.getCenter(), precision,
|
||||||
"Incorrect bottom right point with 45 rotation.");
|
"Incorrect bottom right point with 45 rotation.");
|
||||||
|
|
||||||
rect.degrees = 90;
|
rect.degrees = 90;
|
||||||
expected = new OpenSeadragon.Point(-0.5, 0.5);
|
expected = new OpenSeadragon.Point(-0.5, 0.5);
|
||||||
Util.assertPointsEquals(expected, rect.getCenter(), precision,
|
Util.assertPointsEquals(assert, expected, rect.getCenter(), precision,
|
||||||
"Incorrect bottom right point with 90 rotation.");
|
"Incorrect bottom right point with 90 rotation.");
|
||||||
|
|
||||||
rect.degrees = 135;
|
rect.degrees = 135;
|
||||||
expected = new OpenSeadragon.Point(-0.5 * Math.sqrt(2), 0);
|
expected = new OpenSeadragon.Point(-0.5 * Math.sqrt(2), 0);
|
||||||
Util.assertPointsEquals(expected, rect.getCenter(), precision,
|
Util.assertPointsEquals(assert, expected, rect.getCenter(), precision,
|
||||||
"Incorrect bottom right point with 135 rotation.");
|
"Incorrect bottom right point with 135 rotation.");
|
||||||
});
|
});
|
||||||
|
|
||||||
test('times', function() {
|
QUnit.test('times', function(assert) {
|
||||||
var rect = new OpenSeadragon.Rect(1, 2, 3, 4, 45);
|
var rect = new OpenSeadragon.Rect(1, 2, 3, 4, 45);
|
||||||
var expected = new OpenSeadragon.Rect(2, 4, 6, 8, 45);
|
var expected = new OpenSeadragon.Rect(2, 4, 6, 8, 45);
|
||||||
var actual = rect.times(2);
|
var actual = rect.times(2);
|
||||||
Util.assertRectangleEquals(expected, actual, precision,
|
Util.assertRectangleEquals(assert, expected, actual, precision,
|
||||||
"Incorrect x2 rectangles.");
|
"Incorrect x2 rectangles.");
|
||||||
});
|
});
|
||||||
|
|
||||||
test('translate', function() {
|
QUnit.test('translate', function(assert) {
|
||||||
var rect = new OpenSeadragon.Rect(1, 2, 3, 4, 45);
|
var rect = new OpenSeadragon.Rect(1, 2, 3, 4, 45);
|
||||||
var expected = new OpenSeadragon.Rect(2, 4, 3, 4, 45);
|
var expected = new OpenSeadragon.Rect(2, 4, 3, 4, 45);
|
||||||
var actual = rect.translate(new OpenSeadragon.Point(1, 2));
|
var actual = rect.translate(new OpenSeadragon.Point(1, 2));
|
||||||
Util.assertRectangleEquals(expected, actual, precision,
|
Util.assertRectangleEquals(assert, expected, actual, precision,
|
||||||
"Incorrect translation.");
|
"Incorrect translation.");
|
||||||
});
|
});
|
||||||
|
|
||||||
test('union', function() {
|
QUnit.test('union', function(assert) {
|
||||||
var rect1 = new OpenSeadragon.Rect(2, 2, 2, 3);
|
var rect1 = new OpenSeadragon.Rect(2, 2, 2, 3);
|
||||||
var rect2 = new OpenSeadragon.Rect(0, 1, 1, 1);
|
var rect2 = new OpenSeadragon.Rect(0, 1, 1, 1);
|
||||||
var expected = new OpenSeadragon.Rect(0, 1, 4, 4);
|
var expected = new OpenSeadragon.Rect(0, 1, 4, 4);
|
||||||
var actual = rect1.union(rect2);
|
var actual = rect1.union(rect2);
|
||||||
Util.assertRectangleEquals(expected, actual, precision,
|
Util.assertRectangleEquals(assert, expected, actual, precision,
|
||||||
"Incorrect union with horizontal rectangles.");
|
"Incorrect union with horizontal rectangles.");
|
||||||
|
|
||||||
rect1 = new OpenSeadragon.Rect(0, -Math.sqrt(2), 2, 2, 45);
|
rect1 = new OpenSeadragon.Rect(0, -Math.sqrt(2), 2, 2, 45);
|
||||||
@ -157,30 +157,30 @@
|
|||||||
3 + Math.sqrt(2),
|
3 + Math.sqrt(2),
|
||||||
2 + Math.sqrt(2));
|
2 + Math.sqrt(2));
|
||||||
actual = rect1.union(rect2);
|
actual = rect1.union(rect2);
|
||||||
Util.assertRectangleEquals(expected, actual, precision,
|
Util.assertRectangleEquals(assert, expected, actual, precision,
|
||||||
"Incorrect union with non horizontal rectangles.");
|
"Incorrect union with non horizontal rectangles.");
|
||||||
});
|
});
|
||||||
|
|
||||||
test('intersection', function() {
|
QUnit.test('intersection', function(assert) {
|
||||||
var rect1 = new OpenSeadragon.Rect(2, 2, 2, 3);
|
var rect1 = new OpenSeadragon.Rect(2, 2, 2, 3);
|
||||||
var rect2 = new OpenSeadragon.Rect(0, 1, 1, 1);
|
var rect2 = new OpenSeadragon.Rect(0, 1, 1, 1);
|
||||||
var expected = null;
|
var expected = null;
|
||||||
var actual = rect1.intersection(rect2);
|
var actual = rect1.intersection(rect2);
|
||||||
equal(expected, actual,
|
assert.equal(expected, actual,
|
||||||
"Rectangle " + rect2 + " should not intersect " + rect1);
|
"Rectangle " + rect2 + " should not intersect " + rect1);
|
||||||
actual = rect2.intersection(rect1);
|
actual = rect2.intersection(rect1);
|
||||||
equal(expected, actual,
|
assert.equal(expected, actual,
|
||||||
"Rectangle " + rect1 + " should not intersect " + rect2);
|
"Rectangle " + rect1 + " should not intersect " + rect2);
|
||||||
|
|
||||||
rect1 = new OpenSeadragon.Rect(0, 0, 2, 1);
|
rect1 = new OpenSeadragon.Rect(0, 0, 2, 1);
|
||||||
rect2 = new OpenSeadragon.Rect(1, 0, 2, 2);
|
rect2 = new OpenSeadragon.Rect(1, 0, 2, 2);
|
||||||
expected = new OpenSeadragon.Rect(1, 0, 1, 1);
|
expected = new OpenSeadragon.Rect(1, 0, 1, 1);
|
||||||
actual = rect1.intersection(rect2);
|
actual = rect1.intersection(rect2);
|
||||||
Util.assertRectangleEquals(expected, actual, precision,
|
Util.assertRectangleEquals(assert, expected, actual, precision,
|
||||||
"Intersection of " + rect2 + " with " + rect1 + " should be " +
|
"Intersection of " + rect2 + " with " + rect1 + " should be " +
|
||||||
expected);
|
expected);
|
||||||
actual = rect2.intersection(rect1);
|
actual = rect2.intersection(rect1);
|
||||||
Util.assertRectangleEquals(expected, actual, precision,
|
Util.assertRectangleEquals(assert, expected, actual, precision,
|
||||||
"Intersection of " + rect1 + " with " + rect2 + " should be " +
|
"Intersection of " + rect1 + " with " + rect2 + " should be " +
|
||||||
expected);
|
expected);
|
||||||
|
|
||||||
@ -188,11 +188,11 @@
|
|||||||
rect2 = new OpenSeadragon.Rect(1, 1, 1, 1);
|
rect2 = new OpenSeadragon.Rect(1, 1, 1, 1);
|
||||||
expected = new OpenSeadragon.Rect(1, 1, 1, 1);
|
expected = new OpenSeadragon.Rect(1, 1, 1, 1);
|
||||||
actual = rect1.intersection(rect2);
|
actual = rect1.intersection(rect2);
|
||||||
Util.assertRectangleEquals(expected, actual, precision,
|
Util.assertRectangleEquals(assert, expected, actual, precision,
|
||||||
"Intersection of " + rect2 + " with " + rect1 + " should be " +
|
"Intersection of " + rect2 + " with " + rect1 + " should be " +
|
||||||
expected);
|
expected);
|
||||||
actual = rect2.intersection(rect1);
|
actual = rect2.intersection(rect1);
|
||||||
Util.assertRectangleEquals(expected, actual, precision,
|
Util.assertRectangleEquals(assert, expected, actual, precision,
|
||||||
"Intersection of " + rect1 + " with " + rect2 + " should be " +
|
"Intersection of " + rect1 + " with " + rect2 + " should be " +
|
||||||
expected);
|
expected);
|
||||||
|
|
||||||
@ -201,26 +201,26 @@
|
|||||||
rect2 = new OpenSeadragon.Rect(0, 1, 1, 1);
|
rect2 = new OpenSeadragon.Rect(0, 1, 1, 1);
|
||||||
expected = null;
|
expected = null;
|
||||||
actual = rect1.intersection(rect2);
|
actual = rect1.intersection(rect2);
|
||||||
equal(expected, actual,
|
assert.equal(expected, actual,
|
||||||
"Rectangle " + rect2 + " should not intersect " + rect1);
|
"Rectangle " + rect2 + " should not intersect " + rect1);
|
||||||
actual = rect2.intersection(rect1);
|
actual = rect2.intersection(rect1);
|
||||||
equal(expected, actual,
|
assert.equal(expected, actual,
|
||||||
"Rectangle " + rect1 + " should not intersect " + rect2);
|
"Rectangle " + rect1 + " should not intersect " + rect2);
|
||||||
|
|
||||||
rect1 = new OpenSeadragon.Rect(2, 0, 2, 3, 45);
|
rect1 = new OpenSeadragon.Rect(2, 0, 2, 3, 45);
|
||||||
rect2 = new OpenSeadragon.Rect(0, 1, 1, 1);
|
rect2 = new OpenSeadragon.Rect(0, 1, 1, 1);
|
||||||
expected = new OpenSeadragon.Rect(0, 1, 1, 1);
|
expected = new OpenSeadragon.Rect(0, 1, 1, 1);
|
||||||
actual = rect1.intersection(rect2);
|
actual = rect1.intersection(rect2);
|
||||||
Util.assertRectangleEquals(expected, actual, precision,
|
Util.assertRectangleEquals(assert, expected, actual, precision,
|
||||||
"Intersection of " + rect2 + " with " + rect1 + " should be " +
|
"Intersection of " + rect2 + " with " + rect1 + " should be " +
|
||||||
expected);
|
expected);
|
||||||
actual = rect2.intersection(rect1);
|
actual = rect2.intersection(rect1);
|
||||||
Util.assertRectangleEquals(expected, actual, precision,
|
Util.assertRectangleEquals(assert, expected, actual, precision,
|
||||||
"Intersection of " + rect1 + " with " + rect2 + " should be " +
|
"Intersection of " + rect1 + " with " + rect2 + " should be " +
|
||||||
expected);
|
expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('rotate', function() {
|
QUnit.test('rotate', function(assert) {
|
||||||
var rect = new OpenSeadragon.Rect(0, 0, 2, 1);
|
var rect = new OpenSeadragon.Rect(0, 0, 2, 1);
|
||||||
|
|
||||||
var expected = new OpenSeadragon.Rect(
|
var expected = new OpenSeadragon.Rect(
|
||||||
@ -230,73 +230,73 @@
|
|||||||
1,
|
1,
|
||||||
45);
|
45);
|
||||||
var actual = rect.rotate(-675);
|
var actual = rect.rotate(-675);
|
||||||
Util.assertRectangleEquals(expected, actual, precision,
|
Util.assertRectangleEquals(assert, expected, actual, precision,
|
||||||
"Incorrect rectangle after rotation of -675deg around center.");
|
"Incorrect rectangle after rotation of -675deg around center.");
|
||||||
|
|
||||||
expected = new OpenSeadragon.Rect(0, 0, 2, 1, 33);
|
expected = new OpenSeadragon.Rect(0, 0, 2, 1, 33);
|
||||||
actual = rect.rotate(33, rect.getTopLeft());
|
actual = rect.rotate(33, rect.getTopLeft());
|
||||||
Util.assertRectangleEquals(expected, actual, precision,
|
Util.assertRectangleEquals(assert, expected, actual, precision,
|
||||||
"Incorrect rectangle after rotation of 33deg around topLeft.");
|
"Incorrect rectangle after rotation of 33deg around topLeft.");
|
||||||
|
|
||||||
expected = new OpenSeadragon.Rect(0, 0, 2, 1, 101);
|
expected = new OpenSeadragon.Rect(0, 0, 2, 1, 101);
|
||||||
actual = rect.rotate(101, rect.getTopLeft());
|
actual = rect.rotate(101, rect.getTopLeft());
|
||||||
Util.assertRectangleEquals(expected, actual, precision,
|
Util.assertRectangleEquals(assert, expected, actual, precision,
|
||||||
"Incorrect rectangle after rotation of 187deg around topLeft.");
|
"Incorrect rectangle after rotation of 187deg around topLeft.");
|
||||||
|
|
||||||
expected = new OpenSeadragon.Rect(0, 0, 2, 1, 187);
|
expected = new OpenSeadragon.Rect(0, 0, 2, 1, 187);
|
||||||
actual = rect.rotate(187, rect.getTopLeft());
|
actual = rect.rotate(187, rect.getTopLeft());
|
||||||
Util.assertRectangleEquals(expected, actual, precision,
|
Util.assertRectangleEquals(assert, expected, actual, precision,
|
||||||
"Incorrect rectangle after rotation of 187deg around topLeft.");
|
"Incorrect rectangle after rotation of 187deg around topLeft.");
|
||||||
|
|
||||||
expected = new OpenSeadragon.Rect(0, 0, 2, 1, 300);
|
expected = new OpenSeadragon.Rect(0, 0, 2, 1, 300);
|
||||||
actual = rect.rotate(300, rect.getTopLeft());
|
actual = rect.rotate(300, rect.getTopLeft());
|
||||||
Util.assertRectangleEquals(expected, actual, precision,
|
Util.assertRectangleEquals(assert, expected, actual, precision,
|
||||||
"Incorrect rectangle after rotation of 300deg around topLeft.");
|
"Incorrect rectangle after rotation of 300deg around topLeft.");
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getBoundingBox', function() {
|
QUnit.test('getBoundingBox', function(assert) {
|
||||||
var rect = new OpenSeadragon.Rect(0, 0, 2, 3);
|
var rect = new OpenSeadragon.Rect(0, 0, 2, 3);
|
||||||
|
|
||||||
var bb = rect.getBoundingBox();
|
var bb = rect.getBoundingBox();
|
||||||
ok(rect.equals(bb), "Bounding box of horizontal rectangle should be " +
|
assert.ok(rect.equals(bb), "Bounding box of horizontal rectangle should be " +
|
||||||
"identical to rectangle.");
|
"identical to rectangle.");
|
||||||
|
|
||||||
rect.degrees = 90;
|
rect.degrees = 90;
|
||||||
var expected = new OpenSeadragon.Rect(-3, 0, 3, 2);
|
var expected = new OpenSeadragon.Rect(-3, 0, 3, 2);
|
||||||
Util.assertRectangleEquals(expected, rect.getBoundingBox(), precision,
|
Util.assertRectangleEquals(assert, expected, rect.getBoundingBox(), precision,
|
||||||
"Bounding box of rect rotated 90deg.");
|
"Bounding box of rect rotated 90deg.");
|
||||||
|
|
||||||
rect.degrees = 180;
|
rect.degrees = 180;
|
||||||
var expected = new OpenSeadragon.Rect(-2, -3, 2, 3);
|
expected = new OpenSeadragon.Rect(-2, -3, 2, 3);
|
||||||
Util.assertRectangleEquals(expected, rect.getBoundingBox(), precision,
|
Util.assertRectangleEquals(assert, expected, rect.getBoundingBox(), precision,
|
||||||
"Bounding box of rect rotated 180deg.");
|
"Bounding box of rect rotated 180deg.");
|
||||||
|
|
||||||
rect.degrees = 270;
|
rect.degrees = 270;
|
||||||
var expected = new OpenSeadragon.Rect(0, -2, 3, 2);
|
expected = new OpenSeadragon.Rect(0, -2, 3, 2);
|
||||||
Util.assertRectangleEquals(expected, rect.getBoundingBox(), precision,
|
Util.assertRectangleEquals(assert, expected, rect.getBoundingBox(), precision,
|
||||||
"Bounding box of rect rotated 270deg.");
|
"Bounding box of rect rotated 270deg.");
|
||||||
});
|
});
|
||||||
|
|
||||||
test('containsPoint', function() {
|
QUnit.test('containsPoint', function(assert) {
|
||||||
var rect = new OpenSeadragon.Rect(0, 0, 1, 1, 45);
|
var rect = new OpenSeadragon.Rect(0, 0, 1, 1, 45);
|
||||||
|
|
||||||
ok(rect.containsPoint(new OpenSeadragon.Point(0, 0)),
|
assert.ok(rect.containsPoint(new OpenSeadragon.Point(0, 0)),
|
||||||
'Point 0,0 should be inside ' + rect);
|
'Point 0,0 should be inside ' + rect);
|
||||||
ok(rect.containsPoint(rect.getTopRight()),
|
assert.ok(rect.containsPoint(rect.getTopRight()),
|
||||||
'Top right vertex should be inside ' + rect);
|
'Top right vertex should be inside ' + rect);
|
||||||
ok(rect.containsPoint(rect.getBottomRight()),
|
assert.ok(rect.containsPoint(rect.getBottomRight()),
|
||||||
'Bottom right vertex should be inside ' + rect);
|
'Bottom right vertex should be inside ' + rect);
|
||||||
ok(rect.containsPoint(rect.getBottomLeft()),
|
assert.ok(rect.containsPoint(rect.getBottomLeft()),
|
||||||
'Bottom left vertex should be inside ' + rect);
|
'Bottom left vertex should be inside ' + rect);
|
||||||
ok(rect.containsPoint(rect.getCenter()),
|
assert.ok(rect.containsPoint(rect.getCenter()),
|
||||||
'Center should be inside ' + rect);
|
'Center should be inside ' + rect);
|
||||||
notOk(rect.containsPoint(new OpenSeadragon.Point(1, 0)),
|
assert.notOk(rect.containsPoint(new OpenSeadragon.Point(1, 0)),
|
||||||
'Point 1,0 should not be inside ' + rect);
|
'Point 1,0 should not be inside ' + rect);
|
||||||
ok(rect.containsPoint(new OpenSeadragon.Point(0.5, 0.5)),
|
assert.ok(rect.containsPoint(new OpenSeadragon.Point(0.5, 0.5)),
|
||||||
'Point 0.5,0.5 should be inside ' + rect);
|
'Point 0.5,0.5 should be inside ' + rect);
|
||||||
ok(rect.containsPoint(new OpenSeadragon.Point(0.4, 0.5)),
|
assert.ok(rect.containsPoint(new OpenSeadragon.Point(0.4, 0.5)),
|
||||||
'Point 0.4,0.5 should be inside ' + rect);
|
'Point 0.4,0.5 should be inside ' + rect);
|
||||||
notOk(rect.containsPoint(new OpenSeadragon.Point(0.6, 0.5)),
|
assert.notOk(rect.containsPoint(new OpenSeadragon.Point(0.6, 0.5)),
|
||||||
'Point 0.6,0.5 should not be inside ' + rect);
|
'Point 0.6,0.5 should not be inside ' + rect);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
/* global module, asyncTest, $, ok, equal, notEqual, start, test, Util, testLog */
|
/* global QUnit, $, testLog */
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var viewer;
|
var viewer;
|
||||||
|
|
||||||
module('ReferenceStrip', {
|
QUnit.module('ReferenceStrip', {
|
||||||
setup: function () {
|
beforeEach: function () {
|
||||||
var example = $('<div id="example"></div>').appendTo("#qunit-fixture");
|
$('<div id="example"></div>').appendTo("#qunit-fixture");
|
||||||
|
|
||||||
testLog.reset();
|
testLog.reset();
|
||||||
},
|
},
|
||||||
teardown: function () {
|
afterEach: function () {
|
||||||
if (viewer && viewer.close) {
|
if (viewer && viewer.close) {
|
||||||
viewer.close();
|
viewer.close();
|
||||||
}
|
}
|
||||||
@ -29,7 +29,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('basics', function() {
|
QUnit.test('basics', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
createViewer({
|
createViewer({
|
||||||
sequenceMode: true,
|
sequenceMode: true,
|
||||||
showReferenceStrip: true,
|
showReferenceStrip: true,
|
||||||
@ -39,8 +40,8 @@
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
ok(viewer.referenceStrip, 'referenceStrip exists');
|
assert.ok(viewer.referenceStrip, 'referenceStrip exists');
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
/* global module, asyncTest, $, ok, equal, notEqual, start, test, Util, testLog, propEqual, console */
|
/* global QUnit, Util, console */
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
|
|
||||||
var originalNow;
|
var originalNow;
|
||||||
var now;
|
var now;
|
||||||
|
|
||||||
module("spring", {
|
QUnit.module("spring", {
|
||||||
setup: function () {
|
beforeEach: function () {
|
||||||
now = 0;
|
now = 0;
|
||||||
originalNow = OpenSeadragon.now;
|
originalNow = OpenSeadragon.now;
|
||||||
|
|
||||||
@ -14,39 +14,41 @@
|
|||||||
return now;
|
return now;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
teardown: function () {
|
afterEach: function () {
|
||||||
OpenSeadragon.now = originalNow;
|
OpenSeadragon.now = originalNow;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('regular spring', function() {
|
QUnit.test('regular spring', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var spring = new OpenSeadragon.Spring({
|
var spring = new OpenSeadragon.Spring({
|
||||||
initial: 5,
|
initial: 5,
|
||||||
animationTime: 1,
|
animationTime: 1,
|
||||||
springStiffness: 0.000001
|
springStiffness: 0.000001
|
||||||
});
|
});
|
||||||
|
|
||||||
equal(spring.current.value, 5, 'initial current value');
|
assert.equal(spring.current.value, 5, 'initial current value');
|
||||||
equal(spring.target.value, 5, 'initial target value');
|
assert.equal(spring.target.value, 5, 'initial target value');
|
||||||
|
|
||||||
spring.springTo(6);
|
spring.springTo(6);
|
||||||
equal(spring.current.value, 5, 'current value after springTo');
|
assert.equal(spring.current.value, 5, 'current value after springTo');
|
||||||
equal(spring.target.value, 6, 'target value after springTo');
|
assert.equal(spring.target.value, 6, 'target value after springTo');
|
||||||
|
|
||||||
now = 500;
|
now = 500;
|
||||||
spring.update();
|
spring.update();
|
||||||
Util.assessNumericValue(5.5, spring.current.value, 0.00001, 'current value after first update');
|
Util.assessNumericValue(assert, 5.5, spring.current.value, 0.00001, 'current value after first update');
|
||||||
equal(spring.target.value, 6, 'target value after first update');
|
assert.equal(spring.target.value, 6, 'target value after first update');
|
||||||
|
|
||||||
now = 1000;
|
now = 1000;
|
||||||
spring.update();
|
spring.update();
|
||||||
equal(spring.current.value, 6, 'current value after second update');
|
assert.equal(spring.current.value, 6, 'current value after second update');
|
||||||
equal(spring.target.value, 6, 'target value after second update');
|
assert.equal(spring.target.value, 6, 'target value after second update');
|
||||||
|
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('exponential spring', function() {
|
QUnit.test('exponential spring', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var spring = new OpenSeadragon.Spring({
|
var spring = new OpenSeadragon.Spring({
|
||||||
exponential: true,
|
exponential: true,
|
||||||
initial: 1,
|
initial: 1,
|
||||||
@ -54,24 +56,24 @@
|
|||||||
springStiffness: 0.000001
|
springStiffness: 0.000001
|
||||||
});
|
});
|
||||||
|
|
||||||
equal(spring.current.value, 1, 'initial current value');
|
assert.equal(spring.current.value, 1, 'initial current value');
|
||||||
equal(spring.target.value, 1, 'initial target value');
|
assert.equal(spring.target.value, 1, 'initial target value');
|
||||||
|
|
||||||
spring.springTo(2);
|
spring.springTo(2);
|
||||||
equal(spring.current.value, 1, 'current value after springTo');
|
assert.equal(spring.current.value, 1, 'current value after springTo');
|
||||||
equal(spring.target.value, 2, 'target value after springTo');
|
assert.equal(spring.target.value, 2, 'target value after springTo');
|
||||||
|
|
||||||
now = 500;
|
now = 500;
|
||||||
spring.update();
|
spring.update();
|
||||||
Util.assessNumericValue(1.41421, spring.current.value, 0.00001, 'current value after first update');
|
Util.assessNumericValue(assert, 1.41421, spring.current.value, 0.00001, 'current value after first update');
|
||||||
equal(spring.target.value, 2, 'target value after first update');
|
assert.equal(spring.target.value, 2, 'target value after first update');
|
||||||
|
|
||||||
now = 1000;
|
now = 1000;
|
||||||
spring.update();
|
spring.update();
|
||||||
equal(spring.current.value, 2, 'current value after second update');
|
assert.equal(spring.current.value, 2, 'current value after second update');
|
||||||
equal(spring.target.value, 2, 'target value after second update');
|
assert.equal(spring.target.value, 2, 'target value after second update');
|
||||||
|
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -1,44 +1,44 @@
|
|||||||
/* global module, asyncTest, $, ok, equal, notEqual, start, test, Util, testLog */
|
/* global QUnit, testLog */
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
module("strings", {
|
QUnit.module("strings", {
|
||||||
setup: function () {
|
beforeEach: function () {
|
||||||
testLog.reset();
|
testLog.reset();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test("getSubString", function() {
|
QUnit.test("getSubString", function(assert) {
|
||||||
equal(OpenSeadragon.getString("Errors.Dzi"),
|
assert.equal(OpenSeadragon.getString("Errors.Dzi"),
|
||||||
"Hmm, this doesn't appear to be a valid Deep Zoom Image.",
|
"Hmm, this doesn't appear to be a valid Deep Zoom Image.",
|
||||||
"Read sub-string");
|
"Read sub-string");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("getStringWithPlaceholders", function() {
|
QUnit.test("getStringWithPlaceholders", function(assert) {
|
||||||
equal(OpenSeadragon.getString("Errors.OpenFailed", "foo", "bar"),
|
assert.equal(OpenSeadragon.getString("Errors.OpenFailed", "foo", "bar"),
|
||||||
"Unable to open foo: bar",
|
"Unable to open foo: bar",
|
||||||
"String placeholder replacement");
|
"String placeholder replacement");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("getInvalidString", function() {
|
QUnit.test("getInvalidString", function(assert) {
|
||||||
equal(OpenSeadragon.getString("Greeting"), "", "Handled unset string key");
|
assert.equal(OpenSeadragon.getString("Greeting"), "", "Handled unset string key");
|
||||||
ok(testLog.log.contains('["Untranslated source string:","Greeting"]'),
|
assert.ok(testLog.log.contains('["Untranslated source string:","Greeting"]'),
|
||||||
'Invalid string keys are logged');
|
'Invalid string keys are logged');
|
||||||
|
|
||||||
equal(OpenSeadragon.getString("Errors"), "", "Handled requesting parent key");
|
assert.equal(OpenSeadragon.getString("Errors"), "", "Handled requesting parent key");
|
||||||
ok(testLog.log.contains('["Untranslated source string:","Errors"]'),
|
assert.ok(testLog.log.contains('["Untranslated source string:","Errors"]'),
|
||||||
'Invalid string parent keys are logged');
|
'Invalid string parent keys are logged');
|
||||||
});
|
});
|
||||||
|
|
||||||
test("setString", function() {
|
QUnit.test("setString", function(assert) {
|
||||||
OpenSeadragon.setString("Greeting", "Hello world");
|
OpenSeadragon.setString("Greeting", "Hello world");
|
||||||
equal(OpenSeadragon.getString("Greeting"), "Hello world",
|
assert.equal(OpenSeadragon.getString("Greeting"), "Hello world",
|
||||||
"Set a string");
|
"Set a string");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("setSubString", function() {
|
QUnit.test("setSubString", function(assert) {
|
||||||
OpenSeadragon.setString("CustomGreeting.Hello", "Hello world");
|
OpenSeadragon.setString("CustomGreeting.Hello", "Hello world");
|
||||||
equal(OpenSeadragon.getString("CustomGreeting.Hello"), "Hello world",
|
assert.equal(OpenSeadragon.getString("CustomGreeting.Hello"), "Hello world",
|
||||||
"Set a sub-string");
|
"Set a sub-string");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,18 +1,20 @@
|
|||||||
/* global module, asyncTest, $, ok, equal, notEqual, start, test, Util, testLog */
|
/* global QUnit, testLog */
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
module('TileCache', {
|
QUnit.module('TileCache', {
|
||||||
setup: function () {
|
beforeEach: function () {
|
||||||
testLog.reset();
|
testLog.reset();
|
||||||
},
|
},
|
||||||
teardown: function () {
|
afterEach: function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('basics', function() {
|
// TODO: this used to be async
|
||||||
|
QUnit.test('basics', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var fakeViewer = {
|
var fakeViewer = {
|
||||||
raiseEvent: function() {}
|
raiseEvent: function() {}
|
||||||
};
|
};
|
||||||
@ -38,35 +40,36 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
var cache = new OpenSeadragon.TileCache();
|
var cache = new OpenSeadragon.TileCache();
|
||||||
equal(cache.numTilesLoaded(), 0, 'no tiles to begin with');
|
assert.equal(cache.numTilesLoaded(), 0, 'no tiles to begin with');
|
||||||
|
|
||||||
cache.cacheTile({
|
cache.cacheTile({
|
||||||
tile: fakeTile0,
|
tile: fakeTile0,
|
||||||
tiledImage: fakeTiledImage0
|
tiledImage: fakeTiledImage0
|
||||||
});
|
});
|
||||||
|
|
||||||
equal(cache.numTilesLoaded(), 1, 'tile count after cache');
|
assert.equal(cache.numTilesLoaded(), 1, 'tile count after cache');
|
||||||
|
|
||||||
cache.cacheTile({
|
cache.cacheTile({
|
||||||
tile: fakeTile1,
|
tile: fakeTile1,
|
||||||
tiledImage: fakeTiledImage1
|
tiledImage: fakeTiledImage1
|
||||||
});
|
});
|
||||||
|
|
||||||
equal(cache.numTilesLoaded(), 2, 'tile count after second cache');
|
assert.equal(cache.numTilesLoaded(), 2, 'tile count after second cache');
|
||||||
|
|
||||||
cache.clearTilesFor(fakeTiledImage0);
|
cache.clearTilesFor(fakeTiledImage0);
|
||||||
|
|
||||||
equal(cache.numTilesLoaded(), 1, 'tile count after first clear');
|
assert.equal(cache.numTilesLoaded(), 1, 'tile count after first clear');
|
||||||
|
|
||||||
cache.clearTilesFor(fakeTiledImage1);
|
cache.clearTilesFor(fakeTiledImage1);
|
||||||
|
|
||||||
equal(cache.numTilesLoaded(), 0, 'tile count after second clear');
|
assert.equal(cache.numTilesLoaded(), 0, 'tile count after second clear');
|
||||||
|
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('maxImageCacheCount', function() {
|
QUnit.test('maxImageCacheCount', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var fakeViewer = {
|
var fakeViewer = {
|
||||||
raiseEvent: function() {}
|
raiseEvent: function() {}
|
||||||
};
|
};
|
||||||
@ -99,30 +102,30 @@
|
|||||||
maxImageCacheCount: 1
|
maxImageCacheCount: 1
|
||||||
});
|
});
|
||||||
|
|
||||||
equal(cache.numTilesLoaded(), 0, 'no tiles to begin with');
|
assert.equal(cache.numTilesLoaded(), 0, 'no tiles to begin with');
|
||||||
|
|
||||||
cache.cacheTile({
|
cache.cacheTile({
|
||||||
tile: fakeTile0,
|
tile: fakeTile0,
|
||||||
tiledImage: fakeTiledImage0
|
tiledImage: fakeTiledImage0
|
||||||
});
|
});
|
||||||
|
|
||||||
equal(cache.numTilesLoaded(), 1, 'tile count after add');
|
assert.equal(cache.numTilesLoaded(), 1, 'tile count after add');
|
||||||
|
|
||||||
cache.cacheTile({
|
cache.cacheTile({
|
||||||
tile: fakeTile1,
|
tile: fakeTile1,
|
||||||
tiledImage: fakeTiledImage0
|
tiledImage: fakeTiledImage0
|
||||||
});
|
});
|
||||||
|
|
||||||
equal(cache.numTilesLoaded(), 1, 'tile count after add of second image');
|
assert.equal(cache.numTilesLoaded(), 1, 'tile count after add of second image');
|
||||||
|
|
||||||
cache.cacheTile({
|
cache.cacheTile({
|
||||||
tile: fakeTile2,
|
tile: fakeTile2,
|
||||||
tiledImage: fakeTiledImage0
|
tiledImage: fakeTiledImage0
|
||||||
});
|
});
|
||||||
|
|
||||||
equal(cache.numTilesLoaded(), 2, 'tile count after additional same image');
|
assert.equal(cache.numTilesLoaded(), 2, 'tile count after additional same image');
|
||||||
|
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
/* global module, asyncTest, $, ok, equal, notEqual, start, test, Util, testLog, propEqual */
|
/* global QUnit, $, Util, testLog */
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var viewer;
|
var viewer;
|
||||||
|
|
||||||
module('TiledImage', {
|
QUnit.module('TiledImage', {
|
||||||
setup: function() {
|
beforeEach: function() {
|
||||||
var example = $('<div id="example"></div>').appendTo("#qunit-fixture");
|
$('<div id="example"></div>').appendTo("#qunit-fixture");
|
||||||
|
|
||||||
testLog.reset();
|
testLog.reset();
|
||||||
|
|
||||||
@ -15,7 +15,7 @@
|
|||||||
springStiffness: 100 // Faster animation = faster tests
|
springStiffness: 100 // Faster animation = faster tests
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
teardown: function() {
|
afterEach: function() {
|
||||||
if (viewer && viewer.close) {
|
if (viewer && viewer.close) {
|
||||||
viewer.close();
|
viewer.close();
|
||||||
}
|
}
|
||||||
@ -25,39 +25,40 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
var checkBounds = function(image, expected, message) {
|
var checkBounds = function(assert, image, expected, message) {
|
||||||
var bounds = image.getBounds();
|
var bounds = image.getBounds();
|
||||||
equal(bounds.x, expected.x, message + ' x');
|
assert.equal(bounds.x, expected.x, message + ' x');
|
||||||
equal(bounds.y, expected.y, message + ' y');
|
assert.equal(bounds.y, expected.y, message + ' y');
|
||||||
equal(bounds.width, expected.width, message + ' width');
|
assert.equal(bounds.width, expected.width, message + ' width');
|
||||||
equal(bounds.height, expected.height, message + ' height');
|
assert.equal(bounds.height, expected.height, message + ' height');
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('metrics', function() {
|
QUnit.test('metrics', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var handlerCount = 0;
|
var handlerCount = 0;
|
||||||
|
|
||||||
viewer.addHandler('open', function(event) {
|
viewer.addHandler('open', function(event) {
|
||||||
var image = viewer.world.getItemAt(0);
|
var image = viewer.world.getItemAt(0);
|
||||||
var contentSize = image.getContentSize();
|
var contentSize = image.getContentSize();
|
||||||
equal(contentSize.x, 500, 'contentSize.x');
|
assert.equal(contentSize.x, 500, 'contentSize.x');
|
||||||
equal(contentSize.y, 2000, 'contentSize.y');
|
assert.equal(contentSize.y, 2000, 'contentSize.y');
|
||||||
|
|
||||||
checkBounds(image, new OpenSeadragon.Rect(5, 6, 10, 40), 'initial bounds');
|
checkBounds(assert, image, new OpenSeadragon.Rect(5, 6, 10, 40), 'initial bounds');
|
||||||
|
|
||||||
var scale = image.getContentSize().x / image.getBounds().width;
|
var scale = image.getContentSize().x / image.getBounds().width;
|
||||||
var viewportPoint = new OpenSeadragon.Point(10, 11);
|
var viewportPoint = new OpenSeadragon.Point(10, 11);
|
||||||
var imagePoint = viewportPoint.minus(image.getBounds().getTopLeft()).times(scale);
|
var imagePoint = viewportPoint.minus(image.getBounds().getTopLeft()).times(scale);
|
||||||
|
|
||||||
propEqual(image.viewportToImageCoordinates(viewportPoint), imagePoint, 'viewportToImageCoordinates');
|
assert.propEqual(image.viewportToImageCoordinates(viewportPoint), imagePoint, 'viewportToImageCoordinates');
|
||||||
propEqual(image.imageToViewportCoordinates(imagePoint), viewportPoint, 'imageToViewportCoordinates');
|
assert.propEqual(image.imageToViewportCoordinates(imagePoint), viewportPoint, 'imageToViewportCoordinates');
|
||||||
|
|
||||||
var viewportRect = new OpenSeadragon.Rect(viewportPoint.x, viewportPoint.y, 6, 7);
|
var viewportRect = new OpenSeadragon.Rect(viewportPoint.x, viewportPoint.y, 6, 7);
|
||||||
var imageRect = new OpenSeadragon.Rect(imagePoint.x, imagePoint.y,
|
var imageRect = new OpenSeadragon.Rect(imagePoint.x, imagePoint.y,
|
||||||
viewportRect.width * scale, viewportRect.height * scale);
|
viewportRect.width * scale, viewportRect.height * scale);
|
||||||
|
|
||||||
propEqual(image.viewportToImageRectangle(viewportRect), imageRect, 'viewportToImageRectangle');
|
assert.propEqual(image.viewportToImageRectangle(viewportRect), imageRect, 'viewportToImageRectangle');
|
||||||
propEqual(image.imageToViewportRectangle(imageRect), viewportRect, 'imageToViewportRectangle');
|
assert.propEqual(image.imageToViewportRectangle(imageRect), viewportRect, 'imageToViewportRectangle');
|
||||||
|
|
||||||
image.addHandler('bounds-change', function boundsChangeHandler(event) {
|
image.addHandler('bounds-change', function boundsChangeHandler(event) {
|
||||||
image.removeHandler('bounds-change', boundsChangeHandler);
|
image.removeHandler('bounds-change', boundsChangeHandler);
|
||||||
@ -65,16 +66,16 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
image.setPosition(new OpenSeadragon.Point(7, 8));
|
image.setPosition(new OpenSeadragon.Point(7, 8));
|
||||||
checkBounds(image, new OpenSeadragon.Rect(7, 8, 10, 40), 'bounds after position');
|
checkBounds(assert, image, new OpenSeadragon.Rect(7, 8, 10, 40), 'bounds after position');
|
||||||
|
|
||||||
image.setWidth(5);
|
image.setWidth(5);
|
||||||
checkBounds(image, new OpenSeadragon.Rect(7, 8, 5, 20), 'bounds after width');
|
checkBounds(assert, image, new OpenSeadragon.Rect(7, 8, 5, 20), 'bounds after width');
|
||||||
|
|
||||||
image.setHeight(4);
|
image.setHeight(4);
|
||||||
checkBounds(image, new OpenSeadragon.Rect(7, 8, 1, 4), 'bounds after width');
|
checkBounds(assert, image, new OpenSeadragon.Rect(7, 8, 1, 4), 'bounds after width');
|
||||||
|
|
||||||
equal(handlerCount, 1, 'correct number of handlers called');
|
assert.equal(handlerCount, 1, 'correct number of handlers called');
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
viewer.open({
|
viewer.open({
|
||||||
@ -86,25 +87,26 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('animation', function() {
|
QUnit.test('animation', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer.addHandler("open", function() {
|
viewer.addHandler("open", function() {
|
||||||
var image = viewer.world.getItemAt(0);
|
var image = viewer.world.getItemAt(0);
|
||||||
propEqual(image.getBounds(), new OpenSeadragon.Rect(0, 0, 1, 1), 'target bounds on open');
|
assert.propEqual(image.getBounds(), new OpenSeadragon.Rect(0, 0, 1, 1), 'target bounds on open');
|
||||||
propEqual(image.getBounds(true), new OpenSeadragon.Rect(0, 0, 1, 1), 'current bounds on open');
|
assert.propEqual(image.getBounds(true), new OpenSeadragon.Rect(0, 0, 1, 1), 'current bounds on open');
|
||||||
|
|
||||||
image.setPosition(new OpenSeadragon.Point(1, 2));
|
image.setPosition(new OpenSeadragon.Point(1, 2));
|
||||||
propEqual(image.getBounds(), new OpenSeadragon.Rect(1, 2, 1, 1), 'target bounds after position');
|
assert.propEqual(image.getBounds(), new OpenSeadragon.Rect(1, 2, 1, 1), 'target bounds after position');
|
||||||
propEqual(image.getBounds(true), new OpenSeadragon.Rect(0, 0, 1, 1), 'current bounds after position');
|
assert.propEqual(image.getBounds(true), new OpenSeadragon.Rect(0, 0, 1, 1), 'current bounds after position');
|
||||||
|
|
||||||
image.setWidth(3);
|
image.setWidth(3);
|
||||||
propEqual(image.getBounds(), new OpenSeadragon.Rect(1, 2, 3, 3), 'target bounds after width');
|
assert.propEqual(image.getBounds(), new OpenSeadragon.Rect(1, 2, 3, 3), 'target bounds after width');
|
||||||
propEqual(image.getBounds(true), new OpenSeadragon.Rect(0, 0, 1, 1), 'current bounds after width');
|
assert.propEqual(image.getBounds(true), new OpenSeadragon.Rect(0, 0, 1, 1), 'current bounds after width');
|
||||||
|
|
||||||
viewer.addHandler('animation-finish', function animationHandler() {
|
viewer.addHandler('animation-finish', function animationHandler() {
|
||||||
viewer.removeHandler('animation-finish', animationHandler);
|
viewer.removeHandler('animation-finish', animationHandler);
|
||||||
propEqual(image.getBounds(), new OpenSeadragon.Rect(1, 2, 3, 3), 'target bounds after animation');
|
assert.propEqual(image.getBounds(), new OpenSeadragon.Rect(1, 2, 3, 3), 'target bounds after animation');
|
||||||
propEqual(image.getBounds(true), new OpenSeadragon.Rect(1, 2, 3, 3), 'current bounds after animation');
|
assert.propEqual(image.getBounds(true), new OpenSeadragon.Rect(1, 2, 3, 3), 'current bounds after animation');
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -112,55 +114,56 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('update', function() {
|
QUnit.test('update', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var handlerCount = 0;
|
var handlerCount = 0;
|
||||||
|
|
||||||
viewer.addHandler('open', function(event) {
|
viewer.addHandler('open', function(event) {
|
||||||
var image = viewer.world.getItemAt(0);
|
var image = viewer.world.getItemAt(0);
|
||||||
equal(image.needsDraw(), true, 'needs draw after open');
|
assert.equal(image.needsDraw(), true, 'needs draw after open');
|
||||||
|
|
||||||
viewer.addHandler('update-level', function updateLevelHandler(event) {
|
viewer.addHandler('update-level', function updateLevelHandler(event) {
|
||||||
viewer.removeHandler('update-level', updateLevelHandler);
|
viewer.removeHandler('update-level', updateLevelHandler);
|
||||||
handlerCount++;
|
handlerCount++;
|
||||||
equal(event.eventSource, viewer, 'sender of update-level event was viewer');
|
assert.equal(event.eventSource, viewer, 'sender of update-level event was viewer');
|
||||||
equal(event.tiledImage, image, 'tiledImage of update-level event is correct');
|
assert.equal(event.tiledImage, image, 'tiledImage of update-level event is correct');
|
||||||
ok('havedrawn' in event, 'update-level event includes havedrawn');
|
assert.ok('havedrawn' in event, 'update-level event includes havedrawn');
|
||||||
ok('level' in event, 'update-level event includes level');
|
assert.ok('level' in event, 'update-level event includes level');
|
||||||
ok('opacity' in event, 'update-level event includes opacity');
|
assert.ok('opacity' in event, 'update-level event includes opacity');
|
||||||
ok('visibility' in event, 'update-level event includes visibility');
|
assert.ok('visibility' in event, 'update-level event includes visibility');
|
||||||
ok('topleft' in event, 'update-level event includes topleft');
|
assert.ok('topleft' in event, 'update-level event includes topleft');
|
||||||
ok('bottomright' in event, 'update-level event includes bottomright');
|
assert.ok('bottomright' in event, 'update-level event includes bottomright');
|
||||||
ok('currenttime' in event, 'update-level event includes currenttime');
|
assert.ok('currenttime' in event, 'update-level event includes currenttime');
|
||||||
ok('best' in event, 'update-level event includes best');
|
assert.ok('best' in event, 'update-level event includes best');
|
||||||
});
|
});
|
||||||
|
|
||||||
viewer.addHandler('update-tile', function updateTileHandler(event) {
|
viewer.addHandler('update-tile', function updateTileHandler(event) {
|
||||||
viewer.removeHandler('update-tile', updateTileHandler);
|
viewer.removeHandler('update-tile', updateTileHandler);
|
||||||
handlerCount++;
|
handlerCount++;
|
||||||
equal(event.eventSource, viewer, 'sender of update-tile event was viewer');
|
assert.equal(event.eventSource, viewer, 'sender of update-tile event was viewer');
|
||||||
equal(event.tiledImage, image, 'tiledImage of update-level event is correct');
|
assert.equal(event.tiledImage, image, 'tiledImage of update-level event is correct');
|
||||||
ok(event.tile, 'update-tile event includes tile');
|
assert.ok(event.tile, 'update-tile event includes tile');
|
||||||
});
|
});
|
||||||
|
|
||||||
viewer.addHandler('tile-drawing', function tileDrawingHandler(event) {
|
viewer.addHandler('tile-drawing', function tileDrawingHandler(event) {
|
||||||
viewer.removeHandler('tile-drawing', tileDrawingHandler);
|
viewer.removeHandler('tile-drawing', tileDrawingHandler);
|
||||||
handlerCount++;
|
handlerCount++;
|
||||||
equal(event.eventSource, viewer, 'sender of tile-drawing event was viewer');
|
assert.equal(event.eventSource, viewer, 'sender of tile-drawing event was viewer');
|
||||||
equal(event.tiledImage, image, 'tiledImage of update-level event is correct');
|
assert.equal(event.tiledImage, image, 'tiledImage of update-level event is correct');
|
||||||
ok(event.tile, 'tile-drawing event includes a tile');
|
assert.ok(event.tile, 'tile-drawing event includes a tile');
|
||||||
ok(event.context, 'tile-drawing event includes a context');
|
assert.ok(event.context, 'tile-drawing event includes a context');
|
||||||
ok(event.rendered, 'tile-drawing event includes a rendered');
|
assert.ok(event.rendered, 'tile-drawing event includes a rendered');
|
||||||
});
|
});
|
||||||
|
|
||||||
viewer.addHandler('tile-drawn', function tileDrawnHandler(event) {
|
viewer.addHandler('tile-drawn', function tileDrawnHandler(event) {
|
||||||
viewer.removeHandler('tile-drawn', tileDrawnHandler);
|
viewer.removeHandler('tile-drawn', tileDrawnHandler);
|
||||||
handlerCount++;
|
handlerCount++;
|
||||||
equal(event.eventSource, viewer, 'sender of tile-drawn event was viewer');
|
assert.equal(event.eventSource, viewer, 'sender of tile-drawn event was viewer');
|
||||||
equal(event.tiledImage, image, 'tiledImage of update-level event is correct');
|
assert.equal(event.tiledImage, image, 'tiledImage of update-level event is correct');
|
||||||
ok(event.tile, 'tile-drawn event includes tile');
|
assert.ok(event.tile, 'tile-drawn event includes tile');
|
||||||
|
|
||||||
equal(handlerCount, 4, 'correct number of handlers called');
|
assert.equal(handlerCount, 4, 'correct number of handlers called');
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
image.draw();
|
image.draw();
|
||||||
@ -170,49 +173,51 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('reset', function() {
|
QUnit.test('reset', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer.addHandler('tile-drawn', function updateHandler() {
|
viewer.addHandler('tile-drawn', function updateHandler() {
|
||||||
viewer.removeHandler('tile-drawn', updateHandler);
|
viewer.removeHandler('tile-drawn', updateHandler);
|
||||||
ok(viewer.tileCache.numTilesLoaded() > 0, 'we have tiles after tile-drawn');
|
assert.ok(viewer.tileCache.numTilesLoaded() > 0, 'we have tiles after tile-drawn');
|
||||||
viewer.world.getItemAt(0).reset();
|
viewer.world.getItemAt(0).reset();
|
||||||
equal(viewer.tileCache.numTilesLoaded(), 0, 'no tiles after reset');
|
assert.equal(viewer.tileCache.numTilesLoaded(), 0, 'no tiles after reset');
|
||||||
|
|
||||||
viewer.addHandler('tile-drawn', function updateHandler2() {
|
viewer.addHandler('tile-drawn', function updateHandler2() {
|
||||||
viewer.removeHandler('tile-drawn', updateHandler2);
|
viewer.removeHandler('tile-drawn', updateHandler2);
|
||||||
ok(viewer.tileCache.numTilesLoaded() > 0, 'more tiles load');
|
assert.ok(viewer.tileCache.numTilesLoaded() > 0, 'more tiles load');
|
||||||
viewer.world.getItemAt(0).destroy();
|
viewer.world.getItemAt(0).destroy();
|
||||||
equal(viewer.tileCache.numTilesLoaded(), 0, 'no tiles after destroy');
|
assert.equal(viewer.tileCache.numTilesLoaded(), 0, 'no tiles after destroy');
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
equal(viewer.tileCache.numTilesLoaded(), 0, 'no tiles at start');
|
assert.equal(viewer.tileCache.numTilesLoaded(), 0, 'no tiles at start');
|
||||||
|
|
||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('clip', function() {
|
QUnit.test('clip', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var clip = new OpenSeadragon.Rect(100, 100, 800, 800);
|
var clip = new OpenSeadragon.Rect(100, 100, 800, 800);
|
||||||
|
|
||||||
viewer.addHandler('open', function() {
|
viewer.addHandler('open', function() {
|
||||||
var image = viewer.world.getItemAt(0);
|
var image = viewer.world.getItemAt(0);
|
||||||
propEqual(image.getClip(), clip, 'image has correct clip');
|
assert.propEqual(image.getClip(), clip, 'image has correct clip');
|
||||||
|
|
||||||
image.setClip(null);
|
image.setClip(null);
|
||||||
equal(image.getClip(), null, 'clip is cleared');
|
assert.equal(image.getClip(), null, 'clip is cleared');
|
||||||
|
|
||||||
image.setClip(clip);
|
image.setClip(clip);
|
||||||
propEqual(image.getClip(), clip, 'clip is set correctly');
|
assert.propEqual(image.getClip(), clip, 'clip is set correctly');
|
||||||
|
|
||||||
Util.spyOnce(viewer.drawer, 'setClip', function(rect) {
|
Util.spyOnce(viewer.drawer, 'setClip', function(rect) {
|
||||||
var homeBounds = viewer.viewport.getHomeBounds();
|
var homeBounds = viewer.viewport.getHomeBounds();
|
||||||
var canvasClip = viewer.drawer
|
var canvasClip = viewer.drawer
|
||||||
.viewportToDrawerRectangle(homeBounds);
|
.viewportToDrawerRectangle(homeBounds);
|
||||||
var precision = 0.00000001;
|
var precision = 0.00000001;
|
||||||
Util.assertRectangleEquals(rect, canvasClip, precision,
|
Util.assertRectangleEquals(assert, rect, canvasClip, precision,
|
||||||
'clipping should be ' + canvasClip);
|
'clipping should be ' + canvasClip);
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -223,15 +228,16 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('clip-change event', function() {
|
QUnit.test('clip-change event', function(assert) {
|
||||||
expect(0);
|
var done = assert.async();
|
||||||
|
assert.expect(0);
|
||||||
var clip = new OpenSeadragon.Rect(100, 100, 800, 800);
|
var clip = new OpenSeadragon.Rect(100, 100, 800, 800);
|
||||||
|
|
||||||
viewer.addHandler('open', function() {
|
viewer.addHandler('open', function() {
|
||||||
var image = viewer.world.getItemAt(0);
|
var image = viewer.world.getItemAt(0);
|
||||||
image.addOnceHandler('clip-change', function() {
|
image.addOnceHandler('clip-change', function() {
|
||||||
image.addOnceHandler('clip-change', function() {
|
image.addOnceHandler('clip-change', function() {
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
image.setClip(clip);
|
image.setClip(clip);
|
||||||
});
|
});
|
||||||
@ -244,23 +250,24 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('getClipBounds', function() {
|
QUnit.test('getClipBounds', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var clip = new OpenSeadragon.Rect(100, 200, 800, 500);
|
var clip = new OpenSeadragon.Rect(100, 200, 800, 500);
|
||||||
|
|
||||||
viewer.addHandler('open', function() {
|
viewer.addHandler('open', function() {
|
||||||
var image = viewer.world.getItemAt(0);
|
var image = viewer.world.getItemAt(0);
|
||||||
var bounds = image.getClippedBounds();
|
var bounds = image.getClippedBounds();
|
||||||
var expectedBounds = new OpenSeadragon.Rect(1.2, 1.4, 1.6, 1);
|
var expectedBounds = new OpenSeadragon.Rect(1.2, 1.4, 1.6, 1);
|
||||||
propEqual(bounds, expectedBounds,
|
assert.propEqual(bounds, expectedBounds,
|
||||||
'getClipBounds should take clipping into account.');
|
'getClipBounds should take clipping into account.');
|
||||||
|
|
||||||
image = viewer.world.getItemAt(1);
|
image = viewer.world.getItemAt(1);
|
||||||
bounds = image.getClippedBounds();
|
bounds = image.getClippedBounds();
|
||||||
expectedBounds = new OpenSeadragon.Rect(1, 2, 2, 2);
|
expectedBounds = new OpenSeadragon.Rect(1, 2, 2, 2);
|
||||||
propEqual(bounds, expectedBounds,
|
assert.propEqual(bounds, expectedBounds,
|
||||||
'getClipBounds should work when no clipping set.');
|
'getClipBounds should work when no clipping set.');
|
||||||
|
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
viewer.open([{
|
viewer.open([{
|
||||||
@ -278,15 +285,15 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('opacity', function() {
|
QUnit.test('opacity', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
function testDefaultOpacity() {
|
function testDefaultOpacity() {
|
||||||
viewer.removeHandler('open', testDefaultOpacity);
|
viewer.removeHandler('open', testDefaultOpacity);
|
||||||
var image = viewer.world.getItemAt(0);
|
var image = viewer.world.getItemAt(0);
|
||||||
strictEqual(image.getOpacity(), 0.5, 'image has default opacity');
|
assert.strictEqual(image.getOpacity(), 0.5, 'image has default opacity');
|
||||||
|
|
||||||
image.setOpacity(1);
|
image.setOpacity(1);
|
||||||
strictEqual(image.getOpacity(), 1, 'opacity is set correctly');
|
assert.strictEqual(image.getOpacity(), 1, 'opacity is set correctly');
|
||||||
|
|
||||||
viewer.addHandler('open', testTileSourceOpacity);
|
viewer.addHandler('open', testTileSourceOpacity);
|
||||||
viewer.open({
|
viewer.open({
|
||||||
@ -298,12 +305,12 @@
|
|||||||
function testTileSourceOpacity() {
|
function testTileSourceOpacity() {
|
||||||
viewer.removeHandler('open', testTileSourceOpacity);
|
viewer.removeHandler('open', testTileSourceOpacity);
|
||||||
var image = viewer.world.getItemAt(0);
|
var image = viewer.world.getItemAt(0);
|
||||||
strictEqual(image.getOpacity(), 0.25, 'image has correct opacity');
|
assert.strictEqual(image.getOpacity(), 0.25, 'image has correct opacity');
|
||||||
|
|
||||||
image.setOpacity(0);
|
image.setOpacity(0);
|
||||||
strictEqual(image.getOpacity(), 0, 'opacity is set correctly');
|
assert.strictEqual(image.getOpacity(), 0, 'opacity is set correctly');
|
||||||
|
|
||||||
start();
|
done();
|
||||||
}
|
}
|
||||||
|
|
||||||
viewer.addHandler('open', testDefaultOpacity);
|
viewer.addHandler('open', testDefaultOpacity);
|
||||||
@ -315,20 +322,20 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('rotation', function() {
|
QUnit.test('rotation', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
function testDefaultRotation() {
|
function testDefaultRotation() {
|
||||||
var image = viewer.world.getItemAt(0);
|
var image = viewer.world.getItemAt(0);
|
||||||
strictEqual(image.getRotation(true), 0, 'image has default current rotation');
|
assert.strictEqual(image.getRotation(true), 0, 'image has default current rotation');
|
||||||
strictEqual(image.getRotation(false), 0, 'image has default target rotation');
|
assert.strictEqual(image.getRotation(false), 0, 'image has default target rotation');
|
||||||
|
|
||||||
image.setRotation(400);
|
image.setRotation(400);
|
||||||
strictEqual(image.getRotation(true), 0, 'current rotation is not changed');
|
assert.strictEqual(image.getRotation(true), 0, 'current rotation is not changed');
|
||||||
strictEqual(image.getRotation(false), 400, 'target rotation is set correctly');
|
assert.strictEqual(image.getRotation(false), 400, 'target rotation is set correctly');
|
||||||
|
|
||||||
image.setRotation(200, true);
|
image.setRotation(200, true);
|
||||||
strictEqual(image.getRotation(true), 200, 'current rotation is set correctly');
|
assert.strictEqual(image.getRotation(true), 200, 'current rotation is set correctly');
|
||||||
strictEqual(image.getRotation(false), 200, 'target rotation is set correctly');
|
assert.strictEqual(image.getRotation(false), 200, 'target rotation is set correctly');
|
||||||
|
|
||||||
viewer.addOnceHandler('open', testTileSourceRotation);
|
viewer.addOnceHandler('open', testTileSourceRotation);
|
||||||
viewer.open({
|
viewer.open({
|
||||||
@ -339,9 +346,9 @@
|
|||||||
|
|
||||||
function testTileSourceRotation() {
|
function testTileSourceRotation() {
|
||||||
var image = viewer.world.getItemAt(0);
|
var image = viewer.world.getItemAt(0);
|
||||||
strictEqual(image.getRotation(true), -60, 'image has correct current rotation');
|
assert.strictEqual(image.getRotation(true), -60, 'image has correct current rotation');
|
||||||
strictEqual(image.getRotation(false), -60, 'image has correct target rotation');
|
assert.strictEqual(image.getRotation(false), -60, 'image has correct target rotation');
|
||||||
start();
|
done();
|
||||||
}
|
}
|
||||||
|
|
||||||
viewer.addOnceHandler('open', testDefaultRotation);
|
viewer.addOnceHandler('open', testDefaultRotation);
|
||||||
@ -350,10 +357,10 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('fitBounds', function() {
|
QUnit.test('fitBounds', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
function assertRectEquals(actual, expected, message) {
|
function assertRectEquals(actual, expected, message) {
|
||||||
ok(actual.equals(expected), message + ' should be ' +
|
assert.ok(actual.equals(expected), message + ' should be ' +
|
||||||
expected.toString() + ', found ' + actual.toString());
|
expected.toString() + ', found ' + actual.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,7 +393,7 @@
|
|||||||
actualBounds = wideImage.getBounds(true);
|
actualBounds = wideImage.getBounds(true);
|
||||||
expectedBounds = new OpenSeadragon.Rect(0, 1.75, 1, 0.25);
|
expectedBounds = new OpenSeadragon.Rect(0, 1.75, 1, 0.25);
|
||||||
assertRectEquals(actualBounds, expectedBounds, 'Wide image bounds');
|
assertRectEquals(actualBounds, expectedBounds, 'Wide image bounds');
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
viewer.open([
|
viewer.open([
|
||||||
@ -397,10 +404,10 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('fitBounds in constructor', function() {
|
QUnit.test('fitBounds in constructor', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
function assertRectEquals(actual, expected, message) {
|
function assertRectEquals(actual, expected, message) {
|
||||||
ok(actual.equals(expected), message + ' should be ' +
|
assert.ok(actual.equals(expected), message + ' should be ' +
|
||||||
expected.toString() + ', found ' + actual.toString());
|
expected.toString() + ', found ' + actual.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -421,7 +428,7 @@
|
|||||||
actualBounds = wideImage.getBounds(true);
|
actualBounds = wideImage.getBounds(true);
|
||||||
expectedBounds = new OpenSeadragon.Rect(0, 1.75, 1, 0.25);
|
expectedBounds = new OpenSeadragon.Rect(0, 1.75, 1, 0.25);
|
||||||
assertRectEquals(actualBounds, expectedBounds, 'Wide image bounds');
|
assertRectEquals(actualBounds, expectedBounds, 'Wide image bounds');
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
viewer.open([{
|
viewer.open([{
|
||||||
@ -443,10 +450,10 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('fitBounds with clipping', function() {
|
QUnit.test('fitBounds with clipping', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
function assertRectEquals(actual, expected, message) {
|
function assertRectEquals(actual, expected, message) {
|
||||||
ok(actual.equals(expected), message + ' should be ' +
|
assert.ok(actual.equals(expected), message + ' should be ' +
|
||||||
expected.toString() + ', found ' + actual.toString());
|
expected.toString() + ', found ' + actual.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -467,7 +474,7 @@
|
|||||||
actualBounds = wideImage.getBounds(true);
|
actualBounds = wideImage.getBounds(true);
|
||||||
expectedBounds = new OpenSeadragon.Rect(1, 1, 16, 4);
|
expectedBounds = new OpenSeadragon.Rect(1, 1, 16, 4);
|
||||||
assertRectEquals(actualBounds, expectedBounds, 'Wide image bounds');
|
assertRectEquals(actualBounds, expectedBounds, 'Wide image bounds');
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
viewer.open([{
|
viewer.open([{
|
||||||
@ -488,27 +495,28 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('fullyLoaded', function() {
|
QUnit.test('fullyLoaded', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer.addHandler('open', function openHandler() {
|
viewer.addHandler('open', function openHandler() {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
|
|
||||||
var image = viewer.world.getItemAt(0);
|
var image = viewer.world.getItemAt(0);
|
||||||
equal(image.getFullyLoaded(), false, 'not fully loaded at first');
|
assert.equal(image.getFullyLoaded(), false, 'not fully loaded at first');
|
||||||
|
|
||||||
var count = 0;
|
var count = 0;
|
||||||
|
|
||||||
var fullyLoadedChangeHandler = function(event) {
|
var fullyLoadedChangeHandler = function(event) {
|
||||||
if (count === 0) {
|
if (count === 0) {
|
||||||
equal(event.fullyLoaded, true, 'event includes true fullyLoaded property');
|
assert.equal(event.fullyLoaded, true, 'event includes true fullyLoaded property');
|
||||||
equal(image.getFullyLoaded(), true, 'image is fully loaded after event');
|
assert.equal(image.getFullyLoaded(), true, 'image is fully loaded after event');
|
||||||
viewer.viewport.zoomBy(5, null, true);
|
viewer.viewport.zoomBy(5, null, true);
|
||||||
} else if (count === 1) {
|
} else if (count === 1) {
|
||||||
equal(event.fullyLoaded, false, 'event includes false fullyLoaded property');
|
assert.equal(event.fullyLoaded, false, 'event includes false fullyLoaded property');
|
||||||
equal(image.getFullyLoaded(), false, 'image is not fully loaded after zoom');
|
assert.equal(image.getFullyLoaded(), false, 'image is not fully loaded after zoom');
|
||||||
} else {
|
} else {
|
||||||
image.removeHandler('fully-loaded-change', fullyLoadedChangeHandler);
|
image.removeHandler('fully-loaded-change', fullyLoadedChangeHandler);
|
||||||
equal(image.getFullyLoaded(), true, 'image is once again fully loaded');
|
assert.equal(image.getFullyLoaded(), true, 'image is once again fully loaded');
|
||||||
start();
|
done();
|
||||||
}
|
}
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
@ -529,7 +537,7 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
test('_getCornerTiles without wrapping', function() {
|
QUnit.test('_getCornerTiles without wrapping', function(assert) {
|
||||||
var tiledImageMock = {
|
var tiledImageMock = {
|
||||||
wrapHorizontal: false,
|
wrapHorizontal: false,
|
||||||
wrapVertical: false,
|
wrapVertical: false,
|
||||||
@ -548,10 +556,10 @@
|
|||||||
function assertCornerTiles(topLeftBound, bottomRightBound,
|
function assertCornerTiles(topLeftBound, bottomRightBound,
|
||||||
expectedTopLeft, expectedBottomRight) {
|
expectedTopLeft, expectedBottomRight) {
|
||||||
var cornerTiles = _getCornerTiles(11, topLeftBound, bottomRightBound);
|
var cornerTiles = _getCornerTiles(11, topLeftBound, bottomRightBound);
|
||||||
ok(cornerTiles.topLeft.equals(expectedTopLeft),
|
assert.ok(cornerTiles.topLeft.equals(expectedTopLeft),
|
||||||
'Top left tile should be ' + expectedTopLeft.toString() +
|
'Top left tile should be ' + expectedTopLeft.toString() +
|
||||||
' found ' + cornerTiles.topLeft.toString());
|
' found ' + cornerTiles.topLeft.toString());
|
||||||
ok(cornerTiles.bottomRight.equals(expectedBottomRight),
|
assert.ok(cornerTiles.bottomRight.equals(expectedBottomRight),
|
||||||
'Bottom right tile should be ' + expectedBottomRight.toString() +
|
'Bottom right tile should be ' + expectedBottomRight.toString() +
|
||||||
' found ' + cornerTiles.bottomRight.toString());
|
' found ' + cornerTiles.bottomRight.toString());
|
||||||
}
|
}
|
||||||
@ -561,7 +569,7 @@
|
|||||||
new OpenSeadragon.Point(1, 10 / 15),
|
new OpenSeadragon.Point(1, 10 / 15),
|
||||||
new OpenSeadragon.Point(0, 0),
|
new OpenSeadragon.Point(0, 0),
|
||||||
new OpenSeadragon.Point(7, 6)
|
new OpenSeadragon.Point(7, 6)
|
||||||
)
|
);
|
||||||
|
|
||||||
// Floating point errors should be handled
|
// Floating point errors should be handled
|
||||||
assertCornerTiles(
|
assertCornerTiles(
|
||||||
@ -569,17 +577,17 @@
|
|||||||
new OpenSeadragon.Point(1 + 1e-14, 10 / 15 + 1e-14),
|
new OpenSeadragon.Point(1 + 1e-14, 10 / 15 + 1e-14),
|
||||||
new OpenSeadragon.Point(0, 0),
|
new OpenSeadragon.Point(0, 0),
|
||||||
new OpenSeadragon.Point(7, 6)
|
new OpenSeadragon.Point(7, 6)
|
||||||
)
|
);
|
||||||
|
|
||||||
assertCornerTiles(
|
assertCornerTiles(
|
||||||
new OpenSeadragon.Point(0.3, 0.5),
|
new OpenSeadragon.Point(0.3, 0.5),
|
||||||
new OpenSeadragon.Point(0.5, 0.6),
|
new OpenSeadragon.Point(0.5, 0.6),
|
||||||
new OpenSeadragon.Point(2, 5),
|
new OpenSeadragon.Point(2, 5),
|
||||||
new OpenSeadragon.Point(3, 6)
|
new OpenSeadragon.Point(3, 6)
|
||||||
)
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('_getCornerTiles with horizontal wrapping', function() {
|
QUnit.test('_getCornerTiles with horizontal wrapping', function(assert) {
|
||||||
var tiledImageMock = {
|
var tiledImageMock = {
|
||||||
wrapHorizontal: true,
|
wrapHorizontal: true,
|
||||||
wrapVertical: false,
|
wrapVertical: false,
|
||||||
@ -598,10 +606,10 @@
|
|||||||
function assertCornerTiles(topLeftBound, bottomRightBound,
|
function assertCornerTiles(topLeftBound, bottomRightBound,
|
||||||
expectedTopLeft, expectedBottomRight) {
|
expectedTopLeft, expectedBottomRight) {
|
||||||
var cornerTiles = _getCornerTiles(11, topLeftBound, bottomRightBound);
|
var cornerTiles = _getCornerTiles(11, topLeftBound, bottomRightBound);
|
||||||
ok(cornerTiles.topLeft.equals(expectedTopLeft),
|
assert.ok(cornerTiles.topLeft.equals(expectedTopLeft),
|
||||||
'Top left tile should be ' + expectedTopLeft.toString() +
|
'Top left tile should be ' + expectedTopLeft.toString() +
|
||||||
' found ' + cornerTiles.topLeft.toString());
|
' found ' + cornerTiles.topLeft.toString());
|
||||||
ok(cornerTiles.bottomRight.equals(expectedBottomRight),
|
assert.ok(cornerTiles.bottomRight.equals(expectedBottomRight),
|
||||||
'Bottom right tile should be ' + expectedBottomRight.toString() +
|
'Bottom right tile should be ' + expectedBottomRight.toString() +
|
||||||
' found ' + cornerTiles.bottomRight.toString());
|
' found ' + cornerTiles.bottomRight.toString());
|
||||||
}
|
}
|
||||||
@ -611,24 +619,24 @@
|
|||||||
new OpenSeadragon.Point(1, 10 / 15),
|
new OpenSeadragon.Point(1, 10 / 15),
|
||||||
new OpenSeadragon.Point(0, 0),
|
new OpenSeadragon.Point(0, 0),
|
||||||
new OpenSeadragon.Point(8, 6)
|
new OpenSeadragon.Point(8, 6)
|
||||||
)
|
);
|
||||||
|
|
||||||
assertCornerTiles(
|
assertCornerTiles(
|
||||||
new OpenSeadragon.Point(-1, 0),
|
new OpenSeadragon.Point(-1, 0),
|
||||||
new OpenSeadragon.Point(0.5, 10 / 15 + 1e-14),
|
new OpenSeadragon.Point(0.5, 10 / 15 + 1e-14),
|
||||||
new OpenSeadragon.Point(-8, 0),
|
new OpenSeadragon.Point(-8, 0),
|
||||||
new OpenSeadragon.Point(3, 6)
|
new OpenSeadragon.Point(3, 6)
|
||||||
)
|
);
|
||||||
|
|
||||||
assertCornerTiles(
|
assertCornerTiles(
|
||||||
new OpenSeadragon.Point(1.3, 0.5),
|
new OpenSeadragon.Point(1.3, 0.5),
|
||||||
new OpenSeadragon.Point(1.5, 0.6),
|
new OpenSeadragon.Point(1.5, 0.6),
|
||||||
new OpenSeadragon.Point(10, 5),
|
new OpenSeadragon.Point(10, 5),
|
||||||
new OpenSeadragon.Point(11, 6)
|
new OpenSeadragon.Point(11, 6)
|
||||||
)
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('_getCornerTiles with vertical wrapping', function() {
|
QUnit.test('_getCornerTiles with vertical wrapping', function(assert) {
|
||||||
var tiledImageMock = {
|
var tiledImageMock = {
|
||||||
wrapHorizontal: false,
|
wrapHorizontal: false,
|
||||||
wrapVertical: true,
|
wrapVertical: true,
|
||||||
@ -647,10 +655,10 @@
|
|||||||
function assertCornerTiles(topLeftBound, bottomRightBound,
|
function assertCornerTiles(topLeftBound, bottomRightBound,
|
||||||
expectedTopLeft, expectedBottomRight) {
|
expectedTopLeft, expectedBottomRight) {
|
||||||
var cornerTiles = _getCornerTiles(11, topLeftBound, bottomRightBound);
|
var cornerTiles = _getCornerTiles(11, topLeftBound, bottomRightBound);
|
||||||
ok(cornerTiles.topLeft.equals(expectedTopLeft),
|
assert.ok(cornerTiles.topLeft.equals(expectedTopLeft),
|
||||||
'Top left tile should be ' + expectedTopLeft.toString() +
|
'Top left tile should be ' + expectedTopLeft.toString() +
|
||||||
' found ' + cornerTiles.topLeft.toString());
|
' found ' + cornerTiles.topLeft.toString());
|
||||||
ok(cornerTiles.bottomRight.equals(expectedBottomRight),
|
assert.ok(cornerTiles.bottomRight.equals(expectedBottomRight),
|
||||||
'Bottom right tile should be ' + expectedBottomRight.toString() +
|
'Bottom right tile should be ' + expectedBottomRight.toString() +
|
||||||
' found ' + cornerTiles.bottomRight.toString());
|
' found ' + cornerTiles.bottomRight.toString());
|
||||||
}
|
}
|
||||||
@ -660,21 +668,21 @@
|
|||||||
new OpenSeadragon.Point(1, 10 / 15),
|
new OpenSeadragon.Point(1, 10 / 15),
|
||||||
new OpenSeadragon.Point(0, 0),
|
new OpenSeadragon.Point(0, 0),
|
||||||
new OpenSeadragon.Point(7, 7)
|
new OpenSeadragon.Point(7, 7)
|
||||||
)
|
);
|
||||||
|
|
||||||
assertCornerTiles(
|
assertCornerTiles(
|
||||||
new OpenSeadragon.Point(0, -10 / 15 / 2),
|
new OpenSeadragon.Point(0, -10 / 15 / 2),
|
||||||
new OpenSeadragon.Point(0.5, 0.5),
|
new OpenSeadragon.Point(0.5, 0.5),
|
||||||
new OpenSeadragon.Point(0, -4),
|
new OpenSeadragon.Point(0, -4),
|
||||||
new OpenSeadragon.Point(3, 5)
|
new OpenSeadragon.Point(3, 5)
|
||||||
)
|
);
|
||||||
|
|
||||||
assertCornerTiles(
|
assertCornerTiles(
|
||||||
new OpenSeadragon.Point(0, 10 / 15 + 0.1),
|
new OpenSeadragon.Point(0, 10 / 15 + 0.1),
|
||||||
new OpenSeadragon.Point(0.3, 10 / 15 + 0.3),
|
new OpenSeadragon.Point(0.3, 10 / 15 + 0.3),
|
||||||
new OpenSeadragon.Point(0, 7),
|
new OpenSeadragon.Point(0, 7),
|
||||||
new OpenSeadragon.Point(2, 9)
|
new OpenSeadragon.Point(2, 9)
|
||||||
)
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -1,33 +1,33 @@
|
|||||||
/* global module, ok, equal, start, test, testLog, Util */
|
/* global QUnit, testLog, Util */
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
module('TileSource', {
|
QUnit.module('TileSource', {
|
||||||
setup: function() {
|
beforeEach: function() {
|
||||||
testLog.reset();
|
testLog.reset();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
test("should set sane tile size defaults", function() {
|
QUnit.test("should set sane tile size defaults", function(assert) {
|
||||||
var source = new OpenSeadragon.TileSource();
|
var source = new OpenSeadragon.TileSource();
|
||||||
|
|
||||||
equal(source.getTileWidth(), 0, "getTileWidth() should return 0 if not provided a size");
|
assert.equal(source.getTileWidth(), 0, "getTileWidth() should return 0 if not provided a size");
|
||||||
equal(source.getTileHeight(), 0, "getTileHeight() should return 0 if not provided a size");
|
assert.equal(source.getTileHeight(), 0, "getTileHeight() should return 0 if not provided a size");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("providing tileSize", function(){
|
QUnit.test("providing tileSize", function(assert){
|
||||||
var tileSize = 256,
|
var tileSize = 256,
|
||||||
source = new OpenSeadragon.TileSource({
|
source = new OpenSeadragon.TileSource({
|
||||||
tileSize: tileSize
|
tileSize: tileSize
|
||||||
});
|
});
|
||||||
|
|
||||||
equal(source.tileSize, undefined, "tileSize should not be set on the tileSource");
|
assert.equal(source.tileSize, undefined, "tileSize should not be set on the tileSource");
|
||||||
equal(source.getTileWidth(), tileSize, "getTileWidth() should equal tileSize");
|
assert.equal(source.getTileWidth(), tileSize, "getTileWidth() should equal tileSize");
|
||||||
equal(source.getTileHeight(), tileSize, "getTileHeight() should equal tileSize");
|
assert.equal(source.getTileHeight(), tileSize, "getTileHeight() should equal tileSize");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
test("providing tileWidth and tileHeight", function(){
|
QUnit.test("providing tileWidth and tileHeight", function(assert){
|
||||||
var tileWidth = 256,
|
var tileWidth = 256,
|
||||||
tileHeight = 512,
|
tileHeight = 512,
|
||||||
source = new OpenSeadragon.TileSource({
|
source = new OpenSeadragon.TileSource({
|
||||||
@ -35,20 +35,20 @@
|
|||||||
tileHeight: tileHeight
|
tileHeight: tileHeight
|
||||||
});
|
});
|
||||||
|
|
||||||
equal(source._tileWidth, tileWidth, "tileWidth option should set _tileWidth");
|
assert.equal(source._tileWidth, tileWidth, "tileWidth option should set _tileWidth");
|
||||||
equal(source._tileHeight, tileHeight, "tileHeight option should set _tileHeight");
|
assert.equal(source._tileHeight, tileHeight, "tileHeight option should set _tileHeight");
|
||||||
equal(source.tileWidth, undefined, "tileWidth should be renamed _tileWidth");
|
assert.equal(source.tileWidth, undefined, "tileWidth should be renamed _tileWidth");
|
||||||
equal(source.tileHeight, undefined, "tileHeight should be renamed _tileHeight");
|
assert.equal(source.tileHeight, undefined, "tileHeight should be renamed _tileHeight");
|
||||||
equal(source.getTileWidth(), tileWidth, "getTileWidth() should equal tileWidth");
|
assert.equal(source.getTileWidth(), tileWidth, "getTileWidth() should equal tileWidth");
|
||||||
equal(source.getTileHeight(), tileHeight, "getTileHeight() should equal tileHeight");
|
assert.equal(source.getTileHeight(), tileHeight, "getTileHeight() should equal tileHeight");
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getTileSize() deprecation', function() {
|
QUnit.test('getTileSize() deprecation', function(assert) {
|
||||||
var source = new OpenSeadragon.TileSource();
|
var source = new OpenSeadragon.TileSource();
|
||||||
Util.testDeprecation(source, 'getTileSize');
|
Util.testDeprecation(assert, source, 'getTileSize');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getTileAtPoint', function() {
|
QUnit.test('getTileAtPoint', function(assert) {
|
||||||
var tileSource = new OpenSeadragon.TileSource({
|
var tileSource = new OpenSeadragon.TileSource({
|
||||||
width: 1500,
|
width: 1500,
|
||||||
height: 1000,
|
height: 1000,
|
||||||
@ -57,11 +57,11 @@
|
|||||||
tileOverlap: 1,
|
tileOverlap: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
equal(tileSource.maxLevel, 11, "The max level should be 11.");
|
assert.equal(tileSource.maxLevel, 11, "The max level should be 11.");
|
||||||
|
|
||||||
function assertTileAtPoint(level, position, expected) {
|
function assertTileAtPoint(level, position, expected) {
|
||||||
var actual = tileSource.getTileAtPoint(level, position);
|
var actual = tileSource.getTileAtPoint(level, position);
|
||||||
ok(actual.equals(expected), "The tile at level " + level +
|
assert.ok(actual.equals(expected), "The tile at level " + level +
|
||||||
", position " + position.toString() +
|
", position " + position.toString() +
|
||||||
" should be tile " + expected.toString() +
|
" should be tile " + expected.toString() +
|
||||||
" got " + actual.toString());
|
" got " + actual.toString());
|
||||||
|
@ -1,20 +1,19 @@
|
|||||||
/* global module, asyncTest, $, ok, equal, notEqual, start, test, Util, testLog */
|
/* global QUnit, Util, testLog */
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var viewer;
|
QUnit.module('TileSourceCollection', {
|
||||||
|
beforeEach: function () {
|
||||||
module('TileSourceCollection', {
|
|
||||||
setup: function () {
|
|
||||||
testLog.reset();
|
testLog.reset();
|
||||||
},
|
},
|
||||||
teardown: function () {
|
afterEach: function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('deprecation', function() {
|
QUnit.test('deprecation', function(assert) {
|
||||||
Util.testDeprecation(OpenSeadragon, 'TileSourceCollection');
|
var done = assert.async();
|
||||||
start();
|
Util.testDeprecation(assert, OpenSeadragon, 'TileSourceCollection');
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
/* global module, asyncTest, $, ok, equal, notEqual, start, test, Util, testLog */
|
/* global QUnit, $, Util, testLog */
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
var viewer;
|
var viewer;
|
||||||
var precision = 0.00000001;
|
var precision = 0.00000001;
|
||||||
|
|
||||||
module('Units', {
|
QUnit.module('Units', {
|
||||||
setup: function () {
|
beforeEach: function () {
|
||||||
var example = $('<div id="unitsexample"></div>').appendTo("#qunit-fixture");
|
$('<div id="unitsexample"></div>').appendTo("#qunit-fixture");
|
||||||
|
|
||||||
testLog.reset();
|
testLog.reset();
|
||||||
|
|
||||||
@ -16,7 +16,7 @@
|
|||||||
springStiffness: 100 // Faster animation = faster tests
|
springStiffness: 100 // Faster animation = faster tests
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
teardown: function () {
|
afterEach: function () {
|
||||||
if (viewer && viewer.close) {
|
if (viewer && viewer.close) {
|
||||||
viewer.close();
|
viewer.close();
|
||||||
}
|
}
|
||||||
@ -26,62 +26,62 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function pointEqual(a, b, message) {
|
function pointEqual(assert, a, b, message) {
|
||||||
Util.assessNumericValue(a.x, b.x, precision, message);
|
Util.assessNumericValue(assert, a.x, b.x, precision, message);
|
||||||
Util.assessNumericValue(a.y, b.y, precision, message);
|
Util.assessNumericValue(assert, a.y, b.y, precision, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that f^-1 ( f(x) ) = x
|
// Check that f^-1 ( f(x) ) = x
|
||||||
function checkPoint(context) {
|
function checkPoint(assert, context) {
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
var point = new OpenSeadragon.Point(15, 12);
|
var point = new OpenSeadragon.Point(15, 12);
|
||||||
var result = viewport.viewerElementToImageCoordinates(
|
var result = viewport.viewerElementToImageCoordinates(
|
||||||
viewport.imageToViewerElementCoordinates(point));
|
viewport.imageToViewerElementCoordinates(point));
|
||||||
pointEqual(result, point, 'viewerElement and image ' + context);
|
pointEqual(assert, result, point, 'viewerElement and image ' + context);
|
||||||
|
|
||||||
result = viewport.windowToImageCoordinates(
|
result = viewport.windowToImageCoordinates(
|
||||||
viewport.imageToWindowCoordinates(point));
|
viewport.imageToWindowCoordinates(point));
|
||||||
pointEqual(result, point, 'window and image ' + context);
|
pointEqual(assert, result, point, 'window and image ' + context);
|
||||||
|
|
||||||
result = viewport.viewerElementToViewportCoordinates(
|
result = viewport.viewerElementToViewportCoordinates(
|
||||||
viewport.viewportToViewerElementCoordinates(point));
|
viewport.viewportToViewerElementCoordinates(point));
|
||||||
pointEqual(result, point, 'viewerElement and viewport ' + context);
|
pointEqual(assert, result, point, 'viewerElement and viewport ' + context);
|
||||||
|
|
||||||
result = viewport.windowToViewportCoordinates(
|
result = viewport.windowToViewportCoordinates(
|
||||||
viewport.viewportToWindowCoordinates(point));
|
viewport.viewportToWindowCoordinates(point));
|
||||||
pointEqual(result, point, 'window and viewport ' + context);
|
pointEqual(assert, result, point, 'window and viewport ' + context);
|
||||||
|
|
||||||
for (var i = 0; i < viewer.world.getItemCount(); i++) {
|
for (var i = 0; i < viewer.world.getItemCount(); i++) {
|
||||||
var tiledImage = viewer.world.getItemAt(i);
|
var tiledImage = viewer.world.getItemAt(i);
|
||||||
result = tiledImage.viewportToImageCoordinates(
|
result = tiledImage.viewportToImageCoordinates(
|
||||||
tiledImage.imageToViewportCoordinates(point));
|
tiledImage.imageToViewportCoordinates(point));
|
||||||
pointEqual(result, point, 'viewport and tiled image ' + i + context);
|
pointEqual(assert, result, point, 'viewport and tiled image ' + i + context);
|
||||||
|
|
||||||
result = tiledImage.viewerElementToImageCoordinates(
|
result = tiledImage.viewerElementToImageCoordinates(
|
||||||
tiledImage.imageToViewerElementCoordinates(point));
|
tiledImage.imageToViewerElementCoordinates(point));
|
||||||
pointEqual(result, point, 'viewerElement and tiled image ' + i + context);
|
pointEqual(assert, result, point, 'viewerElement and tiled image ' + i + context);
|
||||||
|
|
||||||
result = tiledImage.windowToImageCoordinates(
|
result = tiledImage.windowToImageCoordinates(
|
||||||
tiledImage.imageToWindowCoordinates(point));
|
tiledImage.imageToWindowCoordinates(point));
|
||||||
pointEqual(result, point, 'window and tiled image ' + i + context);
|
pointEqual(assert, result, point, 'window and tiled image ' + i + context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('Single image coordinates conversions', function () {
|
QUnit.test('Single image coordinates conversions', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer.addHandler("open", function () {
|
viewer.addHandler("open", function () {
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
var tiledImage = viewer.world.getItemAt(0);
|
var tiledImage = viewer.world.getItemAt(0);
|
||||||
|
|
||||||
var point0_0 = new OpenSeadragon.Point(0, 0);
|
var point0_0 = new OpenSeadragon.Point(0, 0);
|
||||||
var point = viewport.viewerElementToViewportCoordinates(point0_0);
|
var point = viewport.viewerElementToViewportCoordinates(point0_0);
|
||||||
pointEqual(point, point0_0, 'When opening, viewer coordinate 0,0 is also point 0,0');
|
pointEqual(assert, point, point0_0, 'When opening, viewer coordinate 0,0 is also point 0,0');
|
||||||
var viewportPixel = viewport.viewerElementToImageCoordinates(point0_0);
|
var viewportPixel = viewport.viewerElementToImageCoordinates(point0_0);
|
||||||
pointEqual(viewportPixel, point0_0, 'When opening, viewer coordinate 0,0 is also viewport pixel 0,0');
|
pointEqual(assert, viewportPixel, point0_0, 'When opening, viewer coordinate 0,0 is also viewport pixel 0,0');
|
||||||
var imagePixel = tiledImage.viewerElementToImageCoordinates(point0_0);
|
var imagePixel = tiledImage.viewerElementToImageCoordinates(point0_0);
|
||||||
pointEqual(imagePixel, point0_0, 'When opening, viewer coordinate 0,0 is also image pixel 0,0');
|
pointEqual(assert, imagePixel, point0_0, 'When opening, viewer coordinate 0,0 is also image pixel 0,0');
|
||||||
|
|
||||||
var viewerWidth = $(viewer.element).width();
|
var viewerWidth = $(viewer.element).width();
|
||||||
var imageWidth = viewer.source.dimensions.x;
|
var imageWidth = viewer.source.dimensions.x;
|
||||||
@ -90,17 +90,17 @@
|
|||||||
var imageTopRight = new OpenSeadragon.Point(imageWidth, 0);
|
var imageTopRight = new OpenSeadragon.Point(imageWidth, 0);
|
||||||
|
|
||||||
point = viewport.viewerElementToViewportCoordinates(viewerTopRight);
|
point = viewport.viewerElementToViewportCoordinates(viewerTopRight);
|
||||||
pointEqual(point, point1_0, 'Viewer top right has viewport coordinates 1,0.');
|
pointEqual(assert, point, point1_0, 'Viewer top right has viewport coordinates 1,0.');
|
||||||
viewportPixel = viewport.viewerElementToImageCoordinates(viewerTopRight);
|
viewportPixel = viewport.viewerElementToImageCoordinates(viewerTopRight);
|
||||||
pointEqual(viewportPixel, imageTopRight, 'Viewer top right has viewport pixel coordinates imageWidth,0.');
|
pointEqual(assert, viewportPixel, imageTopRight, 'Viewer top right has viewport pixel coordinates imageWidth,0.');
|
||||||
imagePixel = tiledImage.viewerElementToImageCoordinates(viewerTopRight);
|
imagePixel = tiledImage.viewerElementToImageCoordinates(viewerTopRight);
|
||||||
pointEqual(imagePixel, imageTopRight, 'Viewer top right has image pixel coordinates imageWidth,0.');
|
pointEqual(assert, imagePixel, imageTopRight, 'Viewer top right has image pixel coordinates imageWidth,0.');
|
||||||
|
|
||||||
checkPoint(' after opening');
|
checkPoint(assert, ' after opening');
|
||||||
viewer.addHandler('animation-finish', function animationHandler() {
|
viewer.addHandler('animation-finish', function animationHandler() {
|
||||||
viewer.removeHandler('animation-finish', animationHandler);
|
viewer.removeHandler('animation-finish', animationHandler);
|
||||||
checkPoint(' after zoom and pan');
|
checkPoint(assert, ' after zoom and pan');
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
viewer.viewport.zoomTo(0.8).panTo(new OpenSeadragon.Point(0.1, 0.2));
|
viewer.viewport.zoomTo(0.8).panTo(new OpenSeadragon.Point(0.1, 0.2));
|
||||||
});
|
});
|
||||||
@ -109,8 +109,8 @@
|
|||||||
|
|
||||||
|
|
||||||
// ---------
|
// ---------
|
||||||
asyncTest('Multiple images coordinates conversion', function () {
|
QUnit.test('Multiple images coordinates conversion', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer.addHandler("open", function () {
|
viewer.addHandler("open", function () {
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
var tiledImage1 = viewer.world.getItemAt(0);
|
var tiledImage1 = viewer.world.getItemAt(0);
|
||||||
@ -120,11 +120,11 @@
|
|||||||
|
|
||||||
var point0_0 = new OpenSeadragon.Point(0, 0);
|
var point0_0 = new OpenSeadragon.Point(0, 0);
|
||||||
var point = viewport.viewerElementToViewportCoordinates(point0_0);
|
var point = viewport.viewerElementToViewportCoordinates(point0_0);
|
||||||
pointEqual(point, point0_0, 'When opening, viewer coordinate 0,0 is also point 0,0');
|
pointEqual(assert, point, point0_0, 'When opening, viewer coordinate 0,0 is also point 0,0');
|
||||||
var image1Pixel = tiledImage1.viewerElementToImageCoordinates(point0_0);
|
var image1Pixel = tiledImage1.viewerElementToImageCoordinates(point0_0);
|
||||||
pointEqual(image1Pixel, point0_0, 'When opening, viewer coordinate 0,0 is also image 1 pixel 0,0');
|
pointEqual(assert, image1Pixel, point0_0, 'When opening, viewer coordinate 0,0 is also image 1 pixel 0,0');
|
||||||
var image2Pixel = tiledImage2.viewerElementToImageCoordinates(point0_0);
|
var image2Pixel = tiledImage2.viewerElementToImageCoordinates(point0_0);
|
||||||
pointEqual(image2Pixel,
|
pointEqual(assert, image2Pixel,
|
||||||
new OpenSeadragon.Point(-2 * imageWidth, -2 * imageHeight),
|
new OpenSeadragon.Point(-2 * imageWidth, -2 * imageHeight),
|
||||||
'When opening, viewer coordinates 0,0 is also image 2 pixel -2*imageWidth, -2*imageHeight');
|
'When opening, viewer coordinates 0,0 is also image 2 pixel -2*imageWidth, -2*imageHeight');
|
||||||
|
|
||||||
@ -133,23 +133,23 @@
|
|||||||
var viewerBottomRight = new OpenSeadragon.Point(viewerWidth, viewerHeight);
|
var viewerBottomRight = new OpenSeadragon.Point(viewerWidth, viewerHeight);
|
||||||
|
|
||||||
point = viewport.viewerElementToViewportCoordinates(viewerBottomRight);
|
point = viewport.viewerElementToViewportCoordinates(viewerBottomRight);
|
||||||
pointEqual(point, new OpenSeadragon.Point(1.5, 1.5),
|
pointEqual(assert, point, new OpenSeadragon.Point(1.5, 1.5),
|
||||||
'Viewer bottom right has viewport coordinates 1.5,1.5.');
|
'Viewer bottom right has viewport coordinates 1.5,1.5.');
|
||||||
image1Pixel = tiledImage1.viewerElementToImageCoordinates(viewerBottomRight);
|
image1Pixel = tiledImage1.viewerElementToImageCoordinates(viewerBottomRight);
|
||||||
pointEqual(image1Pixel,
|
pointEqual(assert, image1Pixel,
|
||||||
new OpenSeadragon.Point(imageWidth * 1.5, imageHeight * 1.5),
|
new OpenSeadragon.Point(imageWidth * 1.5, imageHeight * 1.5),
|
||||||
'Viewer bottom right has image 1 pixel coordinates imageWidth * 1.5, imageHeight * 1.5');
|
'Viewer bottom right has image 1 pixel coordinates imageWidth * 1.5, imageHeight * 1.5');
|
||||||
image2Pixel = tiledImage2.viewerElementToImageCoordinates(viewerBottomRight);
|
image2Pixel = tiledImage2.viewerElementToImageCoordinates(viewerBottomRight);
|
||||||
pointEqual(image2Pixel,
|
pointEqual(assert, image2Pixel,
|
||||||
new OpenSeadragon.Point(imageWidth, imageHeight),
|
new OpenSeadragon.Point(imageWidth, imageHeight),
|
||||||
'Viewer bottom right has image 2 pixel coordinates imageWidth,imageHeight.');
|
'Viewer bottom right has image 2 pixel coordinates imageWidth,imageHeight.');
|
||||||
|
|
||||||
|
|
||||||
checkPoint(' after opening');
|
checkPoint(assert, ' after opening');
|
||||||
viewer.addHandler('animation-finish', function animationHandler() {
|
viewer.addHandler('animation-finish', function animationHandler() {
|
||||||
viewer.removeHandler('animation-finish', animationHandler);
|
viewer.removeHandler('animation-finish', animationHandler);
|
||||||
checkPoint(' after zoom and pan');
|
checkPoint(assert, ' after zoom and pan');
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
viewer.viewport.zoomTo(0.8).panTo(new OpenSeadragon.Point(0.1, 0.2));
|
viewer.viewport.zoomTo(0.8).panTo(new OpenSeadragon.Point(0.1, 0.2));
|
||||||
});
|
});
|
||||||
@ -167,8 +167,8 @@
|
|||||||
|
|
||||||
|
|
||||||
// ---------
|
// ---------
|
||||||
asyncTest('Multiple images coordinates conversion with viewport rotation', function () {
|
QUnit.test('Multiple images coordinates conversion with viewport rotation', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer.addHandler("open", function () {
|
viewer.addHandler("open", function () {
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
var tiledImage1 = viewer.world.getItemAt(0);
|
var tiledImage1 = viewer.world.getItemAt(0);
|
||||||
@ -183,35 +183,35 @@
|
|||||||
|
|
||||||
var point0_0 = new OpenSeadragon.Point(0, 0);
|
var point0_0 = new OpenSeadragon.Point(0, 0);
|
||||||
var point = viewport.viewerElementToViewportCoordinates(viewerMiddleTop);
|
var point = viewport.viewerElementToViewportCoordinates(viewerMiddleTop);
|
||||||
pointEqual(point, point0_0, 'When opening, viewer middle top is also viewport 0,0');
|
pointEqual(assert, point, point0_0, 'When opening, viewer middle top is also viewport 0,0');
|
||||||
var image1Pixel = tiledImage1.viewerElementToImageCoordinates(viewerMiddleTop);
|
var image1Pixel = tiledImage1.viewerElementToImageCoordinates(viewerMiddleTop);
|
||||||
pointEqual(image1Pixel, point0_0, 'When opening, viewer middle top is also image 1 pixel 0,0');
|
pointEqual(assert, image1Pixel, point0_0, 'When opening, viewer middle top is also image 1 pixel 0,0');
|
||||||
var image2Pixel = tiledImage2.viewerElementToImageCoordinates(viewerMiddleTop);
|
var image2Pixel = tiledImage2.viewerElementToImageCoordinates(viewerMiddleTop);
|
||||||
pointEqual(image2Pixel,
|
pointEqual(assert, image2Pixel,
|
||||||
new OpenSeadragon.Point(-2 * imageWidth, -2 * imageHeight),
|
new OpenSeadragon.Point(-2 * imageWidth, -2 * imageHeight),
|
||||||
'When opening, viewer middle top is also image 2 pixel -2*imageWidth, -2*imageHeight');
|
'When opening, viewer middle top is also image 2 pixel -2*imageWidth, -2*imageHeight');
|
||||||
|
|
||||||
point = viewport.viewerElementToViewportCoordinates(viewerMiddleBottom);
|
point = viewport.viewerElementToViewportCoordinates(viewerMiddleBottom);
|
||||||
pointEqual(point, new OpenSeadragon.Point(1.5, 1.5),
|
pointEqual(assert, point, new OpenSeadragon.Point(1.5, 1.5),
|
||||||
'Viewer middle bottom has viewport coordinates 1.5,1.5.');
|
'Viewer middle bottom has viewport coordinates 1.5,1.5.');
|
||||||
image1Pixel = tiledImage1.viewerElementToImageCoordinates(viewerMiddleBottom);
|
image1Pixel = tiledImage1.viewerElementToImageCoordinates(viewerMiddleBottom);
|
||||||
pointEqual(image1Pixel,
|
pointEqual(assert, image1Pixel,
|
||||||
new OpenSeadragon.Point(imageWidth * 1.5, imageHeight * 1.5),
|
new OpenSeadragon.Point(imageWidth * 1.5, imageHeight * 1.5),
|
||||||
'Viewer middle bottom has image 1 pixel coordinates imageWidth * 1.5, imageHeight * 1.5');
|
'Viewer middle bottom has image 1 pixel coordinates imageWidth * 1.5, imageHeight * 1.5');
|
||||||
image2Pixel = tiledImage2.viewerElementToImageCoordinates(viewerMiddleBottom);
|
image2Pixel = tiledImage2.viewerElementToImageCoordinates(viewerMiddleBottom);
|
||||||
pointEqual(image2Pixel,
|
pointEqual(assert, image2Pixel,
|
||||||
new OpenSeadragon.Point(imageWidth, imageHeight),
|
new OpenSeadragon.Point(imageWidth, imageHeight),
|
||||||
'Viewer middle bottom has image 2 pixel coordinates imageWidth,imageHeight.');
|
'Viewer middle bottom has image 2 pixel coordinates imageWidth,imageHeight.');
|
||||||
|
|
||||||
|
|
||||||
checkPoint(' after opening');
|
checkPoint(assert, ' after opening');
|
||||||
viewer.addHandler('animation-finish', function animationHandler() {
|
viewer.addHandler('animation-finish', function animationHandler() {
|
||||||
viewer.removeHandler('animation-finish', animationHandler);
|
viewer.removeHandler('animation-finish', animationHandler);
|
||||||
checkPoint(' after zoom and pan');
|
checkPoint(assert, ' after zoom and pan');
|
||||||
|
|
||||||
//Restore rotation
|
//Restore rotation
|
||||||
viewer.viewport.setRotation(0);
|
viewer.viewport.setRotation(0);
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
viewer.viewport.zoomTo(0.8).panTo(new OpenSeadragon.Point(0.1, 0.2));
|
viewer.viewport.zoomTo(0.8).panTo(new OpenSeadragon.Point(0.1, 0.2));
|
||||||
});
|
});
|
||||||
@ -229,7 +229,8 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('ZoomRatio 1 image', function () {
|
QUnit.test('ZoomRatio 1 image', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer.addHandler("open", function () {
|
viewer.addHandler("open", function () {
|
||||||
|
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -249,10 +250,10 @@
|
|||||||
var expectedViewportZoom = viewport.getZoom(true);
|
var expectedViewportZoom = viewport.getZoom(true);
|
||||||
var actualImageZoom = viewport.viewportToImageZoom(
|
var actualImageZoom = viewport.viewportToImageZoom(
|
||||||
expectedViewportZoom);
|
expectedViewportZoom);
|
||||||
Util.assessNumericValue(actualImageZoom, expectedImageZoom, precision);
|
Util.assessNumericValue(assert, actualImageZoom, expectedImageZoom, precision);
|
||||||
|
|
||||||
var actualViewportZoom = viewport.imageToViewportZoom(actualImageZoom);
|
var actualViewportZoom = viewport.imageToViewportZoom(actualImageZoom);
|
||||||
Util.assessNumericValue(actualViewportZoom, expectedViewportZoom, precision);
|
Util.assessNumericValue(assert, actualViewportZoom, expectedViewportZoom, precision);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkZoom();
|
checkZoom();
|
||||||
@ -260,7 +261,7 @@
|
|||||||
var zoomHandler = function () {
|
var zoomHandler = function () {
|
||||||
viewer.removeHandler('animation-finish', zoomHandler);
|
viewer.removeHandler('animation-finish', zoomHandler);
|
||||||
checkZoom();
|
checkZoom();
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler('animation-finish', zoomHandler);
|
viewer.addHandler('animation-finish', zoomHandler);
|
||||||
@ -271,7 +272,8 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('ZoomRatio 2 images', function () {
|
QUnit.test('ZoomRatio 2 images', function (assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer.addHandler("open", function () {
|
viewer.addHandler("open", function () {
|
||||||
|
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -294,12 +296,12 @@
|
|||||||
var expectedViewportZoom = viewport.getZoom(true);
|
var expectedViewportZoom = viewport.getZoom(true);
|
||||||
var actualImageZoom = image.viewportToImageZoom(
|
var actualImageZoom = image.viewportToImageZoom(
|
||||||
expectedViewportZoom);
|
expectedViewportZoom);
|
||||||
Util.assessNumericValue(actualImageZoom, expectedImageZoom,
|
Util.assessNumericValue(assert, actualImageZoom, expectedImageZoom,
|
||||||
precision);
|
precision);
|
||||||
|
|
||||||
var actualViewportImage1Zoom = image.imageToViewportZoom(actualImageZoom);
|
var actualViewportImage1Zoom = image.imageToViewportZoom(actualImageZoom);
|
||||||
Util.assessNumericValue(
|
Util.assessNumericValue(
|
||||||
actualViewportImage1Zoom, expectedViewportZoom, precision);
|
assert, actualViewportImage1Zoom, expectedViewportZoom, precision);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkZoom(image1);
|
checkZoom(image1);
|
||||||
@ -309,7 +311,7 @@
|
|||||||
viewer.removeHandler('animation-finish', zoomHandler);
|
viewer.removeHandler('animation-finish', zoomHandler);
|
||||||
checkZoom(image1);
|
checkZoom(image1);
|
||||||
checkZoom(image2);
|
checkZoom(image2);
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler('animation-finish', zoomHandler);
|
viewer.addHandler('animation-finish', zoomHandler);
|
||||||
|
@ -1,133 +1,134 @@
|
|||||||
/* global module, asyncTest, $, ok, equal, strictEqual, notEqual, start, test, Util, testLog */
|
/* global QUnit, Util */
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
module("utils");
|
QUnit.module("utils");
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
test("addRemoveClass", function() {
|
QUnit.test("addRemoveClass", function(assert) {
|
||||||
var div = OpenSeadragon.makeNeutralElement('div');
|
var div = OpenSeadragon.makeNeutralElement('div');
|
||||||
strictEqual(div.className, '',
|
assert.strictEqual(div.className, '',
|
||||||
"makeNeutralElement set no classes");
|
"makeNeutralElement set no classes");
|
||||||
|
|
||||||
OpenSeadragon.addClass(div, 'foo');
|
OpenSeadragon.addClass(div, 'foo');
|
||||||
strictEqual(div.className, 'foo',
|
assert.strictEqual(div.className, 'foo',
|
||||||
"Added first class");
|
"Added first class");
|
||||||
OpenSeadragon.addClass(div, 'bar');
|
OpenSeadragon.addClass(div, 'bar');
|
||||||
strictEqual(div.className, 'foo bar',
|
assert.strictEqual(div.className, 'foo bar',
|
||||||
"Added second class");
|
"Added second class");
|
||||||
OpenSeadragon.addClass(div, 'baz');
|
OpenSeadragon.addClass(div, 'baz');
|
||||||
strictEqual(div.className, 'foo bar baz',
|
assert.strictEqual(div.className, 'foo bar baz',
|
||||||
"Added third class");
|
"Added third class");
|
||||||
OpenSeadragon.addClass(div, 'plugh');
|
OpenSeadragon.addClass(div, 'plugh');
|
||||||
strictEqual(div.className, 'foo bar baz plugh',
|
assert.strictEqual(div.className, 'foo bar baz plugh',
|
||||||
"Added fourth class");
|
"Added fourth class");
|
||||||
|
|
||||||
OpenSeadragon.addClass(div, 'foo');
|
OpenSeadragon.addClass(div, 'foo');
|
||||||
strictEqual(div.className, 'foo bar baz plugh',
|
assert.strictEqual(div.className, 'foo bar baz plugh',
|
||||||
"Re-added first class");
|
"Re-added first class");
|
||||||
OpenSeadragon.addClass(div, 'bar');
|
OpenSeadragon.addClass(div, 'bar');
|
||||||
strictEqual(div.className, 'foo bar baz plugh',
|
assert.strictEqual(div.className, 'foo bar baz plugh',
|
||||||
"Re-added middle class");
|
"Re-added middle class");
|
||||||
OpenSeadragon.addClass(div, 'plugh');
|
OpenSeadragon.addClass(div, 'plugh');
|
||||||
strictEqual(div.className, 'foo bar baz plugh',
|
assert.strictEqual(div.className, 'foo bar baz plugh',
|
||||||
"Re-added last class");
|
"Re-added last class");
|
||||||
|
|
||||||
OpenSeadragon.removeClass(div, 'xyzzy');
|
OpenSeadragon.removeClass(div, 'xyzzy');
|
||||||
strictEqual(div.className, 'foo bar baz plugh',
|
assert.strictEqual(div.className, 'foo bar baz plugh',
|
||||||
"Removed nonexistent class");
|
"Removed nonexistent class");
|
||||||
OpenSeadragon.removeClass(div, 'ba');
|
OpenSeadragon.removeClass(div, 'ba');
|
||||||
strictEqual(div.className, 'foo bar baz plugh',
|
assert.strictEqual(div.className, 'foo bar baz plugh',
|
||||||
"Removed nonexistent class with existent substring");
|
"Removed nonexistent class with existent substring");
|
||||||
|
|
||||||
OpenSeadragon.removeClass(div, 'bar');
|
OpenSeadragon.removeClass(div, 'bar');
|
||||||
strictEqual(div.className, 'foo baz plugh',
|
assert.strictEqual(div.className, 'foo baz plugh',
|
||||||
"Removed middle class");
|
"Removed middle class");
|
||||||
OpenSeadragon.removeClass(div, 'plugh');
|
OpenSeadragon.removeClass(div, 'plugh');
|
||||||
strictEqual(div.className, 'foo baz',
|
assert.strictEqual(div.className, 'foo baz',
|
||||||
"Removed last class");
|
"Removed last class");
|
||||||
OpenSeadragon.removeClass(div, 'foo');
|
OpenSeadragon.removeClass(div, 'foo');
|
||||||
strictEqual(div.className, 'baz',
|
assert.strictEqual(div.className, 'baz',
|
||||||
"Removed first class");
|
"Removed first class");
|
||||||
OpenSeadragon.removeClass(div, 'baz');
|
OpenSeadragon.removeClass(div, 'baz');
|
||||||
strictEqual(div.className, '',
|
assert.strictEqual(div.className, '',
|
||||||
"Removed only class");
|
"Removed only class");
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest("makeAjaxRequest", function() {
|
QUnit.test("makeAjaxRequest", function(assert) {
|
||||||
var timeWatcher = Util.timeWatcher();
|
var timeWatcher = Util.timeWatcher(assert);
|
||||||
|
|
||||||
OpenSeadragon.makeAjaxRequest('data/testpattern.dzi',
|
OpenSeadragon.makeAjaxRequest('data/testpattern.dzi',
|
||||||
function(xhr) {
|
function(xhr) {
|
||||||
equal(xhr.status, 200, 'Success callback called for HTTP 200');
|
assert.equal(xhr.status, 200, 'Success callback called for HTTP 200');
|
||||||
ok(/deepzoom/.test(xhr.responseText), 'Success function called');
|
assert.ok(/deepzoom/.test(xhr.responseText), 'Success function called');
|
||||||
timeWatcher.done();
|
timeWatcher.done();
|
||||||
},
|
},
|
||||||
function(xhr) {
|
function(xhr) {
|
||||||
ok(false, 'Error callback should not be called');
|
assert.ok(false, 'Error callback should not be called');
|
||||||
timeWatcher.done();
|
timeWatcher.done();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest("makeAjaxRequest for invalid file", function() {
|
QUnit.test("makeAjaxRequest for invalid file", function(assert) {
|
||||||
var timeWatcher = Util.timeWatcher();
|
var timeWatcher = Util.timeWatcher(assert);
|
||||||
|
|
||||||
OpenSeadragon.makeAjaxRequest('not-a-real-dzi-file',
|
OpenSeadragon.makeAjaxRequest('not-a-real-dzi-file',
|
||||||
function(xhr) {
|
function(xhr) {
|
||||||
ok(false, 'Success function should not be called for errors');
|
assert.ok(false, 'Success function should not be called for errors');
|
||||||
timeWatcher.done();
|
timeWatcher.done();
|
||||||
},
|
},
|
||||||
function(xhr) {
|
function(xhr) {
|
||||||
equal(xhr.status, 404, 'Error callback called for HTTP 404');
|
assert.equal(xhr.status, 404, 'Error callback called for HTTP 404');
|
||||||
ok(true, 'Error function should be called for errors');
|
assert.ok(true, 'Error function should be called for errors');
|
||||||
timeWatcher.done();
|
timeWatcher.done();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("getUrlProtocol", function() {
|
QUnit.test("getUrlProtocol", function(assert) {
|
||||||
|
|
||||||
equal(OpenSeadragon.getUrlProtocol("test"), window.location.protocol,
|
assert.equal(OpenSeadragon.getUrlProtocol("test"), window.location.protocol,
|
||||||
"'test' url protocol should be window.location.protocol");
|
"'test' url protocol should be window.location.protocol");
|
||||||
|
|
||||||
equal(OpenSeadragon.getUrlProtocol("/test"), window.location.protocol,
|
assert.equal(OpenSeadragon.getUrlProtocol("/test"), window.location.protocol,
|
||||||
"'/test' url protocol should be window.location.protocol");
|
"'/test' url protocol should be window.location.protocol");
|
||||||
|
|
||||||
equal(OpenSeadragon.getUrlProtocol("//test"), window.location.protocol,
|
assert.equal(OpenSeadragon.getUrlProtocol("//test"), window.location.protocol,
|
||||||
"'//test' url protocol should be window.location.protocol");
|
"'//test' url protocol should be window.location.protocol");
|
||||||
|
|
||||||
equal(OpenSeadragon.getUrlProtocol("http://test"), "http:",
|
assert.equal(OpenSeadragon.getUrlProtocol("http://test"), "http:",
|
||||||
"'http://test' url protocol should be http:");
|
"'http://test' url protocol should be http:");
|
||||||
|
|
||||||
equal(OpenSeadragon.getUrlProtocol("https://test"), "https:",
|
assert.equal(OpenSeadragon.getUrlProtocol("https://test"), "https:",
|
||||||
"'https://test' url protocol should be https:");
|
"'https://test' url protocol should be https:");
|
||||||
|
|
||||||
equal(OpenSeadragon.getUrlProtocol("file://test"), "file:",
|
assert.equal(OpenSeadragon.getUrlProtocol("file://test"), "file:",
|
||||||
"'file://test' url protocol should be file:");
|
"'file://test' url protocol should be file:");
|
||||||
|
|
||||||
equal(OpenSeadragon.getUrlProtocol("FTP://test"), "ftp:",
|
assert.equal(OpenSeadragon.getUrlProtocol("FTP://test"), "ftp:",
|
||||||
"'FTP://test' url protocol should be ftp:");
|
"'FTP://test' url protocol should be ftp:");
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest("requestAnimationFrame", function() {
|
QUnit.test("requestAnimationFrame", function(assert) {
|
||||||
var timeWatcher = Util.timeWatcher();
|
var timeWatcher = Util.timeWatcher(assert);
|
||||||
|
|
||||||
OpenSeadragon.requestAnimationFrame(function() {
|
OpenSeadragon.requestAnimationFrame(function() {
|
||||||
ok(true, 'frame fired');
|
assert.ok(true, 'frame fired');
|
||||||
timeWatcher.done();
|
timeWatcher.done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest("cancelAnimationFrame", function() {
|
QUnit.test("cancelAnimationFrame", function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var frameFired = false;
|
var frameFired = false;
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
strictEqual(frameFired, false, 'the frame never fired');
|
assert.strictEqual(frameFired, false, 'the frame never fired');
|
||||||
start();
|
done();
|
||||||
}, 150);
|
}, 150);
|
||||||
|
|
||||||
var frameId = OpenSeadragon.requestAnimationFrame(function() {
|
var frameId = OpenSeadragon.requestAnimationFrame(function() {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* global module, asyncTest, $, ok, equal, notEqual, start, test, Util, testLog, propEqual, console */
|
/* global QUnit, $, Util, testLog, console */
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
var viewer;
|
var viewer;
|
||||||
@ -7,9 +7,9 @@
|
|||||||
var SPRING_STIFFNESS = 100; // Faster animation = faster tests
|
var SPRING_STIFFNESS = 100; // Faster animation = faster tests
|
||||||
var EPSILON = 0.0000000001;
|
var EPSILON = 0.0000000001;
|
||||||
|
|
||||||
module("viewport", {
|
QUnit.module("viewport", {
|
||||||
setup: function () {
|
beforeEach: function () {
|
||||||
var example = $('<div id="example"></div>').appendTo("#qunit-fixture");
|
$('<div id="example"></div>').appendTo("#qunit-fixture");
|
||||||
|
|
||||||
testLog.reset();
|
testLog.reset();
|
||||||
|
|
||||||
@ -19,7 +19,7 @@
|
|||||||
springStiffness: SPRING_STIFFNESS
|
springStiffness: SPRING_STIFFNESS
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
teardown: function () {
|
afterEach: function () {
|
||||||
if (viewer && viewer.close) {
|
if (viewer && viewer.close) {
|
||||||
viewer.close();
|
viewer.close();
|
||||||
}
|
}
|
||||||
@ -56,14 +56,15 @@
|
|||||||
|
|
||||||
// Test helper - a lot of these tests loop through a few possible
|
// Test helper - a lot of these tests loop through a few possible
|
||||||
// values for zoom levels, and reopen the viewer for each iteration.
|
// values for zoom levels, and reopen the viewer for each iteration.
|
||||||
var reopenViewerHelper = function(config) {
|
var reopenViewerHelper = function(assert, config) {
|
||||||
|
var done = assert.async();
|
||||||
var expected, level, actual, i = 0;
|
var expected, level, actual, i = 0;
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
expected = config.processExpected(level, expected);
|
expected = config.processExpected(level, expected);
|
||||||
actual = viewport[config.method]();
|
actual = viewport[config.method]();
|
||||||
|
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
actual,
|
actual,
|
||||||
expected,
|
expected,
|
||||||
"Test " + config.method + " with zoom level of " + level + ". Expected : " + expected + ", got " + actual
|
"Test " + config.method + " with zoom level of " + level + ". Expected : " + expected + ", got " + actual
|
||||||
@ -82,7 +83,7 @@
|
|||||||
viewer.addOnceHandler('open', openHandler);
|
viewer.addOnceHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
} else {
|
} else {
|
||||||
start();
|
done();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
level = expected = testZoomLevels[i];
|
level = expected = testZoomLevels[i];
|
||||||
@ -100,7 +101,8 @@
|
|||||||
|
|
||||||
// Test helper - a lot of these tests loop through a test data
|
// Test helper - a lot of these tests loop through a test data
|
||||||
// array and test different values. This helper does not reopen the viewer.
|
// array and test different values. This helper does not reopen the viewer.
|
||||||
var loopingTestHelper = function(config) {
|
var loopingTestHelper = function(assert, config) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -111,78 +113,91 @@
|
|||||||
orig = config.getOrig(config.testArray[i], viewport);
|
orig = config.getOrig(config.testArray[i], viewport);
|
||||||
expected = config.getExpected(orig, viewport);
|
expected = config.getExpected(orig, viewport);
|
||||||
actual = viewport[config.method](orig);
|
actual = viewport[config.method](orig);
|
||||||
var assert = config.assert || propEqual;
|
if(config.assert) {
|
||||||
assert(
|
config.assert(
|
||||||
|
assert,
|
||||||
|
actual,
|
||||||
|
expected,
|
||||||
|
"Correctly converted coordinates " + orig
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
assert.propEqual(
|
||||||
actual,
|
actual,
|
||||||
expected,
|
expected,
|
||||||
"Correctly converted coordinates " + orig
|
"Correctly converted coordinates " + orig
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
start();
|
}
|
||||||
|
|
||||||
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
};
|
};
|
||||||
|
|
||||||
function assertPointsEquals(actual, expected, message) {
|
function assertPointsEquals(assert, actual, expected, message) {
|
||||||
Util.assertPointsEquals(actual, expected, 1e-15, message);
|
Util.assertPointsEquals(assert, actual, expected, 1e-15, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests start here.
|
// Tests start here.
|
||||||
|
|
||||||
asyncTest('getContainerSize', function() {
|
QUnit.test('getContainerSize', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
viewport.zoomTo(ZOOM_FACTOR, null, true);
|
viewport.zoomTo(ZOOM_FACTOR, null, true);
|
||||||
|
|
||||||
propEqual(viewport.getContainerSize(), new OpenSeadragon.Point(500, 500), "Test container size");
|
assert.propEqual(viewport.getContainerSize(), new OpenSeadragon.Point(500, 500), "Test container size");
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('getAspectRatio', function() {
|
QUnit.test('getAspectRatio', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
viewport.zoomTo(ZOOM_FACTOR, null, true);
|
viewport.zoomTo(ZOOM_FACTOR, null, true);
|
||||||
|
|
||||||
equal(viewport.getAspectRatio(), 1, "Test aspect ratio");
|
assert.equal(viewport.getAspectRatio(), 1, "Test aspect ratio");
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('getMinZoomDefault', function() {
|
QUnit.test('getMinZoomDefault', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
equal(viewport.getMinZoom(), 0.9, "Test default min zoom level");
|
assert.equal(viewport.getMinZoom(), 0.9, "Test default min zoom level");
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('getMaxZoomDefault', function() {
|
QUnit.test('getMaxZoomDefault', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
equal(viewport.getMaxZoom(), 2.2, "Test default max zoom level");
|
assert.equal(viewport.getMaxZoom(), 2.2, "Test default max zoom level");
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('getMinZoom', function() {
|
QUnit.test('getMinZoom', function(assert) {
|
||||||
reopenViewerHelper({
|
reopenViewerHelper(assert, {
|
||||||
property: 'minZoomLevel',
|
property: 'minZoomLevel',
|
||||||
method: 'getMinZoom',
|
method: 'getMinZoom',
|
||||||
processExpected: function(level, expected){
|
processExpected: function(level, expected){
|
||||||
@ -196,8 +211,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('getMaxZoom', function() {
|
QUnit.test('getMaxZoom', function(assert) {
|
||||||
reopenViewerHelper({
|
reopenViewerHelper(assert, {
|
||||||
property: 'maxZoomLevel',
|
property: 'maxZoomLevel',
|
||||||
method: 'getMaxZoom',
|
method: 'getMaxZoom',
|
||||||
processExpected: function(level, expected) {
|
processExpected: function(level, expected) {
|
||||||
@ -212,8 +227,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('getHomeBounds', function() {
|
QUnit.test('getHomeBounds', function(assert) {
|
||||||
reopenViewerHelper({
|
reopenViewerHelper(assert, {
|
||||||
property: 'defaultZoomLevel',
|
property: 'defaultZoomLevel',
|
||||||
method: 'getHomeBounds',
|
method: 'getHomeBounds',
|
||||||
processExpected: function(level, expected) {
|
processExpected: function(level, expected) {
|
||||||
@ -224,12 +239,14 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('getHomeBoundsNoRotate with rotation', function() {
|
QUnit.test('getHomeBoundsNoRotate with rotation', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
function openHandler() {
|
function openHandler() {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
viewport.setRotation(-675);
|
viewport.setRotation(-675);
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
|
assert,
|
||||||
viewport.getHomeBoundsNoRotate(),
|
viewport.getHomeBoundsNoRotate(),
|
||||||
new OpenSeadragon.Rect(
|
new OpenSeadragon.Rect(
|
||||||
(1 - Math.sqrt(2)) / 2,
|
(1 - Math.sqrt(2)) / 2,
|
||||||
@ -238,18 +255,20 @@
|
|||||||
Math.sqrt(2)),
|
Math.sqrt(2)),
|
||||||
0.00000001,
|
0.00000001,
|
||||||
"Test getHomeBoundsNoRotate with degrees = -675");
|
"Test getHomeBoundsNoRotate with degrees = -675");
|
||||||
start();
|
done();
|
||||||
}
|
}
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('getHomeBounds with rotation', function() {
|
QUnit.test('getHomeBounds with rotation', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
function openHandler() {
|
function openHandler() {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
viewport.setRotation(-675);
|
viewport.setRotation(-675);
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
|
assert,
|
||||||
viewport.getHomeBounds(),
|
viewport.getHomeBounds(),
|
||||||
new OpenSeadragon.Rect(
|
new OpenSeadragon.Rect(
|
||||||
0.5,
|
0.5,
|
||||||
@ -259,22 +278,24 @@
|
|||||||
45),
|
45),
|
||||||
0.00000001,
|
0.00000001,
|
||||||
"Test getHomeBounds with degrees = -675");
|
"Test getHomeBounds with degrees = -675");
|
||||||
start();
|
done();
|
||||||
}
|
}
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('getHomeBoundsWithMultiImages', function() {
|
QUnit.test('getHomeBoundsWithMultiImages', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
function openHandler() {
|
function openHandler() {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
|
assert,
|
||||||
new OpenSeadragon.Rect(0, 0, 4, 4),
|
new OpenSeadragon.Rect(0, 0, 4, 4),
|
||||||
viewport.getHomeBounds(),
|
viewport.getHomeBounds(),
|
||||||
0.00000001,
|
0.00000001,
|
||||||
"Test getHomeBoundsWithMultiImages");
|
"Test getHomeBoundsWithMultiImages");
|
||||||
start();
|
done();
|
||||||
}
|
}
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open([{
|
viewer.open([{
|
||||||
@ -290,16 +311,18 @@
|
|||||||
}]);
|
}]);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('getHomeBoundsWithMultiImagesAndClipping', function() {
|
QUnit.test('getHomeBoundsWithMultiImagesAndClipping', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
function openHandler() {
|
function openHandler() {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
|
assert,
|
||||||
new OpenSeadragon.Rect(1, 1, 4, 4),
|
new OpenSeadragon.Rect(1, 1, 4, 4),
|
||||||
viewport.getHomeBounds(),
|
viewport.getHomeBounds(),
|
||||||
0.00000001,
|
0.00000001,
|
||||||
"Test getHomeBoundsWithMultiImagesAndClipping");
|
"Test getHomeBoundsWithMultiImagesAndClipping");
|
||||||
start();
|
done();
|
||||||
}
|
}
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open([{
|
viewer.open([{
|
||||||
@ -316,8 +339,8 @@
|
|||||||
}]);
|
}]);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('getHomeZoom', function() {
|
QUnit.test('getHomeZoom', function(assert) {
|
||||||
reopenViewerHelper({
|
reopenViewerHelper(assert, {
|
||||||
property: 'defaultZoomLevel',
|
property: 'defaultZoomLevel',
|
||||||
method: 'getHomeZoom',
|
method: 'getHomeZoom',
|
||||||
processExpected: function(level, expected){
|
processExpected: function(level, expected){
|
||||||
@ -332,13 +355,14 @@
|
|||||||
|
|
||||||
// I don't use the helper for this one because it sets a couple more
|
// I don't use the helper for this one because it sets a couple more
|
||||||
// properties that would need special casing.
|
// properties that would need special casing.
|
||||||
asyncTest('getHomeZoomWithHomeFillsViewer', function() {
|
QUnit.test('getHomeZoomWithHomeFillsViewer', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var i = 0;
|
var i = 0;
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
viewport.zoomTo(ZOOM_FACTOR, null, true);
|
viewport.zoomTo(ZOOM_FACTOR, null, true);
|
||||||
|
|
||||||
equal(
|
assert.equal(
|
||||||
viewport.getHomeZoom(),
|
viewport.getHomeZoom(),
|
||||||
testZoomLevels[i],
|
testZoomLevels[i],
|
||||||
"Test getHomeZoom with homeFillsViewer = true and default zoom level of " + testZoomLevels[i]
|
"Test getHomeZoom with homeFillsViewer = true and default zoom level of " + testZoomLevels[i]
|
||||||
@ -355,7 +379,7 @@
|
|||||||
viewer.addOnceHandler('open', openHandler);
|
viewer.addOnceHandler('open', openHandler);
|
||||||
viewer.open(TALL_PATH); // use a different image for homeFillsViewer
|
viewer.open(TALL_PATH); // use a different image for homeFillsViewer
|
||||||
} else {
|
} else {
|
||||||
start();
|
done();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
viewer = OpenSeadragon({
|
viewer = OpenSeadragon({
|
||||||
@ -369,7 +393,8 @@
|
|||||||
viewer.open(TALL_PATH); // use a different image for homeFillsViewer
|
viewer.open(TALL_PATH); // use a different image for homeFillsViewer
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('resetContentSize', function(){
|
QUnit.test('resetContentSize', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -377,19 +402,20 @@
|
|||||||
for(var i = 0; i < testRects.length; i++){
|
for(var i = 0; i < testRects.length; i++){
|
||||||
var rect = testRects[i].times(viewport.getContainerSize());
|
var rect = testRects[i].times(viewport.getContainerSize());
|
||||||
viewport.resetContentSize(rect.getSize());
|
viewport.resetContentSize(rect.getSize());
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
viewport._contentSize,
|
viewport._contentSize,
|
||||||
rect.getSize(),
|
rect.getSize(),
|
||||||
"Reset content size correctly."
|
"Reset content size correctly."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('goHome', function(){
|
QUnit.test('goHome', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -398,18 +424,19 @@
|
|||||||
viewport.zoomTo(ZOOM_FACTOR, true);
|
viewport.zoomTo(ZOOM_FACTOR, true);
|
||||||
|
|
||||||
viewport.goHome(true);
|
viewport.goHome(true);
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
viewport.getBounds(),
|
viewport.getBounds(),
|
||||||
viewport.getHomeBounds(),
|
viewport.getHomeBounds(),
|
||||||
"Went home."
|
"Went home."
|
||||||
);
|
);
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('ensureVisible', function() {
|
QUnit.test('ensureVisible', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -420,14 +447,15 @@
|
|||||||
|
|
||||||
viewport.ensureVisible(true);
|
viewport.ensureVisible(true);
|
||||||
var bounds = viewport.getBounds();
|
var bounds = viewport.getBounds();
|
||||||
ok(bounds.getSize().x > 1 && bounds.getSize().y > 1, "Moved viewport so that image is visible.");
|
assert.ok(bounds.getSize().x > 1 && bounds.getSize().y > 1, "Moved viewport so that image is visible.");
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('applyConstraints', function() {
|
QUnit.test('applyConstraints', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function() {
|
var openHandler = function() {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -437,17 +465,19 @@
|
|||||||
viewport.applyConstraints(true);
|
viewport.applyConstraints(true);
|
||||||
var bounds = viewport.getBounds();
|
var bounds = viewport.getBounds();
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
|
assert,
|
||||||
new OpenSeadragon.Rect(0.7, 0.7, 1, 1),
|
new OpenSeadragon.Rect(0.7, 0.7, 1, 1),
|
||||||
bounds,
|
bounds,
|
||||||
EPSILON,
|
EPSILON,
|
||||||
"Viewport.applyConstraints should move viewport.");
|
"Viewport.applyConstraints should move viewport.");
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('applyConstraints with visibilityRatio = 1 shouldn\'t bounce around', function() {
|
QUnit.test('applyConstraints with visibilityRatio = 1 shouldn\'t bounce around', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function() {
|
var openHandler = function() {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -458,17 +488,19 @@
|
|||||||
viewport.applyConstraints(true);
|
viewport.applyConstraints(true);
|
||||||
var bounds = viewport.getBounds();
|
var bounds = viewport.getBounds();
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
|
assert,
|
||||||
new OpenSeadragon.Rect(-0.5, 1, 2, 2),
|
new OpenSeadragon.Rect(-0.5, 1, 2, 2),
|
||||||
bounds,
|
bounds,
|
||||||
EPSILON,
|
EPSILON,
|
||||||
"Viewport.applyConstraints should move viewport to the center, not to a side.");
|
"Viewport.applyConstraints should move viewport to the center, not to a side.");
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(TALL_PATH);
|
viewer.open(TALL_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('applyConstraints with rotation', function() {
|
QUnit.test('applyConstraints with rotation', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function() {
|
var openHandler = function() {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -477,11 +509,12 @@
|
|||||||
viewport.applyConstraints(true);
|
viewport.applyConstraints(true);
|
||||||
var bounds = viewport.getBounds();
|
var bounds = viewport.getBounds();
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
|
assert,
|
||||||
bounds,
|
bounds,
|
||||||
new OpenSeadragon.Rect(1, 0, Math.sqrt(2), Math.sqrt(2), 45),
|
new OpenSeadragon.Rect(1, 0, Math.sqrt(2), Math.sqrt(2), 45),
|
||||||
EPSILON,
|
EPSILON,
|
||||||
"Viewport.applyConstraints with rotation should move viewport.");
|
"Viewport.applyConstraints with rotation should move viewport.");
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
@ -545,7 +578,8 @@
|
|||||||
new OpenSeadragon.Rect(0.25, 0.25, 0.5, 0.5)
|
new OpenSeadragon.Rect(0.25, 0.25, 0.5, 0.5)
|
||||||
];
|
];
|
||||||
|
|
||||||
asyncTest('fitBounds', function(){
|
QUnit.test('fitBounds', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -553,19 +587,20 @@
|
|||||||
for(var i = 0; i < testRectsFitBounds.length; i++){
|
for(var i = 0; i < testRectsFitBounds.length; i++){
|
||||||
var rect = testRectsFitBounds[i];
|
var rect = testRectsFitBounds[i];
|
||||||
viewport.fitBounds(rect, true);
|
viewport.fitBounds(rect, true);
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
viewport.getBounds(),
|
viewport.getBounds(),
|
||||||
expectedRectsFitBounds[i],
|
expectedRectsFitBounds[i],
|
||||||
"Fit bounds correctly."
|
"Fit bounds correctly."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('fitBounds with viewport rotation', function(){
|
QUnit.test('fitBounds with viewport rotation', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -575,19 +610,21 @@
|
|||||||
var rect = testRectsFitBounds[i];
|
var rect = testRectsFitBounds[i];
|
||||||
viewport.fitBounds(rect, true);
|
viewport.fitBounds(rect, true);
|
||||||
Util.assertRectangleEquals(
|
Util.assertRectangleEquals(
|
||||||
|
assert,
|
||||||
viewport.getBounds(),
|
viewport.getBounds(),
|
||||||
expectedRectsFitBoundsWithRotation[i],
|
expectedRectsFitBoundsWithRotation[i],
|
||||||
EPSILON,
|
EPSILON,
|
||||||
"Fit bounds correctly."
|
"Fit bounds correctly."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('fitBoundsWithConstraints', function(){
|
QUnit.test('fitBoundsWithConstraints', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -596,90 +633,95 @@
|
|||||||
var rect = testRectsFitBounds[i];
|
var rect = testRectsFitBounds[i];
|
||||||
|
|
||||||
viewport.fitBoundsWithConstraints(rect, true);
|
viewport.fitBoundsWithConstraints(rect, true);
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
viewport.getBounds(),
|
viewport.getBounds(),
|
||||||
expectedRectsFitBoundsWithConstraints[i],
|
expectedRectsFitBoundsWithConstraints[i],
|
||||||
"Fit bounds correctly."
|
"Fit bounds correctly."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('fitBounds with almost same zoom', function() {
|
QUnit.test('fitBounds with almost same zoom', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function() {
|
var openHandler = function() {
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
var rect1 = new OpenSeadragon.Rect(0, 0, 1, 1);
|
var rect1 = new OpenSeadragon.Rect(0, 0, 1, 1);
|
||||||
viewport.fitBounds(rect1, true);
|
viewport.fitBounds(rect1, true);
|
||||||
Util.assertRectangleEquals(rect1, viewport.getBounds(), 1e-6,
|
Util.assertRectangleEquals(assert, rect1, viewport.getBounds(), 1e-6,
|
||||||
'Bounds should be ' + rect1);
|
'Bounds should be ' + rect1);
|
||||||
|
|
||||||
// Zoom and pan
|
// Zoom and pan
|
||||||
var rect2 = new OpenSeadragon.Rect(1, 1, 1 + 1e-8, 1 + 1e-8);
|
var rect2 = new OpenSeadragon.Rect(1, 1, 1 + 1e-8, 1 + 1e-8);
|
||||||
viewport.fitBounds(rect2);
|
viewport.fitBounds(rect2);
|
||||||
Util.assertRectangleEquals(rect2, viewport.getBounds(), 1e-6,
|
Util.assertRectangleEquals(assert, rect2, viewport.getBounds(), 1e-6,
|
||||||
'Bounds should be ' + rect2);
|
'Bounds should be ' + rect2);
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addOnceHandler('open', openHandler);
|
viewer.addOnceHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('fitBounds with big rectangle', function() {
|
QUnit.test('fitBounds with big rectangle', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function() {
|
var openHandler = function() {
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
var rect1 = new OpenSeadragon.Rect(0, 0, 1e9, 1e9);
|
var rect1 = new OpenSeadragon.Rect(0, 0, 1e9, 1e9);
|
||||||
viewport.fitBounds(rect1, true);
|
viewport.fitBounds(rect1, true);
|
||||||
Util.assertRectangleEquals(rect1, viewport.getBounds(), 1e-6,
|
Util.assertRectangleEquals(assert, rect1, viewport.getBounds(), 1e-6,
|
||||||
'Bounds should be ' + rect1);
|
'Bounds should be ' + rect1);
|
||||||
|
|
||||||
// Zoom and pan
|
// Zoom and pan
|
||||||
var rect2 = new OpenSeadragon.Rect(1, 1, 2e9, 2e9);
|
var rect2 = new OpenSeadragon.Rect(1, 1, 2e9, 2e9);
|
||||||
viewport.fitBounds(rect2);
|
viewport.fitBounds(rect2);
|
||||||
Util.assertRectangleEquals(rect2, viewport.getBounds(), 1e-6,
|
Util.assertRectangleEquals(assert, rect2, viewport.getBounds(), 1e-6,
|
||||||
'Bounds should be ' + rect2);
|
'Bounds should be ' + rect2);
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addOnceHandler('open', openHandler);
|
viewer.addOnceHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('fitHorizontally', function(){
|
QUnit.test('fitHorizontally', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
viewport.fitHorizontally(true);
|
viewport.fitHorizontally(true);
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
viewport.getBounds(),
|
viewport.getBounds(),
|
||||||
new OpenSeadragon.Rect(0, 1.5, 1, 1),
|
new OpenSeadragon.Rect(0, 1.5, 1, 1),
|
||||||
"Viewport fit a tall image horizontally."
|
"Viewport fit a tall image horizontally."
|
||||||
);
|
);
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(TALL_PATH);
|
viewer.open(TALL_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('fitVertically', function(){
|
QUnit.test('fitVertically', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
viewport.fitVertically(true);
|
viewport.fitVertically(true);
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
viewport.getBounds(),
|
viewport.getBounds(),
|
||||||
new OpenSeadragon.Rect(0.375, 0, 0.25, 0.25),
|
new OpenSeadragon.Rect(0.375, 0, 0.25, 0.25),
|
||||||
"Viewport fit a wide image vertically."
|
"Viewport fit a wide image vertically."
|
||||||
);
|
);
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(WIDE_PATH);
|
viewer.open(WIDE_PATH);
|
||||||
});
|
});
|
||||||
// End fitBounds tests.
|
// End fitBounds tests.
|
||||||
|
|
||||||
asyncTest('panBy', function(){
|
QUnit.test('panBy', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -687,60 +729,63 @@
|
|||||||
for (var i = 0; i < testPoints.length; i++){
|
for (var i = 0; i < testPoints.length; i++){
|
||||||
var expected = viewport.getCenter().plus(testPoints[i]);
|
var expected = viewport.getCenter().plus(testPoints[i]);
|
||||||
viewport.panBy(testPoints[i], true);
|
viewport.panBy(testPoints[i], true);
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
viewport.getCenter(),
|
viewport.getCenter(),
|
||||||
expected,
|
expected,
|
||||||
"Panned by the correct amount."
|
"Panned by the correct amount."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('panTo', function(){
|
QUnit.test('panTo', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
for (var i = 0; i < testPoints.length; i++){
|
for (var i = 0; i < testPoints.length; i++){
|
||||||
viewport.panTo(testPoints[i], true);
|
viewport.panTo(testPoints[i], true);
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
viewport.getCenter(),
|
viewport.getCenter(),
|
||||||
testPoints[i],
|
testPoints[i],
|
||||||
"Panned to the correct location."
|
"Panned to the correct location."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('zoomBy no ref point', function() {
|
QUnit.test('zoomBy no ref point', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
for (var i = 0; i < testZoomLevels.length; i++) {
|
for (var i = 0; i < testZoomLevels.length; i++) {
|
||||||
viewport.zoomBy(testZoomLevels[i], null, true);
|
viewport.zoomBy(testZoomLevels[i], null, true);
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
viewport.getZoom(),
|
viewport.getZoom(),
|
||||||
testZoomLevels[i],
|
testZoomLevels[i],
|
||||||
"Zoomed by the correct amount."
|
"Zoomed by the correct amount."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('zoomBy with ref point', function() {
|
QUnit.test('zoomBy with ref point', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -756,12 +801,13 @@
|
|||||||
|
|
||||||
for (var i = 0; i < testZoomLevels.length; i++) {
|
for (var i = 0; i < testZoomLevels.length; i++) {
|
||||||
viewport.zoomBy(testZoomLevels[i], testPoints[i], true);
|
viewport.zoomBy(testZoomLevels[i], testPoints[i], true);
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
viewport.getZoom(),
|
viewport.getZoom(),
|
||||||
testZoomLevels[i],
|
testZoomLevels[i],
|
||||||
"Zoomed by the correct amount."
|
"Zoomed by the correct amount."
|
||||||
);
|
);
|
||||||
assertPointsEquals(
|
assertPointsEquals(
|
||||||
|
assert,
|
||||||
viewport.getCenter(),
|
viewport.getCenter(),
|
||||||
expectedCenters[i],
|
expectedCenters[i],
|
||||||
1e-14,
|
1e-14,
|
||||||
@ -769,33 +815,35 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('zoomTo no ref point', function() {
|
QUnit.test('zoomTo no ref point', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
for (var i = 0; i < testZoomLevels.length; i++) {
|
for (var i = 0; i < testZoomLevels.length; i++) {
|
||||||
viewport.zoomTo(testZoomLevels[i], null, true);
|
viewport.zoomTo(testZoomLevels[i], null, true);
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
viewport.getZoom(),
|
viewport.getZoom(),
|
||||||
testZoomLevels[i],
|
testZoomLevels[i],
|
||||||
"Zoomed to the correct level."
|
"Zoomed to the correct level."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('zoomTo with ref point', function() {
|
QUnit.test('zoomTo with ref point', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -811,12 +859,13 @@
|
|||||||
|
|
||||||
for (var i = 0; i < testZoomLevels.length; i++) {
|
for (var i = 0; i < testZoomLevels.length; i++) {
|
||||||
viewport.zoomTo(testZoomLevels[i], testPoints[i], true);
|
viewport.zoomTo(testZoomLevels[i], testPoints[i], true);
|
||||||
propEqual(
|
assert.propEqual(
|
||||||
viewport.getZoom(),
|
viewport.getZoom(),
|
||||||
testZoomLevels[i],
|
testZoomLevels[i],
|
||||||
"Zoomed to the correct level."
|
"Zoomed to the correct level."
|
||||||
);
|
);
|
||||||
assertPointsEquals(
|
assertPointsEquals(
|
||||||
|
assert,
|
||||||
viewport.getCenter(),
|
viewport.getCenter(),
|
||||||
expectedCenters[i],
|
expectedCenters[i],
|
||||||
1e-14,
|
1e-14,
|
||||||
@ -824,30 +873,32 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('rotation', function(){
|
QUnit.test('rotation', function(assert){
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
|
|
||||||
propEqual(viewport.getRotation, 0, "Original rotation should be 0 degrees");
|
assert.propEqual(viewport.getRotation, 0, "Original rotation should be 0 degrees");
|
||||||
viewport.setRotation(90);
|
viewport.setRotation(90);
|
||||||
propEqual(viewport.getRotation, 90, "Rotation should be 90 degrees");
|
assert.propEqual(viewport.getRotation, 90, "Rotation should be 90 degrees");
|
||||||
viewport.setRotation(-75);
|
viewport.setRotation(-75);
|
||||||
propEqual(viewport.getRotation, -75, "Rotation should be -75 degrees");
|
assert.propEqual(viewport.getRotation, -75, "Rotation should be -75 degrees");
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('resize', function() {
|
QUnit.test('resize', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
var viewport = viewer.viewport;
|
var viewport = viewer.viewport;
|
||||||
@ -855,16 +906,16 @@
|
|||||||
for(var i = 0; i < testPoints.length; i++){
|
for(var i = 0; i < testPoints.length; i++){
|
||||||
var new_size = testPoints[i].times(viewer.source.dimensions.x);
|
var new_size = testPoints[i].times(viewer.source.dimensions.x);
|
||||||
viewport.resize(new_size);
|
viewport.resize(new_size);
|
||||||
propEqual(viewport.getContainerSize(), new_size, "Viewport resized successfully.");
|
assert.propEqual(viewport.getContainerSize(), new_size, "Viewport resized successfully.");
|
||||||
}
|
}
|
||||||
start();
|
done();
|
||||||
};
|
};
|
||||||
viewer.addHandler('open', openHandler);
|
viewer.addHandler('open', openHandler);
|
||||||
viewer.open(DZI_PATH);
|
viewer.open(DZI_PATH);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('deltaPixelsFromPoints', function() {
|
QUnit.test('deltaPixelsFromPoints', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport){
|
getOrig: function(el, viewport){
|
||||||
return el.times(viewer.source.dimensions.x);
|
return el.times(viewer.source.dimensions.x);
|
||||||
@ -876,8 +927,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('deltaPointsFromPixels', function() {
|
QUnit.test('deltaPointsFromPixels', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el.times(viewport.getContainerSize().x);
|
return el.times(viewport.getContainerSize().x);
|
||||||
@ -889,8 +940,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('pixelFromPoint', function() {
|
QUnit.test('pixelFromPoint', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el.times(viewer.source.dimensions.x);
|
return el.times(viewer.source.dimensions.x);
|
||||||
@ -902,8 +953,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('pointFromPixel', function() {
|
QUnit.test('pointFromPixel', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el.times(viewport.getContainerSize().x);
|
return el.times(viewport.getContainerSize().x);
|
||||||
@ -915,8 +966,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('viewportToImageCoordinates', function() {
|
QUnit.test('viewportToImageCoordinates', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el.times(viewport.getContainerSize().x);
|
return el.times(viewport.getContainerSize().x);
|
||||||
@ -929,8 +980,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('imageToViewportCoordinates', function() {
|
QUnit.test('imageToViewportCoordinates', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el.times(viewer.source.dimensions.x);
|
return el.times(viewer.source.dimensions.x);
|
||||||
@ -942,8 +993,8 @@
|
|||||||
assert: assertPointsEquals
|
assert: assertPointsEquals
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
asyncTest('imageToViewportRectangle', function() {
|
QUnit.test('imageToViewportRectangle', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testRects,
|
testArray: testRects,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el.times(viewer.source.dimensions.x);
|
return el.times(viewer.source.dimensions.x);
|
||||||
@ -961,8 +1012,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('viewportToImageRectangle', function() {
|
QUnit.test('viewportToImageRectangle', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testRects,
|
testArray: testRects,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el.times(viewport.getContainerSize().x);
|
return el.times(viewport.getContainerSize().x);
|
||||||
@ -979,8 +1030,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('viewerElementToImageCoordinates', function() {
|
QUnit.test('viewerElementToImageCoordinates', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el.times(viewport.getContainerSize().x);
|
return el.times(viewport.getContainerSize().x);
|
||||||
@ -992,8 +1043,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('imageToViewerElementCoordinates', function() {
|
QUnit.test('imageToViewerElementCoordinates', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el.times(viewer.source.dimensions.x);
|
return el.times(viewer.source.dimensions.x);
|
||||||
@ -1005,8 +1056,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('windowToImageCoordinates', function() {
|
QUnit.test('windowToImageCoordinates', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
var window_boundary = Math.min(window.innerWidth, window.innerHeight);
|
var window_boundary = Math.min(window.innerWidth, window.innerHeight);
|
||||||
@ -1020,8 +1071,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('imageToWindowCoordinates', function() {
|
QUnit.test('imageToWindowCoordinates', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el.times(viewer.source.dimensions.x);
|
return el.times(viewer.source.dimensions.x);
|
||||||
@ -1034,8 +1085,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('windowToViewportCoordinates', function() {
|
QUnit.test('windowToViewportCoordinates', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
var window_boundary = Math.min(window.innerWidth, window.innerHeight);
|
var window_boundary = Math.min(window.innerWidth, window.innerHeight);
|
||||||
@ -1049,8 +1100,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('viewportToWindowCoordinates', function() {
|
QUnit.test('viewportToWindowCoordinates', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el.times(viewer.source.dimensions.x);
|
return el.times(viewer.source.dimensions.x);
|
||||||
@ -1063,8 +1114,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('viewportToImageZoom', function() {
|
QUnit.test('viewportToImageZoom', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el;
|
return el;
|
||||||
@ -1076,8 +1127,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('imageToViewportZoom', function() {
|
QUnit.test('imageToViewportZoom', function(assert) {
|
||||||
loopingTestHelper({
|
loopingTestHelper(assert, {
|
||||||
testArray: testPoints,
|
testArray: testPoints,
|
||||||
getOrig: function(el, viewport) {
|
getOrig: function(el, viewport) {
|
||||||
return el;
|
return el;
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
/* global module, asyncTest, $, ok, equal, notEqual, start, test, Util, testLog */
|
/* global QUnit, $, testLog */
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var viewer;
|
var viewer;
|
||||||
|
|
||||||
module('World', {
|
QUnit.module('World', {
|
||||||
setup: function () {
|
beforeEach: function () {
|
||||||
var example = $('<div id="example"></div>').appendTo("#qunit-fixture");
|
$('<div id="example"></div>').appendTo("#qunit-fixture");
|
||||||
|
|
||||||
testLog.reset();
|
testLog.reset();
|
||||||
|
|
||||||
@ -15,7 +15,7 @@
|
|||||||
springStiffness: 100 // Faster animation = faster tests
|
springStiffness: 100 // Faster animation = faster tests
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
teardown: function () {
|
afterEach: function () {
|
||||||
if (viewer && viewer.close) {
|
if (viewer && viewer.close) {
|
||||||
viewer.close();
|
viewer.close();
|
||||||
}
|
}
|
||||||
@ -25,54 +25,56 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
var checkBounds = function(expected, message) {
|
var checkBounds = function(assert, expected, message) {
|
||||||
var bounds = viewer.world.getHomeBounds();
|
var bounds = viewer.world.getHomeBounds();
|
||||||
ok(bounds.equals(expected), message + ' ' + bounds.toString());
|
assert.ok(bounds.equals(expected), message + ' ' + bounds.toString());
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('adding a tiled image', function() {
|
QUnit.test('adding a tiled image', function(assert) {
|
||||||
ok(viewer.world, 'World exists');
|
var done = assert.async();
|
||||||
|
assert.ok(viewer.world, 'World exists');
|
||||||
|
|
||||||
viewer.world.addHandler('add-item', function(event) {
|
viewer.world.addHandler('add-item', function(event) {
|
||||||
ok(event, 'add-item handler received event data');
|
assert.ok(event, 'add-item handler received event data');
|
||||||
equal(event.eventSource, viewer.world, 'sender of add-item event was world');
|
assert.equal(event.eventSource, viewer.world, 'sender of add-item event was world');
|
||||||
ok(event.item, 'add-item event includes item');
|
assert.ok(event.item, 'add-item event includes item');
|
||||||
equal(viewer.world.getItemCount(), 1, 'there is now 1 item');
|
assert.equal(viewer.world.getItemCount(), 1, 'there is now 1 item');
|
||||||
equal(event.item, viewer.world.getItemAt(0), 'item is accessible via getItemAt');
|
assert.equal(event.item, viewer.world.getItemAt(0), 'item is accessible via getItemAt');
|
||||||
equal(viewer.world.getIndexOfItem(event.item), 0, 'item index is 0');
|
assert.equal(viewer.world.getIndexOfItem(event.item), 0, 'item index is 0');
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
equal(viewer.world.getItemCount(), 0, 'no items to start with');
|
assert.equal(viewer.world.getItemCount(), 0, 'no items to start with');
|
||||||
|
|
||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('metrics', function() {
|
QUnit.test('metrics', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer.addHandler('open', function(event) {
|
viewer.addHandler('open', function(event) {
|
||||||
checkBounds(new OpenSeadragon.Rect(0, 0, 4, 4), 'bounds after open');
|
checkBounds(assert, new OpenSeadragon.Rect(0, 0, 4, 4), 'bounds after open');
|
||||||
|
|
||||||
var expectedContentFactor = viewer.world.getItemAt(1).getContentSize().x / 2;
|
var expectedContentFactor = viewer.world.getItemAt(1).getContentSize().x / 2;
|
||||||
equal(viewer.world.getContentFactor(), expectedContentFactor, 'content factor has changed');
|
assert.equal(viewer.world.getContentFactor(), expectedContentFactor, 'content factor has changed');
|
||||||
|
|
||||||
viewer.world.addHandler('metrics-change', function metricsChangeHandler(event) {
|
viewer.world.addHandler('metrics-change', function metricsChangeHandler(event) {
|
||||||
viewer.world.removeHandler('metrics-change', metricsChangeHandler);
|
viewer.world.removeHandler('metrics-change', metricsChangeHandler);
|
||||||
ok(event, 'metrics-change handler received event data');
|
assert.ok(event, 'metrics-change handler received event data');
|
||||||
equal(event.eventSource, viewer.world, 'sender of metrics-change event was world');
|
assert.equal(event.eventSource, viewer.world, 'sender of metrics-change event was world');
|
||||||
checkBounds(new OpenSeadragon.Rect(0, 0, 7, 12), 'bounds after position');
|
checkBounds(assert, new OpenSeadragon.Rect(0, 0, 7, 12), 'bounds after position');
|
||||||
viewer.world.getItemAt(0).setWidth(20);
|
viewer.world.getItemAt(0).setWidth(20);
|
||||||
checkBounds(new OpenSeadragon.Rect(0, 0, 20, 20), 'bounds after size');
|
checkBounds(assert, new OpenSeadragon.Rect(0, 0, 20, 20), 'bounds after size');
|
||||||
|
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
viewer.world.getItemAt(1).setPosition(new OpenSeadragon.Point(5, 10));
|
viewer.world.getItemAt(1).setPosition(new OpenSeadragon.Point(5, 10));
|
||||||
});
|
});
|
||||||
|
|
||||||
checkBounds(new OpenSeadragon.Rect(0, 0, 1, 1), 'default bounds');
|
checkBounds(assert, new OpenSeadragon.Rect(0, 0, 1, 1), 'default bounds');
|
||||||
equal(viewer.world.getContentFactor(), 1, 'default content factor');
|
assert.equal(viewer.world.getContentFactor(), 1, 'default content factor');
|
||||||
|
|
||||||
viewer.open([
|
viewer.open([
|
||||||
{
|
{
|
||||||
@ -86,23 +88,24 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('remove/reorder tiled images', function() {
|
QUnit.test('remove/reorder tiled images', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var handlerCount = 0;
|
var handlerCount = 0;
|
||||||
|
|
||||||
viewer.addHandler('open', function(event) {
|
viewer.addHandler('open', function(event) {
|
||||||
equal(viewer.world.getItemCount(), 3, 'there are now 3 items');
|
assert.equal(viewer.world.getItemCount(), 3, 'there are now 3 items');
|
||||||
var item0 = viewer.world.getItemAt(0);
|
var item0 = viewer.world.getItemAt(0);
|
||||||
var item1 = viewer.world.getItemAt(1);
|
var item1 = viewer.world.getItemAt(1);
|
||||||
|
|
||||||
viewer.world.addHandler('item-index-change', function(event) {
|
viewer.world.addHandler('item-index-change', function(event) {
|
||||||
handlerCount++;
|
handlerCount++;
|
||||||
ok(event, 'item-index-change handler received event data');
|
assert.ok(event, 'item-index-change handler received event data');
|
||||||
equal(event.eventSource, viewer.world, 'sender of item-index-change event was world');
|
assert.equal(event.eventSource, viewer.world, 'sender of item-index-change event was world');
|
||||||
equal(event.item, item0, 'item-index-change event includes correct item');
|
assert.equal(event.item, item0, 'item-index-change event includes correct item');
|
||||||
equal(event.newIndex, 1, 'item-index-change event includes correct newIndex');
|
assert.equal(event.newIndex, 1, 'item-index-change event includes correct newIndex');
|
||||||
equal(event.previousIndex, 0, 'item-index-change event includes correct previousIndex');
|
assert.equal(event.previousIndex, 0, 'item-index-change event includes correct previousIndex');
|
||||||
equal(viewer.world.getItemAt(0), item1, 'item1 is now at index 0');
|
assert.equal(viewer.world.getItemAt(0), item1, 'item1 is now at index 0');
|
||||||
equal(viewer.world.getItemAt(1), item0, 'item0 is now at index 1');
|
assert.equal(viewer.world.getItemAt(1), item0, 'item0 is now at index 1');
|
||||||
});
|
});
|
||||||
|
|
||||||
viewer.world.setItemIndex(item0, 1);
|
viewer.world.setItemIndex(item0, 1);
|
||||||
@ -110,11 +113,11 @@
|
|||||||
viewer.world.addHandler('remove-item', function removeHandler(event) {
|
viewer.world.addHandler('remove-item', function removeHandler(event) {
|
||||||
viewer.world.removeHandler('remove-item', removeHandler);
|
viewer.world.removeHandler('remove-item', removeHandler);
|
||||||
handlerCount++;
|
handlerCount++;
|
||||||
ok(event, 'remove-item handler received event data');
|
assert.ok(event, 'remove-item handler received event data');
|
||||||
equal(event.eventSource, viewer.world, 'sender of remove-item event was world');
|
assert.equal(event.eventSource, viewer.world, 'sender of remove-item event was world');
|
||||||
equal(event.item, item1, 'remove-item event includes correct item');
|
assert.equal(event.item, item1, 'remove-item event includes correct item');
|
||||||
equal(viewer.world.getItemCount(), 2, 'after removal, only two items remain');
|
assert.equal(viewer.world.getItemCount(), 2, 'after removal, only two items remain');
|
||||||
equal(viewer.world.getItemAt(0), item0, 'item0 is now at index 0');
|
assert.equal(viewer.world.getItemAt(0), item0, 'item0 is now at index 0');
|
||||||
});
|
});
|
||||||
|
|
||||||
viewer.world.removeItem(item1);
|
viewer.world.removeItem(item1);
|
||||||
@ -124,17 +127,17 @@
|
|||||||
removeCount++;
|
removeCount++;
|
||||||
if (removeCount === 2) {
|
if (removeCount === 2) {
|
||||||
handlerCount++;
|
handlerCount++;
|
||||||
equal(viewer.world.getItemCount(), 0, 'after removeAll, no items remain');
|
assert.equal(viewer.world.getItemCount(), 0, 'after removeAll, no items remain');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
viewer.world.removeAll();
|
viewer.world.removeAll();
|
||||||
|
|
||||||
equal(handlerCount, 3, 'correct number of handlers called');
|
assert.equal(handlerCount, 3, 'correct number of handlers called');
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
equal(viewer.world.getItemCount(), 0, 'no items to start with');
|
assert.equal(viewer.world.getItemCount(), 0, 'no items to start with');
|
||||||
|
|
||||||
viewer.open([
|
viewer.open([
|
||||||
'/test/data/testpattern.dzi',
|
'/test/data/testpattern.dzi',
|
||||||
@ -144,11 +147,12 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('draw', function() {
|
QUnit.test('draw', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
var handlerCount = 0;
|
var handlerCount = 0;
|
||||||
|
|
||||||
viewer.addHandler('open', function(event) {
|
viewer.addHandler('open', function(event) {
|
||||||
equal(viewer.world.needsDraw(), true, 'needs draw after open');
|
assert.equal(viewer.world.needsDraw(), true, 'needs draw after open');
|
||||||
|
|
||||||
viewer.addHandler('update-level', function updateHandler() {
|
viewer.addHandler('update-level', function updateHandler() {
|
||||||
viewer.removeHandler('update-level', updateHandler);
|
viewer.removeHandler('update-level', updateHandler);
|
||||||
@ -157,34 +161,36 @@
|
|||||||
|
|
||||||
viewer.world.draw();
|
viewer.world.draw();
|
||||||
|
|
||||||
equal(handlerCount, 1, 'correct number of handlers called');
|
assert.equal(handlerCount, 1, 'correct number of handlers called');
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
equal(viewer.world.needsDraw(), false, 'needs no draw at first');
|
assert.equal(viewer.world.needsDraw(), false, 'needs no draw at first');
|
||||||
|
|
||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('resetItems', function() {
|
QUnit.test('resetItems', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer.addHandler('tile-drawn', function updateHandler() {
|
viewer.addHandler('tile-drawn', function updateHandler() {
|
||||||
viewer.removeHandler('tile-drawn', updateHandler);
|
viewer.removeHandler('tile-drawn', updateHandler);
|
||||||
ok(viewer.tileCache.numTilesLoaded() > 0, 'we have tiles after tile-drawn');
|
assert.ok(viewer.tileCache.numTilesLoaded() > 0, 'we have tiles after tile-drawn');
|
||||||
viewer.world.resetItems();
|
viewer.world.resetItems();
|
||||||
equal(viewer.tileCache.numTilesLoaded(), 0, 'no tiles after reset');
|
assert.equal(viewer.tileCache.numTilesLoaded(), 0, 'no tiles after reset');
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
equal(viewer.tileCache.numTilesLoaded(), 0, 'no tiles at start');
|
assert.equal(viewer.tileCache.numTilesLoaded(), 0, 'no tiles at start');
|
||||||
|
|
||||||
viewer.open('/test/data/testpattern.dzi');
|
viewer.open('/test/data/testpattern.dzi');
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
asyncTest('arrange', function() {
|
QUnit.test('arrange', function(assert) {
|
||||||
|
var done = assert.async();
|
||||||
viewer.addHandler('open', function(event) {
|
viewer.addHandler('open', function(event) {
|
||||||
checkBounds(new OpenSeadragon.Rect(0, 0, 1, 1), 'all stacked');
|
checkBounds(assert, new OpenSeadragon.Rect(0, 0, 1, 1), 'all stacked');
|
||||||
|
|
||||||
viewer.world.arrange({
|
viewer.world.arrange({
|
||||||
layout: 'horizontal',
|
layout: 'horizontal',
|
||||||
@ -193,7 +199,7 @@
|
|||||||
tileMargin: 0.5
|
tileMargin: 0.5
|
||||||
});
|
});
|
||||||
|
|
||||||
checkBounds(new OpenSeadragon.Rect(0, 0, 4, 1), 'one horizontal row');
|
checkBounds(assert, new OpenSeadragon.Rect(0, 0, 4, 1), 'one horizontal row');
|
||||||
|
|
||||||
viewer.world.arrange({
|
viewer.world.arrange({
|
||||||
layout: 'horizontal',
|
layout: 'horizontal',
|
||||||
@ -202,7 +208,7 @@
|
|||||||
tileMargin: 0.5
|
tileMargin: 0.5
|
||||||
});
|
});
|
||||||
|
|
||||||
checkBounds(new OpenSeadragon.Rect(0, 0, 2.5, 2.5), 'grid');
|
checkBounds(assert, new OpenSeadragon.Rect(0, 0, 2.5, 2.5), 'grid');
|
||||||
|
|
||||||
viewer.world.arrange({
|
viewer.world.arrange({
|
||||||
layout: 'vertical',
|
layout: 'vertical',
|
||||||
@ -211,7 +217,7 @@
|
|||||||
tileMargin: 0.5
|
tileMargin: 0.5
|
||||||
});
|
});
|
||||||
|
|
||||||
checkBounds(new OpenSeadragon.Rect(0, 0, 1, 4), 'one vertical column');
|
checkBounds(assert, new OpenSeadragon.Rect(0, 0, 1, 4), 'one vertical column');
|
||||||
|
|
||||||
viewer.world.arrange({
|
viewer.world.arrange({
|
||||||
layout: 'horizontal',
|
layout: 'horizontal',
|
||||||
@ -221,7 +227,7 @@
|
|||||||
tileMargin: 0.5
|
tileMargin: 0.5
|
||||||
});
|
});
|
||||||
|
|
||||||
checkBounds(new OpenSeadragon.Rect(0, 0, 4, 1), 'three horizontal columns (one horizontal row)');
|
checkBounds(assert, new OpenSeadragon.Rect(0, 0, 4, 1), 'three horizontal columns (one horizontal row)');
|
||||||
|
|
||||||
viewer.world.arrange({
|
viewer.world.arrange({
|
||||||
layout: 'vertical',
|
layout: 'vertical',
|
||||||
@ -231,9 +237,9 @@
|
|||||||
tileMargin: 0.5
|
tileMargin: 0.5
|
||||||
});
|
});
|
||||||
|
|
||||||
checkBounds(new OpenSeadragon.Rect(0, 0, 1, 4), 'three vertical rows (one vertical column)');
|
checkBounds(assert, new OpenSeadragon.Rect(0, 0, 1, 4), 'three vertical rows (one vertical column)');
|
||||||
|
|
||||||
start();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
viewer.open([
|
viewer.open([
|
||||||
|
Loading…
Reference in New Issue
Block a user