Skip to content

Commit

Permalink
cleaned test hierarchies.
Browse files Browse the repository at this point in the history
more tests
  • Loading branch information
plantec committed Dec 14, 2023
1 parent ae2be29 commit 897c345
Show file tree
Hide file tree
Showing 38 changed files with 329 additions and 59 deletions.
8 changes: 5 additions & 3 deletions src/Toplo-Examples/ToClassNodeExample.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ ToClassNodeExample >> forClassNameAssoc: aClassNameAssoc [
padding: (BlInsets all: 1);
beEditable;
stillPressedStartDelay: 800 milliSeconds;
when: ToStillPressedLookEvent do: [ :event |
event consumed: true.
event currentTarget addEditorEvent: event ];
addEventHandler: (BlEventHandler
on: ToStillPressedLookEvent
do: [ :event |
event consumed: true.
event currentTarget addEditorEvent: event ]);
whenTextReplacedDo: [ self holder data value: label text asString ].


Expand Down
26 changes: 15 additions & 11 deletions src/Toplo-Examples/ToSandBox.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -510,12 +510,15 @@ ToSandBox class >> example_EditableListWithAllClassesNames [
l
nodeClass: ToClassNodeExample;
nodeBuilder: [ :node :holder | node forClassNameAssoc: holder data ];
when: ToListStrongSelectionEvent do: [ :event |
event indexes size == 1 ifTrue: [
(l nodeAt: event indexes first) label addEditorEvent: event ] ];
addEventHandler: (BlEventHandler
on: ToListStrongSelectionEvent
do: [ :event |
event indexes size == 1 ifTrue: [
(l nodeAt: event indexes first) label addEditorEvent: event ] ]);
preserveSelectionOnFocused: false;
withRowNumbers.
l data addAll: (Smalltalk globals allClasses collect: [ :cls | cls -> cls name ]).
l data addAll:
(Smalltalk globals allClasses collect: [ :cls | cls -> cls name ]).

vscrollBar := BlVerticalScrollbarElement new.
vscrollBar constraintsDo: [ :c |
Expand Down Expand Up @@ -888,8 +891,7 @@ ToSandBox class >> example_ListWithAllClasses [
ToSandBox class >> example_ListWithAllClasses3 [

| l |
l := ToListElement new
nodeBuilder: [ :node :holder |
l := ToListElement new nodeBuilder: [ :node :holder |
| icn lab |
icn := holder data hasComment
ifTrue: [ #class ]
Expand All @@ -899,11 +901,13 @@ ToSandBox class >> example_ListWithAllClasses3 [
beEditable;
yourself.
node addChild: (ToLabeledIcon new
label: lab;
icon: (ToImage inner: (Smalltalk ui icons iconNamed: icn));
interspace: 10;
hMatchParent) ].
l when: ToInfiniteSelectionChangedEvent do: [ :evt | evt traceCr ].
label: lab;
icon: (ToImage inner: (Smalltalk ui icons iconNamed: icn));
interspace: 10;
hMatchParent) ].
l addEventHandler: (BlEventHandler
on: ToInfiniteSelectionChangedEvent
do: [ :evt | evt traceCr ]).
l data addAll: Smalltalk globals allClasses.
l withRowNumbers.
l infinite requestFocus.
Expand Down
2 changes: 1 addition & 1 deletion src/Toplo-Tests/TToElementWithContextMenuTest.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : 'TToElementWithContextMenuTest',
#superclass : 'ToParameterizedHostTest',
#superclass : 'ToTestCaseWithSpace',
#category : 'Toplo-Tests-Core',
#package : 'Toplo-Tests',
#tag : 'Core'
Expand Down
2 changes: 1 addition & 1 deletion src/Toplo-Tests/TToElementWithPlaceholderTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ A TToElementWithPlaceholderTest is a test class for testing the behavior of TToE
"
Class {
#name : 'TToElementWithPlaceholderTest',
#superclass : 'ToParameterizedHostTest',
#superclass : 'ToTestCaseWithSpace',
#category : 'Toplo-Tests-Core',
#package : 'Toplo-Tests',
#tag : 'Core'
Expand Down
2 changes: 1 addition & 1 deletion src/Toplo-Tests/TToElementWithTooltipTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ A TToWidgetWithTooltipTest is a test class for testing the behavior of TToWidget
"
Class {
#name : 'TToElementWithTooltipTest',
#superclass : 'ToParameterizedHostTest',
#superclass : 'ToTestCaseWithSpace',
#category : 'Toplo-Tests-Core',
#package : 'Toplo-Tests',
#tag : 'Core'
Expand Down
62 changes: 62 additions & 0 deletions src/Toplo-Tests/ToAnchorEventHandlerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,65 @@ Class {
#package : 'Toplo-Tests',
#tag : 'Core-Window'
}

{ #category : 'tests' }
ToAnchorEventHandlerTest >> testElementPositionInSpaceChangedEvent [

| win e windowManager |
e := ToElement new.
space root addChild: e.
e position: 10 asPoint.
e size: 10 asPoint.
self waitTestingSpaces.

windowManager := ToAnchoredWindowManager new builder: [ :anchWin :element | ].
windowManager element: e.
win := windowManager newWindowEvent: nil.
win popup.
self waitTestingSpaces.
self
assert: win bounds inSpace bounds origin
equals: e bounds inSpace bounds origin.
e position: 20 asPoint.
self waitTestingSpaces.
self assert: e bounds inSpace bounds origin equals: 20 asPoint.
self
assert: win bounds inSpace bounds origin
equals: e bounds inSpace bounds origin.



]

{ #category : 'tests' }
ToAnchorEventHandlerTest >> testElementRemovedFromParentEvent [

| win e windowManager closed |
e := ToElement new.
space root addChild: e.
e position: 10 asPoint.
e size: 10 asPoint.
self waitTestingSpaces.

windowManager := ToAnchoredWindowManager new builder: [
:anchWin
:element | ].
windowManager element: e.
win := windowManager newWindowEvent: nil.
win popup.
closed := false.
win addEventHandler: (BlEventHandler
on: ToWindowClosedEvent
do: [ closed := true ]).
self waitTestingSpaces.
self assert: win isOpened.
space root removeChild: e.
self assert: closed.
self assert: windowManager currentWindow isNil.
]

{ #category : 'tests' }
ToAnchorEventHandlerTest >> testElementRemovedFromSceneGraphEvent [

self testElementRemovedFromParentEvent
]
2 changes: 1 addition & 1 deletion src/Toplo-Tests/ToCheckStateTest.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : 'ToCheckStateTest',
#superclass : 'ToParameterizedHostTest',
#superclass : 'ToTestCaseWithSpace',
#category : 'Toplo-Tests-Core-States',
#package : 'Toplo-Tests',
#tag : 'Core-States'
Expand Down
2 changes: 1 addition & 1 deletion src/Toplo-Tests/ToElementTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ A ToElementTest is a test class for testing the behavior of ToElement
"
Class {
#name : 'ToElementTest',
#superclass : 'ToParameterizedHostTest',
#superclass : 'ToTestCaseWithSpace',
#category : 'Toplo-Tests-Core',
#package : 'Toplo-Tests',
#tag : 'Core'
Expand Down
154 changes: 154 additions & 0 deletions src/Toplo-Tests/ToElementWithPopupEventHandlerTest.class.st
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.

]
2 changes: 1 addition & 1 deletion src/Toplo-Tests/ToEnablementStateTest.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : 'ToEnablementStateTest',
#superclass : 'ToParameterizedHostTest',
#superclass : 'ToTestCaseWithSpace',
#category : 'Toplo-Tests-Core-States',
#package : 'Toplo-Tests',
#tag : 'Core-States'
Expand Down
2 changes: 1 addition & 1 deletion src/Toplo-Tests/ToFocusStateTest.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : 'ToFocusStateTest',
#superclass : 'ToParameterizedHostTest',
#superclass : 'ToTestCaseWithSpace',
#category : 'Toplo-Tests-Core-States',
#package : 'Toplo-Tests',
#tag : 'Core-States'
Expand Down
2 changes: 1 addition & 1 deletion src/Toplo-Tests/ToInstallStateTest.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : 'ToInstallStateTest',
#superclass : 'ToParameterizedHostTest',
#superclass : 'ToTestCaseWithSpace',
#category : 'Toplo-Tests-Core-States',
#package : 'Toplo-Tests',
#tag : 'Core-States'
Expand Down
2 changes: 1 addition & 1 deletion src/Toplo-Tests/ToIntrinsicStateTest.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : 'ToIntrinsicStateTest',
#superclass : 'ToParameterizedHostTest',
#superclass : 'ToTestCaseWithSpace',
#category : 'Toplo-Tests-Core-States',
#package : 'Toplo-Tests',
#tag : 'Core-States'
Expand Down
2 changes: 1 addition & 1 deletion src/Toplo-Tests/ToLabeledIconEventHandlerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ A ToLabeledIconEventHandlerTest is a test class for testing the behavior of ToLa
"
Class {
#name : 'ToLabeledIconEventHandlerTest',
#superclass : 'ToParameterizedHostTest',
#superclass : 'ToTestCaseWithSpace',
#category : 'Toplo-Tests-Core',
#package : 'Toplo-Tests',
#tag : 'Core'
Expand Down
2 changes: 1 addition & 1 deletion src/Toplo-Tests/ToLookEventActionTest.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : 'ToLookEventActionTest',
#superclass : 'ToParameterizedHostTest',
#superclass : 'ToTestCaseWithSpace',
#category : 'Toplo-Tests-Core-StyleSheet',
#package : 'Toplo-Tests',
#tag : 'Core-StyleSheet'
Expand Down
Loading

0 comments on commit 897c345

Please sign in to comment.