@@ -303,6 +303,83 @@ describe('DistanceTool and AreaTool', function () {
303
303
tool . endDraw ( ) ;
304
304
expect ( tool . getLastMeasure ( ) ) . to . be . above ( 0 ) ;
305
305
} ) ;
306
+
307
+ //#1249
308
+ it ( 'undo for multiple times' , function ( ) {
309
+ var tool = new maptalks . AreaTool ( ) . addTo ( map ) ;
310
+ var center = map . getCenter ( ) ;
311
+
312
+ var domPosition = GET_PAGE_POSITION ( container ) ;
313
+ var point = map . coordinateToContainerPoint ( center ) . add ( domPosition ) ;
314
+
315
+ var measure = 0 ;
316
+ happen . mousedown ( eventContainer , {
317
+ 'clientX' :point . x ,
318
+ 'clientY' :point . y
319
+ } ) ;
320
+ happen . click ( eventContainer , {
321
+ 'clientX' :point . x ,
322
+ 'clientY' :point . y
323
+ } ) ;
324
+ var i ;
325
+ for ( i = 1 ; i < 10 ; i ++ ) {
326
+ happen . mousemove ( eventContainer , {
327
+ 'clientX' :point . x + i ,
328
+ 'clientY' :point . y
329
+ } ) ;
330
+ }
331
+
332
+ happen . mousedown ( eventContainer , {
333
+ 'clientX' :point . x + 10 ,
334
+ 'clientY' :point . y
335
+ } ) ;
336
+ happen . click ( eventContainer , {
337
+ 'clientX' :point . x + 10 ,
338
+ 'clientY' :point . y
339
+ } ) ;
340
+ happen . mousedown ( eventContainer , {
341
+ 'clientX' :point . x + 20 ,
342
+ 'clientY' :point . y
343
+ } ) ;
344
+ happen . click ( eventContainer , {
345
+ 'clientX' :point . x + 20 ,
346
+ 'clientY' :point . y
347
+ } ) ;
348
+
349
+ tool . undo ( ) ;
350
+ tool . undo ( ) ;
351
+ happen . click ( eventContainer , {
352
+ 'clientX' :point . x ,
353
+ 'clientY' :point . y
354
+ } ) ;
355
+ var i ;
356
+ for ( i = 1 ; i < 10 ; i ++ ) {
357
+ happen . mousemove ( eventContainer , {
358
+ 'clientX' :point . x + i ,
359
+ 'clientY' :point . y
360
+ } ) ;
361
+ }
362
+
363
+ happen . mousedown ( eventContainer , {
364
+ 'clientX' :point . x + 10 ,
365
+ 'clientY' :point . y
366
+ } ) ;
367
+ happen . click ( eventContainer , {
368
+ 'clientX' :point . x + 10 ,
369
+ 'clientY' :point . y
370
+ } ) ;
371
+ tool . undo ( ) ;
372
+ tool . undo ( ) ;
373
+
374
+ var layers = tool . getMeasureLayers ( ) ;
375
+ for ( var i = 0 ; i < layers . length ; i ++ ) {
376
+ if ( layers [ i ] . getCount ( ) > 0 ) {
377
+ expect ( layers [ i ] . getCount ( ) ) . to . be . eql ( 2 ) ;
378
+ }
379
+ }
380
+ tool . disable ( ) ;
381
+
382
+ } ) ;
306
383
} ) ;
307
384
308
385
0 commit comments