Skip to content

Commit

Permalink
fix on leaf + token and stamps tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyan11 committed Feb 1, 2024
1 parent d36eeaa commit 36cd486
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Toplo-Serialization/ToElement.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Extension { #name : #ToElement }
{ #category : #'*Toplo-Serialization' }
ToElement >> isLeaf [

^ true.
^ (self class == ToElement) not
]

{ #category : #'*Toplo-Serialization' }
Expand Down
5 changes: 5 additions & 0 deletions src/Toplo-Serialization/ToElementWithLeafForTesting.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Class {
#name : #ToElementWithLeafForTesting,
#superclass : #ToElement,
#category : #'Toplo-Serialization-cases-test'
}
65 changes: 59 additions & 6 deletions src/Toplo-Serialization/ToSerializerTest.class.st
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Class {
#name : #ToSerializerTest,
#superclass : #BlocSerializationTests,
#category : #'Toplo-Serialization'
#category : #'Toplo-Serialization-cases-test'
}

{ #category : #tests }
Expand Down Expand Up @@ -61,18 +61,19 @@ ToSerializerTest >> testIsLeaf1 [
ToSerializerTest >> testIsLeaf2 [

| b1 b2 |
b1 := ToElement new
b1 := ToElementWithLeafForTesting new
id: #b1;
yourself.
b2 := ToElement new
id: #b2;
yourself.
b1 addChild: b2.

[ :element |
self assert: element isLeaf equals: true.
self assert: element id equals: #b1.
self assert: element childrenCount equals: 0 ] value: b1 serialize materializeAsBlElement
[ :element |
self assert: element isLeaf equals: true.
self assert: element id equals: #b1.
self assert: element childrenCount equals: 0 ] value:
b1 serialize materializeAsBlElement
]

{ #category : #tests }
Expand All @@ -94,6 +95,42 @@ ToSerializerTest >> testIsLeaf3 [
self assert: (element childAt: 1) id equals: #b2 ]
]

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

| b1 b2 |
b1 := ToElement new
id: #b1;
yourself.
b2 := BlElement new
id: #b2;
yourself.
b1 addChild: b2.

self test: b1 on: [ :element |
self assert: element isLeaf equals: false.
self assert: element id equals: #b1.
self assert: element childrenCount equals: 1.
self assert: (element childAt: 1) id equals: #b2 ]
]

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

| origin |
origin := ToElement new
addStamp: #noValue;
addStamp: #withValue withValue: #toto;
yourself.

self
test: origin
on: [ :element | self assert: (element hasStamp: #noValue).
self assert: (element hasStamp: #withValue).
self assert: (element valueOfStamp: #noValue) value equals: true.
self assert: (element valueOfStamp: #withValue) value equals: #toto ]
]

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

Expand Down Expand Up @@ -274,6 +311,22 @@ ToSerializerTest >> testToLabel [
on: [ :element | self assert: element text asString equals: 'hello' ]
]

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

| origin |
origin := ToElement new
addTokenNamed: #hello withValue: #goodbye;
addTokenNamed: #titi withValue: #toto;
yourself.

self test: origin on: [ :element |
self assert: (element ensuredSkinManager tokenPropertyValue: #hello from: element) isNotNil.
self assert: (element ensuredSkinManager tokenPropertyValue: #titi from: element) isNotNil.
self assert: (element valueOfTokenNamed: #hello) value equals: #goodbye.
self assert: (element valueOfTokenNamed: #titi) value equals: #toto ]
]

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

Expand Down

0 comments on commit 36cd486

Please sign in to comment.