test(GridLayer): fix pan move&forth graph browsers
because graphical browsers, even in non-animated pan, will still perform tile fade-in animation, which require some frames before calling _pruneTiles().
This commit is contained in:
parent
bed7cd101e
commit
abeff4d543
@ -892,29 +892,41 @@ describe('GridLayer', function () {
|
|||||||
// clock.tick(250);
|
// clock.tick(250);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// NOTE: This test has different behaviour in PhantomJS and graphical
|
||||||
|
// browsers due to CSS animations!
|
||||||
it("Loads map, moves forth and back by 512 px, keepBuffer = 0", function (done) {
|
it("Loads map, moves forth and back by 512 px, keepBuffer = 0", function (done) {
|
||||||
|
|
||||||
grid.on('load', function () {
|
grid.once('load', function () {
|
||||||
expect(counts.tileloadstart).to.be(16);
|
expect(counts.tileloadstart).to.be(16);
|
||||||
expect(counts.tileload).to.be(16);
|
expect(counts.tileload).to.be(16);
|
||||||
expect(counts.tileunload).to.be(0);
|
expect(counts.tileunload).to.be(0);
|
||||||
grid.off('load');
|
|
||||||
|
|
||||||
grid.on('load', function () {
|
grid.once('load', function () {
|
||||||
expect(counts.tileloadstart).to.be(28);
|
expect(counts.tileloadstart).to.be(28);
|
||||||
expect(counts.tileload).to.be(28);
|
expect(counts.tileload).to.be(28);
|
||||||
expect(counts.tileunload).to.be(12);
|
|
||||||
|
|
||||||
grid.off('load');
|
// Wait for a frame to let _updateOpacity starting
|
||||||
grid.on('load', function () {
|
// It will prune the 12 tiles outside the new bounds.
|
||||||
expect(counts.tileloadstart).to.be(40);
|
// PhantomJS has Browser.any3d === false, so it actually
|
||||||
expect(counts.tileload).to.be(40);
|
// does not perform the fade animation and does not need
|
||||||
expect(counts.tileunload).to.be(24);
|
// this rAF, but it does not harm either.
|
||||||
done();
|
L.Util.requestAnimFrame(function () {
|
||||||
|
expect(counts.tileunload).to.be(12);
|
||||||
|
|
||||||
|
grid.once('load', function () {
|
||||||
|
expect(counts.tileloadstart).to.be(40);
|
||||||
|
expect(counts.tileload).to.be(40);
|
||||||
|
|
||||||
|
// Wait an extra frame for the tile pruning to happen.
|
||||||
|
L.Util.requestAnimFrame(function () {
|
||||||
|
expect(counts.tileunload).to.be(24);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
map.panBy([-512, -512], {animate: false});
|
||||||
|
clock.tick(250);
|
||||||
});
|
});
|
||||||
|
|
||||||
map.panBy([-512, -512], {animate: false});
|
|
||||||
clock.tick(250);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
map.panBy([512, 512], {animate: false});
|
map.panBy([512, 512], {animate: false});
|
||||||
|
Loading…
Reference in New Issue
Block a user