Skip to content

Commit

Permalink
Merge 207d0ba
Browse files Browse the repository at this point in the history
  • Loading branch information
estebanlm committed Nov 27, 2024
2 parents bb4d379 + 207d0ba commit 61a4886
Show file tree
Hide file tree
Showing 11 changed files with 208 additions and 158 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ SpMorphicTextInputFieldAdapter >> getPlaceholderText [
aString localizedForPresenter: self presenter ]
]

{ #category : 'testing' }
SpMorphicTextInputFieldAdapter >> hasKeyboardFocus [

^ widget hasKeyboardFocus
]

{ #category : 'testing' }
SpMorphicTextInputFieldAdapter >> isPassword [

Expand Down
195 changes: 101 additions & 94 deletions src/Spec2-Backend-Tests/SpGridLayoutAdapterTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,147 +16,150 @@ SpGridLayoutAdapterTest >> newLayout [
SpGridLayoutAdapterTest >> testAddAtSamePositionTwiceReplacesChild [

| first second |
layout add: (first := SpButtonPresenter new) at: 1@1.
layout add: (second := SpButtonPresenter new) at: 1@1.
self assert: self adapter children first equals: second adapter widget
layout add: (first := SpButtonPresenter new) atPoint: 1 @ 1.
layout add: (second := SpButtonPresenter new) atPoint: 1 @ 1.
self
assert: self adapter children first
equals: second adapter widget
]

{ #category : 'tests' }
SpGridLayoutAdapterTest >> testAddAtSamePositionTwiceSetsChildrenSingleTime [

layout add: (SpButtonPresenter new) at: 1@1.
layout add: (SpButtonPresenter new) at: 1@1.
layout add: SpButtonPresenter new atPoint: 1 @ 1.
layout add: SpButtonPresenter new atPoint: 1 @ 1.
self assert: self adapter children size equals: 1
]

{ #category : 'tests' }
SpGridLayoutAdapterTest >> testAddElementAddsToAdapter [

layout add: SpButtonPresenter new at: 1@1.
layout add: SpButtonPresenter new atPoint: 1 @ 1.
self deny: self adapter isEmpty
]

{ #category : 'tests' }
SpGridLayoutAdapterTest >> testAddElementAfterOpenAddsToAdapter [

layout add: SpButtonPresenter new at: 1@1.
layout add: SpButtonPresenter new atPoint: 1 @ 1.
self openInstance.
layout add: SpButtonPresenter new at: 1@2.

layout add: SpButtonPresenter new atPoint: 1 @ 2.
self assert: self adapter children size equals: 2
]

{ #category : 'tests' }
SpGridLayoutAdapterTest >> testBeColumnHomogeneous [

layout
layout
beColumnHomogeneous;
add: 'Test' at: 1@1;
add: 'Other label test' at: 2@1.
add: 'Test' atPoint: 1 @ 1;
add: 'Other label test' atPoint: 2 @ 1.

self openInstance.
self
assert: presenter adapter widget submorphs first width

self
assert: presenter adapter widget submorphs first width
equals: presenter adapter widget submorphs second width
]

{ #category : 'tests' }
SpGridLayoutAdapterTest >> testBeColumnNotHomogeneous [

layout
layout
beColumnNotHomogeneous;
add: 'Test' at: 1@1;
add: 'Other label test' at: 2@1.
add: 'Test' atPoint: 1 @ 1;
add: 'Other label test' atPoint: 2 @ 1.

self openInstance.
self
deny: presenter adapter widget submorphs first width

self
deny: presenter adapter widget submorphs first width
equals: presenter adapter widget submorphs second width
]

{ #category : 'tests' }
SpGridLayoutAdapterTest >> testBeRowHomogeneous [

layout
layout
beRowHomogeneous;
add: 'Test' at: 1@1;
add: (presenter newMorph morph: (Morph new extent: 40@40)) at: 1@2.

add: 'Test' atPoint: 1 @ 1;
add: (presenter newMorph morph: (Morph new extent: 40 @ 40))
atPoint: 1 @ 2.

self openInstance.
self
assert: presenter adapter widget submorphs first height

self
assert: presenter adapter widget submorphs first height
equals: presenter adapter widget submorphs second height
]

{ #category : 'tests' }
SpGridLayoutAdapterTest >> testBeRowNotHomogeneous [

| testMorph |

testMorph := Morph new
vResizing: #rigid;
extent: 40@40;
yourself.
layout
vResizing: #rigid;
extent: 40 @ 40;
yourself.

layout
beRowNotHomogeneous;
add: 'Test' at: 1@1;
add: (presenter newMorph morph: testMorph) at: 1@2.
add: 'Test' atPoint: 1 @ 1;
add: (presenter newMorph morph: testMorph) atPoint: 1 @ 2.

self openInstance.
self
deny: presenter adapter widget submorphs first height

self
deny: presenter adapter widget submorphs first height
equals: presenter adapter widget submorphs second height
]

{ #category : 'tests' }
SpGridLayoutAdapterTest >> testColumnSpanColumnHomogeneous [

layout
layout
beColumnHomogeneous;
add: 'Test' at: 1@1 span: 2@1;
add: 'Other label test' at: 1@2; add: 'span column'at: 2@2.

add: 'Test' atPoint: 1 @ 1 span: 2 @ 1;
add: 'Other label test' atPoint: 1 @ 2;
add: 'span column' at: 2 @ 2.

self openInstance.

self
assert: presenter adapter widget submorphs first width
equals: (
(presenter adapter widget submorphs second width)
+ (presenter adapter widget submorphs third width))

self
assert: presenter adapter widget submorphs first width
equals: presenter adapter widget submorphs second width
+ presenter adapter widget submorphs third width
]

{ #category : 'tests' }
SpGridLayoutAdapterTest >> testColumnSpanColumnNotHomogeneous [

layout
layout
beColumnNotHomogeneous;
add: 'Test' at: 1@1 span: 2@1;
add: 'Other' at: 1@2; add: 'span column, larger'at: 2@2.

add: 'Test' atPoint: 1 @ 1 span: 2 @ 1;
add: 'Other' atPoint: 1 @ 2;
add: 'span column, larger' at: 2 @ 2.

self openInstance.

"the first column width is equal to the sum of two columns"
self
assert: presenter adapter widget submorphs first width
equals: (
(presenter adapter widget submorphs second width)
+ (presenter adapter widget submorphs third width)).
self
assert: presenter adapter widget submorphs first width
equals: presenter adapter widget submorphs second width
+ presenter adapter widget submorphs third width.
"the first column still needs to be smaller than the first"
self
assert: presenter adapter widget submorphs second width < (presenter adapter widget submorphs third width)
self assert: presenter adapter widget submorphs second width
< presenter adapter widget submorphs third width
]

{ #category : 'tests' }
SpGridLayoutAdapterTest >> testRemoveElementAddedAfterOpenRemovesFromAdapter [

| element |
layout add: (element := SpButtonPresenter new) at: 1@1.
layout add: (element := SpButtonPresenter new) atPoint: 1 @ 1.
self openInstance.

layout remove: element.
self assert: self adapter isEmpty
]
Expand All @@ -165,52 +168,56 @@ SpGridLayoutAdapterTest >> testRemoveElementAddedAfterOpenRemovesFromAdapter [
SpGridLayoutAdapterTest >> testRemoveElementRemovesFromAdapter [

| element |
layout add: (element := SpButtonPresenter new) at: 1@1.
layout add: (element := SpButtonPresenter new) atPoint: 1 @ 1.
layout remove: element.
self assert: self adapter isEmpty
]

{ #category : 'tests' }
SpGridLayoutAdapterTest >> testRowSpanRowHomogeneous [

| testMorph |

testMorph := Morph new
vResizing: #rigid;
extent: 40@40;
yourself.
layout
vResizing: #rigid;
extent: 40 @ 40;
yourself.

layout
beRowHomogeneous;
add: 'Test 1' at: 1@1; add: (presenter newMorph morph: testMorph) at: 2@1 span: 1@2;
add: 'Test 2' at: 1@2.

add: 'Test 1' atPoint: 1 @ 1;
add: (presenter newMorph morph: testMorph)
atPoint: 2 @ 1
span: 1 @ 2;
add: 'Test 2' at: 1 @ 2.

self openInstance.
self
assert: presenter adapter widget submorphs second height
equals:
presenter adapter widget submorphs first height
self
assert: presenter adapter widget submorphs second height
equals: presenter adapter widget submorphs first height
+ presenter adapter widget submorphs third height
]

{ #category : 'tests' }
SpGridLayoutAdapterTest >> testRowSpanRowNotHomogeneous [

| testMorph |

testMorph := Morph new
vResizing: #rigid;
extent: 40@40;
yourself.
layout
vResizing: #rigid;
extent: 40 @ 40;
yourself.

layout
beRowNotHomogeneous;
add: 'Test 1' at: 1@1; add: (presenter newMorph morph: testMorph) at: 2@1 span: 1@2;
add: 'Test 2' at: 1@2.

add: 'Test 1' atPoint: 1 @ 1;
add: (presenter newMorph morph: testMorph)
atPoint: 2 @ 1
span: 1 @ 2;
add: 'Test 2' at: 1 @ 2.

self openInstance.

self
assert: presenter adapter widget submorphs second height
equals:
presenter adapter widget submorphs first height

self
assert: presenter adapter widget submorphs second height
equals: presenter adapter widget submorphs first height
+ presenter adapter widget submorphs third height
]
2 changes: 1 addition & 1 deletion src/Spec2-Code-Commands/SystemNavigation.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ SystemNavigation >> browse: anObject [
{ #category : '*Spec2-Code-Commands' }
SystemNavigation >> inspect: anObject [

Smalltalk tools inspector inspect: anObject
self tools inspector inspect: anObject
]
10 changes: 3 additions & 7 deletions src/Spec2-Core/SpDropListPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,11 @@ SpDropListPresenter >> whenSelectedItemChangedDo: aBlock [
{ #category : 'api - events' }
SpDropListPresenter >> whenSelectionChangedDo: aBlock [
"Inform when the selection is changed.
The method should be used only if you are interested in the fact that there was
a change, without caring about what has changed.
The method should be used only if you are interested in the fact that
there was a change, without caring about what has changed.
If you are interested in the items, use `SpDropListPresenter>>#whenSelectedItemChanged:`
`aBlock` receive 3 optional arguments:
- new value
- old value
- announcement triggered"
`aBlock` receives an optional argument with the selection object."

selection whenChangedDo: aBlock
]
Expand Down
2 changes: 1 addition & 1 deletion src/Spec2-Core/SpNumberInputFieldPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ SpNumberInputFieldPresenter >> whenNumberChangedDo: aBlock [
- old value
- the announcement triggering this action"

self whenTextChangedDo: [ :txt | aBlock value: self number ]
self whenTextChangedDo: [ :newValue :oldValue | aBlock cull: self number cull: newValue ]
]

{ #category : 'api - events' }
Expand Down
2 changes: 1 addition & 1 deletion src/Spec2-Dialogs/SpRequestDialog.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ SpRequestDialog >> initializePresenters [
SpRequestDialog >> initializeWindow: aWindowPresenter [

super initializeWindow: aWindowPresenter.
aWindowPresenter whenOpenedDo: [ textInput takeKeyboardFocus ]
aWindowPresenter whenOpenedDo: [ textInput takeKeyboardFocus; selectAll ]
]

{ #category : 'api - showing' }
Expand Down
4 changes: 2 additions & 2 deletions src/Spec2-Examples/SpDemoTextInputPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ SpDemoTextInputPresenter class >> example [
SpDemoTextInputPresenter >> defaultLayout [

^ SpGridLayout new
add: 'Normal:' at: 1 @ 1;
add: fieldNormal at: 2 @ 1 span: 2 @ 1;
add: 'Normal:' atPoint: 1 @ 1;
add: fieldNormal atPoint: 2 @ 1 span: 2 @ 1;
add: 'Disabled:' at: 1 @ 2;
add: fieldDisabled at: 2 @ 2 span: 2 @ 1;
add: 'Placeholder:' at: 1 @ 3;
Expand Down
Loading

0 comments on commit 61a4886

Please sign in to comment.