Skip to content

Commit

Permalink
Merge 1d71813
Browse files Browse the repository at this point in the history
  • Loading branch information
estebanlm committed Nov 18, 2024
2 parents 7cc74d1 + 1d71813 commit 74bad84
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 9 deletions.
164 changes: 163 additions & 1 deletion src/Spec2-Backend-Tests/SpSliderAdapterTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,168 @@ Class {

{ #category : 'accessing' }
SpSliderAdapterTest >> classToTest [
^ SpSliderPresenter
]

{ #category : 'tests' }
SpSliderAdapterTest >> testChangeInLabelUpdatesWidget [

self
assert: self adapter widgetLabel
closeTo: ''.

presenter label: 'test'.

self
assert: self adapter widgetLabel
equals: 'test'
]

{ #category : 'tests' }
SpSliderAdapterTest >> testChangeInMaxUpdatesWidget [

presenter value: 80.

"Default max is 100"
self
assert: self adapter widgetAbsoluteValue
closeTo: 0.8.
self
assert: self adapter widgetValue
equals: 80.

"Changing max updates the slider value"
presenter max: 1000.
self
assert: self adapter widgetAbsoluteValue
closeTo: 0.8.
self
assert: self adapter widgetValue
equals: 800
]

{ #category : 'tests' }
SpSliderAdapterTest >> testChangeInMinUpdatesWidget [

presenter value: 80.

"Default min is 0"
self
assert: self adapter widgetAbsoluteValue
closeTo: 0.8.
self
assert: self adapter widgetValue
equals: 80.

"Changing min updates the slider value"
presenter min: 50.
self
assert: self adapter widgetAbsoluteValue
closeTo: 0.8.
self
assert: self adapter widgetValue
equals: 90
]

{ #category : 'tests' }
SpSliderAdapterTest >> testChangeInQuantumUpdatesWidget [

presenter
min: -50;
max: 150.

"By default, quantum is 1, which means round Floats to Integer"
presenter value: 49.1.
self assert: self adapter widgetValue closeTo: 49.

presenter value: -49.1.
self assert: self adapter widgetValue closeTo: -49.

"Quantum is disabled when nil is set"
presenter quantum: nil.

presenter value: 49.1.
self assert: self adapter widgetValue closeTo: 49.1.

presenter value: -49.1.
self assert: self adapter widgetValue closeTo: -49.1.

"Set 50 as quantum"
presenter quantum: 10.

"Current value is automatically rounded acording to the new quamtum"
self assert: self adapter widgetValue equals: -50.

"It also works with new values"
presenter value: 49.
self assert: self adapter widgetValue equals: 50
]

{ #category : 'tests' }
SpSliderAdapterTest >> testChangeInValueUpdatesWidget [

presenter
min: -50;
max: 150.

presenter value: 50.
self assert: self adapter widgetValue equals: 50.

presenter value: -50.
self assert: self adapter widgetValue equals: -50
]

{ #category : 'tests' }
SpSliderAdapterTest >> testPresenterUpdatesWidget [

presenter
min: -50;
max: 150.

presenter value: 50.
self assert: self adapter widgetValue equals: 50.

presenter value: -50.
self assert: self adapter widgetValue equals: -50.

"By default, quantum is 1, which means round Floats to Integer"
presenter value: 49.1.
self assert: self adapter widgetValue closeTo: 49.

presenter value: -49.1.
self assert: self adapter widgetValue closeTo: -49.

"Quantum is disabled when nil is set"
presenter quantum: nil.

presenter value: 49.1.
self assert: self adapter widgetValue closeTo: 49.1.

presenter value: -49.1.
self assert: self adapter widgetValue closeTo: -49.1.

"Set 50 as quantum"
presenter quantum: 10.

"Current value is automatically rounded acording to the new quamtum"
self assert: self adapter widgetValue equals: -50.

"It also works with new values"
presenter value: 49.
self assert: self adapter widgetValue equals: 50
]

{ #category : 'tests' }
SpSliderAdapterTest >> testWidgetUpdatesPresenter [

presenter
min: -50;
max: 150;
quantum: 10.

"Emulate a change on the widget"
self adapter widgetValue: 54.

^ SpSliderPresenter
self assert: presenter value equals: 50.
self assert: presenter absoluteValue equals: 0.5
]
8 changes: 7 additions & 1 deletion src/Spec2-Code/SpCodePresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ SpCodePresenter >> evaluate: aString onCompileError: compileErrorBlock onError:
^ compileErrorBlock value ];
evaluate.
oldBindings size = self interactionModel bindings size
ifFalse: [ self withAdapterDo: [ :anAdapter | anAdapter refreshStyling ] ].
ifFalse: [ self refreshStyling ].
self announcer announce: (SpCodeEvaluationSucceedAnnouncement newContent: aString).
result ]
on: Error
Expand Down Expand Up @@ -595,6 +595,12 @@ SpCodePresenter >> overridingContextMenu [
self overrideContextMenu: true
]

{ #category : 'api' }
SpCodePresenter >> refreshStyling [

self withAdapterDo: [ :anAdapter | anAdapter refreshStyling ]
]

{ #category : 'initialization' }
SpCodePresenter >> registerEventsForStyling [

Expand Down
6 changes: 6 additions & 0 deletions src/Spec2-Layout/SpGridLayout.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ SpGridLayout >> add: aChild withConstraints: aBlock [
self announceChildAdded: aChild.
]

{ #category : 'accessing' }
SpGridLayout >> at: aPoint [

^ childrenByPosition at: aPoint
]

{ #category : 'api' }
SpGridLayout >> beColumnHomogeneous [

Expand Down
7 changes: 0 additions & 7 deletions src/Spec2-Tests/SpGridLayout.extension.st

This file was deleted.

0 comments on commit 74bad84

Please sign in to comment.