diff --git a/test/spec/ol/renderer/canvas/replay.test.js b/test/spec/ol/renderer/canvas/replay.test.js index 68ee494d1c..da8a61ee52 100644 --- a/test/spec/ol/renderer/canvas/replay.test.js +++ b/test/spec/ol/renderer/canvas/replay.test.js @@ -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]); + }); }); }); diff --git a/test_rendering/spec/ol/style/expected/linestring-strokes-canvas-hidpi.png b/test_rendering/spec/ol/style/expected/linestring-strokes-canvas-hidpi.png new file mode 100644 index 0000000000..600e4c1336 Binary files /dev/null and b/test_rendering/spec/ol/style/expected/linestring-strokes-canvas-hidpi.png differ diff --git a/test_rendering/spec/ol/style/expected/linestring-strokes-canvas.png b/test_rendering/spec/ol/style/expected/linestring-strokes-canvas.png index 0e354d444a..9eb1f39a99 100644 Binary files a/test_rendering/spec/ol/style/expected/linestring-strokes-canvas.png and b/test_rendering/spec/ol/style/expected/linestring-strokes-canvas.png differ diff --git a/test_rendering/spec/ol/style/linestring.test.js b/test_rendering/spec/ol/style/linestring.test.js index 05a6e10a0d..d6eda66cb1 100644 --- a/test_rendering/spec/ol/style/linestring.test.js +++ b/test_rendering/spec/ol/style/linestring.test.js @@ -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); + }); }); });