-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bloc-Tasks: improve example + add tests
- Loading branch information
1 parent
f70c6d4
commit 5a86feb
Showing
2 changed files
with
76 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
Class { | ||
#name : #TKTBlocTest, | ||
#superclass : #BlParameterizedHostTest, | ||
#category : #'Bloc-Taskit-Tests' | ||
} | ||
|
||
{ #category : #running } | ||
TKTBlocTest >> isBeingExecutedInTaskPhase [ | ||
|
||
^ thisContext stack anySatisfy: [ :each | | ||
each receiver class = BlSpaceFrameTaskPhase ] | ||
] | ||
|
||
{ #category : #tests } | ||
TKTBlocTest >> testRunner [ | ||
|
||
| space runner | | ||
space := self newTestingSpace. | ||
space root background: Color green. | ||
|
||
runner := TKTBlSpaceRunner on: space. | ||
runner schedule: [ | ||
space root background: Color red. | ||
self assert: self isBeingExecutedInTaskPhase ] asTask. | ||
|
||
"Task is not executed immediately" | ||
self | ||
assert: space root background paint color | ||
equals: Color green. | ||
"Check again after pulse" | ||
self waitTestingSpaces. | ||
self | ||
assert: space root background paint color | ||
equals: Color red | ||
] | ||
|
||
{ #category : #tests } | ||
TKTBlocTest >> testService [ | ||
|
||
| space service count | | ||
space := self newTestingSpace. | ||
space show. | ||
|
||
service := TKTBlSpaceService on: space. | ||
count := 0. | ||
service step: [ | ||
count := count + 1. | ||
self assert: self isBeingExecutedInTaskPhase ]. | ||
service stepDelay: 50 milliSeconds. | ||
service start. | ||
|
||
0.5 seconds wait. | ||
service stop waitForCompletion: 1 second. | ||
|
||
self assert: count > 1 | ||
] |