One provide per test file
This commit is contained in:
@@ -252,7 +252,7 @@ build/timestamps/eslint-timestamp: $(SRC_JS) $(SPEC_JS) $(SPEC_RENDERING_JS) \
|
|||||||
build/timestamps/node-modules-timestamp
|
build/timestamps/node-modules-timestamp
|
||||||
@mkdir -p $(@D)
|
@mkdir -p $(@D)
|
||||||
@echo "Running eslint..."
|
@echo "Running eslint..."
|
||||||
@./node_modules/.bin/eslint tasks test test_rendering src examples
|
@./node_modules/.bin/eslint --quiet tasks test test_rendering src examples
|
||||||
@touch $@
|
@touch $@
|
||||||
|
|
||||||
build/timestamps/node-modules-timestamp: package.json
|
build/timestamps/node-modules-timestamp: package.json
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
goog.provide('ol.test.style.Icon');
|
goog.provide('ol.test.style.Icon');
|
||||||
goog.provide('ol.test.style.IconImageCache');
|
|
||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.events');
|
|
||||||
goog.require('ol.style');
|
goog.require('ol.style');
|
||||||
goog.require('ol.style.Icon');
|
goog.require('ol.style.Icon');
|
||||||
goog.require('ol.style.IconImage');
|
goog.require('ol.style.IconImage');
|
||||||
@@ -167,66 +165,3 @@ describe('ol.style.Icon', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ol.style.IconImageCache', function() {
|
|
||||||
var originalMaxCacheSize;
|
|
||||||
|
|
||||||
beforeEach(function() {
|
|
||||||
var cache = ol.style.iconImageCache;
|
|
||||||
cache.clear();
|
|
||||||
originalMaxCacheSize = cache.maxCacheSize;
|
|
||||||
cache.maxCacheSize_ = 4;
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(function() {
|
|
||||||
var cache = ol.style.iconImageCache;
|
|
||||||
cache.maxCacheSize_ = originalMaxCacheSize;
|
|
||||||
cache.clear();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#expire', function() {
|
|
||||||
it('expires images when expected', function() {
|
|
||||||
var cache = ol.style.iconImageCache;
|
|
||||||
|
|
||||||
var i, src, iconImage;
|
|
||||||
|
|
||||||
for (i = 0; i < 4; ++i) {
|
|
||||||
src = i + '';
|
|
||||||
iconImage = new ol.style.IconImage(src, null);
|
|
||||||
cache.set(src, null, null, iconImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(cache.cacheSize_).to.eql(4);
|
|
||||||
|
|
||||||
cache.expire();
|
|
||||||
expect(cache.cacheSize_).to.eql(4);
|
|
||||||
|
|
||||||
src = '4';
|
|
||||||
iconImage = new ol.style.IconImage(src, null);
|
|
||||||
cache.set(src, null, null, iconImage);
|
|
||||||
expect(cache.cacheSize_).to.eql(5);
|
|
||||||
|
|
||||||
cache.expire(); // remove '0' and '4'
|
|
||||||
expect(cache.cacheSize_).to.eql(3);
|
|
||||||
|
|
||||||
src = '0';
|
|
||||||
iconImage = new ol.style.IconImage(src, null);
|
|
||||||
ol.events.listen(iconImage, 'change',
|
|
||||||
ol.nullFunction, false);
|
|
||||||
cache.set(src, null, null, iconImage);
|
|
||||||
expect(cache.cacheSize_).to.eql(4);
|
|
||||||
|
|
||||||
src = '4';
|
|
||||||
iconImage = new ol.style.IconImage(src, null);
|
|
||||||
ol.events.listen(iconImage, 'change',
|
|
||||||
ol.nullFunction, false);
|
|
||||||
cache.set(src, null, null, iconImage);
|
|
||||||
expect(cache.cacheSize_).to.eql(5);
|
|
||||||
|
|
||||||
// check that '0' and '4' are not removed from the cache
|
|
||||||
cache.expire();
|
|
||||||
expect(cache.get('0', null, null)).to.not.be(null);
|
|
||||||
expect(cache.get('4', null, null)).to.not.be(null);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
goog.provide('ol.test.style.IconImageCache');
|
||||||
|
|
||||||
|
goog.require('ol');
|
||||||
|
goog.require('ol.events');
|
||||||
|
goog.require('ol.style');
|
||||||
|
goog.require('ol.style.IconImage');
|
||||||
|
|
||||||
|
describe('ol.style.IconImageCache', function() {
|
||||||
|
var originalMaxCacheSize;
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
var cache = ol.style.iconImageCache;
|
||||||
|
cache.clear();
|
||||||
|
originalMaxCacheSize = cache.maxCacheSize;
|
||||||
|
cache.maxCacheSize_ = 4;
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function() {
|
||||||
|
var cache = ol.style.iconImageCache;
|
||||||
|
cache.maxCacheSize_ = originalMaxCacheSize;
|
||||||
|
cache.clear();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('#expire', function() {
|
||||||
|
it('expires images when expected', function() {
|
||||||
|
var cache = ol.style.iconImageCache;
|
||||||
|
|
||||||
|
var i, src, iconImage;
|
||||||
|
|
||||||
|
for (i = 0; i < 4; ++i) {
|
||||||
|
src = i + '';
|
||||||
|
iconImage = new ol.style.IconImage(src, null);
|
||||||
|
cache.set(src, null, null, iconImage);
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(cache.cacheSize_).to.eql(4);
|
||||||
|
|
||||||
|
cache.expire();
|
||||||
|
expect(cache.cacheSize_).to.eql(4);
|
||||||
|
|
||||||
|
src = '4';
|
||||||
|
iconImage = new ol.style.IconImage(src, null);
|
||||||
|
cache.set(src, null, null, iconImage);
|
||||||
|
expect(cache.cacheSize_).to.eql(5);
|
||||||
|
|
||||||
|
cache.expire(); // remove '0' and '4'
|
||||||
|
expect(cache.cacheSize_).to.eql(3);
|
||||||
|
|
||||||
|
src = '0';
|
||||||
|
iconImage = new ol.style.IconImage(src, null);
|
||||||
|
ol.events.listen(iconImage, 'change',
|
||||||
|
ol.nullFunction, false);
|
||||||
|
cache.set(src, null, null, iconImage);
|
||||||
|
expect(cache.cacheSize_).to.eql(4);
|
||||||
|
|
||||||
|
src = '4';
|
||||||
|
iconImage = new ol.style.IconImage(src, null);
|
||||||
|
ol.events.listen(iconImage, 'change',
|
||||||
|
ol.nullFunction, false);
|
||||||
|
cache.set(src, null, null, iconImage);
|
||||||
|
expect(cache.cacheSize_).to.eql(5);
|
||||||
|
|
||||||
|
// check that '0' and '4' are not removed from the cache
|
||||||
|
cache.expire();
|
||||||
|
expect(cache.get('0', null, null)).to.not.be(null);
|
||||||
|
expect(cache.get('4', null, null)).to.not.be(null);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user