2017-12-07 04:20:39 +03:00
|
|
|
/* global QUnit, $, testLog */
|
2014-11-21 03:02:02 +03:00
|
|
|
|
|
|
|
(function() {
|
|
|
|
var viewer;
|
|
|
|
|
2017-12-07 04:20:39 +03:00
|
|
|
QUnit.module('ReferenceStrip', {
|
|
|
|
beforeEach: function () {
|
|
|
|
$('<div id="example"></div>').appendTo("#qunit-fixture");
|
2014-11-21 03:02:02 +03:00
|
|
|
|
|
|
|
testLog.reset();
|
|
|
|
},
|
2017-12-07 04:20:39 +03:00
|
|
|
afterEach: function () {
|
2024-01-10 20:13:00 +03:00
|
|
|
if (viewer){
|
2024-01-18 20:45:27 +03:00
|
|
|
let errors = viewer.drawer._numGlMaxTextureErrors;
|
|
|
|
if(errors > 0){
|
|
|
|
console.log('Number of times MAX_TEXTURE_IMAGE_UNITS had a bad value:', errors);
|
|
|
|
} else {
|
|
|
|
console.log('Num OK draw calls', viewer.drawer._numGlMaxTextureOks);
|
|
|
|
}
|
|
|
|
viewer.destroy();
|
2024-01-18 01:07:25 +03:00
|
|
|
}
|
2014-11-21 03:02:02 +03:00
|
|
|
|
|
|
|
viewer = null;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// ----------
|
|
|
|
var createViewer = function(options) {
|
|
|
|
options = options || {};
|
|
|
|
viewer = OpenSeadragon(OpenSeadragon.extend({
|
|
|
|
id: 'example',
|
|
|
|
prefixUrl: '/build/openseadragon/images/',
|
|
|
|
springStiffness: 100 // Faster animation = faster tests
|
|
|
|
}, options));
|
|
|
|
};
|
|
|
|
|
|
|
|
// ----------
|
2017-12-07 04:20:39 +03:00
|
|
|
QUnit.test('basics', function(assert) {
|
|
|
|
var done = assert.async();
|
2014-11-21 03:02:02 +03:00
|
|
|
createViewer({
|
|
|
|
sequenceMode: true,
|
|
|
|
showReferenceStrip: true,
|
|
|
|
tileSources: [
|
|
|
|
'/test/data/tall.dzi',
|
|
|
|
'/test/data/wide.dzi',
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
2017-12-07 04:20:39 +03:00
|
|
|
assert.ok(viewer.referenceStrip, 'referenceStrip exists');
|
|
|
|
done();
|
2014-11-21 03:02:02 +03:00
|
|
|
});
|
|
|
|
|
2019-07-16 05:27:03 +03:00
|
|
|
// ----------
|
|
|
|
QUnit.test('shadow dom', function(assert) {
|
2019-07-19 23:20:55 +03:00
|
|
|
if (document.head && document.head.attachShadow) {
|
|
|
|
var done = assert.async();
|
2019-07-16 05:27:03 +03:00
|
|
|
|
2019-07-19 23:20:55 +03:00
|
|
|
var shadowDiv = document.createElement('div');
|
|
|
|
shadowDiv.attachShadow({
|
|
|
|
mode: 'open'
|
|
|
|
});
|
|
|
|
shadowDiv.shadowRoot.innerHTML = `<div id="shadow-example"></div>`
|
2019-07-16 05:27:03 +03:00
|
|
|
|
2019-07-19 23:20:55 +03:00
|
|
|
createViewer({
|
|
|
|
element: shadowDiv.shadowRoot.querySelector('#shadow-example'),
|
|
|
|
sequenceMode: true,
|
|
|
|
showReferenceStrip: true,
|
|
|
|
tileSources: [
|
|
|
|
'/test/data/tall.dzi',
|
|
|
|
'/test/data/wide.dzi'
|
|
|
|
]
|
|
|
|
});
|
2019-07-16 05:27:03 +03:00
|
|
|
|
2019-07-19 23:20:55 +03:00
|
|
|
$(shadowDiv).appendTo("#qunit-fixture");
|
2019-07-16 05:27:03 +03:00
|
|
|
|
2019-07-19 23:20:55 +03:00
|
|
|
assert.ok(viewer.referenceStrip, 'referenceStrip exists');
|
|
|
|
done();
|
|
|
|
} else {
|
|
|
|
assert.expect(0);
|
|
|
|
}
|
2019-07-16 05:27:03 +03:00
|
|
|
})
|
|
|
|
|
2014-11-21 03:02:02 +03:00
|
|
|
})();
|