From 6c173c19e9440ed89629d84fd707605469a5c5ec Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Fri, 3 Feb 2017 10:21:04 -0600 Subject: [PATCH] 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). --- gui-test/framework/tests/keys.rkt | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/gui-test/framework/tests/keys.rkt b/gui-test/framework/tests/keys.rkt index 27bb9fe8..138d0fb6 100644 --- a/gui-test/framework/tests/keys.rkt +++ b/gui-test/framework/tests/keys.rkt @@ -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 (λ ()