Skip to content

Commit

Permalink
update test for ToButton
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyan11 committed Jan 23, 2024
1 parent 5a7a971 commit 4d5756f
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 9 deletions.
8 changes: 3 additions & 5 deletions src/Toplo-Serialization/ToElement.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ ToElement >> stonPostReferenceResolution [
self tooltipContent: anElement.
self userData removeKey: #tooltipContent ].
self userData at: #stonLabeledIcon ifPresent: [ :anElement |
self labeledIcon label: anElement label.
self labeledIcon icon: anElement icon.
anElement icon ifNotNil: [ :toIcon | toIcon parent ifNotNil: [ :toParent | toParent removeChild: toIcon]. self labeledIcon icon: toIcon ].
anElement label ifNotNil: [ :toLabel | toLabel parent ifNotNil: [ :toParent | toParent removeChild: toLabel]. self labeledIcon label: toLabel ].
self labeledIcon interspace: anElement interspace.
self labeledIcon iconContainerWidth: anElement iconContainerWidth.
self labeledIcon iconContainerHeight: anElement iconContainerHeight.
self labeledIcon flexible: anElement flexible.
self labeledIcon orientation: anElement orientation.
self labeledIcon direction: anElement direction.

self userData removeKey: #stonLabeledIcon
]
self userData removeKey: #stonLabeledIcon ]
]

{ #category : #'*Toplo-Serialization' }
Expand Down
17 changes: 17 additions & 0 deletions src/Toplo-Serialization/ToImage.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Extension { #name : #ToImage }

{ #category : #'*Toplo-Serialization' }
ToImage >> stonPostReferenceResolution [

super stonPostReferenceResolution.
self userData at: #stonInnerImage ifPresent: [ :toInnerImage |
self innerImage: toInnerImage.
self userData removeKey: #stonInnerImage ]
]

{ #category : #'*Toplo-Serialization' }
ToImage >> stonUserDataOn: aIdentityDictionary [

super stonUserDataOn: aIdentityDictionary.
aIdentityDictionary at: #stonInnerImage put: self innerImage
]
21 changes: 21 additions & 0 deletions src/Toplo-Serialization/ToLabeledIcon.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Extension { #name : #ToLabeledIcon }

{ #category : #'*Toplo-Serialization' }
ToLabeledIcon >> stonPostReferenceResolution [

super stonPostReferenceResolution.
self userData at: #stonToLabel ifPresent: [ :toLabel |
self label: toLabel.
self userData removeKey: #stonToLabel ].
self userData at: #stonToImage ifPresent: [ :toImage |
self icon: toImage.
self userData removeKey: #stonToImage ]
]

{ #category : #'*Toplo-Serialization' }
ToLabeledIcon >> stonUserDataOn: aIdentityDictionary [

super stonUserDataOn: aIdentityDictionary.
aIdentityDictionary at: #stonToLabel put: self label.
aIdentityDictionary at: #stonToImage put: self icon.
]
52 changes: 48 additions & 4 deletions src/Toplo-Serialization/ToSerializerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,60 @@ ToSerializerTest >> testIsLeaf3 [
]

{ #category : #tests }
ToSerializerTest >> testToButton [
ToSerializerTest >> testToButton1 [

| origin |
origin := ToButton new
labelText: 'hello';
iconImage: (self iconNamed: #class);
yourself.

self
test: origin
on: [ :element | self assert: element labelText asString equals: 'hello' ]
self test: origin on: [ :element |
self assert: element labelText asString equals: 'hello'.
self
assert: element iconImage background image bits
equals: (self iconNamed: #class) bits ]
]

{ #category : #tests }
ToSerializerTest >> testToButton2 [

| origin |
origin := ToButton new
labelText: 'hello';
yourself.

self test: origin on: [ :element |
self assert: element labelText asString equals: 'hello'.
self assert: element icon equals: nil ]
]

{ #category : #tests }
ToSerializerTest >> testToButton3 [

| origin |
origin := ToButton new
iconImage: (self iconNamed: #class);
yourself.

self test: origin on: [ :element |
self assert: element label equals: nil.
self
assert: element iconImage background image bits
equals: (self iconNamed: #class) bits ]
]

{ #category : #tests }
ToSerializerTest >> testToButton4 [

| origin |
origin := ToButton new.

self test: origin on: [ :element |
self assert: element label equals: nil.
self
assert: element icon
equals: nil ]
]

{ #category : #tests }
Expand Down

0 comments on commit 4d5756f

Please sign in to comment.