Skip to content

Commit

Permalink
Remove dependency on Glamour.
Browse files Browse the repository at this point in the history
  • Loading branch information
jecisc committed Oct 4, 2019
1 parent 3ff62e1 commit 5b8e3e5
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/BaselineOfSpec2/BaselineOfSpec2.class.st
Expand Up @@ -32,7 +32,7 @@ BaselineOfSpec2 >> baseline: spec [
package: 'Spec2-Commander2-ContactBook' with: [ spec requires: #('Spec2-Commander2') ];
package: 'Spec2-Commander2-ContactBook-Extensions' with: [ spec requires: #('Spec2-Commander2-ContactBook') ];
package: 'Spec2-Tests' with: [ spec requires: #('Spec2-Examples') ];
package: 'Spec2-Morphic-Backend-Tests' with: [ spec requires: #('Spec2-Adapters-Morphic' 'ParametrizedTests') ];
package: 'Spec2-Morphic-Backend-Tests' with: [ spec requires: #('Spec2-Backend-Tests') ];
package: 'Spec2-Backend-Tests' with: [ spec requires: #('Spec2-Adapters-Morphic' 'ParametrizedTests') ];
package: 'Spec2-Adapters-Morphic-Tests' with: [ spec requires: #('Spec2-Tests' 'Spec2-Adapters-Morphic') ];
package: 'Spec2-Tools' with: [ spec requires: #('Spec2-Core') ];
Expand Down
32 changes: 4 additions & 28 deletions src/Spec2-Backend-Tests/SpMorphicBackendForTest.class.st
@@ -1,8 +1,9 @@
Class {
#name : #SpMorphicBackendForTest,
#superclass : #SpAbstractBackendForTest,
#traits : 'SpTMorphicUIRedrawer',
#classTraits : 'SpTMorphicUIRedrawer classTrait',
#instVars : [
'uiWaitingSemaphore',
'app'
],
#category : #'Spec2-Backend-Tests'
Expand Down Expand Up @@ -102,17 +103,10 @@ SpMorphicBackendForTest >> doubleClickFirstRowAndColumn: anAdapter [

]

{ #category : #running }
{ #category : #initialization }
SpMorphicBackendForTest >> initialize [

super initialize.
uiWaitingSemaphore := Semaphore new
]

{ #category : #running }
SpMorphicBackendForTest >> isRunningInUIProcess [

^ UIManager default uiProcess == Processor activeProcess
self initializeSemaphore
]

{ #category : #opening }
Expand All @@ -132,21 +126,3 @@ SpMorphicBackendForTest >> runTest: aBlock [
app useBackend: #Morphic.
aBlock value
]

{ #category : #running }
SpMorphicBackendForTest >> 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: 500 milliSecond
]
39 changes: 39 additions & 0 deletions src/Spec2-Backend-Tests/SpTMorphicUIRedrawer.trait.st
@@ -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
]
@@ -1,6 +1,8 @@
Class {
#name : #SpPresenterFocusOrderTest,
#superclass : #AbstractMorphicUITest,
#superclass : #TestCase,
#traits : 'SpTMorphicUIRedrawer',
#classTraits : 'SpTMorphicUIRedrawer classTrait',
#instVars : [
'mock'
],
Expand Down Expand Up @@ -71,6 +73,12 @@ SpPresenterFocusOrderTest >> pressTab [
self waitUntilUIRedrawed
]

{ #category : #running }
SpPresenterFocusOrderTest >> setUp [
super setUp.
self initializeSemaphore
]

{ #category : #emulating }
SpPresenterFocusOrderTest >> takeKeyboardFocus: aPresenter [

Expand Down

0 comments on commit 5b8e3e5

Please sign in to comment.