diff --git a/src/Spec2-Backend-Tests/SpNotebookAdapterTest.class.st b/src/Spec2-Backend-Tests/SpNotebookAdapterTest.class.st index 99e34002..25c7e90b 100644 --- a/src/Spec2-Backend-Tests/SpNotebookAdapterTest.class.st +++ b/src/Spec2-Backend-Tests/SpNotebookAdapterTest.class.st @@ -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' ] diff --git a/src/Spec2-Backend-Tests/SpScrollableLayoutAdapterTest.class.st b/src/Spec2-Backend-Tests/SpScrollableLayoutAdapterTest.class.st index c0050d1e..23163e84 100644 --- a/src/Spec2-Backend-Tests/SpScrollableLayoutAdapterTest.class.st +++ b/src/Spec2-Backend-Tests/SpScrollableLayoutAdapterTest.class.st @@ -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. diff --git a/src/Spec2-Core/SpJob.class.st b/src/Spec2-Core/SpJob.class.st index bad6dd43..60d61fb3 100644 --- a/src/Spec2-Core/SpJob.class.st +++ b/src/Spec2-Core/SpJob.class.st @@ -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 ] diff --git a/src/Spec2-Core/SpWindowPresenter.class.st b/src/Spec2-Core/SpWindowPresenter.class.st index e797c4b9..c3baa3fa 100644 --- a/src/Spec2-Core/SpWindowPresenter.class.st +++ b/src/Spec2-Core/SpWindowPresenter.class.st @@ -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' } diff --git a/src/Spec2-Dialogs-Tests/SpDialogTest.class.st b/src/Spec2-Dialogs-Tests/SpDialogTest.class.st index 46c9d955..81c7ba77 100644 --- a/src/Spec2-Dialogs-Tests/SpDialogTest.class.st +++ b/src/Spec2-Dialogs-Tests/SpDialogTest.class.st @@ -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 [ @@ -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 [ diff --git a/src/Spec2-Dialogs/SpApplication.extension.st b/src/Spec2-Dialogs/SpApplication.extension.st index a5791566..d9e0f092 100644 --- a/src/Spec2-Dialogs/SpApplication.extension.st +++ b/src/Spec2-Dialogs/SpApplication.extension.st @@ -33,8 +33,7 @@ SpApplication >> informUser: aString during: aBlock [ ^ self newInformUser title: aString; - informUserDuring: aBlock; - openModal + informUserDuring: aBlock ] { #category : '*Spec2-Dialogs' } diff --git a/src/Spec2-Dialogs/SpInformUserDialog.class.st b/src/Spec2-Dialogs/SpInformUserDialog.class.st index bd5d5b27..a57cce3f 100644 --- a/src/Spec2-Dialogs/SpInformUserDialog.class.st +++ b/src/Spec2-Dialogs/SpInformUserDialog.class.st @@ -8,7 +8,8 @@ Class { 'title', 'label', 'progressBar', - 'openAction' + 'openAction', + 'returnValue' ], #category : 'Spec2-Dialogs', #package : 'Spec2-Dialogs' @@ -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 ] ] @@ -79,7 +77,9 @@ SpInformUserDialog >> informUserDuring: aBlock [ openAction := aBlock. self openModal. parentWindow ifNotNil: [ - parentWindow takeKeyboardFocus ] + parentWindow takeKeyboardFocus ]. + + ^ returnValue ] { #category : 'initialization' } diff --git a/src/Spec2-Examples/SpExampleBrowser.class.st b/src/Spec2-Examples/SpExampleBrowser.class.st index 5513c110..8cb03701 100644 --- a/src/Spec2-Examples/SpExampleBrowser.class.st +++ b/src/Spec2-Examples/SpExampleBrowser.class.st @@ -137,9 +137,7 @@ SpExampleBrowser >> runSelectedExample [ | method | method := list selectedItem entity. - method - valueWithReceiver: method methodClass instanceSide - arguments: #() + method valueWithReceiver: method methodClass instanceSide ] { #category : 'updating' }