From 4a6524fa856c79818f08f49238325cc2f3e64f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Thu, 31 Mar 2011 11:35:15 +0000 Subject: [PATCH] better tests for Measure test_cancel, thanks jorix for reporting this (in #3195) git-svn-id: http://svn.openlayers.org/trunk/openlayers@11835 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- tests/Control/Measure.html | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/Control/Measure.html b/tests/Control/Measure.html index 83085517d0..0ea68db029 100644 --- a/tests/Control/Measure.html +++ b/tests/Control/Measure.html @@ -36,7 +36,7 @@ map.addControl(control); control.activate(); - + try { control.cancel(); t.ok(true, "calling cancel before drawing works"); @@ -51,22 +51,26 @@ xy: new OpenLayers.Pixel(x, y) }) }; + + // keep a reference to the line being drawn + var line = control.handler.line; + trigger("mousemove", 0, 0); trigger("mousedown", 0, 0); trigger("mouseup", 0, 0); trigger("mousemove", 10, 10); trigger("mousedown", 10, 10); trigger("mouseup", 10, 10); + trigger("dblclick", 10, 10); + + // the geometry is finalized, we first confirm that it is persisted + t.ok(line.layer === control.handler.layer, "feature persists"); - // confirm that the sketch persists - t.eq(control.handler.layer.features.length, 1, "feature persists"); - // cancel and see that sketch is gone (do not forget that - // cancel will create the new feature) + // cancel and see that sketch is gone control.cancel(); - t.eq(control.handler.layer.features.length, 2, "feature is gone after cancel"); - + t.eq(line.layer, null, "feature is gone after cancel"); + map.destroy(); - } // test for