Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
plantec committed Dec 13, 2023
1 parent c728248 commit 89055be
Show file tree
Hide file tree
Showing 9 changed files with 383 additions and 68 deletions.
311 changes: 278 additions & 33 deletions src/Toplo-Tests/ToAnchoredWindowManagerTest.class.st

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions src/Toplo-Tests/ToOverlayWindowManagerTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"
A ToOverlayWindowManagerTest is a test class for testing the behavior of ToOverlayWindowManager
"
Class {
#name : 'ToOverlayWindowManagerTest',
#superclass : 'ToParameterizedHostTest',
#instVars : [
'space'
],
#category : 'Toplo-Tests-Core-Window',
#package : 'Toplo-Tests',
#tag : 'Core-Window'
}

{ #category : 'running' }
ToOverlayWindowManagerTest >> setUp [

super setUp.
space := self newTestingSpace.

]

{ #category : 'tests' }
ToOverlayWindowManagerTest >> testDefaultSizeHook [

| e windowManager win |
e := ToElement new.
space root addChild: e.
e position: 10 asPoint.
e size: 10 asPoint.
windowManager := ToOverlayWindowManager new.
windowManager element: e.
self assert: (windowManager defaultSizeHook isKindOf: BlockClosure).
win := windowManager newWindowEvent: nil.
win popup.
self waitTestingSpaces.
self assert: win bounds inSpace extent equals: e bounds inSpace extent
]

{ #category : 'tests' }
ToOverlayWindowManagerTest >> testElementEventHandlerClass [

| win e windowManager |
e := ToElement new.
space root addChild: e.
self waitTestingSpaces.

windowManager := ToOverlayWindowManager new builder: [ :anchWin :element | ].
windowManager element: e.
win := windowManager newWindowEvent: nil.
win popup.
self assert: win element equals: e.
self assert: (e eventDispatcher hasEventHandlerSuchThat: [ :eh |
eh isKindOf: ToOverlayedEventHandler ]).
win close.
self assert: (e eventDispatcher hasEventHandlerSuchThat: [ :eh |
eh isKindOf: ToOverlayedEventHandler ])
]
2 changes: 1 addition & 1 deletion src/Toplo-Widget-Album/ToLabelEditorWindowManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Class {
}

{ #category : 'initialization' }
ToLabelEditorWindowManager >> defaulPositionHook [
ToLabelEditorWindowManager >> defaultPositionHook [

^ [ :event :theLabel |
theLabel innerElement bounds inSpace bounds topLeft
Expand Down
2 changes: 1 addition & 1 deletion src/Toplo-Widget-Menu/ToContextMenuWindowManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Class {
}

{ #category : 'initialization' }
ToContextMenuWindowManager >> defaulPositionHook [
ToContextMenuWindowManager >> defaultPositionHook [

^ [ :event :theContextMenu | event position ]
]
Expand Down
2 changes: 1 addition & 1 deletion src/Toplo-Widget-Menu/ToMenuWindowManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Class {
}

{ #category : 'initialization' }
ToMenuWindowManager >> defaulPositionHook [
ToMenuWindowManager >> defaultPositionHook [

^ [ :event :theMenu | theMenu isSubmenu
ifTrue: [ theMenu bounds inSpace bounds topRight ]
Expand Down
58 changes: 35 additions & 23 deletions src/Toplo/ToAnchoredWindowManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,21 @@ ToAnchoredWindowManager >> currentWindow: aWindowElement [
]

{ #category : 'initialization' }
ToAnchoredWindowManager >> defaulPositionHook [
ToAnchoredWindowManager >> defaultBuilder [

^ [ :theWindow :theElement | ]


]

{ #category : 'initialization' }
ToAnchoredWindowManager >> defaultPositionHook [

^ [ :event :theElement| theElement bounds inSpace bounds topLeft ]
]

{ #category : 'initialization' }
ToAnchoredWindowManager >> defaulSizeHook [
ToAnchoredWindowManager >> defaultSizeHook [

^ nil
]
Expand All @@ -90,6 +98,12 @@ ToAnchoredWindowManager >> element: anElement [
element addEventHandler: self newElementEventHandler ]
]

{ #category : 'accessing' }
ToAnchoredWindowManager >> elementEventHandler [

^ elementEventHandler
]

{ #category : 'accessing' }
ToAnchoredWindowManager >> elementEventHandlerClass [

Expand All @@ -106,8 +120,9 @@ ToAnchoredWindowManager >> hasWindow [
ToAnchoredWindowManager >> initialize [

super initialize.
self positionHook: self defaulPositionHook.
self sizeHook: self defaulSizeHook.
self positionHook: self defaultPositionHook.
self sizeHook: self defaultSizeHook.
self builder: self defaultBuilder.


]
Expand All @@ -122,28 +137,34 @@ ToAnchoredWindowManager >> newElementEventHandler [

{ #category : 'window handling' }
ToAnchoredWindowManager >> newWindowEvent: anEvent [

| request |
self currentWindow ifNotNil: [
Error signal: 'Asking for a associate window building twice' ].
^ Error signal: 'Asking for a window building twice' ].
self element ifNil: [ ^ Error signal: 'An element is required for building a window' ].
self builder ifNil: [ ^ Error signal: 'A window builder is required for building a window' ].
request := self windowRequestClass new
sourceEvent: anEvent;
yourself.
sourceEvent: anEvent;
yourself.
self element dispatchEvent: request.
self currentWindow: (self newWindowInstanceAfterRequest: request).
self currentWindow: (self windowClass new
manager: self;
yourself).
builder value: self currentWindow value: request.
windowClosedHandler := BlEventHandler
on: ToWindowClosedEvent
do: [ self windowClosed ].
do: [ self onWindowClosed ].
self currentWindow addEventHandler: windowClosedHandler.
^ self currentWindow
]

{ #category : 'window handling' }
ToAnchoredWindowManager >> newWindowInstanceAfterRequest: aRequest [
ToAnchoredWindowManager >> onWindowClosed [

| w |
w := self windowClass new manager: self; yourself.
builder value: w value: aRequest.
^ w
self currentWindow removeEventHandler: windowClosedHandler.
windowClosedHandler := nil.
currentWindow manager: nil.
currentWindow := nil
]

{ #category : 'accessing' }
Expand Down Expand Up @@ -182,15 +203,6 @@ ToAnchoredWindowManager >> windowClass [
^ ToAnchoredWindow
]

{ #category : 'window handling' }
ToAnchoredWindowManager >> windowClosed [

self currentWindow removeEventHandler: windowClosedHandler.
windowClosedHandler := nil.
currentWindow manager: nil.
currentWindow := nil
]

{ #category : 'accessing' }
ToAnchoredWindowManager >> windowRequestClass [

Expand Down
2 changes: 1 addition & 1 deletion src/Toplo/ToOverlayWindowManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Class {
}

{ #category : 'initialization' }
ToOverlayWindowManager >> defaulSizeHook [
ToOverlayWindowManager >> defaultSizeHook [

^ [ :event :theElement | theElement size ]
]
Expand Down
2 changes: 1 addition & 1 deletion src/Toplo/ToPopupWindowManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ToPopupWindowManager >> autoCloseOnMouseUpDelay: aDelay [
]

{ #category : 'initialization' }
ToPopupWindowManager >> defaulPositionHook [
ToPopupWindowManager >> defaultPositionHook [

^ [ :event :theElement | theElement bounds inSpace bounds bottomLeft ]
]
Expand Down
14 changes: 7 additions & 7 deletions src/Toplo/ToTooltipWindowManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ Class {
#tag : 'Core-Tooltip'
}

{ #category : 'accessing' }
ToTooltipWindowManager >> defaultPopupDelay [

^ 700 milliSeconds
]

{ #category : 'initialization' }
ToTooltipWindowManager >> defaulPositionHook [
ToTooltipWindowManager >> defaultPositionHook [

^ [ :event :theElement|
event position x
@ (theElement localPointToGlobal: 0 @ theElement height) y + self vgap ]
]

{ #category : 'accessing' }
ToTooltipWindowManager >> defaultPopupDelay [

^ 700 milliSeconds
]

{ #category : 'accessing' }
ToTooltipWindowManager >> elementEventHandlerClass [

Expand Down

0 comments on commit 89055be

Please sign in to comment.