Add tests for linedash for HiDPI display

This commit is contained in:
Thomas Chandelle
2016-11-14 09:09:32 +01:00
parent 7ee04ec200
commit 3b64133f21
4 changed files with 29 additions and 2 deletions

View File

@@ -34,7 +34,7 @@ describe('ol.render.canvas.ReplayGroup', function() {
});
style2 = new ol.style.Style({
fill: new ol.style.Fill({color: 'white'}),
stroke: new ol.style.Stroke({color: 'black', width: 1})
stroke: new ol.style.Stroke({color: 'black', width: 1, lineDash: [3, 6]})
});
fillCount = 0;
strokeCount = 0;
@@ -139,6 +139,23 @@ describe('ol.render.canvas.ReplayGroup', function() {
expect(strokeCount).to.be(3);
expect(beginPathCount).to.be(3);
});
it('applies the pixelRatio to the linedash array', function() {
var lineDash, lineDashCount = 0;
context.setLineDash = function(lineDash_) {
lineDashCount++;
lineDash = lineDash_.slice();
};
ol.renderer.vector.renderFeature(replay, feature1, style2, 1);
ol.renderer.vector.renderFeature(replay, feature2, style2, 1);
replay.replay(context, 2, transform, 0, {});
expect(lineDashCount).to.be(1);
expect(style2.getStroke().getLineDash()).to.be.eql([3, 6]);
expect(lineDash).to.be.eql([6, 12]);
});
});
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 928 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 787 B

After

Width:  |  Height:  |  Size: 515 B

View File

@@ -14,7 +14,7 @@ describe('ol.rendering.style.LineString', function() {
var target, map, vectorSource;
function createMap(renderer) {
function createMap(renderer, opt_pixelRatio) {
target = createMapDiv(50, 50);
vectorSource = new ol.source.Vector();
@@ -23,6 +23,7 @@ describe('ol.rendering.style.LineString', function() {
});
map = new ol.Map({
pixelRatio: opt_pixelRatio || 1,
target: target,
renderer: renderer,
layers: [vectorLayer],
@@ -85,6 +86,7 @@ describe('ol.rendering.style.LineString', function() {
color: '#000000',
width: 2,
lineCap: 'square',
lineDash: [4, 8],
lineJoin: 'round'
})
}));
@@ -105,5 +107,13 @@ describe('ol.rendering.style.LineString', function() {
expectResemble(map, 'spec/ol/style/expected/linestring-strokes-webgl.png',
14.6, done);
});
it('tests the canvas renderer (HiDPI)', function(done) {
map = createMap('canvas', 2);
createFeatures();
expectResemble(
map, 'spec/ol/style/expected/linestring-strokes-canvas-hidpi.png',
3.0, done);
});
});
});