forked from pharo-project/pharo
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
53 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
" | ||
I am a class giving the user the hability to wait for an UI redraw in Morphic. | ||
I am useful for tests when they need to be executed in a CI in non interactive mode. | ||
" | ||
Trait { | ||
#name : #SpTMorphicUIRedrawer, | ||
#instVars : [ | ||
'uiWaitingSemaphore' | ||
], | ||
#category : #'Spec2-Backend-Tests' | ||
} | ||
|
||
{ #category : #initialization } | ||
SpTMorphicUIRedrawer >> initializeSemaphore [ | ||
uiWaitingSemaphore := Semaphore new | ||
] | ||
|
||
{ #category : #testing } | ||
SpTMorphicUIRedrawer >> isRunningInUIProcess [ | ||
^ UIManager default uiProcess == Processor activeProcess | ||
] | ||
|
||
{ #category : #utilities } | ||
SpTMorphicUIRedrawer >> waitUntilUIRedrawed [ | ||
"I wait until the UI has been redrawn. | ||
I take care of selecting how to do it. | ||
If I am in the CI I should defer a semaphore signal. | ||
If I am running in the UI process I can directly execute a doOneCycle on the World. | ||
If I am in the CI the tests and the UI run in different process. So I should not do a #doOneCycle. | ||
If I do it, I am in a race condition!" | ||
|
||
self isRunningInUIProcess | ||
ifTrue: [ self currentWorld doOneCycle. | ||
^ self ]. | ||
|
||
self currentWorld defer: [ uiWaitingSemaphore ifNotNil: #signal ]. | ||
uiWaitingSemaphore wait: self defaultWaitDuration | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters