-
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.
more tests
- Loading branch information
Showing
38 changed files
with
329 additions
and
59 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
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
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
154 changes: 154 additions & 0 deletions
154
src/Toplo-Tests/ToElementWithPopupEventHandlerTest.class.st
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,154 @@ | ||
" | ||
A ToElementWithPopupEventHandlerTest is a test class for testing the behavior of ToElementWithPopupEventHandler | ||
" | ||
Class { | ||
#name : 'ToElementWithPopupEventHandlerTest', | ||
#superclass : 'ToParameterizedHostTest', | ||
#category : 'Toplo-Tests-Core-Window', | ||
#package : 'Toplo-Tests', | ||
#tag : 'Core-Window' | ||
} | ||
|
||
{ #category : 'tests' } | ||
ToElementWithPopupEventHandlerTest >> testElementPositionInSpaceChangedEvent [ | ||
|
||
| win e windowManager | | ||
e := ToElement new. | ||
space root addChild: e. | ||
e position: 10 asPoint. | ||
e size: 10 asPoint. | ||
self waitTestingSpaces. | ||
|
||
windowManager := ToPopupWindowManager new. | ||
windowManager element: e. | ||
win := windowManager newWindowEvent: nil. | ||
win popup. | ||
self waitTestingSpaces. | ||
self assert: win isOpened. | ||
e position: 20 asPoint. | ||
self waitTestingSpaces. | ||
self assert: win isClosed | ||
] | ||
|
||
{ #category : 'tests' } | ||
ToElementWithPopupEventHandlerTest >> testMouseDownEvent [ | ||
|
||
| e windowManager position event | | ||
e := ToElement new. | ||
e size: 100 asPoint. | ||
space root addChild: e. | ||
self waitTestingSpaces. | ||
|
||
windowManager := ToPopupWindowManager new. | ||
|
||
windowManager element: e. | ||
position := e bounds inSpace center. | ||
event := BlMouseDownEvent primary position: position. | ||
e dispatchEvent: event. | ||
self assert: windowManager currentWindow notNil. | ||
self waitTestingSpaces. | ||
self assert: windowManager currentWindow isOpened. | ||
|
||
] | ||
|
||
{ #category : 'tests' } | ||
ToElementWithPopupEventHandlerTest >> testMouseUpEvent [ | ||
|
||
| e windowManager closed position event | | ||
e := ToElement new. | ||
e size: 100 asPoint. | ||
space root addChild: e. | ||
self waitTestingSpaces. | ||
|
||
windowManager := ToPopupWindowManager new. | ||
|
||
windowManager element: e. | ||
BlSpace simulateMouseDownOn: e. | ||
self assert: windowManager currentWindow notNil. | ||
self assert: windowManager currentWindow isOpened. | ||
closed := false. | ||
windowManager currentWindow addEventHandler: (BlEventHandler | ||
on: ToWindowClosedEvent | ||
do: [ closed := true ]). | ||
(windowManager autoCloseOnMouseUpDelay + 1 milliSecond ) wait. | ||
position := e bounds inSpace center. | ||
event := BlMouseUpEvent primary position: position. | ||
e dispatchEvent: event. | ||
self waitTestingSpaces. | ||
|
||
" window is closed on mouse-up " | ||
self assert: windowManager currentWindow isNil. | ||
self assert: closed | ||
|
||
] | ||
|
||
{ #category : 'tests' } | ||
ToElementWithPopupEventHandlerTest >> testMouseUpOutsideEvent [ | ||
|
||
| e windowManager closed event | | ||
e := ToElement new. | ||
e size: 100 asPoint. | ||
e position: 100 asPoint. | ||
space root addChild: e. | ||
self waitTestingSpaces. | ||
|
||
windowManager := ToPopupWindowManager new. | ||
|
||
windowManager element: e. | ||
BlSpace simulateMouseDownOn: e. | ||
self assert: windowManager currentWindow notNil. | ||
self assert: windowManager currentWindow isOpened. | ||
closed := false. | ||
windowManager currentWindow addEventHandler: (BlEventHandler | ||
on: ToWindowClosedEvent | ||
do: [ closed := true ]). | ||
(windowManager autoCloseOnMouseUpDelay + 1 milliSecond ) wait. | ||
event := BlMouseUpEvent primary position: 0@0. | ||
e dispatchEvent: event asMouseOutsideEvent. | ||
self waitTestingSpaces. | ||
|
||
" window is closed on mouse-up " | ||
self assert: windowManager currentWindow isNil. | ||
self assert: closed | ||
|
||
] | ||
|
||
{ #category : 'tests' } | ||
ToElementWithPopupEventHandlerTest >> testOnInstalledIn [ | ||
|
||
| e windowManager handler | | ||
e := ToElement new. | ||
windowManager := ToPopupWindowManager new. | ||
windowManager element: e. | ||
handler := e eventDispatcher handlers detect: [ :h | h isKindOf: ToElementWithPopupEventHandler ] ifNone: []. | ||
self assert: handler notNil. | ||
self assert: handler target identicalTo: e. | ||
self assert: e shouldHandleMousePickOutsideEvent. | ||
|
||
] | ||
|
||
{ #category : 'tests' } | ||
ToElementWithPopupEventHandlerTest >> testOnUninstalledIn [ | ||
|
||
| e windowManager handler | | ||
e := ToElement new. | ||
windowManager := ToPopupWindowManager new. | ||
windowManager element: e. | ||
handler := e eventDispatcher handlers detect: [ :h | h isKindOf: ToElementWithPopupEventHandler ] ifNone: []. | ||
self assert: handler target identicalTo: e. | ||
handler onUninstalledIn: e. | ||
self assert: handler target isNil | ||
|
||
] | ||
|
||
{ #category : 'tests' } | ||
ToElementWithPopupEventHandlerTest >> testTarget [ | ||
|
||
| e windowManager handler | | ||
e := ToElement new. | ||
windowManager := ToPopupWindowManager new. | ||
windowManager element: e. | ||
handler := e eventDispatcher handlers detect: [ :h | h isKindOf: ToElementWithPopupEventHandler ] ifNone: []. | ||
self assert: handler target identicalTo: e. | ||
|
||
] |
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
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
Oops, something went wrong.