Fix finishCondition test
This commit is contained in:
@@ -338,8 +338,8 @@ describe('ol.interaction.Draw', function() {
|
|||||||
var draw = new ol.interaction.Draw({
|
var draw = new ol.interaction.Draw({
|
||||||
source: source,
|
source: source,
|
||||||
type: ol.geom.GeometryType.LINE_STRING,
|
type: ol.geom.GeometryType.LINE_STRING,
|
||||||
finishFunction: function(event) {
|
finishCondition: function(event) {
|
||||||
if (ol.array.equals(event.pixel,[30,20])) {
|
if (ol.array.equals(event.coordinate,[30,-20])) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -350,32 +350,33 @@ describe('ol.interaction.Draw', function() {
|
|||||||
|
|
||||||
it('draws a linestring failing to finish it first, the finishes it', function() {
|
it('draws a linestring failing to finish it first, the finishes it', function() {
|
||||||
var features;
|
var features;
|
||||||
|
|
||||||
// first point
|
// first point
|
||||||
simulateEvent('pointermove', 10, 20);
|
simulateEvent('pointermove', 10, 20);
|
||||||
simulateEvent('pointerdown', 10, 20);
|
simulateEvent('pointerdown', 10, 20);
|
||||||
simulateEvent('pointerup', 10, 20);
|
simulateEvent('pointerup', 10, 20);
|
||||||
|
|
||||||
// second point
|
|
||||||
simulateEvent('pointermove', 30, 20);
|
|
||||||
simulateEvent('pointerdown', 30, 20);
|
|
||||||
simulateEvent('pointerup', 30, 20);
|
|
||||||
|
|
||||||
// cannot finish on this point
|
|
||||||
simulateEvent('pointerdown', 30, 20);
|
|
||||||
simulateEvent('pointerup', 30, 20);
|
|
||||||
|
|
||||||
features = source.getFeatures();
|
|
||||||
expect(features).to.have.length(1);
|
|
||||||
|
|
||||||
// second point
|
// second point
|
||||||
simulateEvent('pointermove', 40, 30);
|
simulateEvent('pointermove', 40, 30);
|
||||||
simulateEvent('pointerdown', 40, 30);
|
simulateEvent('pointerdown', 40, 30);
|
||||||
simulateEvent('pointerup', 40, 30);
|
simulateEvent('pointerup', 40, 30);
|
||||||
|
|
||||||
// finish on this point
|
// try to finish on this point
|
||||||
simulateEvent('pointerdown', 40, 30);
|
simulateEvent('pointerdown', 40, 30);
|
||||||
simulateEvent('pointerup', 40, 30);
|
simulateEvent('pointerup', 40, 30);
|
||||||
|
|
||||||
|
features = source.getFeatures();
|
||||||
|
expect(features).to.have.length(0);
|
||||||
|
|
||||||
|
// third point
|
||||||
|
simulateEvent('pointermove', 30, 20);
|
||||||
|
simulateEvent('pointerdown', 30, 20);
|
||||||
|
simulateEvent('pointerup', 30, 20);
|
||||||
|
|
||||||
|
// finish on this point
|
||||||
|
simulateEvent('pointerdown', 30, 20);
|
||||||
|
simulateEvent('pointerup', 30, 20);
|
||||||
|
|
||||||
features = source.getFeatures();
|
features = source.getFeatures();
|
||||||
expect(features).to.have.length(1);
|
expect(features).to.have.length(1);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user