@@ -404,45 +404,11 @@ girderTest.promise.done(function () {
404404 expect ( $ ( 'button.h-draw[data-type="point"]' ) . hasClass ( 'active' ) ) . toBe ( true ) ;
405405 } ) ;
406406 } ) ;
407-
408- it ( 'check that keyboard shortcuts behave correctly' , function ( ) {
409- runs ( function ( ) {
410- // expect that hitting keyboard shortcut for each shape will
411- // switch the annotation mode to it, and hitting it again will
412- // turn off drawing mode.
413- $ ( '.h-image-body' ) . trigger ( $ . Event ( 'keydown' , { key : 'r' } ) ) ;
414- expect ( $ ( '.h-draw.active' ) . attr ( 'data-type' ) ) . toBe ( 'rectangle' ) ;
415- $ ( '.h-image-body' ) . trigger ( $ . Event ( 'keydown' , { key : 'r' } ) ) ;
416- expect ( $ ( '.h-draw.active' ) . length ) . toBe ( 0 ) ;
417-
418- $ ( '.h-image-body' ) . trigger ( $ . Event ( 'keydown' , { key : 'o' } ) ) ;
419- expect ( $ ( '.h-draw.active' ) . attr ( 'data-type' ) ) . toBe ( 'point' ) ;
420- $ ( '.h-image-body' ) . trigger ( $ . Event ( 'keydown' , { key : 'o' } ) ) ;
421- expect ( $ ( '.h-draw.active' ) . length ) . toBe ( 0 ) ;
422-
423- $ ( '.h-image-body' ) . trigger ( $ . Event ( 'keydown' , { key : 'c' } ) ) ;
424- expect ( $ ( '.h-draw.active' ) . attr ( 'data-type' ) ) . toBe ( 'circle' ) ;
425- $ ( '.h-image-body' ) . trigger ( $ . Event ( 'keydown' , { key : 'c' } ) ) ;
426- expect ( $ ( '.h-draw.active' ) . length ) . toBe ( 0 ) ;
427-
428- $ ( '.h-image-body' ) . trigger ( $ . Event ( 'keydown' , { key : 'i' } ) ) ;
429- expect ( $ ( '.h-draw.active' ) . attr ( 'data-type' ) ) . toBe ( 'ellipse' ) ;
430- $ ( '.h-image-body' ) . trigger ( $ . Event ( 'keydown' , { key : 'i' } ) ) ;
431- expect ( $ ( '.h-draw.active' ) . length ) . toBe ( 0 ) ;
432-
433- $ ( '.h-image-body' ) . trigger ( $ . Event ( 'keydown' , { key : 'p' } ) ) ;
434- expect ( $ ( '.h-draw.active' ) . attr ( 'data-type' ) ) . toBe ( 'polygon' ) ;
435- $ ( '.h-image-body' ) . trigger ( $ . Event ( 'keydown' , { key : 'p' } ) ) ;
436- expect ( $ ( '.h-draw.active' ) . length ) . toBe ( 0 ) ;
437-
438- $ ( '.h-image-body' ) . trigger ( $ . Event ( 'keydown' , { key : 'l' } ) ) ;
439- expect ( $ ( '.h-draw.active' ) . attr ( 'data-type' ) ) . toBe ( 'line' ) ;
440- $ ( '.h-image-body' ) . trigger ( $ . Event ( 'keydown' , { key : 'l' } ) ) ;
441- expect ( $ ( '.h-draw.active' ) . length ) . toBe ( 0 ) ;
442- } ) ;
443- } ) ;
444407 it ( 'test a boolean polygon operation' , function ( ) {
445408 var annotCount , toggle ;
409+ // The system isn't always ready here. A wait helps; it'd be
410+ // better to track down what we need to wait for.
411+ waits ( 500 ) ;
446412 runs ( function ( ) {
447413 annotCount = $ ( '.h-elements-container .h-element' ) . length ;
448414 $ ( '.h-draw[data-type="rectangle"]' ) . click ( ) ;
@@ -605,6 +571,42 @@ girderTest.promise.done(function () {
605571 return $ ( '.h-elements-container .h-element' ) . length === annotCount + 1 ;
606572 } , 'two annotations to merge into one' ) ;
607573 } ) ;
574+ it ( 'check that keyboard shortcuts behave correctly' , function ( ) {
575+ runs ( function ( ) {
576+ // expect that hitting keyboard shortcut for each shape will
577+ // switch the annotation mode to it, and hitting it again will
578+ // turn off drawing mode.
579+ $ ( '.h-image-body' ) . trigger ( $ . Event ( 'keydown' , { key : 'r' } ) ) ;
580+ expect ( $ ( '.h-draw.active' ) . attr ( 'data-type' ) ) . toBe ( 'rectangle' ) ;
581+ $ ( '.h-image-body' ) . trigger ( $ . Event ( 'keydown' , { key : 'r' } ) ) ;
582+ expect ( $ ( '.h-draw.active' ) . length ) . toBe ( 0 ) ;
583+
584+ $ ( '.h-image-body' ) . trigger ( $ . Event ( 'keydown' , { key : 'o' } ) ) ;
585+ expect ( $ ( '.h-draw.active' ) . attr ( 'data-type' ) ) . toBe ( 'point' ) ;
586+ $ ( '.h-image-body' ) . trigger ( $ . Event ( 'keydown' , { key : 'o' } ) ) ;
587+ expect ( $ ( '.h-draw.active' ) . length ) . toBe ( 0 ) ;
588+
589+ $ ( '.h-image-body' ) . trigger ( $ . Event ( 'keydown' , { key : 'c' } ) ) ;
590+ expect ( $ ( '.h-draw.active' ) . attr ( 'data-type' ) ) . toBe ( 'circle' ) ;
591+ $ ( '.h-image-body' ) . trigger ( $ . Event ( 'keydown' , { key : 'c' } ) ) ;
592+ expect ( $ ( '.h-draw.active' ) . length ) . toBe ( 0 ) ;
593+
594+ $ ( '.h-image-body' ) . trigger ( $ . Event ( 'keydown' , { key : 'i' } ) ) ;
595+ expect ( $ ( '.h-draw.active' ) . attr ( 'data-type' ) ) . toBe ( 'ellipse' ) ;
596+ $ ( '.h-image-body' ) . trigger ( $ . Event ( 'keydown' , { key : 'i' } ) ) ;
597+ expect ( $ ( '.h-draw.active' ) . length ) . toBe ( 0 ) ;
598+
599+ $ ( '.h-image-body' ) . trigger ( $ . Event ( 'keydown' , { key : 'p' } ) ) ;
600+ expect ( $ ( '.h-draw.active' ) . attr ( 'data-type' ) ) . toBe ( 'polygon' ) ;
601+ $ ( '.h-image-body' ) . trigger ( $ . Event ( 'keydown' , { key : 'p' } ) ) ;
602+ expect ( $ ( '.h-draw.active' ) . length ) . toBe ( 0 ) ;
603+
604+ $ ( '.h-image-body' ) . trigger ( $ . Event ( 'keydown' , { key : 'l' } ) ) ;
605+ expect ( $ ( '.h-draw.active' ) . attr ( 'data-type' ) ) . toBe ( 'line' ) ;
606+ $ ( '.h-image-body' ) . trigger ( $ . Event ( 'keydown' , { key : 'l' } ) ) ;
607+ expect ( $ ( '.h-draw.active' ) . length ) . toBe ( 0 ) ;
608+ } ) ;
609+ } ) ;
608610 } ) ;
609611
610612 describe ( 'Annotation styles' , function ( ) {
0 commit comments