avoid using separate events to send keystrokes in a hope of avoiding

intermittent failures in these tests

The guess that motivates this commit about what's going wrong is that
under some conditions that have to do with parallel tests that might
grab the OS-level focus, racket/gui is deciding that some of the two
keystroke combinations count as separate keystrokes, instead of being
combined in the search for the keymap handler. For example, if the
test suite tries to type c:c and then c:l, that will come in as two
separate events. If unlucky timing coincidence happens, then
racket/gui will decide that those should not count together in the
search for a keymap entry, but count as two separate ones (so we'd get
c:l centering the view instead of c:c;c:l inserting let-ans).
This commit is contained in:
Robby Findler 2017-02-03 10:21:04 -06:00
parent ff00d309ff
commit 6c173c19e9

View File

@ -403,9 +403,24 @@
(send text set-overwrite-mode (buff-spec-overwrite? before))
(send text erase)
(send text insert (buff-spec-string before))
(send text set-position (buff-spec-start before) (buff-spec-end before))))
(for ([key (in-list key-sequence)])
(test:keystroke (car key) (cdr key)))
(send text set-position (buff-spec-start before) (buff-spec-end before))
(for ([key (in-list key-sequence)])
(define event (make-object key-event%))
(send event set-key-code (car key))
(send event set-time-stamp (current-milliseconds))
(for ([mod (in-list (cdr key))])
(cond
[(eq? mod 'alt) (send event set-alt-down #t)]
[(eq? mod 'control) (send event set-control-down #t)]
[(eq? mod 'meta) (send event set-meta-down #t)]
[(eq? mod 'shift) (send event set-shift-down #t)]
[(eq? mod 'noalt) (send event set-alt-down #f)]
[(eq? mod 'nocontrol) (send event set-control-down #f)]
[(eq? mod 'nometa) (send event set-meta-down #f)]
[(eq? mod 'noshift) (send event set-shift-down #f)]
[else (error 'keys.rkt "unknown key modifier: ~e" mod)]))
(send text on-local-char event))))
(check-equal?
(queue-callback/wait
(λ ()