Add tests for linedash for HiDPI display
This commit is contained in:
@@ -34,7 +34,7 @@ describe('ol.render.canvas.ReplayGroup', function() {
|
|||||||
});
|
});
|
||||||
style2 = new ol.style.Style({
|
style2 = new ol.style.Style({
|
||||||
fill: new ol.style.Fill({color: 'white'}),
|
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;
|
fillCount = 0;
|
||||||
strokeCount = 0;
|
strokeCount = 0;
|
||||||
@@ -139,6 +139,23 @@ describe('ol.render.canvas.ReplayGroup', function() {
|
|||||||
expect(strokeCount).to.be(3);
|
expect(strokeCount).to.be(3);
|
||||||
expect(beginPathCount).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 |
@@ -14,7 +14,7 @@ describe('ol.rendering.style.LineString', function() {
|
|||||||
|
|
||||||
var target, map, vectorSource;
|
var target, map, vectorSource;
|
||||||
|
|
||||||
function createMap(renderer) {
|
function createMap(renderer, opt_pixelRatio) {
|
||||||
target = createMapDiv(50, 50);
|
target = createMapDiv(50, 50);
|
||||||
|
|
||||||
vectorSource = new ol.source.Vector();
|
vectorSource = new ol.source.Vector();
|
||||||
@@ -23,6 +23,7 @@ describe('ol.rendering.style.LineString', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
map = new ol.Map({
|
map = new ol.Map({
|
||||||
|
pixelRatio: opt_pixelRatio || 1,
|
||||||
target: target,
|
target: target,
|
||||||
renderer: renderer,
|
renderer: renderer,
|
||||||
layers: [vectorLayer],
|
layers: [vectorLayer],
|
||||||
@@ -85,6 +86,7 @@ describe('ol.rendering.style.LineString', function() {
|
|||||||
color: '#000000',
|
color: '#000000',
|
||||||
width: 2,
|
width: 2,
|
||||||
lineCap: 'square',
|
lineCap: 'square',
|
||||||
|
lineDash: [4, 8],
|
||||||
lineJoin: 'round'
|
lineJoin: 'round'
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
@@ -105,5 +107,13 @@ describe('ol.rendering.style.LineString', function() {
|
|||||||
expectResemble(map, 'spec/ol/style/expected/linestring-strokes-webgl.png',
|
expectResemble(map, 'spec/ol/style/expected/linestring-strokes-webgl.png',
|
||||||
14.6, done);
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user