Leaflet/spec/suites/layer/tile/TileLayerSpec.js

471 lines
21 KiB
JavaScript

describe('TileLayer', function () {
var div, map;
// Placekitten via http://placekitten.com/attribution.html
// Image licensed under CC-by-sa by http://flickr.com/photos/lachlanrogers/
var placeKitten = "data:image/jpeg;base64," +
"/9j/4AAQSkZJRgABAQAAAQABAAD//gA7Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcgSlBF" +
"RyB2NjIpLCBxdWFsaXR5ID0gNjUK/9sAQwALCAgKCAcLCgkKDQwLDREcEhEPDxEiGRoUHCkkKyooJCcn" +
"LTJANy0wPTAnJzhMOT1DRUhJSCs2T1VORlRAR0hF/9sAQwEMDQ0RDxEhEhIhRS4nLkVFRUVFRUVFRUVF" +
"RUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVF/8AAEQgBAAEAAwEiAAIRAQMRAf/E" +
"AB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUS" +
"ITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RV" +
"VldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TF" +
"xsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgME" +
"BQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1Lw" +
"FWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKD" +
"hIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp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546Uxtodd0iDHGQeVPsKcxVPuA7duSSMg9v5UNgyGVhtHRsAYx659aAHsElixJIwA4znH48VGVYB" +
"jGFMa9ieRSJhHCI24KCDu7+/0pMxwuWQEqMlsnlqQFgjd8rde9S4IUbTjApp2nADD607PAw1MAMilCMc" +
"ikBBzjOTQqKWwR1pUR1fABx3oATJ8wsueOMHijaWJPpzk1In3XUn5vUU4AMmCcH6UAV2di27qRxxUpDA" +
"fdO5ecgfzpBEJGYg4IGBSh9uVLHJ60ANDEMDjdk8g0pQFWbGTT8FiVK557d6a2VGeQvb1FADWjYKdwHy" +
"84+tOVsDDDt90jNBk3yA8lgBnHNI5JUsRnPTA6UAARSNxG9up9qiLmRyI/mBOODincOm1gwdeBx1FKiG" +
"Mhwo+bgigBJEWNiTuUDnAbPaiNoxyxwTj34pFYtMwbGw9QewpwjVjjd8q8ADgUASearEOqsVXgDP3uOK" +
"gLxh/MCt847GmtAIpDEmVXlmbPNPkCvONrfOg+UN/n60AAyVLoBvXCnByB71Ai52syblJ6sRhhVpUDFg" +
"G2q2MKTj8ajIACxqvyA8DoM9DxQBHIrZJPPOQucbgPehiqxh8ghVycjnGf5UjeZ1YkBjksfUetKVzHhl" +
"OG7jBI9P60AEIaIAygKTjAPbg4FClZl3MeJOPu8HPFK5Jl3rsbC4XdxnrmmLuXCwxkL3XHXP1/z1oAdc" +
"REGNY13tnPoM+3vUjyCSLaQW2t8wzgn3qAIEmG5y+CGHcA05GVV25AEhJTnkDpQA0H5mUZcBsEsMc+n0" +
"qMEAbA4BUkEHPNTRh5Y2wTuJ6MOvSovLEsSKoMar/Fnk9e9AEzMWg2hsEkjI71DCWhh+V94Xnjk/lTDG" +
"8kRchtw56dc9z/nvTjIftC+YoUtwMHqPegBiYZ98Qdc8fMP5VI+Vh8zZltuCPf2odlWMlmIIOwsw4P69" +
"qQzPJJgDeASMHuOx+lAH/9k=";
beforeEach(function () {
div = document.createElement('div');
div.style.width = '800px';
div.style.height = '600px';
div.style.visibility = 'hidden';
document.body.appendChild(div);
map = L.map(div);
});
afterEach(function () {
document.body.removeChild(div);
});
function kittenLayerFactory(options) {
return L.tileLayer(placeKitten, options || {});
}
describe("number of kittens loaded", function () {
var clock, kittenLayer, counts;
// animationFrame helper, just runs requestAnimFrame() a given number of times
function runFrames(n) {
return _runFrames(n)();
}
function _runFrames(n) {
if (n) {
return function () {
clock.tick(40); // 40msec/frame ~= 25fps
map.fire('_frame');
L.Util.requestAnimFrame(_runFrames(n - 1));
};
} else {
return L.Util.falseFn;
}
}
beforeEach(function () {
clock = sinon.useFakeTimers();
kittenLayer = kittenLayerFactory();
counts = {
tileload: 0,
tileerror: 0,
tileloadstart: 0,
tileunload: 0
};
kittenLayer.on('tileload tileunload tileerror tileloadstart', function (ev) {
// console.log(ev.type);
counts[ev.type]++;
});
// grid.on('tileunload', function (ev) {
// console.log(ev.type, ev.coords, counts);
// });
map.options.fadeAnimation = false;
map.options.zoomAnimation = false;
});
afterEach(function () {
clock.restore();
kittenLayer.off();
kittenLayer = undefined;
counts = undefined;
});
it("Loads 8 kittens zoom 1", function (done) {
kittenLayer.on('load', function () {
expect(counts.tileloadstart).to.be(8);
expect(counts.tileload).to.be(8);
expect(counts.tileunload).to.be(0);
expect(kittenLayer._container.querySelectorAll('img').length).to.be(8);
done();
});
map.addLayer(kittenLayer).setView([0, 0], 1);
clock.tick(250);
});
// NOTE: This test has different behaviour in PhantomJS and graphical
// browsers due to CSS animations!
it.skipInPhantom("Loads 290, unloads 275 kittens on MAD-TRD flyTo()", function (done) {
this.timeout(10000); // This test takes longer than usual due to frames
var mad = [40.40, -3.7], trd = [63.41, 10.41];
kittenLayer.on('load', function () {
expect(counts.tileloadstart).to.be(12);
expect(counts.tileload).to.be(12);
expect(counts.tileunload).to.be(0);
kittenLayer.off('load');
map.on('zoomend', function () {
expect(counts.tileloadstart).to.be(290);
expect(counts.tileunload).to.be(275);
// image tiles take time, so then might not be fully loaded yet.
expect(counts.tileload).to.be.lessThan(counts.tileloadstart + 1);
expect(counts.tileload).to.be.greaterThan(counts.tileunload);
expect(kittenLayer._container.querySelectorAll('img').length).to.be(15);
done();
});
map.flyTo(trd, 12, {animate: true});
// map.on('_frame', function () {
// console.log('frame', counts);
// });
runFrames(500);
});
map.addLayer(kittenLayer).setView(mad, 12);
clock.tick(250);
});
});
describe('url template', function () {
beforeEach(function () {
div = document.createElement('div');
div.style.width = '400px';
div.style.height = '400px';
div.style.visibility = 'hidden';
document.body.appendChild(div);
map = L.map(div).setView([0, 0], 2);
});
function eachImg(layer, callback) {
var imgtags = layer._container.children[0].children;
for (var i in imgtags) {
if (imgtags[i].tagName === 'IMG') {
callback(imgtags[i]);
}
}
}
it('replaces {y} with y coordinate', function () {
var layer = L.tileLayer('http://example.com/{z}/{y}/{x}.png').addTo(map);
var urls = [
'http://example.com/2/1/1.png',
'http://example.com/2/1/2.png',
'http://example.com/2/2/1.png',
'http://example.com/2/2/2.png'
];
var i = 0;
eachImg(layer, function (img) {
expect(img.src).to.eql(urls[i]);
i++;
});
});
it('replaces {-y} with inverse y coordinate', function () {
var layer = L.tileLayer('http://example.com/{z}/{-y}/{x}.png').addTo(map);
var urls = [
'http://example.com/2/2/1.png',
'http://example.com/2/2/2.png',
'http://example.com/2/1/1.png',
'http://example.com/2/1/2.png'
];
var i = 0;
eachImg(layer, function (img) {
expect(img.src).to.eql(urls[i]);
i++;
});
});
it('Does not replace {-y} on map with infinite CRS', function () {
var simplediv = document.createElement('div');
simplediv.style.width = '400px';
simplediv.style.height = '400px';
simplediv.style.visibility = 'hidden';
document.body.appendChild(simplediv);
var simpleMap = L.map(simplediv, {
crs: L.CRS.Simple
}).setView([0, 0], 5);
var layer = L.tileLayer('http://example.com/{z}/{-y}/{x}.png');
expect(function () {
layer.addTo(simpleMap);
}).to.throwError('No value provided for variable {-y}');
simpleMap.remove();
document.body.removeChild(simplediv);
});
it('replaces {s} with [abc] by default', function () {
var layer = L.tileLayer('http://{s}.example.com/{z}/{-y}/{x}.png').addTo(map);
eachImg(layer, function (img) {
expect(['a', 'b', 'c'].indexOf(img.src[7]) >= 0).to.eql(true);
});
});
it('replaces {s} with specified prefixes', function () {
var layer = L.tileLayer('http://{s}.example.com/{z}/{-y}/{x}.png', {
subdomains: 'qrs'
}).addTo(map);
eachImg(layer, function (img) {
expect(['q', 'r', 's'].indexOf(img.src[7]) >= 0).to.eql(true);
});
});
});
describe('minNativeZoom', function () {
before(function () {
div = document.createElement('div');
div.style.width = '400px';
div.style.height = '400px';
div.style.visibility = 'hidden';
document.body.appendChild(div);
map = L.map(div).setView([0, 0], 0);
});
it('returns downscaled tileSize when zoom is lower than minNativeZoom (zoom = 0, minNativeZoom = 1)', function () {
var layer = L.tileLayer('http://{s}.example.com/{z}/{-y}/{x}.png', {
minNativeZoom: 1,
tileSize: 256
}).addTo(map);
map.setView([0, 0], 0);
expect(map.getZoom()).to.equal(0);
expect(layer.getTileSize().x).to.equal(128);
expect(layer.getTileSize().y).to.equal(128);
});
it('returns regular tileSize when zoom is equal to minNativeZoom (zoom = 1, minNativeZoom = 1)', function () {
var layer = L.tileLayer('http://{s}.example.com/{z}/{-y}/{x}.png', {
minNativeZoom: 1,
tileSize: 256
}).addTo(map);
map.setView([0, 0], 1);
expect(map.getZoom()).to.equal(1);
expect(layer.getTileSize().x).to.equal(256);
expect(layer.getTileSize().y).to.equal(256);
});
it('returns regular tileSize when zoom is greater than minNativeZoom (zoom = 2, minNativeZoom = 1)', function () {
var layer = L.tileLayer('http://{s}.example.com/{z}/{-y}/{x}.png', {
minNativeZoom: 1,
tileSize: 256
}).addTo(map);
map.setView([0, 0], 2);
expect(map.getZoom()).to.equal(2);
expect(layer.getTileSize().x).to.equal(256);
expect(layer.getTileSize().y).to.equal(256);
});
});
describe('maxNativeZoom', function () {
before(function () {
div = document.createElement('div');
div.style.width = '400px';
div.style.height = '400px';
div.style.visibility = 'hidden';
document.body.appendChild(div);
map = L.map(div).setView([0, 0], 0);
});
it('returns upscaled tileSize when zoom is higher than maxNativeZoom (zoom = 2, maxNativeZoom = 1)', function () {
var layer = L.tileLayer('http://{s}.example.com/{z}/{-y}/{x}.png', {
maxNativeZoom: 1,
tileSize: 256
}).addTo(map);
map.setView([0, 0], 2);
expect(layer.getTileSize().x).to.equal(512);
expect(layer.getTileSize().y).to.equal(512);
});
it('returns regular tileSize when zoom is equal to minNativeZoom (zoom = 1, maxNativeZoom = 1)', function () {
var layer = L.tileLayer('http://{s}.example.com/{z}/{-y}/{x}.png', {
maxNativeZoom: 1,
tileSize: 256
}).addTo(map);
map.setView([0, 0], 1);
expect(layer.getTileSize().x).to.equal(256);
expect(layer.getTileSize().y).to.equal(256);
});
it('returns regular tileSize when zoom is lower than minNativeZoom (zoom = 0, maxNativeZoom = 1)', function () {
var layer = L.tileLayer('http://{s}.example.com/{z}/{-y}/{x}.png', {
maxNativeZoom: 1,
tileSize: 256
}).addTo(map);
map.setView([0, 0], 0);
expect(layer.getTileSize().x).to.equal(256);
expect(layer.getTileSize().y).to.equal(256);
});
});
});