Skip to content

Commit

Permalink
+ ToMenuItemBarElementTest
Browse files Browse the repository at this point in the history
  • Loading branch information
plantec committed Jan 14, 2025
1 parent 842ebb2 commit 2d09569
Show file tree
Hide file tree
Showing 2 changed files with 169 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Toplo-Widget-List-Tests/ToItemBarElementTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ ToItemBarElementTest >> testDisableItemAfterAdding2 [
item := ToItemElementForTest new text: 'B'.
l addItem: item.
item disable.
item := ToItemElementForTest new text: 'B'.
item := ToItemElementForTest new text: 'C'.
l addItem: item.
self waitTestingSpaces.

Expand Down Expand Up @@ -138,7 +138,7 @@ ToItemBarElementTest >> testDisableItemBeforeAdding2 [
item := ToItemElementForTest new text: 'B'.
item disable.
l addItem: item.
item := ToItemElementForTest new text: 'B'.
item := ToItemElementForTest new text: 'C'.
l addItem: item.
self waitTestingSpaces.

Expand Down
167 changes: 167 additions & 0 deletions src/Toplo-Widget-Menu-Tests/ToMenuItemBarElementTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
"
A ToMenuItemBarElementTest is a test class for testing the behavior of ToMenuItemBarElement
"
Class {
#name : #ToMenuItemBarElementTest,
#superclass : #ToParameterizedHostTest,
#instVars : [
'l'
],
#category : #'Toplo-Widget-Menu-Tests-ItemBar'
}

{ #category : #running }
ToMenuItemBarElementTest >> setUp [

super setUp.
l := ToMenuItemBarElement new.
l vMatchParent.
space root addChild: l
]

{ #category : #tests }
ToMenuItemBarElementTest >> test [

| n |
self assert: l nodes size equals: l dataAccessor size.
self assert: (l nodeManager isKindOf: ToMenuItemNodeManager).
l addAllItems:
((1 to: 10) collect: [ :i | ToMenuItem new labelText: i asString ]).
n := l nodes first.
self assert: (n isKindOf: ToMenuItemNode).
self assert: (n holder isKindOf: ToItemBarNodeHolder).
self assert: (n holder dataItem isKindOf: ToMenuItem)

]

{ #category : #tests }
ToMenuItemBarElementTest >> testAddItem [

| n item |
item := ToMenuItem new labelText: '#1'.
l addItem: item.
self waitTestingSpaces.
self assert: l nodes size equals: 1.
n := l nodes first.
self assert: (n isKindOf: ToMenuItemNode).
self assert: (n holder isKindOf: ToItemBarNodeHolder).
self assert: (n holder dataItem isKindOf: ToMenuItem).
self assert: item barElement identicalTo: l.
self assert: item positionInBar equals: 1
]

{ #category : #tests }
ToMenuItemBarElementTest >> testDisableItemAfterAdding [

| n item |
self assert: l nodes size equals: 0.
item := ToMenuItem new labelText: 'A'.
l addItem: item.
item disable.
self waitTestingSpaces.

n := l nodes first.
self assert: n holder dataItem identicalTo: item.
self assert: item positionInBar equals: 1.
self assert: (l disabledSelectionModel containsIndex: item positionInBar).
self assert: item isDisabled.
self deny: n isDisabled.


]

{ #category : #tests }
ToMenuItemBarElementTest >> testDisableItemAfterAdding2 [

| n item|
self assert: l nodes size equals: 0.
item := ToMenuItem new labelText: 'A'.
l addItem: item.
item := ToMenuItem new labelText: 'B'.
l addItem: item.
item disable.
item := ToMenuItem new labelText: 'C'.
l addItem: item.
self waitTestingSpaces.

n := l nodes first.
self assert: n item positionInBar equals: 1.
self deny: (l disabledSelectionModel containsIndex: n item positionInBar).
self deny: n item isDisabled.
self deny: n isDisabled.

n := l nodes second.
self waitTestingSpaces.
self assert: n item positionInBar equals: 2.
self assert: (l disabledSelectionModel containsIndex: n item positionInBar).
self assert: n item isDisabled.
self deny: n isDisabled.

n := l nodes third.
self assert: n item positionInBar equals: 3.
self deny: (l disabledSelectionModel containsIndex: n item positionInBar).
self deny: n item isDisabled.
self deny: n isDisabled.




]

{ #category : #tests }
ToMenuItemBarElementTest >> testDisableItemBeforeAdding [

| n item |
self assert: l nodes size equals: 0.
item := ToMenuItem new labelText: 'A'.
item disabled: true.
l addItem: item.
self waitTestingSpaces.

n := l nodes first.
self assert: n holder dataItem identicalTo: item.
self assert: item isDisabled.
self assert: item positionInBar equals: 1.
self assert: (l disabledSelectionModel containsIndex: item positionInBar).
self assert: item isDisabled.
self deny: n isDisabled.

]

{ #category : #tests }
ToMenuItemBarElementTest >> testDisableItemBeforeAdding2 [

| n item|
self assert: l nodes size equals: 0.
item := ToMenuItem new labelText: 'A'.
l addItem: item.
item := ToMenuItem new labelText: 'B'.
item disable.
l addItem: item.
item := ToMenuItem new labelText: 'C'.
l addItem: item.
self waitTestingSpaces.

n := l nodes first.
self assert: n item positionInBar equals: 1.
self deny: (l disabledSelectionModel containsIndex: n item positionInBar).
self deny: n item isDisabled.
self deny: n isDisabled.

n := l nodes second.
self waitTestingSpaces.
self assert: n item positionInBar equals: 2.
self assert: (l disabledSelectionModel containsIndex: n item positionInBar).
self assert: n item isDisabled.
self deny: n isDisabled.

n := l nodes third.
self assert: n item positionInBar equals: 3.
self deny: (l disabledSelectionModel containsIndex: n item positionInBar).
self deny: n item isDisabled.
self deny: n isDisabled.




]

0 comments on commit 2d09569

Please sign in to comment.