Skip to content

Commit

Permalink
Merge fdeba46
Browse files Browse the repository at this point in the history
  • Loading branch information
estebanlm committed Dec 7, 2023
2 parents 0c6f175 + fdeba46 commit 2c6a345
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 28 deletions.
11 changes: 7 additions & 4 deletions src/Spec2-Backend-Tests/SpNotebookAdapterTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,16 @@ SpNotebookAdapterTest >> testSelectedPage [

{ #category : 'tests' }
SpNotebookAdapterTest >> testSelectingPageShouldAnnounceChangeEvent [
| change |

| change |
self adapter widget tabSelectorMorph selectedIndex: 1.
self adapter widget announcer when: SpNotebookPageChanged do: [ :ann | change := ann ].

self adapter widget announcer
when: SpNotebookPageChanged
do: [ :ann | change := ann ]
for: self.

self adapter widget tabSelectorMorph selectedIndex: 2.

self assert: change oldPage model title equals: 'Mock'.
self assert: change page model title equals: 'Mock2'
]
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ SpScrollableLayoutAdapterTest >> testAddWithSymbolWorks [
presenterClass := classFactory make: [ :aBuilder |
aBuilder
superclass: SpPresenter;
slotsFromString: 'textInput';
slots: #(textInput);
package: self class package name ].

presenter := presenterClass new.
Expand Down
4 changes: 2 additions & 2 deletions src/Spec2-Core/SpJob.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,11 @@ SpJob >> whenChangedDo: aBlock [
{ #category : 'events' }
SpJob >> whenEndDo: aBlock [

self announcer when: JobEnd do: aBlock
self announcer when: JobEnd do: aBlock for: aBlock receiver
]

{ #category : 'events' }
SpJob >> whenStartDo: aBlock [

self announcer when: JobStart do: aBlock
self announcer when: JobStart do: aBlock for: aBlock receiver
]
5 changes: 3 additions & 2 deletions src/Spec2-Core/SpWindowPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -698,10 +698,11 @@ SpWindowPresenter >> whenWillCloseDo: aBlock [
"Inform when window will close, allowing process before the close happen.
Note that user cannot cancel the close operation using this event.
`aBlock` receives one optional argument (an instance of the announcement `SpWindowWillClose`)."
self announcer

self announcer
when: SpWindowWillClose
do: aBlock
for: aBlock receiver
]

{ #category : 'private' }
Expand Down
30 changes: 30 additions & 0 deletions src/Spec2-Dialogs-Tests/SpDialogTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,28 @@ SpDialogTest >> testInformUserDuringExecutesItsBlock [
self assert: executed.
]

{ #category : 'tests - progress bar' }
SpDialogTest >> testInformUserDuringExecutesTheBlockOnlyOnce [

| count |
count := 0.
SpInformUserDialog new
informUser: 'I am a text' during: [ count := count + 1 ].

self assert: count equals: 1
]

{ #category : 'tests - progress bar' }
SpDialogTest >> testInformUserDuringInSpApplicationExecutesTheBlockOnlyOnce [

| count |
count := 0.
SpApplication new
informUser: 'I am a text' during: [ count := count + 1 ].

self assert: count equals: 1
]

{ #category : 'tests - informUserDuring' }
SpDialogTest >> testInformUserDuringViaApplication [

Expand All @@ -34,6 +56,14 @@ SpDialogTest >> testInformUserDuringViaPresenter [
self shouldnt: [ SpPresenter new informUser: 'hello' during: [ (Delay forMilliseconds: 100) wait] ] raise: Error
]

{ #category : 'tests - progress bar' }
SpDialogTest >> testInformUserReturnsValueOfTheBlock [

| returned |
returned := SpInformUserDialog new informUser: 'hello' during: [ 42 ].
self assert: returned equals: 42.
]

{ #category : 'tests - progress bar' }
SpDialogTest >> testProgressInformUserDuringExecutesItsBlock [

Expand Down
3 changes: 1 addition & 2 deletions src/Spec2-Dialogs/SpApplication.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ SpApplication >> informUser: aString during: aBlock [

^ self newInformUser
title: aString;
informUserDuring: aBlock;
openModal
informUserDuring: aBlock
]

{ #category : '*Spec2-Dialogs' }
Expand Down
28 changes: 14 additions & 14 deletions src/Spec2-Dialogs/SpInformUserDialog.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Class {
'title',
'label',
'progressBar',
'openAction'
'openAction',
'returnValue'
],
#category : 'Spec2-Dialogs',
#package : 'Spec2-Dialogs'
Expand Down Expand Up @@ -46,27 +47,24 @@ SpInformUserDialog class >> extent [

{ #category : 'private - actions' }
SpInformUserDialog >> afterOpenAction [

openAction ifNil: [ ^ self ].

[
[
openAction value.
self accept ]
on: Error
fork: [ :e |
self cancel.
e pass ].
] fork
[
[
returnValue := openAction value.
self accept ] on: Error fork: [ :e |
self cancel.
e pass ] ] fork
]

{ #category : 'api' }
{ #category : 'simple dialog helpers' }
SpInformUserDialog >> informUser: aString during: aBlock [
"Pay attention that the aBlock argument does not expect an argument representing the bar.
Check class side example."

title := aString.
self informUserDuring: [
^ self informUserDuring: [
aBlock value ]
]

Expand All @@ -79,7 +77,9 @@ SpInformUserDialog >> informUserDuring: aBlock [
openAction := aBlock.
self openModal.
parentWindow ifNotNil: [
parentWindow takeKeyboardFocus ]
parentWindow takeKeyboardFocus ].

^ returnValue
]

{ #category : 'initialization' }
Expand Down
4 changes: 1 addition & 3 deletions src/Spec2-Examples/SpExampleBrowser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,7 @@ SpExampleBrowser >> runSelectedExample [
| method |

method := list selectedItem entity.
method
valueWithReceiver: method methodClass instanceSide
arguments: #()
method valueWithReceiver: method methodClass instanceSide
]

{ #category : 'updating' }
Expand Down

0 comments on commit 2c6a345

Please sign in to comment.