From 84a1e6d1c3aab1d56685b6f679fb2a61765b6913 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Thu, 30 Jul 2015 14:11:08 -0400 Subject: [PATCH] remove request coalescing tests --- test/js/map.test.js | 138 -------------------------------------------- 1 file changed, 138 deletions(-) diff --git a/test/js/map.test.js b/test/js/map.test.js index b60b21a6c..509eaa17d 100644 --- a/test/js/map.test.js +++ b/test/js/map.test.js @@ -155,144 +155,6 @@ test('Map', function(t) { t.end(); }); - t.test('request coalesting', function(t) { - var requestList = []; - var optionsDoNotReply = {}; - - // This file source will never reply to any - // request other than "./fixtures/tiles.tilejson" which - // will force the cancellation of the pending requests. - optionsDoNotReply.request = function(req) { - if (req.url != "./fixtures/tiles.tilejson") { - requestList.push(req); - return; - } - - fs.readFile(path.join('test', req.url), function(err, data) { - req.respond(err, { data: data }); - }); - }; - - optionsDoNotReply.cancel = function() { - requestList.pop(); - }; - - t.test('merge requests/cancels for the same resource', function(t) { - var map1 = new mbgl.Map(optionsDoNotReply); - var map2 = new mbgl.Map(optionsDoNotReply); - var map3 = new mbgl.Map(optionsDoNotReply); - var map4 = new mbgl.Map(optionsDoNotReply); - var map5 = new mbgl.Map(optionsDoNotReply); - - map1.load(style); - map2.load(style); - map3.load(style); - map4.load(style); - map5.load(style); - - var renderCallback = function(err, data) {} - - map1.render({}, renderCallback); - map2.render({}, renderCallback); - map3.render({}, renderCallback); - map4.render({}, renderCallback); - map5.render({}, renderCallback); - - var checkCancel = function() { - t.equal(requestList.length, 0); - t.end(); - }; - - var checkCoalescing = function() { - // Check if all the 5 vector tile - // requests are going to merge in - // a single request. - t.equal(requestList.length, 1); - - // This should cause the pending - // resources to get canceled, but - // only one cancel is emitted, because - // all map objects requested the same - // resource. - map1.release(); - map2.release(); - map3.release(); - map4.release(); - map5.release(); - - setTimeout(checkCancel, 500); - }; - - setTimeout(checkCoalescing, 500); - }); - - var vectorTileRequestCount = 0; - var optionsDelay = {}; - - // This file source will add a little delay before - // replying so we make sure that all the map objects - // request the same resource will get a reply from the - // same request. - optionsDelay.request = function(req) { - var timeout = 0; - - if (req.url != "./fixtures/tiles.tilejson") { - timeout = 500; - t.ok(++vectorTileRequestCount == 1, "Should make only one request for tiles"); - } - - var readFile = function() { - fs.readFile(path.join('test', req.url), function(err, data) { - req.respond(err, { data: data }); - }); - }; - - setTimeout(readFile, timeout); - }; - - optionsDelay.cancel = function() { - t.fail("Should never cancel"); - }; - - t.test('one request for the same resource notifies multiple map objects', function(t) { - var map1 = new mbgl.Map(optionsDelay); - var map2 = new mbgl.Map(optionsDelay); - var map3 = new mbgl.Map(optionsDelay); - var map4 = new mbgl.Map(optionsDelay); - var map5 = new mbgl.Map(optionsDelay); - - map1.load(style); - map2.load(style); - map3.load(style); - map4.load(style); - map5.load(style); - - var renderFinishedCount = 0; - var renderCallback = function(err, data) { - // We make only one request for tiles, but that - // should be enough for all these map objects because - // they all want the same resource. - if (++renderFinishedCount == 5) { - map1.release(); - map2.release(); - map3.release(); - map4.release(); - map5.release(); - - t.end(); - } - } - - map1.render({}, renderCallback); - map2.render({}, renderCallback); - map3.render({}, renderCallback); - map4.render({}, renderCallback); - map5.render({}, renderCallback); - }); - - t.end(); - }); - t.test('render argument requirements', function(t) { var options = {}; options.request = function(req) {