From 27d8e3af11d810a1f87c0286d7f57abff0f72f3d Mon Sep 17 00:00:00 2001 From: Simon Immelmann Date: Fri, 12 Jul 2024 11:53:35 +0200 Subject: [PATCH] test refactoring + transparent global color --- src/SqueakWhiteboard-Core/WBElement.class.st | 10 +- src/SqueakWhiteboard-Core/WBToolbar.class.st | 42 ++++- .../WBButtonTests.class.st | 60 ++++--- .../WBDeletePopUpTests.class.st | 100 +++++++----- .../WBGlobalColorPopUpTests.class.st | 151 +++++++++--------- .../WBLineChoosingPopUpTests.class.st | 92 +++++++---- .../WBShapeChoosingPopUpTests.class.st | 88 ++++++---- .../WBToolbarButtonTests.class.st | 20 +-- 8 files changed, 337 insertions(+), 226 deletions(-) diff --git a/src/SqueakWhiteboard-Core/WBElement.class.st b/src/SqueakWhiteboard-Core/WBElement.class.st index 9f645df..d25f873 100644 --- a/src/SqueakWhiteboard-Core/WBElement.class.st +++ b/src/SqueakWhiteboard-Core/WBElement.class.st @@ -897,15 +897,19 @@ WBElement >> right [ { #category : #layout, - #'squeak_changestamp' : 'si 7/11/2024 14:48' + #'squeak_changestamp' : 'si 7/12/2024 11:38' } WBElement >> setLayout [ self extent: self class defaultSize; borderWidth: 3; - color: self canvas globalColor; - borderColor: self canvas globalColor + borderColor: self canvas globalColor. + self canvas globalColor = Color transparent + ifTrue: + [self color: self canvas globalColor. + self borderColor: Color black] + ifFalse: [self color: self canvas globalColor] ] { diff --git a/src/SqueakWhiteboard-Core/WBToolbar.class.st b/src/SqueakWhiteboard-Core/WBToolbar.class.st index 7175c51..2a24661 100644 --- a/src/SqueakWhiteboard-Core/WBToolbar.class.st +++ b/src/SqueakWhiteboard-Core/WBToolbar.class.st @@ -164,6 +164,15 @@ WBToolbar >> buttonFunctionalityForTextbox [ ^ [:aButton | self canvas spawnAnElement: (WBTextbox newWithCanvas: self canvas) At: aButton currentMouseEvent] ] +{ + #category : #'button functionalities', + #'squeak_changestamp' : 'si 7/12/2024 11:35' +} +WBToolbar >> buttonFunctionalityForTransparentColor [ + + ^ [:aButton | self canvas globalColor: Color transparent] +] + { #category : #appearance, #'squeak_changestamp' : 'si 7/11/2024 15:38' @@ -212,20 +221,23 @@ WBToolbar >> canvas: aCanvas [ { #category : #'button creation', - #'squeak_changestamp' : 'si 7/11/2024 15:32' + #'squeak_changestamp' : 'si 7/12/2024 11:34' } WBToolbar >> createColorButtons [ ^ OrderedCollection new - add: (self getColorButtonWithColor: Color yellow); - add: (self getColorButtonWithColor: Color orange); + add: (self getColorButtonWithColor: Color black); + add: (self getColorButtonWithColor: Color gray); + add: (self getTransparentColorButton); add: (self getColorButtonWithColor: Color red); - add: (self getColorButtonWithColor: Color magenta); - add: (self getColorButtonWithColor: Color blue); - add: (self getColorButtonWithColor: Color cyan); + add: (self getColorButtonWithColor: Color orange); + add: (self getColorButtonWithColor: Color yellow); add: (self getColorButtonWithColor: Color green); - add: (self getColorButtonWithColor: Color gray); - add: (self getColorButtonWithColor: Color black); + add: (self getColorButtonWithColor: Color cyan); + add: (self getColorButtonWithColor: Color blue); + add: (self getColorButtonWithColor: Color ocean); + add: (self getColorButtonWithColor: Color magenta); + add: (self getColorButtonWithColor: Color magenta muchDarker); yourself ] @@ -469,6 +481,20 @@ WBToolbar >> getTextboxButton [ ] +{ + #category : #'get buttons', + #'squeak_changestamp' : 'si 7/12/2024 11:34' +} +WBToolbar >> getTransparentColorButton [ + + ^ WBButton new + color: Color white; + backgroundColor: Color white; + clickedColor: Color white muchDarker; + block: self buttonFunctionalityForTransparentColor; + yourself +] + { #category : #appearance, #'squeak_changestamp' : 'is 6/23/2024 02:09' diff --git a/src/SqueakWhiteboard-Tests/WBButtonTests.class.st b/src/SqueakWhiteboard-Tests/WBButtonTests.class.st index 7039bc6..90008e0 100644 --- a/src/SqueakWhiteboard-Tests/WBButtonTests.class.st +++ b/src/SqueakWhiteboard-Tests/WBButtonTests.class.st @@ -7,6 +7,18 @@ Class { #category : #'SqueakWhiteboard-Tests' } +{ + #category : #'mouse click', + #'squeak_changestamp' : 'si 7/12/2024 10:57' +} +WBButtonTests >> artificialMouseClick [ + | mouseEvent | + + mouseEvent := MouseButtonEvent new. + mouseEvent setType: #mouseDown position: self canvas position + (100 @ 100) which: 4 buttons: mouseEvent class redButton hand: HandMorph new stamp: 0. + ^ mouseEvent +] + { #category : #accessing, #'squeak_changestamp' : 'is 6/15/2024 13:00' @@ -25,6 +37,15 @@ WBButtonTests >> canvas: aCanvas [ canvas := aCanvas ] +{ + #category : #'getting button', + #'squeak_changestamp' : 'si 7/12/2024 10:56' +} +WBButtonTests >> getButtonWithFunctionality: aBlock from: aCollection [ + + aCollection do: [:b | b block asString = aBlock asString ifTrue: [^ b]] +] + { #category : #setUp, #'squeak_changestamp' : 'is 6/15/2024 13:02' @@ -48,20 +69,18 @@ WBButtonTests >> tearDown [ { #category : #testing, - #'squeak_changestamp' : 'is 6/21/2024 18:52' + #'squeak_changestamp' : 'si 7/12/2024 10:58' } WBButtonTests >> testButtonClickColor [ - | aButton aMouseEvent | + | aButton | aButton := WBButton new block: [:b | nil]. self assert: aButton color = aButton backgroundColor. - aMouseEvent := MouseButtonEvent new. - aMouseEvent setType: #mouseDown position: aButton position which: 4 buttons: aMouseEvent class redButton hand: HandMorph new stamp: 1. - aButton mouseDown: aMouseEvent. + aButton mouseDown: self artificialMouseClick. self assert: aButton color = aButton clickedColor. - aButton mouseUp: aMouseEvent. + aButton mouseUp: self artificialMouseClick. self assert: aButton color = aButton backgroundColor @@ -73,20 +92,18 @@ WBButtonTests >> testButtonClickColor [ { #category : #testing, - #'squeak_changestamp' : 'is 6/21/2024 18:52' + #'squeak_changestamp' : 'si 7/12/2024 10:59' } WBButtonTests >> testButtonHoverColor [ - | aButton aMouseEvent | + | aButton | aButton := WBButton new. self assert: aButton color = aButton backgroundColor. - aMouseEvent := MouseEvent new position: aButton position. - aButton mouseEnter: aMouseEvent. + aButton mouseEnter: self artificialMouseClick. self assert: aButton color = aButton hoverColor. - aMouseEvent position: aMouseEvent position + aButton extent + 1000. - aButton mouseLeave: aMouseEvent. + aButton mouseLeave: self artificialMouseClick. self assert: aButton color = aButton backgroundColor @@ -98,28 +115,25 @@ WBButtonTests >> testButtonHoverColor [ { #category : #testing, - #'squeak_changestamp' : 'si 7/10/2024 13:24' + #'squeak_changestamp' : 'si 7/12/2024 11:01' } WBButtonTests >> testMouseDown [ - | aButton aMouseEvent | + | aButton | aButton := self canvas toolbar buttons at: 1. - aMouseEvent := MouseButtonEvent new. - aMouseEvent setType: #mouseDown position: (aButton position + aButton extent + (1 @ 1)) which: 4 buttons: aMouseEvent class redButton hand: HandMorph new stamp: 0. - self assert: (aButton handlesMouseOver: aMouseEvent) = true. - self assert: (aButton handlesMouseDown: aMouseEvent) = true. + self assert: (aButton handlesMouseOver: self artificialMouseClick) = true. + self assert: (aButton handlesMouseDown: self artificialMouseClick) = true. "Test whether button actives on mouseUp" - aButton mouseDown: aMouseEvent. + aButton mouseDown: self artificialMouseClick. self assert: aButton currentMouseEvent = nil. "Test whether button activates only if position of mouse is still above button. Currently the mouse isn't" - aButton mouseUp: aMouseEvent. + aButton mouseUp: self artificialMouseClick. self assert: aButton currentMouseEvent = nil. - aMouseEvent position: aButton position. - aButton mouseUp: aMouseEvent. - self assert: aButton currentMouseEvent = aMouseEvent + aButton mouseUp: (self artificialMouseClick position: aButton center). + self assert: aButton currentMouseEvent = (self artificialMouseClick position: aButton center) diff --git a/src/SqueakWhiteboard-Tests/WBDeletePopUpTests.class.st b/src/SqueakWhiteboard-Tests/WBDeletePopUpTests.class.st index 30e982b..f1828e1 100644 --- a/src/SqueakWhiteboard-Tests/WBDeletePopUpTests.class.st +++ b/src/SqueakWhiteboard-Tests/WBDeletePopUpTests.class.st @@ -1,28 +1,58 @@ Class { #name : #WBDeletePopUpTests, #superclass : #WBToolbarButtonTests, + #instVars : [ + 'buttonForDelete' + ], #category : #'SqueakWhiteboard-Tests' } +{ + #category : #asserting, + #'squeak_changestamp' : 'si 7/12/2024 11:12' +} +WBDeletePopUpTests >> buttonForDelete [ + + ^ buttonForDelete +] + +{ + #category : #asserting, + #'squeak_changestamp' : 'si 7/12/2024 11:12' +} +WBDeletePopUpTests >> buttonForDelete: aButton [ + + buttonForDelete := aButton +] + +{ + #category : #setUp, + #'squeak_changestamp' : 'si 7/12/2024 11:13' +} +WBDeletePopUpTests >> setUp [ + + super setUp. + self buttonForDelete: (self getButtonWithFunctionality: self canvas toolbar buttonFunctionalityForDeleteAll from: self canvas toolbar submorphs) +] + { #category : #tests, - #'squeak_changestamp' : 'si 7/11/2024 14:13' + #'squeak_changestamp' : 'si 7/12/2024 11:18' } WBDeletePopUpTests >> testButtonFunctionalityForCancel [ - | button buttonForCancel mouseEvent | + | buttonForConfirm | + + self buttonForDelete clickFunctionality: self artificialMouseClick. - mouseEvent := MouseButtonEvent new. - mouseEvent setType: #mouseDown position: self canvas position + (100 @ 100) which: 4 buttons: mouseEvent class redButton hand: HandMorph new stamp: 0. - button := self canvas toolbar buttons at: 6. - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). + self canvas spawnAnElement: (WBRectangularElement newWithCanvas: self canvas) At: self artificialMouseClick. + self canvas dropElement: self artificialMouseClick. + self canvas spawnAnElement: (WBRectangularElement newWithCanvas: self canvas) At: self artificialMouseClick. + self canvas dropElement: self artificialMouseClick. - self canvas spawnAnElement: (WBRectangularElement newWithCanvas: self canvas) At: (MouseButtonEvent new position: self canvas position + (100 @ 100)). - self canvas dropElement: mouseEvent. - self canvas spawnAnElement: (WBRectangularElement newWithCanvas: self canvas) At: (MouseButtonEvent new position: self canvas position + (200 @ 200)). - self canvas dropElement: mouseEvent. + self assert: self canvas elements size = 2. - buttonForCancel := self canvas toolbar popUp submorphs at: 1. - buttonForCancel clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). + buttonForConfirm := self getButtonWithFunctionality: self canvas toolbar buttonFunctionalityForDeleteCancel from: canvas toolbar popUp submorphs. + buttonForConfirm clickFunctionality: self artificialMouseClick. self assert: self canvas elements size = 2. self assert: self canvas toolbar popUp = nil. @@ -31,24 +61,22 @@ WBDeletePopUpTests >> testButtonFunctionalityForCancel [ { #category : #tests, - #'squeak_changestamp' : 'si 7/11/2024 14:13' + #'squeak_changestamp' : 'si 7/12/2024 11:18' } WBDeletePopUpTests >> testButtonFunctionalityForConfirm [ - | button buttonForConfirm mouseEvent | + | buttonForConfirm | - mouseEvent := MouseButtonEvent new. - mouseEvent setType: #mouseDown position: self canvas position + (100 @ 100) which: 4 buttons: mouseEvent class redButton hand: HandMorph new stamp: 0. + self buttonForDelete clickFunctionality: self artificialMouseClick. - button := self canvas toolbar buttons at: 6. - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). + self canvas spawnAnElement: (WBRectangularElement newWithCanvas: self canvas) At: self artificialMouseClick. + self canvas dropElement: self artificialMouseClick. + self canvas spawnAnElement: (WBRectangularElement newWithCanvas: self canvas) At: self artificialMouseClick. + self canvas dropElement: self artificialMouseClick. - self canvas spawnAnElement: (WBRectangularElement newWithCanvas: self canvas) At: (MouseButtonEvent new position: self canvas position + (100 @ 100)). - self canvas dropElement: mouseEvent. - self canvas spawnAnElement: (WBRectangularElement newWithCanvas: self canvas) At: (MouseButtonEvent new position: self canvas position + (200 @ 200)). - self canvas dropElement: mouseEvent. + self assert: self canvas elements size = 2. - buttonForConfirm := self canvas toolbar popUp submorphs at: 2. - buttonForConfirm clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). + buttonForConfirm := self getButtonWithFunctionality: self canvas toolbar buttonFunctionalityForDeleteConfirm from: canvas toolbar popUp submorphs. + buttonForConfirm clickFunctionality: self artificialMouseClick. self assert: self canvas elements size = 0. self assert: self canvas toolbar popUp = nil. @@ -57,26 +85,22 @@ WBDeletePopUpTests >> testButtonFunctionalityForConfirm [ { #category : #tests, - #'squeak_changestamp' : 'ACL 7/7/2024 18:21' + #'squeak_changestamp' : 'si 7/12/2024 11:15' } WBDeletePopUpTests >> testButtonsOfPopUp [ - | button | - button := self canvas toolbar buttons at: 6. - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). + self buttonForDelete clickFunctionality: self artificialMouseClick. self assert: self canvas toolbar popUp submorphs size = 2 ] { #category : #tests, - #'squeak_changestamp' : 'ACL 7/7/2024 18:21' + #'squeak_changestamp' : 'si 7/12/2024 11:14' } WBDeletePopUpTests >> testExistenceOfPopUp [ - | button| - button := self canvas toolbar buttons at: 6. - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). + self buttonForDelete clickFunctionality: self artificialMouseClick. self assert: self canvas toolbar popUp notNil. self assert: self canvas text contents = WBToolbar textForDeleteAll @@ -84,13 +108,11 @@ WBDeletePopUpTests >> testExistenceOfPopUp [ { #category : #tests, - #'squeak_changestamp' : 'ACL 7/7/2024 18:21' + #'squeak_changestamp' : 'si 7/12/2024 11:15' } WBDeletePopUpTests >> testPopUpPlacementInX [ - | button | - button := self canvas toolbar buttons at: 6. - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). + self buttonForDelete clickFunctionality: self artificialMouseClick. self assert: (self canvas center x - 100) <= self canvas toolbar popUp left. self assert: self canvas toolbar popUp right <= (self canvas center x + 100) @@ -98,13 +120,11 @@ WBDeletePopUpTests >> testPopUpPlacementInX [ { #category : #tests, - #'squeak_changestamp' : 'ACL 7/7/2024 18:21' + #'squeak_changestamp' : 'si 7/12/2024 11:15' } WBDeletePopUpTests >> testPopUpPlacementInY [ - | button | - button := self canvas toolbar buttons at: 6. - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). + self buttonForDelete clickFunctionality: self artificialMouseClick. self assert: self canvas center y <= self canvas toolbar popUp top. self assert: self canvas toolbar popUp bottom <= (self canvas bottom) diff --git a/src/SqueakWhiteboard-Tests/WBGlobalColorPopUpTests.class.st b/src/SqueakWhiteboard-Tests/WBGlobalColorPopUpTests.class.st index f2ffd23..23aa2b0 100644 --- a/src/SqueakWhiteboard-Tests/WBGlobalColorPopUpTests.class.st +++ b/src/SqueakWhiteboard-Tests/WBGlobalColorPopUpTests.class.st @@ -1,123 +1,124 @@ Class { #name : #WBGlobalColorPopUpTests, #superclass : #WBToolbarButtonTests, + #instVars : [ + 'buttonForGlobalColor' + ], #category : #'SqueakWhiteboard-Tests' } +{ + #category : #accessing, + #'squeak_changestamp' : 'si 7/12/2024 11:19' +} +WBGlobalColorPopUpTests >> buttonForGlobalColor [ + + ^ buttonForGlobalColor +] + +{ + #category : #accessing, + #'squeak_changestamp' : 'si 7/12/2024 11:19' +} +WBGlobalColorPopUpTests >> buttonForGlobalColor: aButton [ + + buttonForGlobalColor := aButton +] + +{ + #category : #setUp, + #'squeak_changestamp' : 'si 7/12/2024 11:21' +} +WBGlobalColorPopUpTests >> setUp [ + + super setUp. + self buttonForGlobalColor: (self getButtonWithFunctionality: self canvas toolbar buttonFunctionalityForColorPalette from: self canvas toolbar submorphs) +] + { #category : #tests, - #'squeak_changestamp' : 'ACL 7/7/2024 18:22' + #'squeak_changestamp' : 'si 7/12/2024 11:40' } WBGlobalColorPopUpTests >> testButtonFunctionality [ - | button buttonForColor | + | buttonForColor | - button := self canvas toolbar buttons at: 5. - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). - - buttonForColor := self canvas toolbar popUp submorphs at: 1. - buttonForColor clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). - self assert: self canvas globalColor = Color black. - - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). - - buttonForColor := self canvas toolbar popUp submorphs at: 2. - buttonForColor clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). - self assert: self canvas globalColor = Color gray. - - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). - - buttonForColor := self canvas toolbar popUp submorphs at: 3. - buttonForColor clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). - self assert: self canvas globalColor = Color green. - - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). - - buttonForColor := self canvas toolbar popUp submorphs at: 4. - buttonForColor clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). - self assert: self canvas globalColor = Color cyan. + self buttonForGlobalColor clickFunctionality: self artificialMouseClick. - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). - - buttonForColor := self canvas toolbar popUp submorphs at: 5. - buttonForColor clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). - self assert: self canvas globalColor = Color blue. - - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). - - buttonForColor := self canvas toolbar popUp submorphs at: 6. - buttonForColor clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). - self assert: self canvas globalColor = Color magenta. - - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). - - buttonForColor := self canvas toolbar popUp submorphs at: 7. - buttonForColor clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). - self assert: self canvas globalColor = Color red. - - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). - - buttonForColor := self canvas toolbar popUp submorphs at: 8. - buttonForColor clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). - self assert: self canvas globalColor = Color orange. + self canvas toolbar popUp submorphs do: [:b | b color = Color red ifTrue: [buttonForColor := b]]. + buttonForColor clickFunctionality: self artificialMouseClick. + self assert: self canvas globalColor = buttonForColor color. + + self buttonForGlobalColor clickFunctionality: self artificialMouseClick. - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). + self canvas toolbar popUp submorphs do: [:b | b color = Color white ifTrue: [buttonForColor := b]]. + buttonForColor clickFunctionality: self artificialMouseClick. + self assert: self canvas globalColor = Color transparent - buttonForColor := self canvas toolbar popUp submorphs at: 9. - buttonForColor clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). - self assert: self canvas globalColor = Color yellow ] { #category : #tests, - #'squeak_changestamp' : 'ACL 7/7/2024 18:22' + #'squeak_changestamp' : 'si 7/12/2024 11:36' } WBGlobalColorPopUpTests >> testButtonsOfPopUp [ - | button | - - button := self canvas toolbar buttons at: 5. - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). - self assert: self canvas toolbar popUp submorphs size = 9 + self buttonForGlobalColor clickFunctionality: self artificialMouseClick. + + self assert: self canvas toolbar popUp submorphs size = 12 ] { #category : #tests, - #'squeak_changestamp' : 'ACL 7/7/2024 18:23' + #'squeak_changestamp' : 'si 7/12/2024 11:24' } WBGlobalColorPopUpTests >> testExistenceOfPopUp [ - | button | - button := self canvas toolbar buttons at: 5. - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). + self buttonForGlobalColor clickFunctionality: self artificialMouseClick. self assert: self canvas toolbar popUp notNil ] { #category : #tests, - #'squeak_changestamp' : 'ACL 7/7/2024 18:23' + #'squeak_changestamp' : 'si 7/12/2024 11:25' } WBGlobalColorPopUpTests >> testPopUpPlacementInX [ - | button | - button := self canvas toolbar buttons at: 5. - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). + self buttonForGlobalColor clickFunctionality: self artificialMouseClick. - self assert: button right <= self canvas toolbar popUp left. - self assert: self canvas toolbar popUp left <= (button right + 200) + self assert: self buttonForGlobalColor right <= self canvas toolbar popUp left. + self assert: self canvas toolbar popUp left <= (self buttonForGlobalColor right + 200) ] { #category : #tests, - #'squeak_changestamp' : 'ACL 7/7/2024 18:23' + #'squeak_changestamp' : 'si 7/12/2024 11:25' } WBGlobalColorPopUpTests >> testPopUpPlacementInY [ - | button | + + self buttonForGlobalColor clickFunctionality: self artificialMouseClick. + + self assert: self buttonForGlobalColor center y - 200 < self canvas toolbar popUp top. + self assert: self canvas toolbar popUp bottom < (self buttonForGlobalColor center y + 500) +] - button := self canvas toolbar buttons at: 5. - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). +{ + #category : #tests, + #'squeak_changestamp' : 'si 7/12/2024 11:43' +} +WBGlobalColorPopUpTests >> testTransparentGlobalColor [ + | buttonForColor | + + self buttonForGlobalColor clickFunctionality: self artificialMouseClick. + + self canvas toolbar popUp submorphs do: [:b | b color = Color white ifTrue: [buttonForColor := b]]. + buttonForColor clickFunctionality: self artificialMouseClick. + + self canvas spawnAnElement: (WBRectangularElement newWithCanvas: self canvas) At: self artificialMouseClick. + self canvas dropElement: self artificialMouseClick. + + self assert: (self canvas elements at: 1) morph borderColor = Color black + - self assert: button center y - 200 < self canvas toolbar popUp top. - self assert: self canvas toolbar popUp bottom < (button center y + 500) ] diff --git a/src/SqueakWhiteboard-Tests/WBLineChoosingPopUpTests.class.st b/src/SqueakWhiteboard-Tests/WBLineChoosingPopUpTests.class.st index df59031..02a5f9b 100644 --- a/src/SqueakWhiteboard-Tests/WBLineChoosingPopUpTests.class.st +++ b/src/SqueakWhiteboard-Tests/WBLineChoosingPopUpTests.class.st @@ -1,80 +1,102 @@ Class { #name : #WBLineChoosingPopUpTests, #superclass : #WBToolbarButtonTests, + #instVars : [ + 'lineChoosingButton' + ], #category : #'SqueakWhiteboard-Tests' } +{ + #category : #accessing, + #'squeak_changestamp' : 'si 7/12/2024 11:21' +} +WBLineChoosingPopUpTests >> lineChoosingButton [ + + ^ lineChoosingButton +] + +{ + #category : #accessing, + #'squeak_changestamp' : 'si 7/12/2024 11:21' +} +WBLineChoosingPopUpTests >> lineChoosingButton: aButton [ + + lineChoosingButton := aButton +] + +{ + #category : #setUp, + #'squeak_changestamp' : 'si 7/12/2024 11:22' +} +WBLineChoosingPopUpTests >> setUp [ + + super setUp. + self lineChoosingButton: (self getButtonWithFunctionality: self canvas toolbar buttonFunctionalityForLineChoosing from: self canvas toolbar submorphs) +] + { #category : #tests, - #'squeak_changestamp' : 'is 7/10/2024 00:30' + #'squeak_changestamp' : 'si 7/12/2024 11:48' } WBLineChoosingPopUpTests >> testButtonFunctionality [ - | button buttonForLine | - - button := self canvas toolbar buttons at: 2. - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). + | buttonForLine | - buttonForLine := self canvas toolbar popUp submorphs at: 2. - buttonForLine clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). + self lineChoosingButton clickFunctionality: self artificialMouseClick. + + buttonForLine := self getButtonWithFunctionality: self canvas toolbar buttonFunctionalityForLine from: self canvas toolbar popUp submorphs. + buttonForLine clickFunctionality: self artificialMouseClick. self assert: self canvas elementToSpawn notNil. - self assert: self canvas elementToSpawn arrowHead = true. + self assert: self canvas elementToSpawn arrowHead = false. - buttonForLine := self canvas toolbar popUp submorphs at: 1. - buttonForLine clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). + buttonForLine := self getButtonWithFunctionality: self canvas toolbar buttonFunctionalityForArrow from: self canvas toolbar popUp submorphs. + buttonForLine clickFunctionality: self artificialMouseClick. self assert: self canvas elementToSpawn notNil. - self assert: self canvas elementToSpawn arrowHead = false + self assert: self canvas elementToSpawn arrowHead = true. ] { #category : #tests, - #'squeak_changestamp' : 'ACL 7/7/2024 18:24' + #'squeak_changestamp' : 'si 7/12/2024 11:46' } WBLineChoosingPopUpTests >> testButtonsOfPopUp [ - | button | - - button := self canvas toolbar buttons at: 2. - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). + + self lineChoosingButton clickFunctionality: self artificialMouseClick. self assert: self canvas toolbar popUp submorphs size = 2 ] { #category : #tests, - #'squeak_changestamp' : 'ACL 7/7/2024 18:24' + #'squeak_changestamp' : 'si 7/12/2024 11:45' } WBLineChoosingPopUpTests >> testExistenceOfPopUp [ - | button | - - button := self canvas toolbar buttons at: 2. - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). + + self lineChoosingButton clickFunctionality: self artificialMouseClick. self assert: self canvas toolbar popUp notNil ] { #category : #tests, - #'squeak_changestamp' : 'ACL 7/7/2024 18:24' + #'squeak_changestamp' : 'si 7/12/2024 11:45' } WBLineChoosingPopUpTests >> testPopUpPlacementInX [ - | button | - - button := self canvas toolbar buttons at: 2. - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). - self assert: button right <= self canvas toolbar popUp left. - self assert: self canvas toolbar popUp left <= (button right + 200) + self lineChoosingButton clickFunctionality: self artificialMouseClick. + + self assert: self lineChoosingButton right <= self canvas toolbar popUp left. + self assert: self canvas toolbar popUp left <= (self lineChoosingButton right + 200) ] { #category : #tests, - #'squeak_changestamp' : 'ACL 7/7/2024 18:24' + #'squeak_changestamp' : 'si 7/12/2024 11:45' } WBLineChoosingPopUpTests >> testPopUpPlacementInY [ - | button | - - button := self canvas toolbar buttons at: 2. - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). - self assert: button center y - 200 < self canvas toolbar popUp top. - self assert: self canvas toolbar popUp bottom < (button center y + 500) + self lineChoosingButton clickFunctionality: self artificialMouseClick. + + self assert: self lineChoosingButton center y - 200 < self canvas toolbar popUp top. + self assert: self canvas toolbar popUp bottom < (self lineChoosingButton center y + 500) ] diff --git a/src/SqueakWhiteboard-Tests/WBShapeChoosingPopUpTests.class.st b/src/SqueakWhiteboard-Tests/WBShapeChoosingPopUpTests.class.st index f0156c7..5939df9 100644 --- a/src/SqueakWhiteboard-Tests/WBShapeChoosingPopUpTests.class.st +++ b/src/SqueakWhiteboard-Tests/WBShapeChoosingPopUpTests.class.st @@ -1,78 +1,100 @@ Class { #name : #WBShapeChoosingPopUpTests, #superclass : #WBToolbarButtonTests, + #instVars : [ + 'shapeChoosingButton' + ], #category : #'SqueakWhiteboard-Tests' } +{ + #category : #setUp, + #'squeak_changestamp' : 'si 7/12/2024 11:24' +} +WBShapeChoosingPopUpTests >> setUp [ + + super setUp. + self shapeChoosingButton: (self getButtonWithFunctionality: self canvas toolbar buttonFunctionalityForShapeChoosing from: self canvas toolbar submorphs) +] + +{ + #category : #accessing, + #'squeak_changestamp' : 'si 7/12/2024 11:23' +} +WBShapeChoosingPopUpTests >> shapeChoosingButton [ + + ^ shapeChoosingButton +] + +{ + #category : #accessing, + #'squeak_changestamp' : 'si 7/12/2024 11:23' +} +WBShapeChoosingPopUpTests >> shapeChoosingButton: aButton [ + + shapeChoosingButton := aButton +] + { #category : #tests, - #'squeak_changestamp' : 'si 7/11/2024 14:12' + #'squeak_changestamp' : 'si 7/12/2024 11:53' } WBShapeChoosingPopUpTests >> testButtonFunctionality [ - | button buttonForShape | - - button := self canvas toolbar buttons at: 1. - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). + | buttonForShape | - buttonForShape := self canvas toolbar popUp submorphs at: 1. - buttonForShape clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). + self shapeChoosingButton clickFunctionality: self artificialMouseClick. + + buttonForShape := self getButtonWithFunctionality: self canvas toolbar buttonFunctionalityForRectangle from: canvas toolbar popUp submorphs. + buttonForShape clickFunctionality: self artificialMouseClick. self assert: self canvas elementToSpawn class = WBRectangularElement. - buttonForShape := self canvas toolbar popUp submorphs at: 2. - buttonForShape clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). + buttonForShape := self getButtonWithFunctionality: self canvas toolbar buttonFunctionalityForCircle from: canvas toolbar popUp submorphs. + buttonForShape clickFunctionality: self artificialMouseClick. self assert: self canvas elementToSpawn class = WBCircularElement ] { #category : #tests, - #'squeak_changestamp' : 'ACL 7/7/2024 18:24' + #'squeak_changestamp' : 'si 7/12/2024 11:50' } WBShapeChoosingPopUpTests >> testButtonsOfPopUp [ - | button | - - button := self canvas toolbar buttons at: 1. - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). + + self shapeChoosingButton clickFunctionality: self artificialMouseClick. self assert: self canvas toolbar popUp submorphs size = 2 ] { #category : #tests, - #'squeak_changestamp' : 'ACL 7/7/2024 18:24' + #'squeak_changestamp' : 'si 7/12/2024 11:49' } WBShapeChoosingPopUpTests >> testExistenceOfPopUp [ - | button | - - button := self canvas toolbar buttons at: 1. - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). + + self shapeChoosingButton clickFunctionality: self artificialMouseClick. self assert: self canvas toolbar popUp notNil ] { #category : #tests, - #'squeak_changestamp' : 'ACL 7/7/2024 18:24' + #'squeak_changestamp' : 'si 7/12/2024 11:49' } WBShapeChoosingPopUpTests >> testPopUpPlacementInX [ - | button | - - button := self canvas toolbar buttons at: 1. - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). - self assert: button right <= self canvas toolbar popUp left. - self assert: self canvas toolbar popUp left <= (button right + 200) + self shapeChoosingButton clickFunctionality: self artificialMouseClick. + + self assert: self shapeChoosingButton right <= self canvas toolbar popUp left. + self assert: self canvas toolbar popUp left <= (self shapeChoosingButton right + 200) ] { #category : #tests, - #'squeak_changestamp' : 'ACL 7/7/2024 18:25' + #'squeak_changestamp' : 'si 7/12/2024 11:50' } WBShapeChoosingPopUpTests >> testPopUpPlacementInY [ - | button | - - button := self canvas toolbar buttons at: 1. - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). - self assert: button center y - 200 < self canvas toolbar popUp top. - self assert: self canvas toolbar popUp bottom < (button center y + 500) + self shapeChoosingButton clickFunctionality: self artificialMouseClick. + + self assert: self shapeChoosingButton center y - 200 < self canvas toolbar popUp top. + self assert: self canvas toolbar popUp bottom < (self shapeChoosingButton center y + 500) ] diff --git a/src/SqueakWhiteboard-Tests/WBToolbarButtonTests.class.st b/src/SqueakWhiteboard-Tests/WBToolbarButtonTests.class.st index 9f95021..011e1d2 100644 --- a/src/SqueakWhiteboard-Tests/WBToolbarButtonTests.class.st +++ b/src/SqueakWhiteboard-Tests/WBToolbarButtonTests.class.st @@ -6,24 +6,26 @@ Class { { #category : #tests, - #'squeak_changestamp' : 'ACL 7/7/2024 18:19' + #'squeak_changestamp' : 'si 7/12/2024 11:03' } -WBToolbarButtonTests >> testButtonFunctionality [ +WBToolbarButtonTests >> testNoteButtonFunctionality [ | button | - button := self canvas toolbar buttons at: 1. - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)) + button := self getButtonWithFunctionality: self canvas toolbar buttonFunctionalityForNote from: self canvas toolbar submorphs. + button clickFunctionality: self artificialMouseClick. + + self assert: self canvas elementToSpawn class = WBNote ] { #category : #tests, - #'squeak_changestamp' : 'ACL 7/7/2024 18:26' + #'squeak_changestamp' : 'si 7/12/2024 11:05' } -WBToolbarButtonTests >> testNoteButtonFunctionality [ +WBToolbarButtonTests >> testTextboxButtonFunctionality [ | button | - button := self canvas toolbar buttons at: 3. - button clickFunctionality: (MouseButtonEvent new position: self canvas position + (100 @ 100)). + button := self getButtonWithFunctionality: self canvas toolbar buttonFunctionalityForTextbox from: self canvas toolbar submorphs. + button clickFunctionality: self artificialMouseClick. - self assert: self canvas elementToSpawn class = WBNote + self assert: self canvas elementToSpawn class = WBTextbox ]