Skip to content

Commit

Permalink
Cleaning more and adding better tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ducasse committed Nov 21, 2023
1 parent c9874d7 commit 4ac5d9f
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 25 deletions.
5 changes: 3 additions & 2 deletions src/BaselineOfSpecCore/BaselineOfSpecCore.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ BaselineOfSpecCore >> baseline: spec [
"Core"
package: 'Spec2-Layout';
package: 'Spec2-Core' with: [ spec requires: #('Spec2-Layout') ];
package: 'Spec2-Dialogs' with: [ spec requires: #('Spec2-Core') ];
package: 'Spec2-Dialogs' with: [ spec requires: #('Spec2-Dialogs') ];
package: 'Spec2-Dialogs-Tests' with: [ spec requires: #('Spec2-Core') ];
package: 'Spec2-CommandLine' with: [ spec requires: #('Spec2-Core') ];
package: 'Spec2-Commands';
package: 'Spec2-Transmission' with: [ spec requires: #('Spec2-Core') ];
Expand All @@ -32,7 +33,7 @@ BaselineOfSpecCore >> baseline: spec [
"Tests"
package: 'Spec2-Adapters-Stub' with: [ spec requires: #('Spec2-Core') ];
package: 'Spec2-Commander2-Tests' with: [ spec requires: #('Spec2-Commander2') ];
package: 'Spec2-Tests' with: [ spec requires: #('Spec2-Core' 'Spec2-Examples') ];
package: 'Spec2-Tests' with: [ spec requires: #('Spec2-Core' 'Spec2-Examples' 'Spec2-Dialogs-Tests') ];
package: 'Spec2-Code-Tests' with: [ spec requires: #('Spec2-Tests' 'Spec2-Code') ];
package: 'Spec2-Code-Diff-Tests' with: [ spec requires: #('Spec2-Tests' 'Spec2-Code-Diff') ];
"Examples"
Expand Down
44 changes: 44 additions & 0 deletions src/Spec2-Dialogs-Tests/SpDialogTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Class {
#name : 'SpDialogTest',
#superclass : 'TestCase',
#category : 'Spec2-Dialogs-Tests',
#package : 'Spec2-Dialogs-Tests'
}

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

self shouldnt: [ SpInformUserDialog new informUser: 'hello' during: [ (Delay forMilliseconds: 100) wait] ] raise: Error
]

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

| executed |
executed := false.
SpInformUserDialog new informUser: 'hello' during: [ executed := true ].
self assert: executed.
]

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

self shouldnt: [ SpPresenter new application informUser: 'hello' during: [ (Delay forMilliseconds: 100) wait] ] raise: Error.

]

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

self shouldnt: [ SpPresenter new informUser: 'hello' during: [ (Delay forMilliseconds: 100) wait] ] raise: Error.
self shouldnt: [ SpPresenter new informUser: 'hello' during: [ (Delay forMilliseconds: 100) wait] ] raise: Error
]

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

| executed |
executed := false.
SpProgressDialog new informUser: 'hello' during: [ executed := true. ].
self assert: executed.
]
1 change: 1 addition & 0 deletions src/Spec2-Dialogs-Tests/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : 'Spec2-Dialogs-Tests' }
13 changes: 9 additions & 4 deletions src/Spec2-Dialogs/SpInformUserDialog.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,20 @@ SpInformUserDialog >> afterOpenAction [

{ #category : 'api' }
SpInformUserDialog >> informUser: aString during: aBlock [

self informUserDuring: [ :bar |
bar label: aString.
"Pay attention that the aBlock argument does not expect an argument representing the bar.
Check class side example."

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

{ #category : 'api' }
SpInformUserDialog >> informUserDuring: aBlock [

"Inform the user with a title during an execution.
Pay attention in this method the block is expecting no argument while in the subclass
it expects the progress bar.
Check examples on the class side"
openAction := aBlock.
self openModal.
parentWindow ifNotNil: [
Expand Down
22 changes: 3 additions & 19 deletions src/Spec2-Dialogs/SpProgressDialog.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -65,32 +65,16 @@ SpProgressDialog >> afterOpenAction [
] fork
]

{ #category : 'examples' }
SpProgressDialog >> exampleModal [

self new
title: 'Example Progress';
label: 'You are seeing a progress dialog!';
openModal
]

{ #category : 'api' }
SpProgressDialog >> informUser: aString during: aBlock [

"Pay attention that the aBlock argument does not expect an argument representing the bar.
Check class side example."

self informUserDuring: [ :bar |
bar label: aString.
aBlock value ]
]

{ #category : 'api' }
SpProgressDialog >> informUserDuring: aBlock [

openAction := aBlock.
self openModal.
parentWindow ifNotNil: [
parentWindow takeKeyboardFocus ]
]

{ #category : 'initialization' }
SpProgressDialog >> initialize [

Expand Down

0 comments on commit 4ac5d9f

Please sign in to comment.