Add more text style tests

This commit is contained in:
Andreas Hocevar
2017-08-31 21:51:36 +02:00
parent 6469d3e864
commit b5966b8ff3
2 changed files with 88 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

View File

@@ -103,6 +103,94 @@ describe('ol.rendering.style.Text', function() {
expectResemble(map, 'rendering/ol/style/expected/text-rotated-canvas.png', IMAGE_TOLERANCE, done);
});
it('renders multiline text with alignment options', function(done) {
createMap('canvas');
var feature;
feature = new ol.Feature(new ol.geom.Point([25, 0]));
feature.setStyle(new ol.style.Style({
text: new ol.style.Text({
text: 'Hello world\nleft',
font: 'bold 14px sans-serif',
textAlign: 'left'
})
}));
vectorSource.addFeature(feature);
feature = new ol.Feature(new ol.geom.Point([-25, 0]));
feature.setStyle(new ol.style.Style({
text: new ol.style.Text({
text: 'Hello world\nright',
font: 'bold 14px sans-serif',
textAlign: 'right'
})
}));
vectorSource.addFeature(feature);
feature = new ol.Feature(new ol.geom.Point([0, 25]));
feature.setStyle(new ol.style.Style({
text: new ol.style.Text({
text: 'Hello world\nbottom',
font: 'bold 14px sans-serif',
textBaseline: 'bottom'
})
}));
vectorSource.addFeature(feature);
feature = new ol.Feature(new ol.geom.Point([0, -25]));
feature.setStyle(new ol.style.Style({
text: new ol.style.Text({
text: 'top\nHello world',
font: 'bold 14px sans-serif',
textBaseline: 'top'
})
}));
vectorSource.addFeature(feature);
expectResemble(map, 'rendering/ol/style/expected/text-align-offset-canvas.png', 5, done);
});
it('renders multiline text with positioning options', function(done) {
createMap('canvas');
var feature;
feature = new ol.Feature(new ol.geom.Point([0, 0]));
feature.setStyle(new ol.style.Style({
text: new ol.style.Text({
text: 'Hello world\nleft',
font: 'bold 14px sans-serif',
textAlign: 'left',
offsetX: 25
})
}));
vectorSource.addFeature(feature);
feature = new ol.Feature(new ol.geom.Point([0, 0]));
feature.setStyle(new ol.style.Style({
text: new ol.style.Text({
text: 'Hello world\nright',
font: 'bold 14px sans-serif',
textAlign: 'right',
offsetX: -25
})
}));
vectorSource.addFeature(feature);
feature = new ol.Feature(new ol.geom.Point([0, 0]));
feature.setStyle(new ol.style.Style({
text: new ol.style.Text({
text: 'Hello world\nbottom',
font: 'bold 14px sans-serif',
textBaseline: 'bottom',
offsetY: -25
})
}));
vectorSource.addFeature(feature);
feature = new ol.Feature(new ol.geom.Point([0, 0]));
feature.setStyle(new ol.style.Style({
text: new ol.style.Text({
text: 'top\nHello world',
font: 'bold 14px sans-serif',
textBaseline: 'top',
offsetY: 25
})
}));
vectorSource.addFeature(feature);
expectResemble(map, 'rendering/ol/style/expected/text-align-offset-canvas.png', 5, done);
});
where('WebGL').it('tests the webgl renderer without rotation', function(done) {
createMap('webgl');
createFeatures();