-
Notifications
You must be signed in to change notification settings - Fork 9
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
2 changed files
with
95 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Class { | ||
#name : 'ToTransientStateForTest', | ||
#superclass : 'ToTransientState', | ||
#instVars : [ | ||
'applyCount' | ||
], | ||
#category : 'Toplo-Tests-Core-States', | ||
#package : 'Toplo-Tests', | ||
#tag : 'Core-States' | ||
} | ||
|
||
{ #category : 'accessing' } | ||
ToTransientStateForTest >> applyCount [ | ||
|
||
^ applyCount | ||
] | ||
|
||
{ #category : 'initialization' } | ||
ToTransientStateForTest >> initialize [ | ||
|
||
super initialize. | ||
applyCount := 0 | ||
] | ||
|
||
{ #category : 'look event sending' } | ||
ToTransientStateForTest >> onAppliedOn: anElement [ | ||
|
||
super onAppliedOn: anElement. | ||
applyCount := applyCount + 1 | ||
] |
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,65 @@ | ||
" | ||
A ToTransientStateTest is a test class for testing the behavior of ToTransientState | ||
" | ||
Class { | ||
#name : 'ToTransientStateTest', | ||
#superclass : 'ToParameterizedHostTest', | ||
#instVars : [ | ||
'space' | ||
], | ||
#category : 'Toplo-Tests-Core-States', | ||
#package : 'Toplo-Tests', | ||
#tag : 'Core-States' | ||
} | ||
|
||
{ #category : 'running' } | ||
ToTransientStateTest >> setUp [ | ||
|
||
super setUp. | ||
space := self newTestingSpace. | ||
|
||
] | ||
|
||
{ #category : 'tests' } | ||
ToTransientStateTest >> testApplyOn [ | ||
|
||
| e stateEvt receivedEvt | | ||
e := ToElement new. | ||
space root addChild: e. | ||
e when: ToHoveredLookEvent do: [ :event | receivedEvt := event ]. | ||
(ToTransientState lookEvent: (stateEvt := ToHoveredLookEvent new) ) applyOn: e. | ||
self assert: receivedEvt identicalTo: stateEvt | ||
|
||
] | ||
|
||
{ #category : 'tests' } | ||
ToTransientStateTest >> testLookEvent [ | ||
|
||
| state stateEvt | | ||
state := ToTransientState new. | ||
state lookEvent: (stateEvt := ToHoveredLookEvent new). | ||
self assert: state lookEvent identicalTo: stateEvt | ||
|
||
] | ||
|
||
{ #category : 'tests' } | ||
ToTransientStateTest >> testOnAppliedOn [ | ||
|
||
| e stateEvt state | | ||
e := ToElement new. | ||
space root addChild: e. | ||
state := ToTransientStateForTest lookEvent: (stateEvt := ToHoveredLookEvent new). | ||
state applyOn: e. | ||
self assert: state applyCount equals: 1 | ||
|
||
] | ||
|
||
{ #category : 'tests' } | ||
ToTransientStateTest >> testSourceEvent [ | ||
|
||
| state stateEvt sourceEvt | | ||
state := ToTransientState new. | ||
sourceEvt := BlMouseEnterEvent new position: 10@10. | ||
state lookEvent: (stateEvt := ToHoveredLookEvent new sourceEvent: sourceEvt). | ||
self assert: state sourceEvent identicalTo: sourceEvt | ||
] |