Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions drracket-test/tests/drracket/private/easter-egg-lib.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ and then loading the framework after that.
(define drr-frame (wait-for-drracket-frame))
(set-module-language! drr-frame)
(queue-callback/res
(λ () (send (send (send drr-frame get-definitions-text) get-canvas) focus)))
(λ () (send+ drr-frame (get-definitions-text) (get-canvas) (focus))))
(for ([x (in-string "(car 'x)")])
(test:keystroke x))
(let ([button (queue-callback/res (λ () (send drr-frame get-execute-button)))])
Expand All @@ -81,15 +81,12 @@ and then loading the framework after that.
(define (wait-for-drracket-frame [print-message? #f])
(define (wait-for-drracket-frame-pred)
(define active (test:get-active-top-level-window))
(if (and active
(drracket-frame? active))
active
#f))
(and active (drracket-frame? active) active))
(define drr-fr
(or (wait-for-drracket-frame-pred)
(begin
(when print-message?
(printf "Select DrRacket frame\n"))
(displayln "Select DrRacket frame"))
(poll-until wait-for-drracket-frame-pred))))
(when drr-fr
(wait-for-events-in-frame-eventspace drr-fr))
Expand All @@ -113,10 +110,9 @@ and then loading the framework after that.

(define (verify-drracket-frame-frontmost function-name frame)
(on-eventspace-handler-thread 'verify-drracket-frame-frontmost)
(let ([tl (test:get-active-top-level-window)])
(unless (and (eq? frame tl)
(drracket-frame? tl))
(error function-name "drracket frame not frontmost: ~e (found ~e)" frame tl))))
(define tl (test:get-active-top-level-window))
(unless (and (eq? frame tl) (drracket-frame? tl))
(error function-name "drracket frame not frontmost: ~e (found ~e)" frame tl)))

(define (set-module-language! drr-frame)
(test:menu-select "Language" "Choose Language…")
Expand Down
45 changes: 16 additions & 29 deletions drracket-test/tests/drracket/private/gui.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,17 @@
(cond
[(= i (string-length string1)) (only-whitespace? string2 j)]
[(= j (string-length string2)) (only-whitespace? string1 i)]
[else (let ([c1 (string-ref string1 i)]
[c2 (string-ref string2 j)])
(cond
[in-whitespace?
(cond
[(whitespace? c1)
(loop (+ i 1)
j
#t)]
[(whitespace? c2)
(loop i
(+ j 1)
#t)]
[else (loop i j #f)])]
[(and (whitespace? c1)
(whitespace? c2))
(loop (+ i 1)
(+ j 1)
#t)]
[(char=? c1 c2)
(loop (+ i 1)
(+ j 1)
#f)]
[else #f]))])))
[else (define c1 (string-ref string1 i))
(define c2 (string-ref string2 j))
(cond
[in-whitespace?
(cond
[(whitespace? c1) (loop (+ i 1) j #t)]
[(whitespace? c2) (loop i (+ j 1) #t)]
[else (loop i j #f)])]
[(and (whitespace? c1) (whitespace? c2)) (loop (+ i 1) (+ j 1) #t)]
[(char=? c1 c2) (loop (+ i 1) (+ j 1) #f)]
[else #f])])))

;; whitespace? : char -> boolean
;; deteremines if `c' is whitespace
Expand Down Expand Up @@ -113,11 +100,11 @@
window label class))
(let loop ([window window])
(cond
[(and (or (not class)
(is-a? window class))
(let ([win-label (and (is-a? window window<%>)
(send window get-label))])
(equal? label win-label)))
[(cond
[(or (not class) (is-a? window class))
(define win-label (and (is-a? window window<%>) (send window get-label)))
(equal? label win-label)]
[else #f])
(list window)]
[(is-a? window area-container<%>) (apply append (map loop (send window get-children)))]
[else '()])))
Expand Down
47 changes: 25 additions & 22 deletions drracket-test/tests/drracket/private/no-fw-test-util.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -105,32 +105,35 @@
(not-on-eventspace-handler-thread
'queue-callback/res
#:more (λ () (format "\n thunk: ~e" thunk)))
(let ([c (make-channel)])
(queue-callback (λ () (channel-put c (with-handlers ((exn:fail? values))
(call-with-values thunk list))))
#f)
(define res (channel-get c))
(when (exn? res) (raise res))
(apply values res)))
(define c (make-channel))
(queue-callback (λ ()
(channel-put c
(with-handlers ([exn:fail? values])
(call-with-values thunk list))))
#f)
(define res (channel-get c))
(when (exn? res)
(raise res))
(apply values res))

;; poll-until : (-> alpha) number (-> alpha) -> alpha
;; waits until pred return a true value and returns that.
;; if that doesn't happen by `secs', calls fail and returns that.
(define (poll-until pred
[secs 10]
[fail (lambda ()
(error 'poll-until
"timeout after ~e secs, ~e never returned a true value"
secs pred))])
(let ([step 1/20])
(let loop ([counter secs])
(if (<= counter 0)
(fail)
(let ([result (pred)])
(or result
(begin
(sleep step)
(loop (- counter step)))))))))
(define (poll-until
pred
[secs 10]
[fail
(lambda ()
(error 'poll-until "timeout after ~e secs, ~e never returned a true value" secs pred))])
(define step 1/20)
(let loop ([counter secs])
(if (<= counter 0)
(fail)
(let ([result (pred)])
(or result
(begin
(sleep step)
(loop (- counter step))))))))

(define (wait-for-events-in-frame-eventspace fr)
(define sema (make-semaphore 0))
Expand Down
Loading