Add some test to PolygonReplay

This commit is contained in:
GaborFarkas
2016-10-05 18:34:54 +02:00
parent 5cf2e9c072
commit 8e8098b362
6 changed files with 53 additions and 41 deletions

View File

@@ -397,7 +397,7 @@ describe('ol.render.webgl.PolygonReplay', function() {
replay = new ol.render.webgl.PolygonReplay(tolerance, maxExtent); replay = new ol.render.webgl.PolygonReplay(tolerance, maxExtent);
}); });
describe('#drawPolygonGeometry', function() { describe('#drawPolygon', function() {
beforeEach(function() { beforeEach(function() {
replay.setFillStrokeStyle(fillStyle, strokeStyle); replay.setFillStrokeStyle(fillStyle, strokeStyle);
}); });
@@ -406,44 +406,30 @@ describe('ol.render.webgl.PolygonReplay', function() {
var polygon1 = new ol.geom.Polygon( var polygon1 = new ol.geom.Polygon(
[[[1000, 2000], [1200, 2000], [1200, 3000]]] [[[1000, 2000], [1200, 2000], [1200, 3000]]]
); );
replay.drawPolygonGeometry(polygon1, null); replay.drawPolygon(polygon1, null);
expect(replay.vertices_).to.have.length(18); expect(replay.vertices).to.have.length(6);
expect(replay.indices_).to.have.length(3); expect(replay.indices).to.have.length(3);
expect(replay.vertices_).to.eql([ expect(replay.vertices).to.eql([
1200, 2000, 0, 0, 1, 0.5, 1200, 3000, 1200, 2000, 1000, 2000]);
1200, 3000, 0, 0, 1, 0.5, expect(replay.indices).to.eql([2, 0, 1]);
1000, 2000, 0, 0, 1, 0.5]);
expect(replay.indices_).to.eql([0, 1, 2]);
expect(replay.lineStringReplay_.vertices_).to.have.length(24);
expect(replay.lineStringReplay_.vertices_).to.eql([
1000, 2000, 0, 1, 0, 0.4,
1200, 2000, 0, 1, 0, 0.4,
1200, 2000, 0, 1, 0, 0.4,
1200, 3000, 0, 1, 0, 0.4
]);
var polygon2 = new ol.geom.Polygon( var polygon2 = new ol.geom.Polygon(
[[[4000, 2000], [4200, 2000], [4200, 3000]]] [[[4000, 2000], [4200, 2000], [4200, 3000]]]
); );
replay.drawPolygonGeometry(polygon2, null); replay.drawPolygon(polygon2, null);
expect(replay.vertices_).to.have.length(36); expect(replay.vertices).to.have.length(12);
expect(replay.indices_).to.have.length(6); expect(replay.indices).to.have.length(6);
expect(replay.vertices_).to.eql([ expect(replay.vertices).to.eql([
1200, 2000, 0, 0, 1, 0.5, 1200, 3000, 1200, 2000, 1000, 2000,
1200, 3000, 0, 0, 1, 0.5, 4200, 3000, 4200, 2000, 4000, 2000
1000, 2000, 0, 0, 1, 0.5,
4200, 2000, 0, 0, 1, 0.5,
4200, 3000, 0, 0, 1, 0.5,
4000, 2000, 0, 0, 1, 0.5
]); ]);
expect(replay.indices_).to.eql([0, 1, 2, 3, 4, 5]); expect(replay.indices).to.eql([2, 0, 1, 5, 3, 4]);
}); });
}); });
describe('#drawMultiPolygonGeometry', function() { describe('#drawMultiPolygon', function() {
beforeEach(function() { beforeEach(function() {
replay.setFillStrokeStyle(fillStyle, strokeStyle); replay.setFillStrokeStyle(fillStyle, strokeStyle);
}); });
@@ -453,19 +439,15 @@ describe('ol.render.webgl.PolygonReplay', function() {
[[[1000, 2000], [1200, 2000], [1200, 3000]]], [[[1000, 2000], [1200, 2000], [1200, 3000]]],
[[[4000, 2000], [4200, 2000], [4200, 3000]]] [[[4000, 2000], [4200, 2000], [4200, 3000]]]
]); ]);
replay.drawMultiPolygonGeometry(multiPolygon, null); replay.drawMultiPolygon(multiPolygon, null);
expect(replay.vertices_).to.have.length(36); expect(replay.vertices).to.have.length(12);
expect(replay.indices_).to.have.length(6); expect(replay.indices).to.have.length(6);
expect(replay.vertices_).to.eql([ expect(replay.vertices).to.eql([
1200, 2000, 0, 0, 1, 0.5, 1200, 3000, 1200, 2000, 1000, 2000,
1200, 3000, 0, 0, 1, 0.5, 4200, 3000, 4200, 2000, 4000, 2000
1000, 2000, 0, 0, 1, 0.5,
4200, 2000, 0, 0, 1, 0.5,
4200, 3000, 0, 0, 1, 0.5,
4000, 2000, 0, 0, 1, 0.5
]); ]);
expect(replay.indices_).to.eql([0, 1, 2, 3, 4, 5]); expect(replay.indices).to.eql([2, 0, 1, 5, 3, 4]);
}); });
}); });
}); });

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 780 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 300 B

View File

@@ -86,11 +86,18 @@ describe('ol.rendering.style.Polygon', function() {
} }
it('tests the canvas renderer', function(done) { it('tests the canvas renderer', function(done) {
map = createMap('canvas'); map = createMap('webgl');
createFeatures(); createFeatures();
expectResemble(map, 'spec/ol/style/expected/polygon-types-canvas.png', expectResemble(map, 'spec/ol/style/expected/polygon-types-canvas.png',
IMAGE_TOLERANCE, done); IMAGE_TOLERANCE, done);
}); });
it('tests the webgl renderer', function(done) {
map = createMap('webgl');
createFeatures();
expectResemble(map, 'spec/ol/style/expected/polygon-types-webgl.png',
IMAGE_TOLERANCE, done);
});
}); });
describe('different types with stroke', function() { describe('different types with stroke', function() {
@@ -153,6 +160,14 @@ describe('ol.rendering.style.Polygon', function() {
expectResemble(map, 'spec/ol/style/expected/polygon-types-canvas-stroke.png', expectResemble(map, 'spec/ol/style/expected/polygon-types-canvas-stroke.png',
IMAGE_TOLERANCE, done); IMAGE_TOLERANCE, done);
}); });
it('tests the webgl renderer', function(done) {
map = createMap('webgl', 100);
map.getView().setResolution(0.5);
createFeatures();
expectResemble(map, 'spec/ol/style/expected/polygon-types-webgl-stroke.png',
IMAGE_TOLERANCE, done);
});
}); });
describe('z-index', function() { describe('z-index', function() {
@@ -206,6 +221,13 @@ describe('ol.rendering.style.Polygon', function() {
expectResemble(map, 'spec/ol/style/expected/polygon-zindex-canvas.png', expectResemble(map, 'spec/ol/style/expected/polygon-zindex-canvas.png',
IMAGE_TOLERANCE, done); IMAGE_TOLERANCE, done);
}); });
it('tests the webgl renderer', function(done) {
map = createMap('webgl');
createFeatures();
expectResemble(map, 'spec/ol/style/expected/polygon-zindex-webgl.png',
IMAGE_TOLERANCE, done);
});
}); });
describe('different fills and strokes', function() { describe('different fills and strokes', function() {
@@ -259,6 +281,14 @@ describe('ol.rendering.style.Polygon', function() {
map, 'spec/ol/style/expected/polygon-fill-and-strokes-canvas.png', map, 'spec/ol/style/expected/polygon-fill-and-strokes-canvas.png',
IMAGE_TOLERANCE, done); IMAGE_TOLERANCE, done);
}); });
it('tests the webgl renderer', function(done) {
map = createMap('webgl');
createFeatures();
expectResemble(
map, 'spec/ol/style/expected/polygon-fill-and-strokes-webgl.png',
5.76, done);
});
}); });
describe('CanvasPattern and LinearGradient as fills and strokes', function() { describe('CanvasPattern and LinearGradient as fills and strokes', function() {