-
Notifications
You must be signed in to change notification settings - Fork 0
Add serialization and tests #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: devStage
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 } | ||
| ] |
| 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 } | ||
| ] |
| 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 } | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 [ | ||
|
|
||
|
|
@@ -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 ] | ||
| ] | ||
|
|
||
| { #category : #tests } | ||
| ToSerializerTest >> testToButton1 [ | ||
|
|
||
|
|
@@ -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 [ | ||
|
|
||
|
|
@@ -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. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Idem. remove equals:true |
||
| self assert: element useInfiniteLayout equals: true. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 [ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ]. | ||
| ] | ||
There was a problem hiding this comment.
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: