Skip to content

Commit

Permalink
Merge pull request #666 from pharo-graphics/638-Error-throwed-when-st…
Browse files Browse the repository at this point in the history
…oppping-animation

Animations: tolerate redundant #start and #stop
  • Loading branch information
tinchodias authored Dec 5, 2024
2 parents 6cd631b + 1af011a commit 7d9b535
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Bloc-Animation/BlBaseAnimation.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ BlBaseAnimation >> shouldStop [
{ #category : #'api - running' }
BlBaseAnimation >> start [

isRunning ifTrue: [
self error: 'Animation can not be start multiple times without stop' ].
"Ignore if it's already started"
isRunning ifTrue: [ ^ self ].

self initStart
]
Expand Down Expand Up @@ -410,8 +410,8 @@ BlBaseAnimation >> step [
{ #category : #'api - running' }
BlBaseAnimation >> stop [

isRunning ifFalse: [
self error: 'Animation is not running' ].
"Ignore if it's already stopped"
isRunning ifFalse: [ ^ self ].

isRunning := false.

Expand Down
25 changes: 25 additions & 0 deletions src/Bloc-Examples/BlAnimationExamplesTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,31 @@ BlAnimationExamplesTest >> testBaseAnimation [
^ aBaseAnimation
]

{ #category : #'examples - base animation' }
BlAnimationExamplesTest >> testBaseAnimationTolaratesRedundantStartAndStop [

| anAnimation |
anAnimation := BlAnimation new.
self deny: anAnimation isRunning.
anAnimation stop.
self deny: anAnimation isRunning.
anAnimation stop; stop; stop.
self deny: anAnimation isRunning.

anAnimation start.
self assert: anAnimation isRunning.
anAnimation run.
anAnimation start; start; start.
self assert: anAnimation isRunning.
anAnimation run.
self assert: anAnimation isRunning.

anAnimation stop.
self deny: anAnimation isRunning.
anAnimation stop.
self deny: anAnimation isRunning
]

{ #category : #'examples - base animation' }
BlAnimationExamplesTest >> testBaseAnimationWithDelay [

Expand Down

0 comments on commit 7d9b535

Please sign in to comment.