Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/Toplo-Serialization-Stash/ToAlbum.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Extension { #name : #ToAlbum }

{ #category : #'*Toplo-Serialization-Stash' }
ToAlbum >> stashPlaceholder [

<stashAccessors>
self userData at: #placeholder ifAbsent: [ ^ { } ].
^ { ([ :e |
' placeholderText: '''
, (BlTextNonPrintableCharacterPrinter print:
(self userData at: #placeholder) children first children first
text) , '''' ] -> self) onlySetOnStash }
]

{ #category : #'*Toplo-Serialization-Stash' }
ToAlbum >> stashUseScrollbar [

<stashAccessors>
^ { ([ :e | 'useScrollbar: ' , self useScrollbar printString ]
-> self) onlySetOnStash }
]
20 changes: 20 additions & 0 deletions src/Toplo-Serialization-Stash/ToBasicListElement.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Extension { #name : #ToBasicListElement }

{ #category : #'*Toplo-Serialization-Stash' }
ToBasicListElement >> stashRowNumbers [
<stashAccessors>
self toConfiguration rowNumbers ifFalse: [ ^ { } ].
^ { ([ :e | 'withRowNumbers' ] -> self) onlySetOnStash }
]

{ #category : #'*Toplo-Serialization-Stash' }
ToBasicListElement >> stashUseInfiniteLayout [
<stashAccessors>
^ { ([ :e | 'useInfiniteLayout: ' , self useInfiniteLayout printString ] -> self) onlySetOnStash }
]

{ #category : #'*Toplo-Serialization-Stash' }
ToBasicListElement >> stashUseScrollbar [
<stashAccessors>
^ { ([ :e | 'useScrollbar: ' , self useScrollbar printString ] -> self) onlySetOnStash }
]
11 changes: 3 additions & 8 deletions src/Toplo-Serialization-Stash/ToTextField.extension.st
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
Extension { #name : #ToTextField }

{ #category : #'*Toplo-Serialization-Stash' }
ToTextField >> stashPlaceholder [

ToTextField >> stashWrappingMode [
<stashAccessors>
self userData at: #placeholder ifAbsent: [ ^ { } ].
^ { ([ :e |
' placeholderText: '''
, (BlTextNonPrintableCharacterPrinter print:
(self userData at: #placeholder) children first children first
text) , ''''] -> self) onlySetOnStash }
self wrappingMode ifNil: [ ^ { } ].
^ { ([ :e | 'wrappingMode: ' , self wrappingMode printString ] -> self) onlySetOnStash }
]
202 changes: 171 additions & 31 deletions src/Toplo-Serialization-Tests/ToSerializerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,6 @@ ToSerializerTest >> testLocalTheme2 [
self assert: element localTheme class equals: ToBeeDarkTheme ]
]

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

| origin textElement|
origin := ToTextField new
placeholderText: 'Enter text...'.



self
test: origin
on: [ :element | textElement := (((element userData at:#placeholder) children first) children first).
self assert: (BlTextNonPrintableCharacterPrinter print:textElement text) equals: 'Enter text...' ]
]

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

Expand All @@ -175,6 +160,23 @@ ToSerializerTest >> testStamps [
self assert: (element valueOfStamp: #withValue) value equals: #toto ]
]

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

| origin placeholderString |
placeholderString := 'Enter text...'.
origin := ToAlbum new
placeholderString: placeholderString;
useScrollbar: true;
yourself.
self test: origin on: [ :element |
| text |
text := (element userData at: #placeholder) children first.
self
assert: (BlTextNonPrintableCharacterPrinter print: text text)
equals: 'Enter text...'. self assert: element useScrollbar equals: true ]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem, no need equals: true. Just use assert:

]

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

Expand Down Expand Up @@ -358,6 +360,19 @@ ToSerializerTest >> testToCheckbox4 [
(element childAt: 3)) ]
]

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

| origin |
origin := ToIconicButton new
iconImage: (ToMaterialDesignIconProvider innerImageNamed:
'outlined_keyboardarrowright');
yourself.
self test: origin on: [ :element |
self assert: (element isKindOf: ToIconicButton).
self assert: element innerImage isNotNil ]
]

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

Expand Down Expand Up @@ -416,25 +431,150 @@ ToSerializerTest >> testToLabelMultiLine [
]

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

| origin |
self skip.
origin := ToElement new
addTokenNamed: #hello withValue: #goodbye;
addTokenNamed: #titi withValue: #toto;
origin := ToListElement new
useScrollbar: true;
useInfiniteLayout: true;
beVertical;
withRowNumbers;
yourself.
self test: origin on: [ :element |
self assert: element useScrollbar equals: true.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem. remove equals:true

self assert: element useInfiniteLayout equals: true.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use assert: (no need equals: true)

self assert: element isVertical equals: true.
self assert: element toConfiguration rowNumbers equals: true.].
]

{ #category : #tests }
ToSerializerTest >> testToRadioButton1 [
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is too much tests for only 2 parameters (1,2,3,4). You should keep only tests radioButton 2,3,4,5 (rename theme 1,2,3,4 of course)


| origin |
origin := ToRadioButton new
labelText: 'hello';
iconImage: (self iconNamed: #class);
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 ]
self assert: element labelText asString equals: 'hello'.
self
assert: element iconImage background image bits
equals: (self iconNamed: #class) bits ]
]

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

| origin |
origin := ToRadioButton 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 >> testToRadioButton3 [

| origin |
origin := ToRadioButton 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 >> testToRadioButton4 [

| origin |
origin := ToRadioButton new.

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

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

| origin |
origin := ToRadioButton new.

self test: origin on: [ :element | self assert: element isCheckable ]
]

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

| origin textElement |
origin := ToTextField new placeholderText: 'Enter text...'.

self test: origin on: [ :element |
textElement := (element userData at: #placeholder) children first.
self
assert:
(BlTextNonPrintableCharacterPrinter print: textElement text)
equals: 'Enter text...' ].
]

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

| origin |
origin := ToTextField new
width: 150;
wrappingMode: true;
yourself.
self test: origin on: [ :element |
element forceLayout.
self assert: element width equals: 150.
self assert: element wrappingMode equals: true ]
]

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

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

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

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

| origin |
origin := ToButton new.

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

]

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

| origin |
origin := ToToggleButton new
icon:
(ToImage new innerImage: (self iconNamed: #solidMenu));
yourself.

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