From 76147848557e42d3812e60c501e6d36b3dc5b32b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Mon, 2 Oct 2023 12:06:41 +0200 Subject: [PATCH 1/6] removing useless pragma. --- src/Bloc-Layout/BlGridLayoutAxis.class.st | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Bloc-Layout/BlGridLayoutAxis.class.st b/src/Bloc-Layout/BlGridLayoutAxis.class.st index 36ef20ad1..3dc064670 100644 --- a/src/Bloc-Layout/BlGridLayoutAxis.class.st +++ b/src/Bloc-Layout/BlGridLayoutAxis.class.st @@ -130,7 +130,7 @@ BlGridLayoutAxis >> arcs [ { #category : #'computing links' } BlGridLayoutAxis >> backwardLinks [ - + "Return a BlGridPackedMap whose key is an interval and value is aBlGridMutableInteger" backwardLinks ifNil: [ backwardLinks := self createLinks: false ]. @@ -299,7 +299,8 @@ BlGridLayoutAxis >> createArcs [ { #category : #'computing group bounds' } BlGridLayoutAxis >> createGroupBounds [ - + "Return a BlGridPackedMap whose key is an BlGridLayoutSpec and value is BlGridLayoutBounds" + |assocs| assocs := OrderedCollection new. @@ -313,7 +314,8 @@ BlGridLayoutAxis >> createGroupBounds [ { #category : #'computing links' } BlGridLayoutAxis >> createLinks: isMin [ - + "Return a BlGridPackedMap whose key is an interval and value is aBlGridMutableInteger" + | theLinks | theLinks := OrderedCollection new. @@ -359,7 +361,7 @@ BlGridLayoutAxis >> element: anElement [ { #category : #'computing links' } BlGridLayoutAxis >> forwardLinks [ - + "Return a BlGridPackedMap whose key is an interval and value is aBlGridMutableInteger" forwardLinks ifNil: [ forwardLinks := self createLinks: true ]. @@ -376,7 +378,8 @@ BlGridLayoutAxis >> groupArcsByFirstVertex: theArcs [ "Group arcs by their first vertex, returning an array of arrays of Arcs. This is linear in the number of arcs. theArcs is collection of BlGridLayoutArc." - + "return an Array of Array of BlGridLayoutArc" + | n groups sizes | n := self count + 1. @@ -402,7 +405,7 @@ BlGridLayoutAxis >> groupArcsByFirstVertex: theArcs [ { #category : #'computing group bounds' } BlGridLayoutAxis >> groupBounds [ - + "Return a BlGridPackedMap whose key is a BlGridLayoutSpec and value is aBlGridLayoutBounds" groupBounds ifNil: [ groupBounds := self createGroupBounds ]. From 1115a5ac0abe14b10cfa1a0441a097f348ff661c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Dias?= Date: Fri, 9 Aug 2024 20:41:51 -0400 Subject: [PATCH 2/6] Removing some spurious and sometimes wrong pragmas Cherrypicked from a @Ducasse's 27f67ad137c5a5c822d9be2b4f4af626fc47c3be --- ...metryVisualAndLayoutBoundsTestOld.class.st | 360 ++++++++++++++++++ .../BlInfiniteDataSourceManager.class.st | 1 - .../BlInfiniteLayoutOrientation.class.st | 1 - .../BlRopedTextIterator.class.st | 1 - src/Bloc-Text/BlSubTextIterator.class.st | 1 - src/Bloc-Text/BlTextIterator.class.st | 1 - src/Bloc-Text/BlTextReadStream.class.st | 2 +- src/Bloc/BlAttributeRope.class.st | 2 +- src/Bloc/BlHandlerRegistry.class.st | 2 +- src/Bloc/BlLayoutChildNode.class.st | 1 - src/Bloc/BlLayoutChildNodeWithEdges.class.st | 1 - .../BlLayoutChildNodeWithElement.class.st | 1 - src/Bloc/BlRope.class.st | 2 +- src/Bloc/BlVector.class.st | 1 - src/Bloc/TBlLayoutChildNode.trait.st | 1 - 15 files changed, 364 insertions(+), 14 deletions(-) create mode 100644 src/Bloc-Examples/BlGeometryVisualAndLayoutBoundsTestOld.class.st diff --git a/src/Bloc-Examples/BlGeometryVisualAndLayoutBoundsTestOld.class.st b/src/Bloc-Examples/BlGeometryVisualAndLayoutBoundsTestOld.class.st new file mode 100644 index 000000000..d179e153e --- /dev/null +++ b/src/Bloc-Examples/BlGeometryVisualAndLayoutBoundsTestOld.class.st @@ -0,0 +1,360 @@ +" +I have been automatically converted and probably manually tweaked from BlGeometryVisualAndLayoutBoundsExamples. Pay attention there is an important design decision in such tests. First to let GT people execute them, the tests and helpers are tagged with do not remove them, let also the . + Finally and more important such tests should not use setup because every method should be in capacity of returning a fully working object called an example :) +" +Class { + #name : #BlGeometryVisualAndLayoutBoundsTestOld, + #superclass : #TestCase, + #traits : 'TBlExample', + #classTraits : 'TBlExample classTrait', + #category : #'Bloc-Examples' +} + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testAlignedIcon [ + + | anIconElement aLabelElement aContainerElement | + anIconElement := self testEmptyIconElement geometry: + self testTrianglePolygon. + aLabelElement := self testTextElementWithRunText. + aContainerElement := self testIconAndTextContainer. + aContainerElement addChildren: { + anIconElement. + aLabelElement }. + ^ aContainerElement +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testCenteredOutskirts [ + "Rectangle and star elements with centered stroke" + + | aContainer | + aContainer := self testContainer. + aContainer addChild: self testRectangleWithSmallerGeometryCentered. + aContainer addChild: self testStarWithSmallerGeometryCentered. + + ^ aContainer +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testClippedTriangle [ + + + "Clipped triangle polygon with layount bounds" + | aContainer | + aContainer := self testUnclippedTriangle. + aContainer clipChildren: true. + ^ aContainer +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testContainer [ + + + + | aContainer | + aContainer := BlElement new. + aContainer layout: (BlGridLayout horizontal cellSpacing: 20). + aContainer margin: (BlInsets all: 10). + aContainer padding: (BlInsets all: 10). + aContainer constraintsDo: [ :c | + c horizontal fitContent. + c vertical fitContent ]. + ^ aContainer +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testDebuggingAlignedIcon [ + + + | aContainerElement | + aContainerElement := self alignedIcon. + ^ aContainerElement +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testDebuggingMisalignedIcon [ + + + | aContainerElement | + aContainerElement := self misalignedIcon. + aContainerElement children first. + ^ aContainerElement +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testDebuggingMode [ + + + + | aContainer | + aContainer := self fullyVisibleTriangle. + ^ aContainer +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testEmptyIconElement [ + + + ^ BlDevElement new + size: 8 @ 12; + background: Color green muchDarker +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testFullyVisibleTriangle [ + + + + | aContainer | + aContainer := self clippedTriangle. + aContainer clipChildren: false. + aContainer position: 30 @ 30. + ^ aContainer +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testIconAndTextContainer [ + + + | aContainerElement | + aContainerElement := BlElement new + layout: BlLinearLayout horizontal alignCenter; + constraintsDo: [ :c | + c horizontal fitContent. + c vertical fitContent ]; + background: (Color gray alpha: 0.3); + padding: (BlInsets all: 3); + margin: (BlInsets left: 5). + aContainerElement transformDo: [ :t | + t origin: BlAffineTransformationTopLeftOrigin new. + t scaleBy: 5 ]. + ^ aContainerElement +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testInsideOutskirts [ + + + + | aContainer | + aContainer := self container. + aContainer addChild: self rectangleWithSmallerGeometryInside. + aContainer addChild: self starWithSmallerGeometryInside. + + ^ aContainer +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testMisalignedIcon [ + + + | anIconElement aLabelElement aContainerElement | + anIconElement := self emptyIconElement geometry: + self misalignedTrianglePolygon. + aLabelElement := self textElementWithRunText. + aContainerElement := self iconAndTextContainer. + aContainerElement addChildren: { + anIconElement. + aLabelElement }. + ^ aContainerElement +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testMisalignedTrianglePolygon [ + + + + ^ BlPolygonGeometry vertices: { + (0 @ 3). + (8 @ 7.5). + (0 @ 12) } +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testOutsideOutskirts [ + + + + | aContainer | + aContainer := self container. + aContainer addChild: self rectangleWithSmallerGeometryOutside. + aContainer addChild: self starWithSmallerGeometryOutside. + + ^ aContainer +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testRectanglePolygon [ + + + + ^ BlPolygonGeometry vertices: { + (50 @ 50). + (150 @ 50). + (150 @ 100). + (50 @ 100) } +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testRectangleWithSmallerGeometry [ + + + + | aRectangleElement | + aRectangleElement := BlDevElement new. + aRectangleElement geometry: self testRectanglePolygon. + aRectangleElement size: 200 @ 150. + aRectangleElement background: (Color gray alpha: 0.2). + aRectangleElement border: + (BlBorder paint: (Color gray alpha: 0.5) width: 10). + + ^ aRectangleElement +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testRectangleWithSmallerGeometryCentered [ + "Rectangle element with centered stroke" + + | aRectangleElement | + aRectangleElement := self testRectangleWithSmallerGeometry. + aRectangleElement outskirts: BlOutskirts centered. + + ^ aRectangleElement +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testRectangleWithSmallerGeometryInside [ + + + + | aRectangleElement | + aRectangleElement := self rectangleWithSmallerGeometry. + aRectangleElement outskirts: BlOutskirts inside. + + ^ aRectangleElement +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testRectangleWithSmallerGeometryOutside [ + + + + | aRectangleElement | + aRectangleElement := self rectangleWithSmallerGeometry. + aRectangleElement outskirts: BlOutskirts outside. + + ^ aRectangleElement +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testStarPolygon [ + + ^ BlPolygonGeometry vertices: { + (100 @ 50). + (115 @ 90). + (150 @ 90). + (125 @ 110). + (135 @ 150). + (100 @ 130). + (65 @ 150). + (75 @ 110). + (50 @ 90). + (85 @ 90) } +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testStarWithSmallerGeometry [ + "Star element in debug mode, displaying bounds" + + | aStarElement | + aStarElement := BlDevElement new. + aStarElement geometry: self testStarPolygon. + aStarElement size: 200 @ 200. + aStarElement background: (Color gray alpha: 0.2). + aStarElement border: + (BlBorder paint: (Color gray alpha: 0.5) width: 10). + ^ aStarElement +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testStarWithSmallerGeometryCentered [ + + + "Star element with centered stroke" + | aStarElement | + aStarElement := self testStarWithSmallerGeometry. + aStarElement outskirts: BlOutskirts centered. + + ^ aStarElement +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testStarWithSmallerGeometryInside [ + + + + | aStarElement | + aStarElement := self starWithSmallerGeometry. + aStarElement outskirts: BlOutskirts inside. + + ^ aStarElement +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testStarWithSmallerGeometryOutside [ + + + + | aStarElement | + aStarElement := self starWithSmallerGeometry. + aStarElement outskirts: BlOutskirts outside. + + ^ aStarElement +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testTextElementWithRunText [ + + ^ BlTextElement new text: 'Run' asRopedText +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testTrianglePolygon [ + + ^ BlPolygonGeometry vertices: { + (0 @ 0). + (8 @ 6). + (0 @ 12) } +] + +{ #category : #tests } +BlGeometryVisualAndLayoutBoundsTestOld >> testUnclippedTriangle [ + "Clipped triangle polygon with layount bounds" + + | aContainer aPolygonElement | + aContainer := BlElement new. + aContainer size: 8 @ 11. + aContainer position: 50 @ 50. + aContainer clipChildren: false. + aContainer transformDo: [ :t | + t origin: BlAffineTransformationTopLeftOrigin new. + t scaleBy: 10 ]. + aContainer outskirts: BlOutskirts centered. + aContainer border: + (BlBorder paint: (Color green alpha: 0.4) width: 0.2). + + aPolygonElement := BlElement new. + aPolygonElement size: 8 @ 11. + aPolygonElement geometry: (BlPolygon vertices: { + (0 @ 0). + (8 @ 5.5). + (0 @ 11) }). + aPolygonElement border: + (BlBorder paint: (Color gray alpha: 0.4) width: 2). + aPolygonElement outskirts: BlOutskirts centered. + + aContainer addChild: aPolygonElement. + + ^ aContainer +] diff --git a/src/Bloc-Infinite/BlInfiniteDataSourceManager.class.st b/src/Bloc-Infinite/BlInfiniteDataSourceManager.class.st index 6c8624848..9ed2cb3d3 100644 --- a/src/Bloc-Infinite/BlInfiniteDataSourceManager.class.st +++ b/src/Bloc-Infinite/BlInfiniteDataSourceManager.class.st @@ -106,7 +106,6 @@ BlInfiniteDataSourceManager >> dispatchCommand: aCommand to: anInfiniteElement [ BlInfiniteDataSourceManager >> hasCommands [ "Return true if there are both pending and postponed commands, otherwise false" - ^ self hasPendingCommands and: [ self hasPostponedCommands ] ] diff --git a/src/Bloc-Infinite/BlInfiniteLayoutOrientation.class.st b/src/Bloc-Infinite/BlInfiniteLayoutOrientation.class.st index ff5f7036a..ebc02253b 100644 --- a/src/Bloc-Infinite/BlInfiniteLayoutOrientation.class.st +++ b/src/Bloc-Infinite/BlInfiniteLayoutOrientation.class.st @@ -184,7 +184,6 @@ BlInfiniteLayoutOrientation >> startWithPadding [ { #category : #geometry } BlInfiniteLayoutOrientation >> totalSpace [ "Returns the total space to layout" - ^ self endWithPadding - self startWithPadding ] diff --git a/src/Bloc-Text-Rope/BlRopedTextIterator.class.st b/src/Bloc-Text-Rope/BlRopedTextIterator.class.st index 9d98c4b70..d6482ebd1 100644 --- a/src/Bloc-Text-Rope/BlRopedTextIterator.class.st +++ b/src/Bloc-Text-Rope/BlRopedTextIterator.class.st @@ -66,7 +66,6 @@ BlRopedTextIterator >> hasPrevious [ { #category : #'iterator - enumeration' } BlRopedTextIterator >> next [ "Return an item (character) at current position and move one to the right" - ^ iterator next ] diff --git a/src/Bloc-Text/BlSubTextIterator.class.st b/src/Bloc-Text/BlSubTextIterator.class.st index eb7c75214..45b979eb1 100644 --- a/src/Bloc-Text/BlSubTextIterator.class.st +++ b/src/Bloc-Text/BlSubTextIterator.class.st @@ -73,7 +73,6 @@ BlSubTextIterator >> hasPrevious [ { #category : #'iterator - enumeration' } BlSubTextIterator >> next [ "Return an item (character) at current position and move one to the right" - ^ iterator next ] diff --git a/src/Bloc-Text/BlTextIterator.class.st b/src/Bloc-Text/BlTextIterator.class.st index 0e5534917..20523eb22 100644 --- a/src/Bloc-Text/BlTextIterator.class.st +++ b/src/Bloc-Text/BlTextIterator.class.st @@ -69,7 +69,6 @@ BlTextIterator >> hasPrevious [ { #category : #'iterator - enumeration' } BlTextIterator >> next [ "Return an item (character) at current position and move one to the right" - ^ self subclassResponsibility ] diff --git a/src/Bloc-Text/BlTextReadStream.class.st b/src/Bloc-Text/BlTextReadStream.class.st index 6b955d51a..42630d2be 100644 --- a/src/Bloc-Text/BlTextReadStream.class.st +++ b/src/Bloc-Text/BlTextReadStream.class.st @@ -42,7 +42,7 @@ BlTextReadStream >> iterator: aBlTextIterator [ { #category : #'stream - enumeration' } BlTextReadStream >> next [ "Return an item (character) at current position and move one to the right" - + ^ self iterator next ] diff --git a/src/Bloc/BlAttributeRope.class.st b/src/Bloc/BlAttributeRope.class.st index 25729b285..cc7c82b10 100644 --- a/src/Bloc/BlAttributeRope.class.st +++ b/src/Bloc/BlAttributeRope.class.st @@ -232,7 +232,7 @@ BlAttributeRope >> isAttributed [ { #category : #'rope - testing' } BlAttributeRope >> isEmpty [ "Attribute rope is empty then and only then when attributes and underlying rope are empty" - + ^ self attributes isEmpty and: [ self rope isEmpty ] ] diff --git a/src/Bloc/BlHandlerRegistry.class.st b/src/Bloc/BlHandlerRegistry.class.st index 58540eed3..c80f8ef67 100644 --- a/src/Bloc/BlHandlerRegistry.class.st +++ b/src/Bloc/BlHandlerRegistry.class.st @@ -137,7 +137,7 @@ BlHandlerRegistry >> hasHandler: anEventHandler [ { #category : #'api - testing' } BlHandlerRegistry >> isEmpty [ "Return true if registry is empty (there are no handlers), false otherwise" - + ^ self numberOfHandlers isZero ] diff --git a/src/Bloc/BlLayoutChildNode.class.st b/src/Bloc/BlLayoutChildNode.class.st index 76adeed7d..7deb71a92 100644 --- a/src/Bloc/BlLayoutChildNode.class.st +++ b/src/Bloc/BlLayoutChildNode.class.st @@ -96,7 +96,6 @@ BlLayoutChildNode >> position [ { #category : #'api - geometry' } BlLayoutChildNode >> position: aPoint [ "Set position of the top left corner in the parent coordinate system" - measurement position: aPoint ] diff --git a/src/Bloc/BlLayoutChildNodeWithEdges.class.st b/src/Bloc/BlLayoutChildNodeWithEdges.class.st index 1758d494e..21ea206d6 100644 --- a/src/Bloc/BlLayoutChildNodeWithEdges.class.st +++ b/src/Bloc/BlLayoutChildNodeWithEdges.class.st @@ -151,7 +151,6 @@ BlLayoutChildNodeWithEdges >> position [ { #category : #'api - geometry' } BlLayoutChildNodeWithEdges >> position: aPoint [ "Set position of the top left corner in the parent coordinate system" - childNode position: aPoint ] diff --git a/src/Bloc/BlLayoutChildNodeWithElement.class.st b/src/Bloc/BlLayoutChildNodeWithElement.class.st index a0e0362d1..76a384b7b 100644 --- a/src/Bloc/BlLayoutChildNodeWithElement.class.st +++ b/src/Bloc/BlLayoutChildNodeWithElement.class.st @@ -100,7 +100,6 @@ BlLayoutChildNodeWithElement >> position [ { #category : #'api - geometry' } BlLayoutChildNodeWithElement >> position: aPoint [ "Set position of the top left corner in the parent coordinate system" - childNode position: aPoint ] diff --git a/src/Bloc/BlRope.class.st b/src/Bloc/BlRope.class.st index 2116071d1..e1e1d0834 100644 --- a/src/Bloc/BlRope.class.st +++ b/src/Bloc/BlRope.class.st @@ -298,7 +298,7 @@ BlRope >> isConcatenation [ { #category : #'rope - testing' } BlRope >> isEmpty [ "Return true if rope is empty, false otherwise" - + ^ self size isZero ] diff --git a/src/Bloc/BlVector.class.st b/src/Bloc/BlVector.class.st index c7fe7f3f3..e47d5df63 100644 --- a/src/Bloc/BlVector.class.st +++ b/src/Bloc/BlVector.class.st @@ -93,7 +93,6 @@ BlVector class >> zAxis [ { #category : #'instance creation' } BlVector class >> zero [ "Return a vector of zero length." - ^ Zero ifNil: [ Zero := self x: 0 y: 0 z: 0 ] ] diff --git a/src/Bloc/TBlLayoutChildNode.trait.st b/src/Bloc/TBlLayoutChildNode.trait.st index b3135e0e8..4971fff6e 100644 --- a/src/Bloc/TBlLayoutChildNode.trait.st +++ b/src/Bloc/TBlLayoutChildNode.trait.st @@ -93,7 +93,6 @@ TBlLayoutChildNode >> position [ { #category : #'api - geometry' } TBlLayoutChildNode >> position: aPoint [ "Set position of the top left corner in the parent coordinate system" - self explicitRequirement ] From 7b5ad6528f7810e51456e3163bfba534ba80f067 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Dias?= Date: Fri, 9 Aug 2024 20:59:15 -0400 Subject: [PATCH 3/6] BlHandlerArrayRegistryTest Cherrypicked from a @Ducasse's d99142d --- ...dlerAnnouncerRegistryExamplesTest.class.st | 18 ---- ...lHandlerArrayRegistryExamplesTest.class.st | 18 ---- .../BlHandlerAnnouncerRegistryTest.class.st} | 91 ++++++++----------- .../BlHandlerArrayRegistryTest.class.st | 11 +++ 4 files changed, 51 insertions(+), 87 deletions(-) delete mode 100644 src/Bloc-Examples/BlHandlerAnnouncerRegistryExamplesTest.class.st delete mode 100644 src/Bloc-Examples/BlHandlerArrayRegistryExamplesTest.class.st rename src/{Bloc-Examples/TBlHandlerRegistryExamples.trait.st => Bloc-UnitedTests/BlHandlerAnnouncerRegistryTest.class.st} (51%) create mode 100644 src/Bloc-UnitedTests/BlHandlerArrayRegistryTest.class.st diff --git a/src/Bloc-Examples/BlHandlerAnnouncerRegistryExamplesTest.class.st b/src/Bloc-Examples/BlHandlerAnnouncerRegistryExamplesTest.class.st deleted file mode 100644 index b2a665e2d..000000000 --- a/src/Bloc-Examples/BlHandlerAnnouncerRegistryExamplesTest.class.st +++ /dev/null @@ -1,18 +0,0 @@ -" -I contain examples of event handler registry with Announcer as its backend - -" -Class { - #name : #BlHandlerAnnouncerRegistryExamplesTest, - #superclass : #TestCase, - #traits : 'TBlHandlerRegistryExamples', - #classTraits : 'TBlHandlerRegistryExamples classTrait', - #category : #'Bloc-Examples-EventHandling' -} - -{ #category : #'instance creation' } -BlHandlerAnnouncerRegistryExamplesTest >> emptyRegistry [ - - - ^ BlHandlerAnnouncerRegistry new -] diff --git a/src/Bloc-Examples/BlHandlerArrayRegistryExamplesTest.class.st b/src/Bloc-Examples/BlHandlerArrayRegistryExamplesTest.class.st deleted file mode 100644 index 7ac675ba3..000000000 --- a/src/Bloc-Examples/BlHandlerArrayRegistryExamplesTest.class.st +++ /dev/null @@ -1,18 +0,0 @@ -" -I contain examples of event handler registry with Array as its backend - -" -Class { - #name : #BlHandlerArrayRegistryExamplesTest, - #superclass : #TestCase, - #traits : 'TBlHandlerRegistryExamples', - #classTraits : 'TBlHandlerRegistryExamples classTrait', - #category : #'Bloc-Examples-EventHandling' -} - -{ #category : #'instance creation' } -BlHandlerArrayRegistryExamplesTest >> emptyRegistry [ - - - ^ BlHandlerArrayRegistry new -] diff --git a/src/Bloc-Examples/TBlHandlerRegistryExamples.trait.st b/src/Bloc-UnitedTests/BlHandlerAnnouncerRegistryTest.class.st similarity index 51% rename from src/Bloc-Examples/TBlHandlerRegistryExamples.trait.st rename to src/Bloc-UnitedTests/BlHandlerAnnouncerRegistryTest.class.st index 700f7cc51..181cd9aeb 100644 --- a/src/Bloc-Examples/TBlHandlerRegistryExamples.trait.st +++ b/src/Bloc-UnitedTests/BlHandlerAnnouncerRegistryTest.class.st @@ -1,126 +1,115 @@ " -I define examples of the public api of event handler registry. All concrete implementations should behave in the same way +I contain examples of event handler registry with Announcer as its backend + " -Trait { - #name : #TBlHandlerRegistryExamples, - #category : #'Bloc-Examples-EventHandling' +Class { + #name : #BlHandlerAnnouncerRegistryTest, + #superclass : #TestCase, + #category : #'Bloc-UnitedTests-Handler' } { #category : #'instance creation' } -TBlHandlerRegistryExamples >> emptyRegistry [ - +BlHandlerAnnouncerRegistryTest >> emptyRegistry [ - ^ self explicitRequirement + ^ BlHandlerAnnouncerRegistry new ] { #category : #'examples - add' } -TBlHandlerRegistryExamples >> testAddMouseDown [ - +BlHandlerAnnouncerRegistryTest >> testAddMouseDown [ + | aRegistry | aRegistry := self emptyRegistry. self assert: aRegistry numberOfHandlers equals: 0. - aRegistry add: (BlExampleLoggingEventHandler on: BlMouseDownEvent). - self assert: aRegistry numberOfHandlers equals: 1. - ^ aRegistry ] { #category : #'examples - add' } -TBlHandlerRegistryExamples >> testAddMouseDownAndMouseUp [ - +BlHandlerAnnouncerRegistryTest >> testAddMouseDownAndMouseUp [ + | aRegistry | aRegistry := self testAddMouseDown. aRegistry add: (BlExampleLoggingEventHandler on: BlMouseUpEvent). - self assert: aRegistry numberOfHandlers equals: 2. - ^ aRegistry ] { #category : #'examples - add' } -TBlHandlerRegistryExamples >> testAddMouseDownTwice [ - +BlHandlerAnnouncerRegistryTest >> testAddMouseDownTwice [ + | aRegistry | - aRegistry := self testAddMouseDown. + aRegistry := self testAddMouseDown. aRegistry add: (BlExampleLoggingEventHandler on: BlMouseDownEvent). - self assert: aRegistry numberOfHandlers equals: 2. - ^ aRegistry ] { #category : #'examples - add' } -TBlHandlerRegistryExamples >> testAddMouseDownTwiceAndMouseUp [ - +BlHandlerAnnouncerRegistryTest >> testAddMouseDownTwiceAndMouseUp [ + | aRegistry | - aRegistry := self testAddMouseDownTwice. + aRegistry := self testAddMouseDownTwice. aRegistry add: (BlExampleLoggingEventHandler on: BlMouseUpEvent). - self assert: aRegistry numberOfHandlers equals: 3. + ^ aRegistry +] +{ #category : #'examples - add' } +BlHandlerAnnouncerRegistryTest >> testAddMouseDownTwiceror [ + + + | aRegistry | + aRegistry := self testAddMouseDown. + aRegistry add: (BlExampleLoggingEventHandler on: BlMouseDownEvent). + self assert: aRegistry numberOfHandlers equals: 2. ^ aRegistry ] { #category : #'examples - remove' } -TBlHandlerRegistryExamples >> testRemoveAllMouseDownFromTwice [ - - +BlHandlerAnnouncerRegistryTest >> testRemoveAllMouseDownFromTwice [ + | aRegistry | aRegistry := self testAddMouseDownTwice. - aRegistry removeAllSuchThat: [ :aHandler | - (aHandler isKindOf: BlEventHandler) and: [ - aHandler eventClass = BlMouseDownEvent ] ]. - + aRegistry removeAllSuchThat: [ :aHandler | (aHandler isKindOf: BlEventHandler) and: [ aHandler eventClass = BlMouseDownEvent ] ]. self assert: aRegistry numberOfHandlers equals: 0. ^ aRegistry ] { #category : #'examples - remove' } -TBlHandlerRegistryExamples >> testRemoveAllMouseDownFromTwiceLeaveUp [ - +BlHandlerAnnouncerRegistryTest >> testRemoveAllMouseDownFromTwiceLeaveUp [ + | aRegistry | aRegistry := self testAddMouseDownTwiceAndMouseUp. - aRegistry removeAllSuchThat: [ :aHandler | - (aHandler isKindOf: BlEventHandler) and: [ - aHandler eventClass = BlMouseDownEvent ] ]. - + aRegistry removeAllSuchThat: [ :aHandler | (aHandler isKindOf: BlEventHandler) and: [ aHandler eventClass = BlMouseDownEvent ] ]. self assert: aRegistry numberOfHandlers equals: 1. - ^ aRegistry ] { #category : #'examples - remove' } -TBlHandlerRegistryExamples >> testRemoveMouseDownLeaveEmpty [ - +BlHandlerAnnouncerRegistryTest >> testRemoveMouseDownLeaveEmpty [ + | aRegistry | aRegistry := self testRemoveMouseUpLeaveMouseDown. - aRegistry remove: (aRegistry handlers detect: [ :aHandler | - aHandler eventClass = BlMouseDownEvent ]). - + aRegistry remove: (aRegistry handlers detect: [ :aHandler | aHandler eventClass = BlMouseDownEvent]). self assert: aRegistry numberOfHandlers equals: 0. - ^ aRegistry ] { #category : #'examples - remove' } -TBlHandlerRegistryExamples >> testRemoveMouseUpLeaveMouseDown [ - +BlHandlerAnnouncerRegistryTest >> testRemoveMouseUpLeaveMouseDown [ + | aRegistry | aRegistry := self testAddMouseDownAndMouseUp. - aRegistry remove: (aRegistry handlers detect: [ :aHandler | - aHandler eventClass = BlMouseUpEvent ]). - + aRegistry remove: (aRegistry handlers detect: [ :aHandler | aHandler eventClass = BlMouseUpEvent]). self assert: aRegistry numberOfHandlers equals: 1. - ^ aRegistry ] diff --git a/src/Bloc-UnitedTests/BlHandlerArrayRegistryTest.class.st b/src/Bloc-UnitedTests/BlHandlerArrayRegistryTest.class.st new file mode 100644 index 000000000..6dd36f4d0 --- /dev/null +++ b/src/Bloc-UnitedTests/BlHandlerArrayRegistryTest.class.st @@ -0,0 +1,11 @@ +Class { + #name : #BlHandlerArrayRegistryTest, + #superclass : #BlHandlerAnnouncerRegistryTest, + #category : #'Bloc-UnitedTests-Handler' +} + +{ #category : #'instance creation' } +BlHandlerArrayRegistryTest >> emptyRegistry [ + + ^ BlHandlerArrayRegistry new +] From 6c64092be516f5895c60c0ed83745c59f66ae333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Mon, 2 Oct 2023 11:35:52 +0200 Subject: [PATCH 4/6] Removing empty classes Migrated BlGridLayoutUsageExamples to TestCase --- .../BlGridLayoutUsageTest.class.st | 9 - .../BlGridLayoutUsageTest.class.st | 451 ++++++++++++++++++ 2 files changed, 451 insertions(+), 9 deletions(-) delete mode 100644 src/Bloc-Examples/BlGridLayoutUsageTest.class.st create mode 100644 src/Bloc-UnitedTests/BlGridLayoutUsageTest.class.st diff --git a/src/Bloc-Examples/BlGridLayoutUsageTest.class.st b/src/Bloc-Examples/BlGridLayoutUsageTest.class.st deleted file mode 100644 index 05b3fd964..000000000 --- a/src/Bloc-Examples/BlGridLayoutUsageTest.class.st +++ /dev/null @@ -1,9 +0,0 @@ -" -I have been automatically converted and probably manually tweaked from BlGridLayoutUsageExamples. Pay attention there is an important design decision in such tests. First to let GT people execute them, the tests and helpers are tagged with do not remove them, let also the . - Finally and more important such tests should not use setup because every method should be in capacity of returning a fully working object called an example :) -" -Class { - #name : #BlGridLayoutUsageTest, - #superclass : #TestCase, - #category : #'Bloc-Examples-Layouts' -} diff --git a/src/Bloc-UnitedTests/BlGridLayoutUsageTest.class.st b/src/Bloc-UnitedTests/BlGridLayoutUsageTest.class.st new file mode 100644 index 000000000..c59ef1c79 --- /dev/null +++ b/src/Bloc-UnitedTests/BlGridLayoutUsageTest.class.st @@ -0,0 +1,451 @@ +" +I have been automatically converted and probably manually tweaked from BlGridLayoutUsageExamples. Pay attention there is an important design decision in such tests. First to let GT people execute them, the tests and helpers are tagged with do not remove them, let also the . + Finally and more important such tests should not use setup because every method should be in capacity of returning a fully working object called an example :) +" +Class { + #name : #BlGridLayoutUsageTest, + #superclass : #TestCase, + #category : #'Bloc-UnitedTests' +} + +{ #category : #fixture } +BlGridLayoutUsageTest >> testExampleDistributed2x2Grid [ + + + | e1 e2 e3 e4 el | + e1 := BlElement new + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + background: Color pink. + + e2 := BlElement new + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + background: Color green. + + e3 := BlElement new + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + background: Color red. + + e4 := BlElement new + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + background: Color yellow. + + el := BlElement new + layout: (BlGridLayout new columnCount: 2); + size: 300 @ 300; + position: 200 @ 100; + background: Color blue; + addChildren: { + e1. + e2. + e3. + e4 }; + yourself. + ^ el +] + +{ #category : #fixture } +BlGridLayoutUsageTest >> testExampleDistributedWithSpan2x2Grid [ + + + | e1 e2 e3 el | + e1 := BlElement new + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent. + c grid vertical span: 2 ]; + background: Color yellow. + + e2 := BlElement new + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent. + c grid horizontal weight: 2 ]; + background: Color green. + + e3 := BlElement new + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent. + c grid vertical weight: 0.5 ]; + background: Color red. + + el := BlElement new + layout: (BlGridLayout new columnCount: 2); + size: 300 @ 300; + position: 200 @ 100; + background: Color blue; + addChildren: { + e1. + e2. + e3 }; + yourself. + ^ el +] + +{ #category : #fixture } +BlGridLayoutUsageTest >> testExampleDistributedWithWeight2x2Grid [ + + + | e1 e2 e3 e4 el | + e1 := BlElement new + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent. + c grid horizontal weight: 2 ]; + background: Color pink. + + e2 := BlElement new + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + background: Color green. + + e3 := BlElement new + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + background: Color red. + + e4 := BlElement new + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent. + c grid vertical weight: 2 ]; + background: Color yellow. + + el := BlElement new + layout: (BlGridLayout new columnCount: 2); + size: 300 @ 300; + position: 200 @ 100; + background: Color blue; + addChildren: { + e1. + e2. + e3. + e4 }; + yourself. + ^ el +] + +{ #category : #fixture } +BlGridLayoutUsageTest >> testExampleHorizontal2x1Grid [ + + + | e1 e2 el | + e1 := BlElement new + size: 150 asPoint; + background: Color red. + + e2 := BlElement new + size: 150 asPoint; + background: Color yellow. + + el := BlElement new + layout: BlGridLayout horizontal; + size: 400 @ 400; + position: 200 @ 100; + background: Color blue; + addChildren: { + e1. + e2 }; + yourself. + ^ el +] + +{ #category : #fixture } +BlGridLayoutUsageTest >> testExampleHorizontalSpacing2x1Grid [ + + + | e1 e2 el | + e1 := BlElement new + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + background: Color red. + + e2 := BlElement new + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + background: Color yellow. + + el := BlElement new + layout: (BlGridLayout horizontal cellSpacing: 20); + size: 400 @ 200; + position: 200 @ 100; + background: Color blue; + addChildren: { + e1. + e2 }; + yourself. + ^ el +] + +{ #category : #fixture } +BlGridLayoutUsageTest >> testExampleInCellAlignment2x2Grid [ + + + | e1 e2 e3 el | + e1 := BlElement new + constraintsDo: [ :c | + c horizontal exact: 100. + c vertical matchParent. + c grid vertical span: 2 ]; + background: Color yellow. + + e2 := BlElement new + constraintsDo: [ :c | + c horizontal exact: 100. + c vertical exact: 50. + c grid horizontal alignCenter ]; + background: Color green. + + e3 := BlElement new + constraintsDo: [ :c | + c horizontal matchParent. + c vertical exact: 100. + c grid vertical alignBottom. + c grid horizontal weight: 2 ]; + background: Color red. + + el := BlElement new + layout: (BlGridLayout new columnCount: 2); + size: 300 @ 300; + position: 200 @ 100; + background: Color blue; + addChildren: { + e1. + e2. + e3 }; + yourself. + ^ el +] + +{ #category : #fixture } +BlGridLayoutUsageTest >> testExampleNautilusGrid [ + + + | e1 e2 e3 e4 e5 el | + e1 := BlElement new + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + background: Color white. + + e2 := BlElement new + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + background: Color white. + + e3 := BlElement new + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + background: Color white. + + e4 := BlElement new + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + background: Color white. + + e5 := BlElement new + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent. + c grid horizontal span: 4 ]; + background: Color white. + + el := BlElement new + layout: (BlGridLayout new + columnCount: 4; + cellSpacing: 10); + size: 300 @ 300; + background: Color veryLightGray; + addChildren: { + e1. + e2. + e3. + e4. + e5 }; + yourself. + ^ el +] + +{ #category : #fixture } +BlGridLayoutUsageTest >> testExampleSimple2x2Grid [ + + + | e1 e2 e3 e4 el | + e1 := BlElement new + size: 150 asPoint; + background: Color pink. + + e2 := BlElement new + size: 150 asPoint; + background: Color green. + + e3 := BlElement new + size: 150 asPoint; + background: Color red. + + e4 := BlElement new + size: 150 asPoint; + background: Color yellow. + + el := BlElement new + layout: (BlGridLayout new columnCount: 2); + size: 400 @ 400; + position: 200 @ 100; + background: Color blue; + addChildren: { + e1. + e2. + e3. + e4 }; + yourself. + ^ el +] + +{ #category : #fixture } +BlGridLayoutUsageTest >> testExampleSpacing9x9Grid [ + + + | children el dim | + dim := 9. + + children := (1 to: (dim raisedTo: 2)) collect: [ :i | + BlElement new + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent. + c grid ]; + background: Color random muchLighter; + yourself ]. + + el := BlElement new + layout: (BlGridLayout new + columnCount: dim; + rowCount: dim; + yourself); + constraintsDo: [ :c | + c horizontal exact: 400. + c vertical exact: 400 ]; + position: 0 @ 0; + background: Color blue; + addChildren: children; + yourself. + ^ el +] + +{ #category : #fixture } +BlGridLayoutUsageTest >> testExampleVertical1x2Grid [ + + + | e1 e2 el | + e1 := BlElement new + size: 150 asPoint; + background: Color red. + + e2 := BlElement new + size: 150 asPoint; + background: Color yellow. + + el := BlElement new + layout: BlGridLayout vertical; + size: 400 @ 400; + position: 200 @ 100; + background: Color blue; + addChildren: { + e1. + e2 }; + yourself. + ^ el +] + +{ #category : #fixture } +BlGridLayoutUsageTest >> testExampleVerticalSpacing1x2Grid [ + + + | e1 e2 el | + e1 := BlElement new + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + background: Color red. + + e2 := BlElement new + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + background: Color yellow. + + el := BlElement new + layout: (BlGridLayout vertical cellSpacing: 20); + size: 200 @ 400; + position: 200 @ 100; + background: Color blue; + addChildren: { + e1. + e2 }; + yourself. + ^ el +] + +{ #category : #fixture } +BlGridLayoutUsageTest >> testVerticalSpan [ + + + | grid child1 child2 child3 | + grid := BlElement new. + grid size: 500 @ 400. + grid layout: (BlGridLayout horizontal + cellSpacing: 10; + columnCount: 2). + + child1 := BlElement new. + child1 background: (Color red alpha: 0.5). + child1 constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]. + + child2 := BlElement new. + child2 background: (Color blue alpha: 0.5). + child2 constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent. + c grid vertical span: 2 ]. + + child3 := BlElement new. + child3 background: (Color green alpha: 0.5). + child3 constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]. + + grid addChildren: { + child1. + child2. + child3 }. + + grid forceLayout. + self assert: grid extent equals: 500 @ 400. + self assert: child1 position equals: 10 @ 10. + self assert: child1 extent equals: 235 @ 185. + + self assert: child2 position equals: 255 @ 10. + self assert: child2 extent equals: 235 @ 380. + + self assert: child3 position equals: 10 @ 205. + self assert: child3 extent equals: 235 @ 185. + + ^ grid +] From f594ad226bf420e8fe3793e892f5bbf1b505b4b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Mon, 2 Oct 2023 11:36:37 +0200 Subject: [PATCH 5/6] Remove migrated classes BlGridLayoutUsageExamples --- .../BlGridLayoutUsageExamples.class.st | 465 ------------------ 1 file changed, 465 deletions(-) delete mode 100644 src/Bloc-Examples/BlGridLayoutUsageExamples.class.st diff --git a/src/Bloc-Examples/BlGridLayoutUsageExamples.class.st b/src/Bloc-Examples/BlGridLayoutUsageExamples.class.st deleted file mode 100644 index 191cd16ea..000000000 --- a/src/Bloc-Examples/BlGridLayoutUsageExamples.class.st +++ /dev/null @@ -1,465 +0,0 @@ -" -I contain examples of a grid layout - -I show how different resizing strategies work and how to build advanced layouts with the help of a grid - -" -Class { - #name : #BlGridLayoutUsageExamples, - #superclass : #BlExamplesTest, - #category : #'Bloc-Examples-Documentation' -} - -{ #category : #examples } -BlGridLayoutUsageExamples >> exampleDistributed2x2Grid [ - - - - | e1 e2 e3 e4 el | - e1 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - background: Color pink. - - e2 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - background: Color green. - - e3 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - background: Color red. - - e4 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - background: Color yellow. - - el := BlElement new - layout: (BlGridLayout new columnCount: 2); - size: 300 @ 300; - position: 200 @ 100; - background: Color blue; - addChildren: { - e1. - e2. - e3. - e4 }; - yourself. - ^ el -] - -{ #category : #examples } -BlGridLayoutUsageExamples >> exampleDistributedWithSpan2x2Grid [ - - - - | e1 e2 e3 el | - e1 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent. - c grid vertical span: 2 ]; - background: Color yellow. - - e2 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent. - c grid horizontal weight: 2 ]; - background: Color green. - - e3 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent. - c grid vertical weight: 0.5 ]; - background: Color red. - - el := BlElement new - layout: (BlGridLayout new columnCount: 2); - size: 300 @ 300; - position: 200 @ 100; - background: Color blue; - addChildren: { - e1. - e2. - e3 }; - yourself. - ^ el -] - -{ #category : #examples } -BlGridLayoutUsageExamples >> exampleDistributedWithWeight2x2Grid [ - - - - | e1 e2 e3 e4 el | - e1 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent. - c grid horizontal weight: 2 ]; - background: Color pink. - - e2 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - background: Color green. - - e3 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - background: Color red. - - e4 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent. - c grid vertical weight: 2 ]; - background: Color yellow. - - el := BlElement new - layout: (BlGridLayout new columnCount: 2); - size: 300 @ 300; - position: 200 @ 100; - background: Color blue; - addChildren: { - e1. - e2. - e3. - e4 }; - yourself. - ^ el -] - -{ #category : #examples } -BlGridLayoutUsageExamples >> exampleHorizontal2x1Grid [ - - - - | e1 e2 el | - e1 := BlElement new - size: 150 asPoint; - background: Color red. - - e2 := BlElement new - size: 150 asPoint; - background: Color yellow. - - el := BlElement new - layout: BlGridLayout horizontal; - size: 400 @ 400; - position: 200 @ 100; - background: Color blue; - addChildren: { - e1. - e2 }; - yourself. - ^ el -] - -{ #category : #examples } -BlGridLayoutUsageExamples >> exampleHorizontalSpacing2x1Grid [ - - - - | e1 e2 el | - e1 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - background: Color red. - - e2 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - background: Color yellow. - - el := BlElement new - layout: (BlGridLayout horizontal cellSpacing: 20); - size: 400 @ 200; - position: 200 @ 100; - background: Color blue; - addChildren: { - e1. - e2 }; - yourself. - ^ el -] - -{ #category : #examples } -BlGridLayoutUsageExamples >> exampleInCellAlignment2x2Grid [ - - - - | e1 e2 e3 el | - e1 := BlElement new - constraintsDo: [ :c | - c horizontal exact: 100. - c vertical matchParent. - c grid vertical span: 2 ]; - background: Color yellow. - - e2 := BlElement new - constraintsDo: [ :c | - c horizontal exact: 100. - c vertical exact: 50. - c grid horizontal alignCenter ]; - background: Color green. - - e3 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical exact: 100. - c grid vertical alignBottom. - c grid horizontal weight: 2 ]; - background: Color red. - - el := BlElement new - layout: (BlGridLayout new columnCount: 2); - size: 300 @ 300; - position: 200 @ 100; - background: Color blue; - addChildren: { - e1. - e2. - e3 }; - yourself. - ^ el -] - -{ #category : #examples } -BlGridLayoutUsageExamples >> exampleNautilusGrid [ - - - - | e1 e2 e3 e4 e5 el | - e1 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - background: Color white. - - e2 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - background: Color white. - - e3 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - background: Color white. - - e4 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - background: Color white. - - e5 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent. - c grid horizontal span: 4 ]; - background: Color white. - - el := BlElement new - layout: (BlGridLayout new - columnCount: 4; - cellSpacing: 10); - size: 300 @ 300; - background: Color veryLightGray; - addChildren: { - e1. - e2. - e3. - e4. - e5 }; - yourself. - ^ el -] - -{ #category : #examples } -BlGridLayoutUsageExamples >> exampleSimple2x2Grid [ - - - - | e1 e2 e3 e4 el | - e1 := BlElement new - size: 150 asPoint; - background: Color pink. - - e2 := BlElement new - size: 150 asPoint; - background: Color green. - - e3 := BlElement new - size: 150 asPoint; - background: Color red. - - e4 := BlElement new - size: 150 asPoint; - background: Color yellow. - - el := BlElement new - layout: (BlGridLayout new columnCount: 2); - size: 400 @ 400; - position: 200 @ 100; - background: Color blue; - addChildren: { - e1. - e2. - e3. - e4 }; - yourself. - ^ el -] - -{ #category : #examples } -BlGridLayoutUsageExamples >> exampleSpacing9x9Grid [ - - - - | children el dim | - dim := 9. - - children := (1 to: (dim raisedTo: 2)) collect: [ :i | - BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent. - c grid ]; - background: Color random muchLighter; - yourself ]. - - el := BlElement new - layout: (BlGridLayout new - columnCount: dim; - rowCount: dim; - yourself); - constraintsDo: [ :c | - c horizontal exact: 400. - c vertical exact: 400 ]; - position: 0 @ 0; - background: Color blue; - addChildren: children; - yourself. - ^ el -] - -{ #category : #examples } -BlGridLayoutUsageExamples >> exampleVertical1x2Grid [ - - - - | e1 e2 el | - e1 := BlElement new - size: 150 asPoint; - background: Color red. - - e2 := BlElement new - size: 150 asPoint; - background: Color yellow. - - el := BlElement new - layout: BlGridLayout vertical; - size: 400 @ 400; - position: 200 @ 100; - background: Color blue; - addChildren: { - e1. - e2 }; - yourself. - ^ el -] - -{ #category : #examples } -BlGridLayoutUsageExamples >> exampleVerticalSpacing1x2Grid [ - - - - | e1 e2 el | - e1 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - background: Color red. - - e2 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - background: Color yellow. - - el := BlElement new - layout: (BlGridLayout vertical cellSpacing: 20); - size: 200 @ 400; - position: 200 @ 100; - background: Color blue; - addChildren: { - e1. - e2 }; - yourself. - ^ el -] - -{ #category : #examples } -BlGridLayoutUsageExamples >> verticalSpan [ - - - - | grid child1 child2 child3 | - grid := BlElement new. - grid size: 500 @ 400. - grid layout: (BlGridLayout horizontal - cellSpacing: 10; - columnCount: 2). - - child1 := BlElement new. - child1 background: (Color red alpha: 0.5). - child1 constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]. - - child2 := BlElement new. - child2 background: (Color blue alpha: 0.5). - child2 constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent. - c grid vertical span: 2 ]. - - child3 := BlElement new. - child3 background: (Color green alpha: 0.5). - child3 constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]. - - grid addChildren: { - child1. - child2. - child3 }. - - grid forceLayout. - self assert: grid extent equals: 500 @ 400. - self assert: child1 position equals: 10 @ 10. - self assert: child1 extent equals: 235 @ 185. - - self assert: child2 position equals: 255 @ 10. - self assert: child2 extent equals: 235 @ 380. - - self assert: child3 position equals: 10 @ 205. - self assert: child3 extent equals: 235 @ 185. - - ^ grid -] From fa0e88439f28a7f17c9f6fddfc91bd304675e172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Dias?= Date: Mon, 12 Aug 2024 13:33:13 +0000 Subject: [PATCH 6/6] Delete BlGeometryVisualAndLayoutBoundsTestOld --- ...metryVisualAndLayoutBoundsTestOld.class.st | 360 ------------------ 1 file changed, 360 deletions(-) delete mode 100644 src/Bloc-Examples/BlGeometryVisualAndLayoutBoundsTestOld.class.st diff --git a/src/Bloc-Examples/BlGeometryVisualAndLayoutBoundsTestOld.class.st b/src/Bloc-Examples/BlGeometryVisualAndLayoutBoundsTestOld.class.st deleted file mode 100644 index d179e153e..000000000 --- a/src/Bloc-Examples/BlGeometryVisualAndLayoutBoundsTestOld.class.st +++ /dev/null @@ -1,360 +0,0 @@ -" -I have been automatically converted and probably manually tweaked from BlGeometryVisualAndLayoutBoundsExamples. Pay attention there is an important design decision in such tests. First to let GT people execute them, the tests and helpers are tagged with do not remove them, let also the . - Finally and more important such tests should not use setup because every method should be in capacity of returning a fully working object called an example :) -" -Class { - #name : #BlGeometryVisualAndLayoutBoundsTestOld, - #superclass : #TestCase, - #traits : 'TBlExample', - #classTraits : 'TBlExample classTrait', - #category : #'Bloc-Examples' -} - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testAlignedIcon [ - - | anIconElement aLabelElement aContainerElement | - anIconElement := self testEmptyIconElement geometry: - self testTrianglePolygon. - aLabelElement := self testTextElementWithRunText. - aContainerElement := self testIconAndTextContainer. - aContainerElement addChildren: { - anIconElement. - aLabelElement }. - ^ aContainerElement -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testCenteredOutskirts [ - "Rectangle and star elements with centered stroke" - - | aContainer | - aContainer := self testContainer. - aContainer addChild: self testRectangleWithSmallerGeometryCentered. - aContainer addChild: self testStarWithSmallerGeometryCentered. - - ^ aContainer -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testClippedTriangle [ - - - "Clipped triangle polygon with layount bounds" - | aContainer | - aContainer := self testUnclippedTriangle. - aContainer clipChildren: true. - ^ aContainer -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testContainer [ - - - - | aContainer | - aContainer := BlElement new. - aContainer layout: (BlGridLayout horizontal cellSpacing: 20). - aContainer margin: (BlInsets all: 10). - aContainer padding: (BlInsets all: 10). - aContainer constraintsDo: [ :c | - c horizontal fitContent. - c vertical fitContent ]. - ^ aContainer -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testDebuggingAlignedIcon [ - - - | aContainerElement | - aContainerElement := self alignedIcon. - ^ aContainerElement -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testDebuggingMisalignedIcon [ - - - | aContainerElement | - aContainerElement := self misalignedIcon. - aContainerElement children first. - ^ aContainerElement -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testDebuggingMode [ - - - - | aContainer | - aContainer := self fullyVisibleTriangle. - ^ aContainer -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testEmptyIconElement [ - - - ^ BlDevElement new - size: 8 @ 12; - background: Color green muchDarker -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testFullyVisibleTriangle [ - - - - | aContainer | - aContainer := self clippedTriangle. - aContainer clipChildren: false. - aContainer position: 30 @ 30. - ^ aContainer -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testIconAndTextContainer [ - - - | aContainerElement | - aContainerElement := BlElement new - layout: BlLinearLayout horizontal alignCenter; - constraintsDo: [ :c | - c horizontal fitContent. - c vertical fitContent ]; - background: (Color gray alpha: 0.3); - padding: (BlInsets all: 3); - margin: (BlInsets left: 5). - aContainerElement transformDo: [ :t | - t origin: BlAffineTransformationTopLeftOrigin new. - t scaleBy: 5 ]. - ^ aContainerElement -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testInsideOutskirts [ - - - - | aContainer | - aContainer := self container. - aContainer addChild: self rectangleWithSmallerGeometryInside. - aContainer addChild: self starWithSmallerGeometryInside. - - ^ aContainer -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testMisalignedIcon [ - - - | anIconElement aLabelElement aContainerElement | - anIconElement := self emptyIconElement geometry: - self misalignedTrianglePolygon. - aLabelElement := self textElementWithRunText. - aContainerElement := self iconAndTextContainer. - aContainerElement addChildren: { - anIconElement. - aLabelElement }. - ^ aContainerElement -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testMisalignedTrianglePolygon [ - - - - ^ BlPolygonGeometry vertices: { - (0 @ 3). - (8 @ 7.5). - (0 @ 12) } -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testOutsideOutskirts [ - - - - | aContainer | - aContainer := self container. - aContainer addChild: self rectangleWithSmallerGeometryOutside. - aContainer addChild: self starWithSmallerGeometryOutside. - - ^ aContainer -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testRectanglePolygon [ - - - - ^ BlPolygonGeometry vertices: { - (50 @ 50). - (150 @ 50). - (150 @ 100). - (50 @ 100) } -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testRectangleWithSmallerGeometry [ - - - - | aRectangleElement | - aRectangleElement := BlDevElement new. - aRectangleElement geometry: self testRectanglePolygon. - aRectangleElement size: 200 @ 150. - aRectangleElement background: (Color gray alpha: 0.2). - aRectangleElement border: - (BlBorder paint: (Color gray alpha: 0.5) width: 10). - - ^ aRectangleElement -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testRectangleWithSmallerGeometryCentered [ - "Rectangle element with centered stroke" - - | aRectangleElement | - aRectangleElement := self testRectangleWithSmallerGeometry. - aRectangleElement outskirts: BlOutskirts centered. - - ^ aRectangleElement -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testRectangleWithSmallerGeometryInside [ - - - - | aRectangleElement | - aRectangleElement := self rectangleWithSmallerGeometry. - aRectangleElement outskirts: BlOutskirts inside. - - ^ aRectangleElement -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testRectangleWithSmallerGeometryOutside [ - - - - | aRectangleElement | - aRectangleElement := self rectangleWithSmallerGeometry. - aRectangleElement outskirts: BlOutskirts outside. - - ^ aRectangleElement -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testStarPolygon [ - - ^ BlPolygonGeometry vertices: { - (100 @ 50). - (115 @ 90). - (150 @ 90). - (125 @ 110). - (135 @ 150). - (100 @ 130). - (65 @ 150). - (75 @ 110). - (50 @ 90). - (85 @ 90) } -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testStarWithSmallerGeometry [ - "Star element in debug mode, displaying bounds" - - | aStarElement | - aStarElement := BlDevElement new. - aStarElement geometry: self testStarPolygon. - aStarElement size: 200 @ 200. - aStarElement background: (Color gray alpha: 0.2). - aStarElement border: - (BlBorder paint: (Color gray alpha: 0.5) width: 10). - ^ aStarElement -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testStarWithSmallerGeometryCentered [ - - - "Star element with centered stroke" - | aStarElement | - aStarElement := self testStarWithSmallerGeometry. - aStarElement outskirts: BlOutskirts centered. - - ^ aStarElement -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testStarWithSmallerGeometryInside [ - - - - | aStarElement | - aStarElement := self starWithSmallerGeometry. - aStarElement outskirts: BlOutskirts inside. - - ^ aStarElement -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testStarWithSmallerGeometryOutside [ - - - - | aStarElement | - aStarElement := self starWithSmallerGeometry. - aStarElement outskirts: BlOutskirts outside. - - ^ aStarElement -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testTextElementWithRunText [ - - ^ BlTextElement new text: 'Run' asRopedText -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testTrianglePolygon [ - - ^ BlPolygonGeometry vertices: { - (0 @ 0). - (8 @ 6). - (0 @ 12) } -] - -{ #category : #tests } -BlGeometryVisualAndLayoutBoundsTestOld >> testUnclippedTriangle [ - "Clipped triangle polygon with layount bounds" - - | aContainer aPolygonElement | - aContainer := BlElement new. - aContainer size: 8 @ 11. - aContainer position: 50 @ 50. - aContainer clipChildren: false. - aContainer transformDo: [ :t | - t origin: BlAffineTransformationTopLeftOrigin new. - t scaleBy: 10 ]. - aContainer outskirts: BlOutskirts centered. - aContainer border: - (BlBorder paint: (Color green alpha: 0.4) width: 0.2). - - aPolygonElement := BlElement new. - aPolygonElement size: 8 @ 11. - aPolygonElement geometry: (BlPolygon vertices: { - (0 @ 0). - (8 @ 5.5). - (0 @ 11) }). - aPolygonElement border: - (BlBorder paint: (Color gray alpha: 0.4) width: 2). - aPolygonElement outskirts: BlOutskirts centered. - - aContainer addChild: aPolygonElement. - - ^ aContainer -]