Transformed

This commit is contained in:
Tim Schaub
2017-12-11 16:29:33 -07:00
parent 1cdb6a66f0
commit 7f47883c48
737 changed files with 22216 additions and 21609 deletions
+23 -25
View File
@@ -1,7 +1,5 @@
goog.require('ol.style.Atlas');
goog.require('ol.style.AtlasManager');
import _ol_style_Atlas_ from '../../../../src/ol/style/Atlas.js';
import _ol_style_AtlasManager_ from '../../../../src/ol/style/AtlasManager.js';
describe('ol.style.Atlas', function() {
@@ -12,7 +10,7 @@ describe('ol.style.Atlas', function() {
describe('#constructor', function() {
it('inits the atlas', function() {
var atlas = new ol.style.Atlas(256, 1);
var atlas = new _ol_style_Atlas_(256, 1);
expect(atlas.emptyBlocks_).to.eql(
[{x: 0, y: 0, width: 256, height: 256}]);
});
@@ -21,7 +19,7 @@ describe('ol.style.Atlas', function() {
describe('#add (squares with same size)', function() {
it('adds one entry', function() {
var atlas = new ol.style.Atlas(128, 1);
var atlas = new _ol_style_Atlas_(128, 1);
var info = atlas.add('1', 32, 32, defaultRender);
expect(info).to.eql(
@@ -31,7 +29,7 @@ describe('ol.style.Atlas', function() {
});
it('adds two entries', function() {
var atlas = new ol.style.Atlas(128, 1);
var atlas = new _ol_style_Atlas_(128, 1);
atlas.add('1', 32, 32, defaultRender);
var info = atlas.add('2', 32, 32, defaultRender);
@@ -43,7 +41,7 @@ describe('ol.style.Atlas', function() {
});
it('adds three entries', function() {
var atlas = new ol.style.Atlas(128, 1);
var atlas = new _ol_style_Atlas_(128, 1);
atlas.add('1', 32, 32, defaultRender);
atlas.add('2', 32, 32, defaultRender);
@@ -56,7 +54,7 @@ describe('ol.style.Atlas', function() {
});
it('adds four entries (new row)', function() {
var atlas = new ol.style.Atlas(128, 1);
var atlas = new _ol_style_Atlas_(128, 1);
atlas.add('1', 32, 32, defaultRender);
atlas.add('2', 32, 32, defaultRender);
@@ -70,7 +68,7 @@ describe('ol.style.Atlas', function() {
});
it('returns null when an entry is too big', function() {
var atlas = new ol.style.Atlas(128, 1);
var atlas = new _ol_style_Atlas_(128, 1);
atlas.add('1', 32, 32, defaultRender);
atlas.add('2', 32, 32, defaultRender);
@@ -81,7 +79,7 @@ describe('ol.style.Atlas', function() {
});
it('fills up the whole atlas', function() {
var atlas = new ol.style.Atlas(128, 1);
var atlas = new _ol_style_Atlas_(128, 1);
for (var i = 1; i <= 16; i++) {
expect(atlas.add(i.toString(), 28, 28, defaultRender)).to.be.ok();
@@ -95,7 +93,7 @@ describe('ol.style.Atlas', function() {
describe('#add (rectangles with different sizes)', function() {
it('adds a bunch of rectangles', function() {
var atlas = new ol.style.Atlas(128, 1);
var atlas = new _ol_style_Atlas_(128, 1);
expect(atlas.add('1', 64, 32, defaultRender)).to.eql(
{offsetX: 1, offsetY: 1, image: atlas.canvas_});
@@ -118,7 +116,7 @@ describe('ol.style.Atlas', function() {
});
it('fills up the whole atlas (rectangles in portrait format)', function() {
var atlas = new ol.style.Atlas(128, 1);
var atlas = new _ol_style_Atlas_(128, 1);
for (var i = 1; i <= 32; i++) {
expect(atlas.add(i.toString(), 28, 14, defaultRender)).to.be.ok();
@@ -129,7 +127,7 @@ describe('ol.style.Atlas', function() {
});
it('fills up the whole atlas (rectangles in landscape format)', function() {
var atlas = new ol.style.Atlas(128, 1);
var atlas = new _ol_style_Atlas_(128, 1);
for (var i = 1; i <= 32; i++) {
expect(atlas.add(i.toString(), 14, 28, defaultRender)).to.be.ok();
@@ -143,7 +141,7 @@ describe('ol.style.Atlas', function() {
describe('#add (rendering)', function() {
it('calls the render callback with the right values', function() {
var atlas = new ol.style.Atlas(128, 1);
var atlas = new _ol_style_Atlas_(128, 1);
var rendererCallback = sinon.spy();
atlas.add('1', 32, 32, rendererCallback);
@@ -158,7 +156,7 @@ describe('ol.style.Atlas', function() {
});
it('is possible to actually draw on the canvas', function() {
var atlas = new ol.style.Atlas(128, 1);
var atlas = new _ol_style_Atlas_(128, 1);
var rendererCallback = function(context, x, y) {
context.fillStyle = '#FFA500';
@@ -181,7 +179,7 @@ describe('ol.style.AtlasManager', function() {
describe('#constructor', function() {
it('inits the atlas manager', function() {
var manager = new ol.style.AtlasManager();
var manager = new _ol_style_AtlasManager_();
expect(manager.atlases_).to.not.be.empty();
});
});
@@ -189,7 +187,7 @@ describe('ol.style.AtlasManager', function() {
describe('#add', function() {
it('adds one entry', function() {
var manager = new ol.style.AtlasManager({initialSize: 128});
var manager = new _ol_style_AtlasManager_({initialSize: 128});
var info = manager.add('1', 32, 32, defaultRender);
expect(info).to.eql({
@@ -200,7 +198,7 @@ describe('ol.style.AtlasManager', function() {
});
it('adds one entry (also to the hit detection atlas)', function() {
var manager = new ol.style.AtlasManager({initialSize: 128});
var manager = new _ol_style_AtlasManager_({initialSize: 128});
var info = manager.add('1', 32, 32, defaultRender, defaultRender);
expect(info).to.eql({
@@ -211,7 +209,7 @@ describe('ol.style.AtlasManager', function() {
});
it('creates a new atlas if needed', function() {
var manager = new ol.style.AtlasManager({initialSize: 128});
var manager = new _ol_style_AtlasManager_({initialSize: 128});
expect(manager.add('1', 100, 100, defaultRender, defaultRender))
.to.be.ok();
var info = manager.add('2', 100, 100, defaultRender, defaultRender);
@@ -223,7 +221,7 @@ describe('ol.style.AtlasManager', function() {
});
it('creates new atlases until one is large enough', function() {
var manager = new ol.style.AtlasManager({initialSize: 128});
var manager = new _ol_style_AtlasManager_({initialSize: 128});
expect(manager.add('1', 100, 100, defaultRender, defaultRender))
.to.be.ok();
expect(manager.atlases_).to.have.length(1);
@@ -237,7 +235,7 @@ describe('ol.style.AtlasManager', function() {
});
it('checks all existing atlases and create a new if needed', function() {
var manager = new ol.style.AtlasManager({initialSize: 128});
var manager = new _ol_style_AtlasManager_({initialSize: 128});
expect(manager.add('1', 100, 100, defaultRender, defaultRender))
.to.be.ok();
expect(manager.add('2', 100, 100, defaultRender, defaultRender))
@@ -253,7 +251,7 @@ describe('ol.style.AtlasManager', function() {
});
it('returns null if the size exceeds the maximum size', function() {
var manager = new ol.style.AtlasManager(
var manager = new _ol_style_AtlasManager_(
{initialSize: 128, maxSize: 2048});
expect(manager.add('1', 100, 100, defaultRender, defaultRender))
.to.be.ok();
@@ -262,7 +260,7 @@ describe('ol.style.AtlasManager', function() {
});
it('always has the same offset for the hit-detection', function() {
var manager = new ol.style.AtlasManager({initialSize: 128});
var manager = new _ol_style_AtlasManager_({initialSize: 128});
// add one image without hit-detection callback
var info = manager.add('1', 32, 32, defaultRender);
// add then one with hit-detection callback
@@ -279,7 +277,7 @@ describe('ol.style.AtlasManager', function() {
describe('#getInfo', function() {
it('returns null if no entry for the given id', function() {
var manager = new ol.style.AtlasManager({initialSize: 128});
var manager = new _ol_style_AtlasManager_({initialSize: 128});
expect(manager.getInfo('123456')).to.eql(null);
});
});
+56 -58
View File
@@ -1,9 +1,7 @@
goog.require('ol.style.AtlasManager');
goog.require('ol.style.Circle');
goog.require('ol.style.Fill');
goog.require('ol.style.Stroke');
import _ol_style_AtlasManager_ from '../../../../src/ol/style/AtlasManager.js';
import _ol_style_Circle_ from '../../../../src/ol/style/Circle.js';
import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js';
import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js';
describe('ol.style.Circle', function() {
@@ -11,7 +9,7 @@ describe('ol.style.Circle', function() {
describe('#constructor', function() {
it('creates a canvas if no atlas is used (no fill-style)', function() {
var style = new ol.style.Circle({radius: 10});
var style = new _ol_style_Circle_({radius: 10});
expect(style.getImage()).to.be.an(HTMLCanvasElement);
expect(style.getSize()).to.eql([21, 21]);
expect(style.getImageSize()).to.eql([21, 21]);
@@ -24,9 +22,9 @@ describe('ol.style.Circle', function() {
});
it('creates a canvas if no atlas is used (fill-style)', function() {
var style = new ol.style.Circle({
var style = new _ol_style_Circle_({
radius: 10,
fill: new ol.style.Fill({
fill: new _ol_style_Fill_({
color: '#FFFF00'
})
});
@@ -42,8 +40,8 @@ describe('ol.style.Circle', function() {
});
it('adds itself to an atlas manager (no fill-style)', function() {
var atlasManager = new ol.style.AtlasManager({initialSize: 512});
var style = new ol.style.Circle({radius: 10, atlasManager: atlasManager});
var atlasManager = new _ol_style_AtlasManager_({initialSize: 512});
var style = new _ol_style_Circle_({radius: 10, atlasManager: atlasManager});
expect(style.getImage()).to.be.an(HTMLCanvasElement);
expect(style.getSize()).to.eql([21, 21]);
expect(style.getImageSize()).to.eql([512, 512]);
@@ -56,11 +54,11 @@ describe('ol.style.Circle', function() {
});
it('adds itself to an atlas manager (fill-style)', function() {
var atlasManager = new ol.style.AtlasManager({initialSize: 512});
var style = new ol.style.Circle({
var atlasManager = new _ol_style_AtlasManager_({initialSize: 512});
var style = new _ol_style_Circle_({
radius: 10,
atlasManager: atlasManager,
fill: new ol.style.Fill({
fill: new _ol_style_Fill_({
color: '#FFFF00'
})
});
@@ -79,18 +77,18 @@ describe('ol.style.Circle', function() {
describe('#clone', function() {
it('creates a new ol.style.Circle', function() {
var original = new ol.style.Circle();
var original = new _ol_style_Circle_();
var clone = original.clone();
expect(clone).to.be.an(ol.style.Circle);
expect(clone).to.be.an(_ol_style_Circle_);
expect(clone).to.not.be(original);
});
it('copies all values', function() {
var original = new ol.style.Circle({
fill: new ol.style.Fill({
var original = new _ol_style_Circle_({
fill: new _ol_style_Fill_({
color: '#319FD3'
}),
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3'
}),
radius: 5,
@@ -108,11 +106,11 @@ describe('ol.style.Circle', function() {
});
it('the clone does not reference the same objects as the original', function() {
var original = new ol.style.Circle({
fill: new ol.style.Fill({
var original = new _ol_style_Circle_({
fill: new _ol_style_Fill_({
color: '#319FD3'
}),
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3'
})
});
@@ -131,39 +129,39 @@ describe('ol.style.Circle', function() {
describe('#getChecksum', function() {
it('calculates the same hash code for default options', function() {
var style1 = new ol.style.Circle();
var style2 = new ol.style.Circle();
var style1 = new _ol_style_Circle_();
var style2 = new _ol_style_Circle_();
expect(style1.getChecksum()).to.eql(style2.getChecksum());
});
it('calculates not the same hash code (radius)', function() {
var style1 = new ol.style.Circle();
var style2 = new ol.style.Circle({
var style1 = new _ol_style_Circle_();
var style2 = new _ol_style_Circle_({
radius: 5
});
expect(style1.getChecksum()).to.not.eql(style2.getChecksum());
});
it('calculates the same hash code (radius)', function() {
var style1 = new ol.style.Circle({
var style1 = new _ol_style_Circle_({
radius: 5
});
var style2 = new ol.style.Circle({
var style2 = new _ol_style_Circle_({
radius: 5
});
expect(style1.getChecksum()).to.eql(style2.getChecksum());
});
it('calculates not the same hash code (color)', function() {
var style1 = new ol.style.Circle({
var style1 = new _ol_style_Circle_({
radius: 5,
fill: new ol.style.Fill({
fill: new _ol_style_Fill_({
color: '#319FD3'
})
});
var style2 = new ol.style.Circle({
var style2 = new _ol_style_Circle_({
radius: 5,
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3'
})
});
@@ -171,12 +169,12 @@ describe('ol.style.Circle', function() {
});
it('calculates the same hash code (everything set)', function() {
var style1 = new ol.style.Circle({
var style1 = new _ol_style_Circle_({
radius: 5,
fill: new ol.style.Fill({
fill: new _ol_style_Fill_({
color: '#319FD3'
}),
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3',
lineCap: 'round',
lineDash: [5, 15, 25],
@@ -185,12 +183,12 @@ describe('ol.style.Circle', function() {
width: 2
})
});
var style2 = new ol.style.Circle({
var style2 = new _ol_style_Circle_({
radius: 5,
fill: new ol.style.Fill({
fill: new _ol_style_Fill_({
color: '#319FD3'
}),
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3',
lineCap: 'round',
lineDash: [5, 15, 25],
@@ -203,12 +201,12 @@ describe('ol.style.Circle', function() {
});
it('calculates not the same hash code (stroke width differs)', function() {
var style1 = new ol.style.Circle({
var style1 = new _ol_style_Circle_({
radius: 5,
fill: new ol.style.Fill({
fill: new _ol_style_Fill_({
color: '#319FD3'
}),
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3',
lineCap: 'round',
lineDash: [5, 15, 25],
@@ -217,12 +215,12 @@ describe('ol.style.Circle', function() {
width: 3
})
});
var style2 = new ol.style.Circle({
var style2 = new _ol_style_Circle_({
radius: 5,
fill: new ol.style.Fill({
fill: new _ol_style_Fill_({
color: '#319FD3'
}),
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3',
lineCap: 'round',
lineDash: [5, 15, 25],
@@ -235,21 +233,21 @@ describe('ol.style.Circle', function() {
});
it('invalidates a cached checksum if values change (fill)', function() {
var style1 = new ol.style.Circle({
var style1 = new _ol_style_Circle_({
radius: 5,
fill: new ol.style.Fill({
fill: new _ol_style_Fill_({
color: '#319FD3'
}),
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3'
})
});
var style2 = new ol.style.Circle({
var style2 = new _ol_style_Circle_({
radius: 5,
fill: new ol.style.Fill({
fill: new _ol_style_Fill_({
color: '#319FD3'
}),
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3'
})
});
@@ -260,21 +258,21 @@ describe('ol.style.Circle', function() {
});
it('invalidates a cached checksum if values change (stroke)', function() {
var style1 = new ol.style.Circle({
var style1 = new _ol_style_Circle_({
radius: 5,
fill: new ol.style.Fill({
fill: new _ol_style_Fill_({
color: '#319FD3'
}),
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3'
})
});
var style2 = new ol.style.Circle({
var style2 = new _ol_style_Circle_({
radius: 5,
fill: new ol.style.Fill({
fill: new _ol_style_Fill_({
color: '#319FD3'
}),
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3'
})
});
@@ -288,9 +286,9 @@ describe('ol.style.Circle', function() {
describe('#setRadius', function() {
it('changes the circle radius', function() {
var style = new ol.style.Circle({
var style = new _ol_style_Circle_({
radius: 10,
fill: new ol.style.Fill({
fill: new _ol_style_Fill_({
color: '#FFFF00'
})
});
+5 -7
View File
@@ -1,20 +1,18 @@
goog.require('ol.style.Fill');
import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js';
describe('ol.style.Fill', function() {
describe('#clone', function() {
it('creates a new ol.style.Fill', function() {
var original = new ol.style.Fill();
var original = new _ol_style_Fill_();
var clone = original.clone();
expect(clone).to.be.an(ol.style.Fill);
expect(clone).to.be.an(_ol_style_Fill_);
expect(clone).to.not.be(original);
});
it('copies all values', function() {
var original = new ol.style.Fill({
var original = new _ol_style_Fill_({
color: '#319FD3'
});
var clone = original.clone();
@@ -22,7 +20,7 @@ describe('ol.style.Fill', function() {
});
it('the clone does not reference the same objects as the original', function() {
var original = new ol.style.Fill({
var original = new _ol_style_Fill_({
color: [63, 255, 127, 0.7]
});
var clone = original.clone();
+26 -28
View File
@@ -1,9 +1,7 @@
goog.require('ol');
goog.require('ol.style');
goog.require('ol.style.Icon');
goog.require('ol.style.IconImage');
import _ol_ from '../../../../src/ol.js';
import _ol_style_ from '../../../../src/ol/style.js';
import _ol_style_Icon_ from '../../../../src/ol/style/Icon.js';
import _ol_style_IconImage_ from '../../../../src/ol/style/IconImage.js';
describe('ol.style.Icon', function() {
@@ -15,16 +13,16 @@ describe('ol.style.Icon', function() {
it('caches canvas images with a uid as src', function() {
var canvas = document.createElement('canvas');
new ol.style.Icon({
new _ol_style_Icon_({
img: canvas,
imgSize: size
});
expect(ol.style.IconImage.get(
canvas, ol.getUid(canvas), size, '').getImage()).to.eql(canvas);
expect(_ol_style_IconImage_.get(
canvas, _ol_.getUid(canvas), size, '').getImage()).to.eql(canvas);
});
it('imgSize overrides img.width and img.height', function(done) {
var style = new ol.style.Icon({
var style = new _ol_style_Icon_({
src: src,
imgSize: size
});
@@ -41,17 +39,17 @@ describe('ol.style.Icon', function() {
describe('#clone', function() {
it('creates a new ol.style.Icon', function() {
var original = new ol.style.Icon({
var original = new _ol_style_Icon_({
src: src
});
var clone = original.clone();
expect(clone).to.be.an(ol.style.Icon);
expect(clone).to.be.an(_ol_style_Icon_);
expect(clone).to.not.be(original);
});
it('copies all values ', function() {
var canvas = document.createElement('canvas');
var original = new ol.style.Icon({
var original = new _ol_style_Icon_({
anchor: [1, 0],
anchorOrigin: 'bottom-right',
anchorXUnits: 'pixels',
@@ -87,7 +85,7 @@ describe('ol.style.Icon', function() {
expect(original.getRotateWithView()).to.eql(clone.getRotateWithView());
expect(original.getSnapToPixel()).to.eql(clone.getSnapToPixel());
var original2 = new ol.style.Icon({
var original2 = new _ol_style_Icon_({
src: src
});
var clone2 = original2.clone();
@@ -97,7 +95,7 @@ describe('ol.style.Icon', function() {
});
it('the clone does not reference the same objects as the original', function() {
var original = new ol.style.Icon({
var original = new _ol_style_Icon_({
anchor: [1, 0],
color: [1, 2, 3, 0.4],
src: src,
@@ -125,7 +123,7 @@ describe('ol.style.Icon', function() {
var fractionAnchor = [0.25, 0.25];
it('uses fractional units by default', function() {
var iconStyle = new ol.style.Icon({
var iconStyle = new _ol_style_Icon_({
src: 'test.png',
size: size,
anchor: fractionAnchor
@@ -134,7 +132,7 @@ describe('ol.style.Icon', function() {
});
it('uses pixels units', function() {
var iconStyle = new ol.style.Icon({
var iconStyle = new _ol_style_Icon_({
src: 'test.png',
size: size,
anchor: [2, 18],
@@ -145,7 +143,7 @@ describe('ol.style.Icon', function() {
});
it('uses a bottom left anchor origin', function() {
var iconStyle = new ol.style.Icon({
var iconStyle = new _ol_style_Icon_({
src: 'test.png',
size: size,
anchor: fractionAnchor,
@@ -155,7 +153,7 @@ describe('ol.style.Icon', function() {
});
it('uses a bottom right anchor origin', function() {
var iconStyle = new ol.style.Icon({
var iconStyle = new _ol_style_Icon_({
src: 'test.png',
size: size,
anchor: fractionAnchor,
@@ -165,7 +163,7 @@ describe('ol.style.Icon', function() {
});
it('uses a top right anchor origin', function() {
var iconStyle = new ol.style.Icon({
var iconStyle = new _ol_style_Icon_({
src: 'test.png',
size: size,
anchor: fractionAnchor,
@@ -180,7 +178,7 @@ describe('ol.style.Icon', function() {
var imageSize = [144, 192];
it('uses a top left offset origin (default)', function() {
var iconStyle = new ol.style.Icon({
var iconStyle = new _ol_style_Icon_({
src: 'test.png',
size: size,
offset: offset
@@ -189,7 +187,7 @@ describe('ol.style.Icon', function() {
});
it('uses a bottom left offset origin', function() {
var iconStyle = new ol.style.Icon({
var iconStyle = new _ol_style_Icon_({
src: 'test.png',
size: size,
offset: offset,
@@ -200,7 +198,7 @@ describe('ol.style.Icon', function() {
});
it('uses a bottom right offset origin', function() {
var iconStyle = new ol.style.Icon({
var iconStyle = new _ol_style_Icon_({
src: 'test.png',
size: size,
offset: offset,
@@ -211,7 +209,7 @@ describe('ol.style.Icon', function() {
});
it('uses a top right offset origin', function() {
var iconStyle = new ol.style.Icon({
var iconStyle = new _ol_style_Icon_({
src: 'test.png',
size: size,
offset: offset,
@@ -228,19 +226,19 @@ describe('ol.style.Icon', function() {
it('takes the real image size', function() {
// pretend that the image is already in the cache,
// this image will be used for the icon.
var cache = ol.style.iconImageCache;
var cache = _ol_style_.iconImageCache;
var src = 'test.png';
var iconImage = new ol.style.IconImage(null, 'test.png', imgSize);
var iconImage = new _ol_style_IconImage_(null, 'test.png', imgSize);
cache.set(src, null, null, iconImage);
var iconStyle = new ol.style.Icon({
var iconStyle = new _ol_style_Icon_({
src: 'test.png'
});
expect(iconStyle.getImageSize()).to.eql(imgSize);
});
it('uses the given image size', function() {
var iconStyle = new ol.style.Icon({
var iconStyle = new _ol_style_Icon_({
img: {src: 'test.png'},
imgSize: imgSize
});
+17 -19
View File
@@ -1,35 +1,33 @@
goog.require('ol');
goog.require('ol.events');
goog.require('ol.style');
goog.require('ol.style.IconImage');
import _ol_ from '../../../../src/ol.js';
import _ol_events_ from '../../../../src/ol/events.js';
import _ol_style_ from '../../../../src/ol/style.js';
import _ol_style_IconImage_ from '../../../../src/ol/style/IconImage.js';
describe('ol.style.IconImageCache', function() {
var originalMaxCacheSize;
beforeEach(function() {
var cache = ol.style.iconImageCache;
var cache = _ol_style_.iconImageCache;
cache.clear();
originalMaxCacheSize = cache.maxCacheSize;
cache.maxCacheSize_ = 4;
});
afterEach(function() {
var cache = ol.style.iconImageCache;
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 cache = _ol_style_.iconImageCache;
var i, src, iconImage;
for (i = 0; i < 4; ++i) {
src = i + '';
iconImage = new ol.style.IconImage(null, src);
iconImage = new _ol_style_IconImage_(null, src);
cache.set(src, null, null, iconImage);
}
@@ -39,7 +37,7 @@ describe('ol.style.IconImageCache', function() {
expect(cache.cacheSize_).to.eql(4);
src = '4';
iconImage = new ol.style.IconImage(null, src);
iconImage = new _ol_style_IconImage_(null, src);
cache.set(src, null, null, iconImage);
expect(cache.cacheSize_).to.eql(5);
@@ -47,16 +45,16 @@ describe('ol.style.IconImageCache', function() {
expect(cache.cacheSize_).to.eql(3);
src = '0';
iconImage = new ol.style.IconImage(null, src);
ol.events.listen(iconImage, 'change',
ol.nullFunction, false);
iconImage = new _ol_style_IconImage_(null, src);
_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(null, src);
ol.events.listen(iconImage, 'change',
ol.nullFunction, false);
iconImage = new _ol_style_IconImage_(null, src);
_ol_events_.listen(iconImage, 'change',
_ol_.nullFunction, false);
cache.set(src, null, null, iconImage);
expect(cache.cacheSize_).to.eql(5);
@@ -69,13 +67,13 @@ describe('ol.style.IconImageCache', function() {
describe('#setSize', function() {
it('sets max cache size and expires cache', function() {
var cache = ol.style.iconImageCache;
var cache = _ol_style_.iconImageCache;
var i, src, iconImage;
for (i = 0; i < 3; ++i) {
src = i + '';
iconImage = new ol.style.IconImage(null, src);
iconImage = new _ol_style_IconImage_(null, src);
cache.set(src, null, null, iconImage);
}
+57 -59
View File
@@ -1,9 +1,7 @@
goog.require('ol.style.AtlasManager');
goog.require('ol.style.RegularShape');
goog.require('ol.style.Fill');
goog.require('ol.style.Stroke');
import _ol_style_AtlasManager_ from '../../../../src/ol/style/AtlasManager.js';
import _ol_style_RegularShape_ from '../../../../src/ol/style/RegularShape.js';
import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js';
import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js';
describe('ol.style.RegularShape', function() {
@@ -11,7 +9,7 @@ describe('ol.style.RegularShape', function() {
describe('#constructor', function() {
it('can use rotateWithView', function() {
var style = new ol.style.RegularShape({
var style = new _ol_style_RegularShape_({
rotateWithView: true,
radius: 0
});
@@ -19,7 +17,7 @@ describe('ol.style.RegularShape', function() {
});
it('can use radius', function() {
var style = new ol.style.RegularShape({
var style = new _ol_style_RegularShape_({
radius: 5,
radius2: 10
});
@@ -28,7 +26,7 @@ describe('ol.style.RegularShape', function() {
});
it('can use radius1 as an alias for radius', function() {
var style = new ol.style.RegularShape({
var style = new _ol_style_RegularShape_({
radius1: 5,
radius2: 10
});
@@ -37,7 +35,7 @@ describe('ol.style.RegularShape', function() {
});
it('creates a canvas if no atlas is used (no fill-style)', function() {
var style = new ol.style.RegularShape({radius: 10});
var style = new _ol_style_RegularShape_({radius: 10});
expect(style.getImage()).to.be.an(HTMLCanvasElement);
expect(style.getSize()).to.eql([21, 21]);
expect(style.getImageSize()).to.eql([21, 21]);
@@ -50,9 +48,9 @@ describe('ol.style.RegularShape', function() {
});
it('creates a canvas if no atlas is used (fill-style)', function() {
var style = new ol.style.RegularShape({
var style = new _ol_style_RegularShape_({
radius: 10,
fill: new ol.style.Fill({
fill: new _ol_style_Fill_({
color: '#FFFF00'
})
});
@@ -68,8 +66,8 @@ describe('ol.style.RegularShape', function() {
});
it('adds itself to an atlas manager (no fill-style)', function() {
var atlasManager = new ol.style.AtlasManager({initialSize: 512});
var style = new ol.style.RegularShape(
var atlasManager = new _ol_style_AtlasManager_({initialSize: 512});
var style = new _ol_style_RegularShape_(
{radius: 10, atlasManager: atlasManager});
expect(style.getImage()).to.be.an(HTMLCanvasElement);
expect(style.getSize()).to.eql([21, 21]);
@@ -83,11 +81,11 @@ describe('ol.style.RegularShape', function() {
});
it('adds itself to an atlas manager (fill-style)', function() {
var atlasManager = new ol.style.AtlasManager({initialSize: 512});
var style = new ol.style.RegularShape({
var atlasManager = new _ol_style_AtlasManager_({initialSize: 512});
var style = new _ol_style_RegularShape_({
radius: 10,
atlasManager: atlasManager,
fill: new ol.style.Fill({
fill: new _ol_style_Fill_({
color: '#FFFF00'
})
});
@@ -106,17 +104,17 @@ describe('ol.style.RegularShape', function() {
describe('#clone', function() {
it('creates a new ol.style.RegularShape', function() {
var original = new ol.style.RegularShape({
var original = new _ol_style_RegularShape_({
points: 5
});
var clone = original.clone();
expect(clone).to.be.an(ol.style.RegularShape);
expect(clone).to.be.an(_ol_style_RegularShape_);
expect(clone).to.not.be(original);
});
it('copies all values', function() {
var original = new ol.style.RegularShape({
fill: new ol.style.Fill({
var original = new _ol_style_RegularShape_({
fill: new _ol_style_Fill_({
color: '#319FD3'
}),
points: 5,
@@ -124,7 +122,7 @@ describe('ol.style.RegularShape', function() {
radius2: 6,
angle: 1,
snapToPixel: false,
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3'
}),
rotation: 2,
@@ -147,11 +145,11 @@ describe('ol.style.RegularShape', function() {
});
it('the clone does not reference the same objects as the original', function() {
var original = new ol.style.RegularShape({
fill: new ol.style.Fill({
var original = new _ol_style_RegularShape_({
fill: new _ol_style_Fill_({
color: '#319FD3'
}),
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3'
})
});
@@ -170,11 +168,11 @@ describe('ol.style.RegularShape', function() {
describe('#getChecksum', function() {
it('calculates not the same hash code (radius)', function() {
var style1 = new ol.style.RegularShape({
var style1 = new _ol_style_RegularShape_({
radius: 4,
radius2: 5
});
var style2 = new ol.style.RegularShape({
var style2 = new _ol_style_RegularShape_({
radius: 3,
radius2: 5
});
@@ -182,11 +180,11 @@ describe('ol.style.RegularShape', function() {
});
it('calculates not the same hash code (radius2)', function() {
var style1 = new ol.style.RegularShape({
var style1 = new _ol_style_RegularShape_({
radius: 4,
radius2: 5
});
var style2 = new ol.style.RegularShape({
var style2 = new _ol_style_RegularShape_({
radius: 4,
radius2: 6
});
@@ -194,25 +192,25 @@ describe('ol.style.RegularShape', function() {
});
it('calculates the same hash code (radius)', function() {
var style1 = new ol.style.RegularShape({
var style1 = new _ol_style_RegularShape_({
radius: 5
});
var style2 = new ol.style.RegularShape({
var style2 = new _ol_style_RegularShape_({
radius: 5
});
expect(style1.getChecksum()).to.eql(style2.getChecksum());
});
it('calculates not the same hash code (color)', function() {
var style1 = new ol.style.RegularShape({
var style1 = new _ol_style_RegularShape_({
radius: 5,
fill: new ol.style.Fill({
fill: new _ol_style_Fill_({
color: '#319FD3'
})
});
var style2 = new ol.style.RegularShape({
var style2 = new _ol_style_RegularShape_({
radius: 5,
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3'
})
});
@@ -220,15 +218,15 @@ describe('ol.style.RegularShape', function() {
});
it('calculates the same hash code (everything set)', function() {
var style1 = new ol.style.RegularShape({
var style1 = new _ol_style_RegularShape_({
radius: 5,
radius2: 3,
angle: 1.41,
points: 5,
fill: new ol.style.Fill({
fill: new _ol_style_Fill_({
color: '#319FD3'
}),
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3',
lineCap: 'round',
lineDash: [5, 15, 25],
@@ -237,15 +235,15 @@ describe('ol.style.RegularShape', function() {
width: 2
})
});
var style2 = new ol.style.RegularShape({
var style2 = new _ol_style_RegularShape_({
radius: 5,
radius2: 3,
angle: 1.41,
points: 5,
fill: new ol.style.Fill({
fill: new _ol_style_Fill_({
color: '#319FD3'
}),
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3',
lineCap: 'round',
lineDash: [5, 15, 25],
@@ -258,15 +256,15 @@ describe('ol.style.RegularShape', function() {
});
it('calculates not the same hash code (stroke width differs)', function() {
var style1 = new ol.style.RegularShape({
var style1 = new _ol_style_RegularShape_({
radius: 5,
radius2: 3,
angle: 1.41,
points: 5,
fill: new ol.style.Fill({
fill: new _ol_style_Fill_({
color: '#319FD3'
}),
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3',
lineCap: 'round',
lineDash: [5, 15, 25],
@@ -275,15 +273,15 @@ describe('ol.style.RegularShape', function() {
width: 3
})
});
var style2 = new ol.style.RegularShape({
var style2 = new _ol_style_RegularShape_({
radius: 5,
radius2: 3,
angle: 1.41,
points: 5,
fill: new ol.style.Fill({
fill: new _ol_style_Fill_({
color: '#319FD3'
}),
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3',
lineCap: 'round',
lineDash: [5, 15, 25],
@@ -296,21 +294,21 @@ describe('ol.style.RegularShape', function() {
});
it('invalidates a cached checksum if values change (fill)', function() {
var style1 = new ol.style.RegularShape({
var style1 = new _ol_style_RegularShape_({
radius: 5,
fill: new ol.style.Fill({
fill: new _ol_style_Fill_({
color: '#319FD3'
}),
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3'
})
});
var style2 = new ol.style.RegularShape({
var style2 = new _ol_style_RegularShape_({
radius: 5,
fill: new ol.style.Fill({
fill: new _ol_style_Fill_({
color: '#319FD3'
}),
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3'
})
});
@@ -321,21 +319,21 @@ describe('ol.style.RegularShape', function() {
});
it('invalidates a cached checksum if values change (stroke)', function() {
var style1 = new ol.style.RegularShape({
var style1 = new _ol_style_RegularShape_({
radius: 5,
fill: new ol.style.Fill({
fill: new _ol_style_Fill_({
color: '#319FD3'
}),
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3'
})
});
var style2 = new ol.style.RegularShape({
var style2 = new _ol_style_RegularShape_({
radius: 5,
fill: new ol.style.Fill({
fill: new _ol_style_Fill_({
color: '#319FD3'
}),
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3'
})
});
+5 -7
View File
@@ -1,20 +1,18 @@
goog.require('ol.style.Stroke');
import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js';
describe('ol.style.Stroke', function() {
describe('#clone', function() {
it('creates a new ol.style.Stroke', function() {
var original = new ol.style.Stroke();
var original = new _ol_style_Stroke_();
var clone = original.clone();
expect(clone).to.be.an(ol.style.Stroke);
expect(clone).to.be.an(_ol_style_Stroke_);
expect(clone).to.not.be(original);
});
it('copies all values', function() {
var original = new ol.style.Stroke({
var original = new _ol_style_Stroke_({
color: '#319FD3',
lineCap: 'square',
lineJoin: 'miter',
@@ -34,7 +32,7 @@ describe('ol.style.Stroke', function() {
});
it('the clone does not reference the same objects as the original', function() {
var original = new ol.style.Stroke({
var original = new _ol_style_Stroke_({
color: [1, 2, 3, 0.4],
lineDash: [1, 2, 3]
});
+48 -50
View File
@@ -1,62 +1,60 @@
goog.require('ol.Feature');
goog.require('ol.geom.Point');
goog.require('ol.style.Style');
goog.require('ol.style.Fill');
goog.require('ol.style.Circle');
goog.require('ol.style.Stroke');
goog.require('ol.style.Text');
import _ol_Feature_ from '../../../../src/ol/Feature.js';
import _ol_geom_Point_ from '../../../../src/ol/geom/Point.js';
import _ol_style_Style_ from '../../../../src/ol/style/Style.js';
import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js';
import _ol_style_Circle_ from '../../../../src/ol/style/Circle.js';
import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js';
import _ol_style_Text_ from '../../../../src/ol/style/Text.js';
describe('ol.style.Style', function() {
var testFill = new ol.style.Fill({
var testFill = new _ol_style_Fill_({
color: 'rgba(255, 255, 255, 0.6)'
});
var testStroke = new ol.style.Stroke({
var testStroke = new _ol_style_Stroke_({
color: '#319FD3',
width: 1
});
var testText = new ol.style.Text({
var testText = new _ol_style_Text_({
font: '12px Calibri,sans-serif',
fill: new ol.style.Fill({
fill: new _ol_style_Fill_({
color: '#000'
}),
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#fff',
width: 3
})
});
var testImage = new ol.style.Circle({
var testImage = new _ol_style_Circle_({
radius: 5
});
describe('#clone', function() {
it('creates a new ol.style.Style', function() {
var original = new ol.style.Style();
var original = new _ol_style_Style_();
var clone = original.clone();
expect(clone).to.be.an(ol.style.Style);
expect(clone).to.be.an(_ol_style_Style_);
expect(clone).to.not.be(original);
});
it('copies all values', function() {
var original = new ol.style.Style({
geometry: new ol.geom.Point([0, 0, 0]),
fill: new ol.style.Fill({
var original = new _ol_style_Style_({
geometry: new _ol_geom_Point_([0, 0, 0]),
fill: new _ol_style_Fill_({
color: '#319FD3'
}),
image: new ol.style.Circle({
image: new _ol_style_Circle_({
radius: 5
}),
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3'
}),
text: new ol.style.Text({
text: new _ol_style_Text_({
text: 'test'
}),
zIndex: 2
@@ -71,18 +69,18 @@ describe('ol.style.Style', function() {
});
it('the clone does not reference the same objects as the original', function() {
var original = new ol.style.Style({
geometry: new ol.geom .Point([0, 0, 0]),
fill: new ol.style.Fill({
var original = new _ol_style_Style_({
geometry: new _ol_geom_Point_([0, 0, 0]),
fill: new _ol_style_Fill_({
color: '#319FD3'
}),
image: new ol.style.Circle({
image: new _ol_style_Circle_({
radius: 5
}),
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3'
}),
text: new ol.style.Text({
text: new _ol_style_Text_({
text: 'test'
})
});
@@ -109,7 +107,7 @@ describe('ol.style.Style', function() {
describe('#setZIndex', function() {
it('sets the zIndex', function() {
var style = new ol.style.Style();
var style = new _ol_style_Style_();
style.setZIndex(0.7);
expect(style.getZIndex()).to.be(0.7);
@@ -117,7 +115,7 @@ describe('ol.style.Style', function() {
});
describe('#getFill', function() {
var style = new ol.style.Style({
var style = new _ol_style_Style_({
fill: testFill
});
@@ -127,7 +125,7 @@ describe('ol.style.Style', function() {
});
describe('#setFill', function() {
var style = new ol.style.Style();
var style = new _ol_style_Style_();
it('sets the fill style of a style', function() {
style.setFill(testFill);
@@ -136,7 +134,7 @@ describe('ol.style.Style', function() {
});
describe('#getImage', function() {
var style = new ol.style.Style({
var style = new _ol_style_Style_({
image: testImage
});
@@ -146,7 +144,7 @@ describe('ol.style.Style', function() {
});
describe('#setImage', function() {
var style = new ol.style.Style();
var style = new _ol_style_Style_();
it('sets the image style of a style', function() {
style.setImage(testImage);
@@ -155,7 +153,7 @@ describe('ol.style.Style', function() {
});
describe('#getStroke', function() {
var style = new ol.style.Style({
var style = new _ol_style_Style_({
stroke: testStroke
});
@@ -165,7 +163,7 @@ describe('ol.style.Style', function() {
});
describe('#setStroke', function() {
var style = new ol.style.Style();
var style = new _ol_style_Style_();
it('sets the stroke style of a style', function() {
style.setStroke(testStroke);
@@ -174,7 +172,7 @@ describe('ol.style.Style', function() {
});
describe('#getText', function() {
var style = new ol.style.Style({
var style = new _ol_style_Style_({
text: testText
});
@@ -184,7 +182,7 @@ describe('ol.style.Style', function() {
});
describe('#setText', function() {
var style = new ol.style.Style();
var style = new _ol_style_Style_();
it('sets the text style of a style', function() {
style.setText(testText);
@@ -193,25 +191,25 @@ describe('ol.style.Style', function() {
});
describe('#setGeometry', function() {
var style = new ol.style.Style();
var style = new _ol_style_Style_();
it('creates a geometry function from a string', function() {
var feature = new ol.Feature();
feature.set('myGeom', new ol.geom.Point([0, 0]));
var feature = new _ol_Feature_();
feature.set('myGeom', new _ol_geom_Point_([0, 0]));
style.setGeometry('myGeom');
expect(style.getGeometryFunction()(feature))
.to.eql(feature.get('myGeom'));
});
it('creates a geometry function from a geometry', function() {
var geom = new ol.geom.Point([0, 0]);
var geom = new _ol_geom_Point_([0, 0]);
style.setGeometry(geom);
expect(style.getGeometryFunction()())
.to.eql(geom);
});
it('returns the configured geometry function', function() {
var geom = new ol.geom.Point([0, 0]);
var geom = new _ol_geom_Point_([0, 0]);
style.setGeometry(function() {
return geom;
});
@@ -223,10 +221,10 @@ describe('ol.style.Style', function() {
describe('#getGeometry', function() {
it('returns whatever was passed to setGeometry', function() {
var style = new ol.style.Style();
var style = new _ol_style_Style_();
style.setGeometry('foo');
expect(style.getGeometry()).to.eql('foo');
var geom = new ol.geom.Point([1, 2]);
var geom = new _ol_geom_Point_([1, 2]);
style.setGeometry(geom);
expect(style.getGeometry()).to.eql(geom);
var fn = function() {
@@ -243,15 +241,15 @@ describe('ol.style.Style', function() {
});
describe('ol.style.Style.createFunction()', function() {
var style = new ol.style.Style();
var style = new _ol_style_Style_();
it('creates a style function from a single style', function() {
var styleFunction = ol.style.Style.createFunction(style);
var styleFunction = _ol_style_Style_.createFunction(style);
expect(styleFunction()).to.eql([style]);
});
it('creates a style function from an array of styles', function() {
var styleFunction = ol.style.Style.createFunction([style]);
var styleFunction = _ol_style_Style_.createFunction([style]);
expect(styleFunction()).to.eql([style]);
});
@@ -259,13 +257,13 @@ describe('ol.style.Style.createFunction()', function() {
var original = function() {
return [style];
};
var styleFunction = ol.style.Style.createFunction(original);
var styleFunction = _ol_style_Style_.createFunction(original);
expect(styleFunction).to.be(original);
});
it('throws on (some) unexpected input', function() {
expect(function() {
ol.style.Style.createFunction({bogus: 'input'});
_ol_style_Style_.createFunction({bogus: 'input'});
}).to.throwException();
});
+15 -17
View File
@@ -1,8 +1,6 @@
goog.require('ol.style.Fill');
goog.require('ol.style.Stroke');
goog.require('ol.style.Text');
import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js';
import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js';
import _ol_style_Text_ from '../../../../src/ol/style/Text.js';
describe('ol.style.Text', function() {
@@ -10,19 +8,19 @@ describe('ol.style.Text', function() {
describe('#constructor', function() {
it('uses a default fill style if none passed', function() {
var style = new ol.style.Text();
var style = new _ol_style_Text_();
expect(style.getFill().getColor()).to.be('#333');
});
it('uses a provided fill style if one passed', function() {
var style = new ol.style.Text({
fill: new ol.style.Fill({color: '#123456'})
var style = new _ol_style_Text_({
fill: new _ol_style_Fill_({color: '#123456'})
});
expect(style.getFill().getColor()).to.be('#123456');
});
it('can always be resetted to no color', function() {
var style = new ol.style.Text();
var style = new _ol_style_Text_();
style.getFill().setColor();
expect(style.getFill().getColor()).to.be(undefined);
});
@@ -32,14 +30,14 @@ describe('ol.style.Text', function() {
describe('#clone', function() {
it('creates a new ol.style.Text', function() {
var original = new ol.style.Text();
var original = new _ol_style_Text_();
var clone = original.clone();
expect(clone).to.be.an(ol.style.Text);
expect(clone).to.be.an(_ol_style_Text_);
expect(clone).to.not.be(original);
});
it('copies all values', function() {
var original = new ol.style.Text({
var original = new _ol_style_Text_({
font: '12px serif',
offsetX: 4,
offsetY: 10,
@@ -49,10 +47,10 @@ describe('ol.style.Text', function() {
text: 'test',
textAlign: 'center',
textBaseline: 'top',
fill: new ol.style.Fill({
fill: new _ol_style_Fill_({
color: '#319FD3'
}),
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3'
})
});
@@ -71,11 +69,11 @@ describe('ol.style.Text', function() {
});
it('the clone does not reference the same objects as the original', function() {
var original = new ol.style.Text({
fill: new ol.style.Fill({
var original = new _ol_style_Text_({
fill: new _ol_style_Fill_({
color: '#319FD3'
}),
stroke: new ol.style.Stroke({
stroke: new _ol_style_Stroke_({
color: '#319FD3'
})
});