loleaflet: tilebench cleanup

This commit is contained in:
Mihai Varga 2015-08-11 17:29:38 +03:00
parent 079b8c562f
commit 653aa2c9ea

View file

@ -2,7 +2,7 @@ describe('TileBench', function () {
// 25 s timeout // 25 s timeout
this.timeout(25000); this.timeout(25000);
var map; var map;
var loadCount = 0; var timeOut
var log = function (msg) { var log = function (msg) {
// write custom log messages // write custom log messages
@ -61,12 +61,11 @@ describe('TileBench', function () {
describe('Benchmarking', function () { describe('Benchmarking', function () {
it('Load all new tiles', function (done) { it('Load all new tiles', function (done) {
map.on('statusindicator', L.bind(function (e) { map.on('statusindicator', function (e) {
if (e.statusType === 'alltilesloaded') { if (e.statusType === 'alltilesloaded') {
loadCount += 1;
done(); done();
} }
}, done)); });
}); });
@ -76,13 +75,12 @@ describe('TileBench', function () {
// allow 2 seconds to pass after the last key input // allow 2 seconds to pass after the last key input
var aproxTime = keyInput[keyInput.length - 1][0] + 2000; var aproxTime = keyInput[keyInput.length - 1][0] + 2000;
setTimeout(L.bind(function () { setTimeout(function () {
map.on('statusindicator', L.bind(function (e) { map.on('statusindicator', function (e) {
if (e.statusType === 'alltilesloaded') { if (e.statusType === 'alltilesloaded') {
loadCount += 1;
getTimes(done); getTimes(done);
} }
}, done)); });
// request an empty tile and when it arrives we know that the // request an empty tile and when it arrives we know that the
@ -100,7 +98,7 @@ describe('TileBench', function () {
} }
var fragment = document.createDocumentFragment(); var fragment = document.createDocumentFragment();
docLayer._addTile(coords, fragment); docLayer._addTile(coords, fragment);
}, done), aproxTime); }, aproxTime);
for (var i = 0; i < keyInput.length; i++) { for (var i = 0; i < keyInput.length; i++) {
setTimeout(L.bind(function () { setTimeout(L.bind(function () {
@ -113,7 +111,7 @@ describe('TileBench', function () {
$('.scroll-container').mCustomScrollbar('scrollTo', 'bottom', {scrollInertia: 3000}); $('.scroll-container').mCustomScrollbar('scrollTo', 'bottom', {scrollInertia: 3000});
// check how we're doing 200ms after the scroll has ended // check how we're doing 200ms after the scroll has ended
// (allow enough time to request new tiles) // (allow enough time to request new tiles)
this.timeOut = setTimeout(L.bind(function () { timeOut = setTimeout(function () {
if (map._docLayer._emptyTilesCount === 0) { if (map._docLayer._emptyTilesCount === 0) {
// no pending tile requests // no pending tile requests
done(); done();
@ -121,13 +119,12 @@ describe('TileBench', function () {
else { else {
map.on('statusindicator', L.bind(function (e) { map.on('statusindicator', L.bind(function (e) {
if (e.statusType === 'alltilesloaded') { if (e.statusType === 'alltilesloaded') {
loadCount += 1; clearTimeout(timeOut);
clearTimeout(this.timeOut);
done(); done();
} }
}, done)); }, done));
} }
}, done), 3200); }, 3200);
}); });
}); });