Skip to content

Commit

Permalink
+ ToTransientStateTest
Browse files Browse the repository at this point in the history
  • Loading branch information
plantec committed Dec 4, 2023
1 parent f7fa83e commit 069fb97
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/Toplo-Tests/ToTransientStateForTest.class.st
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
]
65 changes: 65 additions & 0 deletions src/Toplo-Tests/ToTransientStateTest.class.st
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
]

0 comments on commit 069fb97

Please sign in to comment.