From 53fd0ebe2392ebc7d6b6888d1dd7ddb06b063494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Wed, 12 Apr 2023 08:20:37 +0200 Subject: [PATCH 1/8] MIgrated BlGridLayoutExamples -> test :) --- .../BlGridLayoutExamples.class.st | 464 -------------- .../BlGridLayoutTest.class.st | 603 ++++++++++++++++++ 2 files changed, 603 insertions(+), 464 deletions(-) delete mode 100644 src/Bloc-Layout-Examples/BlGridLayoutExamples.class.st create mode 100644 src/Bloc-Layout-Tests/BlGridLayoutTest.class.st diff --git a/src/Bloc-Layout-Examples/BlGridLayoutExamples.class.st b/src/Bloc-Layout-Examples/BlGridLayoutExamples.class.st deleted file mode 100644 index e1f5298f9..000000000 --- a/src/Bloc-Layout-Examples/BlGridLayoutExamples.class.st +++ /dev/null @@ -1,464 +0,0 @@ -Class { - #name : #BlGridLayoutExamples, - #superclass : #BlExampleTest, - #traits : 'TBlLayoutExamplesSetup', - #classTraits : 'TBlLayoutExamplesSetup classTrait', - #category : #'Bloc-Layout-Examples-Grid' -} - -{ #category : #'examples - layout' } -BlGridLayoutExamples >> exampleCellFitContent [ - - | parent child subchild | - - parent := self parentWithGridHorizontalLayout. - parent constraintsDo: [ :c | - c horizontal exact: 300. - c vertical fitContent ]. - parent background: Color white. - - child := self matchWidthFitHeight. - child layout: BlGridLayout vertical. - child background: Color paleBlue. - - subchild := self childExact: 200@100. - subchild background: Color paleRed. - - child addChild: subchild. - parent addChild: child. - - parent forceLayout. - - self assert: subchild extent equals: 200@100. - self assert: subchild position equals: 0@0. - - self assert: child extent equals: 300@100. - self assert: child position equals: 0@0. - - self assert: parent extent equals: 300@100. - self assert: parent position equals: 0@0. - - ^ parent -] - -{ #category : #'examples - layout' } -BlGridLayoutExamples >> exampleCellSpacingHorizontal1 [ - - | parent childA childB | - - childA := self childElementMatchingParent. - childB := self childElementMatchingParent. - - parent := self parentWithGridHorizontalLayout. - parent constraints horizontal exact: 400. - parent constraints vertical exact: 200. - parent layout cellSpacing: 20. - parent layout horizontal. - - parent addChildren: { childA. childB }. - parent forceLayout. - - self assert: childA extent equals: 170@160. - self assert: childA position equals: 20@20. - - self assert: childB extent equals: 170@160. - self assert: childB position equals: 210@20. - - self assert: parent extent equals: 400@200. - self assert: parent position equals: 0@0. - ^ parent -] - -{ #category : #'examples - layout' } -BlGridLayoutExamples >> exampleCellSpacingVertical1 [ - - | parent childA childB | - - childA := self childElementMatchingParent. - childB := self childElementMatchingParent. - - parent := self parentWithGridHorizontalLayout. - parent constraints horizontal exact: 200. - parent constraints vertical exact: 400. - parent layout cellSpacing: 20. - parent layout vertical. - - parent addChildren: { childA. childB }. - parent forceLayout. - - self assert: childA extent equals: 160@170. - self assert: childA position equals: 20@20. - - self assert: childB extent equals: 160@170. - self assert: childB position equals: 20@210. - - self assert: parent extent equals: 200@400. - self assert: parent position equals: 0@0. - ^ parent -] - -{ #category : #'examples - unit - fill' } -BlGridLayoutExamples >> exampleGridLayoutArrayFillEmpty [ - - | grid array | - grid := BlGridLayoutImpl new. - array := Array new: 0 withAll: 0. - - grid fill: array from: 0 to: 1 with: 1. - - self assert: array equals: #(). - ^ grid -] - -{ #category : #'examples - unit - fill' } -BlGridLayoutExamples >> exampleGridLayoutArrayFillFirstInFourElements [ - - | grid array | - grid := BlGridLayoutImpl new. - array := Array new: 4 withAll: 0. - - grid fill: array from: 0 to: 1 with: 1. - - self assert: array equals: #(1 0 0 0). - ^ grid -] - -{ #category : #'examples - unit - fill' } -BlGridLayoutExamples >> exampleGridLayoutArrayFillForthInFourElements [ - - | grid array | - grid := BlGridLayoutImpl new. - array := Array new: 4 withAll: 0. - - grid fill: array from: 3 to: 4 with: 1. - - self assert: array equals: #(0 0 0 1). - ^ grid -] - -{ #category : #'examples - unit - fill' } -BlGridLayoutExamples >> exampleGridLayoutArrayFillOneElement [ - - | grid array | - grid := BlGridLayoutImpl new. - array := Array new: 1 withAll: 0. - - grid fill: array from: 0 to: 1 with: 1. - - self assert: array equals: #(1). - ^ grid -] - -{ #category : #'examples - unit - fill' } -BlGridLayoutExamples >> exampleGridLayoutArrayFillOutOfBoundsEmpty1 [ - - | grid array | - grid := BlGridLayoutImpl new. - array := Array new: 0 withAll: 0. - - self - should: [ grid fill: array from: -1 to: 0 with: 1 ] - raise: SubscriptOutOfBounds - description: 'Should raise SubscriptOutOfBounds'. - ^ grid -] - -{ #category : #'examples - unit - fill' } -BlGridLayoutExamples >> exampleGridLayoutArrayFillOutOfBoundsEmpty2 [ - - | grid array | - grid := BlGridLayoutImpl new. - array := Array new: 0 withAll: 0. - - self - should: [ grid fill: array from: -1 to: 1 with: 1 ] - raise: SubscriptOutOfBounds - description: 'Should raise SubscriptOutOfBounds'. - ^ grid -] - -{ #category : #'examples - unit - fill' } -BlGridLayoutExamples >> exampleGridLayoutArrayFillOutOfBoundsEmpty3 [ - - | grid array | - - grid := BlGridLayoutImpl new. - array := Array new: 0 withAll: 0. - - grid fill: array from: 0 to: 0 with: 1. - self assert: array equals: #(). - ^ grid -] - -{ #category : #'examples - unit - fill' } -BlGridLayoutExamples >> exampleGridLayoutArrayFillOutOfBoundsEmpty4 [ - - | grid array | - grid := BlGridLayoutImpl new. - array := Array new: 0 withAll: 0. - grid fill: array from: 0 to: 2 with: 1. - self assert: array equals: #(). - ^ grid -] - -{ #category : #'examples - unit - fill' } -BlGridLayoutExamples >> exampleGridLayoutArrayFillOutOfBoundsInFourElements1 [ - - | grid array | - grid := BlGridLayoutImpl new. - array := Array new: 4 withAll: 0. - - self - should: [ grid fill: array from: -1 to: 3 with: 1 ] - raise: SubscriptOutOfBounds - description: 'Should raise SubscriptOutOfBounds'. - ^ grid -] - -{ #category : #'examples - unit - fill' } -BlGridLayoutExamples >> exampleGridLayoutArrayFillOutOfBoundsInFourElements2 [ - - | grid array | - grid := BlGridLayoutImpl new. - array := Array new: 4 withAll: 0. - - self - should: [ grid fill: array from: -1 to: 6 with: 1 ] - raise: SubscriptOutOfBounds - description: 'Should raise SubscriptOutOfBounds'. - ^ grid -] - -{ #category : #'examples - unit - fill' } -BlGridLayoutExamples >> exampleGridLayoutArrayFillOutOfBoundsInFourElements3 [ - - | grid array | - grid := BlGridLayoutImpl new. - array := Array new: 4 withAll: 0. - grid fill: array from: 4 to: 6 with: 1. - self assert: array equals: #(0 0 0 0). - ^ grid - -] - -{ #category : #'examples - unit - fill' } -BlGridLayoutExamples >> exampleGridLayoutArrayFillSecondInFourElements [ - - | grid array | - grid := BlGridLayoutImpl new. - array := Array new: 4 withAll: 0. - - grid fill: array from: 1 to: 2 with: 1. - - self assert: array equals: #(0 1 0 0). - ^ grid -] - -{ #category : #'examples - unit - fill' } -BlGridLayoutExamples >> exampleGridLayoutArrayFillThreeElements [ - - | grid array | - grid := BlGridLayoutImpl new. - array := Array new: 3 withAll: 0. - - grid fill: array from: 0 to: 3 with: 1. - - self assert: array equals: #(1 1 1). - ^ grid -] - -{ #category : #'examples - unit - fill' } -BlGridLayoutExamples >> exampleGridLayoutArrayFillTwoElements [ - - | grid array | - grid := BlGridLayoutImpl new. - array := Array new: 2 withAll: 0. - - grid fill: array from: 0 to: 2 with: 1. - - self assert: array equals: #(1 1). - ^ grid -] - -{ #category : #'examples - unit - fill' } -BlGridLayoutExamples >> exampleGridLayoutArrayFillTwoInFourElements1 [ - - | grid array | - grid := BlGridLayoutImpl new. - array := Array new: 4 withAll: 0. - - grid fill: array from: 0 to: 2 with: 1. - - self assert: array equals: #(1 1 0 0). - ^ grid -] - -{ #category : #'examples - unit - fill' } -BlGridLayoutExamples >> exampleGridLayoutArrayFillTwoInFourElements2 [ - - | grid array | - grid := BlGridLayoutImpl new. - array := Array new: 4 withAll: 0. - - grid fill: array from: 1 to: 3 with: 1. - - self assert: array equals: #(0 1 1 0). - ^ grid -] - -{ #category : #'examples - unit - fill' } -BlGridLayoutExamples >> exampleGridLayoutArrayFillTwoInFourElements3 [ - - | grid array | - grid := BlGridLayoutImpl new. - array := Array new: 4 withAll: 0. - - grid fill: array from: 2 to: 4 with: 1. - - self assert: array equals: #(0 0 1 1). - ^ grid -] - -{ #category : #'examples - layout' } -BlGridLayoutExamples >> exampleOneCellExactChildInExactParent [ - - | parent child | - - child := self childExact: 200@300. - - parent := self parentWithGridHorizontalLayout. - parent constraints horizontal exact: 300. - parent constraints vertical exact: 400. - - parent addChild: child. - parent forceLayout. - - self assert: child extent equals: 200@300. - self assert: child position equals: 0@0. - - self assert: parent extent equals: 300@400. - self assert: parent position equals: 0@0. - ^ parent -] - -{ #category : #'examples - layout' } -BlGridLayoutExamples >> exampleOneCellExactChildInFitParent [ - - | parent child | - - child := self childExact: 200@300. - - parent := self parentWithGridHorizontalLayout. - parent constraints horizontal fitContent. - parent constraints vertical fitContent. - - parent addChild: child. - parent forceLayout. - - self assert: child extent equals: 200@300. - self assert: child position equals: 0@0. - - self assert: parent extent equals: 200@300. - self assert: parent position equals: 0@0. - ^ parent -] - -{ #category : #'examples - layout' } -BlGridLayoutExamples >> exampleOneCellMatchChildInExactParent [ - - | parent child | - - child := self childElementMatchingParent. - - parent := self parentWithGridHorizontalLayout. - parent constraints horizontal exact: 400. - parent constraints vertical exact: 300. - - parent addChild: child. - parent forceLayout. - - self assert: child extent equals: 400@300. - self assert: child position equals: 0@0. - - self assert: parent extent equals: 400@300. - self assert: parent position equals: 0@0. - ^ parent -] - -{ #category : #'examples - unit - spans' } -BlGridLayoutExamples >> exampleSpanDistributeOneColumn [ - - | parent childA childB childC | - - childA := self childElementMatchingParent. - childB := self childElementMatchingParent. - childC := self childElementMatchingParent. - - parent := self parentWithGridHorizontalLayout. - parent constraints horizontal exact: 400. - parent constraints vertical exact: 400. - parent layout columnCount: 1. - - parent addChildren: { childA. childB. childC }. - parent forceLayout. - - self assert: (childA constraints grid horizontal spec span) equals: (BlGridLayoutInterval min: 0 max: 1). - self assert: (childA constraints grid vertical spec span) equals: (BlGridLayoutInterval min: 0 max: 1). - - self assert: (childB constraints grid horizontal spec span) equals: (BlGridLayoutInterval min: 0 max: 1). - self assert: (childB constraints grid vertical spec span) equals: (BlGridLayoutInterval min: 1 max: 2). - - self assert: (childC constraints grid horizontal spec span) equals: (BlGridLayoutInterval min: 0 max: 1). - self assert: (childC constraints grid vertical spec span) equals: (BlGridLayoutInterval min: 2 max: 3). - - ^ parent -] - -{ #category : #'examples - unit - spans' } -BlGridLayoutExamples >> exampleSpanDistributeOneRow [ - - | parent childA childB childC | - - childA := self childElementMatchingParent. - childB := self childElementMatchingParent. - childC := self childElementMatchingParent. - - parent := self parentWithGridHorizontalLayout. - parent constraints horizontal exact: 400. - parent constraints vertical exact: 400. - parent layout rowCount: 1. - - parent addChildren: { childA. childB. childC }. - parent forceLayout. - - self assert: (childA constraints grid horizontal spec span) equals: (BlGridLayoutInterval min: 0 max: 1). - self assert: (childA constraints grid vertical spec span) equals: (BlGridLayoutInterval min: 0 max: 1). - - self assert: (childB constraints grid horizontal spec span) equals: (BlGridLayoutInterval min: 1 max: 2). - self assert: (childB constraints grid vertical spec span) equals: (BlGridLayoutInterval min: 0 max: 1). - - self assert: (childC constraints grid horizontal spec span) equals: (BlGridLayoutInterval min: 2 max: 3). - self assert: (childC constraints grid vertical spec span) equals: (BlGridLayoutInterval min: 0 max: 1). - ^ parent -] - -{ #category : #'examples - setup' } -BlGridLayoutExamples >> matchWidthFitHeight [ - ^ BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical fitContent ] -] - -{ #category : #'examples - setup' } -BlGridLayoutExamples >> parentWithGridHorizontalLayout [ - - | element | - element := BlElement new - border: (BlBorder builder dashed; paint: Color red; width: 3; build); - layout: BlGridLayout horizontal. - - self assert: element layout class equals: BlGridLayout. - - ^ element -] diff --git a/src/Bloc-Layout-Tests/BlGridLayoutTest.class.st b/src/Bloc-Layout-Tests/BlGridLayoutTest.class.st new file mode 100644 index 000000000..ab3e9a4fa --- /dev/null +++ b/src/Bloc-Layout-Tests/BlGridLayoutTest.class.st @@ -0,0 +1,603 @@ +" +I have been automatically converted and probably manually tweaked from BlGridLayoutExamples. 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 : #BlGridLayoutTest, + #superclass : #BlRootLayoutTest, + #category : #'Bloc-Layout-Tests' +} + +{ #category : #fixture } +BlGridLayoutTest >> childExact: aPoint [ + + ^ self testChildElementWithVisualProperties + constraintsDo: [ :c | + c horizontal exact: aPoint x. + c vertical exact: aPoint y ]; + yourself +] + +{ #category : #fixture } +BlGridLayoutTest >> matchWidthFitHeight [ + + + ^ BlElement new constraintsDo: [ :c | + c horizontal matchParent. + c vertical fitContent ] +] + +{ #category : #tests } +BlGridLayoutTest >> testExampleCellFitContent [ + + + | parent child subchild | + parent := self testParentWithGridHorizontalLayout. + parent constraintsDo: [ :c | + c horizontal exact: 300. + c vertical fitContent ]. + parent background: Color white. + + child := self matchWidthFitHeight. + child layout: BlGridLayout vertical. + child background: Color paleBlue. + + subchild := self childExact: 200 @ 100. + subchild background: Color paleRed. + + child addChild: subchild. + parent addChild: child. + + parent forceLayout. + + self assert: subchild extent equals: 200 @ 100. + self assert: subchild position equals: 0 @ 0. + + self assert: child extent equals: 300 @ 100. + self assert: child position equals: 0 @ 0. + + self assert: parent extent equals: 300 @ 100. + self assert: parent position equals: 0 @ 0. + + ^ parent +] + +{ #category : #tests } +BlGridLayoutTest >> testExampleCellSpacingHorizontal1 [ + + + | parent childA childB | + childA := self testChildElementMatchingParent. + childB := self testChildElementMatchingParent. + + parent := self testParentWithGridHorizontalLayout. + parent constraints horizontal exact: 400. + parent constraints vertical exact: 200. + parent layout cellSpacing: 20. + parent layout horizontal. + + parent addChildren: { + childA. + childB }. + parent forceLayout. + + self assert: childA extent equals: 170 @ 160. + self assert: childA position equals: 20 @ 20. + + self assert: childB extent equals: 170 @ 160. + self assert: childB position equals: 210 @ 20. + + self assert: parent extent equals: 400 @ 200. + self assert: parent position equals: 0 @ 0. + ^ parent +] + +{ #category : #tests } +BlGridLayoutTest >> testExampleCellSpacingVertical1 [ + + + | parent childA childB | + childA := self testChildElementMatchingParent. + childB := self testChildElementMatchingParent. + + parent := self testParentWithGridHorizontalLayout. + parent constraints horizontal exact: 200. + parent constraints vertical exact: 400. + parent layout cellSpacing: 20. + parent layout vertical. + + parent addChildren: { + childA. + childB }. + parent forceLayout. + + self assert: childA extent equals: 160 @ 170. + self assert: childA position equals: 20 @ 20. + + self assert: childB extent equals: 160 @ 170. + self assert: childB position equals: 20 @ 210. + + self assert: parent extent equals: 200 @ 400. + self assert: parent position equals: 0 @ 0. + ^ parent +] + +{ #category : #tests } +BlGridLayoutTest >> testExampleGridLayoutArrayFillEmpty [ + + + | grid array | + grid := BlGridLayoutImpl new. + array := Array new: 0 withAll: 0. + + grid + fill: array + from: 0 + to: 1 + with: 1. + + self assert: array equals: #( ). + ^ grid +] + +{ #category : #tests } +BlGridLayoutTest >> testExampleGridLayoutArrayFillFirstInFourElements [ + + + | grid array | + grid := BlGridLayoutImpl new. + array := Array new: 4 withAll: 0. + + grid + fill: array + from: 0 + to: 1 + with: 1. + + self assert: array equals: #( 1 0 0 0 ). + ^ grid +] + +{ #category : #tests } +BlGridLayoutTest >> testExampleGridLayoutArrayFillForthInFourElements [ + + + | grid array | + grid := BlGridLayoutImpl new. + array := Array new: 4 withAll: 0. + + grid + fill: array + from: 3 + to: 4 + with: 1. + + self assert: array equals: #( 0 0 0 1 ). + ^ grid +] + +{ #category : #tests } +BlGridLayoutTest >> testExampleGridLayoutArrayFillOneElement [ + + + | grid array | + grid := BlGridLayoutImpl new. + array := Array new: 1 withAll: 0. + + grid + fill: array + from: 0 + to: 1 + with: 1. + + self assert: array equals: #( 1 ). + ^ grid +] + +{ #category : #tests } +BlGridLayoutTest >> testExampleGridLayoutArrayFillOutOfBoundsEmpty1 [ + + + | grid array | + grid := BlGridLayoutImpl new. + array := Array new: 0 withAll: 0. + + self + should: [ + grid + fill: array + from: -1 + to: 0 + with: 1 ] + raise: SubscriptOutOfBounds + description: 'Should raise SubscriptOutOfBounds'. + ^ grid +] + +{ #category : #tests } +BlGridLayoutTest >> testExampleGridLayoutArrayFillOutOfBoundsEmpty2 [ + + + | grid array | + grid := BlGridLayoutImpl new. + array := Array new: 0 withAll: 0. + + self + should: [ + grid + fill: array + from: -1 + to: 1 + with: 1 ] + raise: SubscriptOutOfBounds + description: 'Should raise SubscriptOutOfBounds'. + ^ grid +] + +{ #category : #tests } +BlGridLayoutTest >> testExampleGridLayoutArrayFillOutOfBoundsEmpty3 [ + + + | grid array | + grid := BlGridLayoutImpl new. + array := Array new: 0 withAll: 0. + + grid + fill: array + from: 0 + to: 0 + with: 1. + self assert: array equals: #( ). + ^ grid +] + +{ #category : #tests } +BlGridLayoutTest >> testExampleGridLayoutArrayFillOutOfBoundsEmpty4 [ + + + | grid array | + grid := BlGridLayoutImpl new. + array := Array new: 0 withAll: 0. + grid + fill: array + from: 0 + to: 2 + with: 1. + self assert: array equals: #( ). + ^ grid +] + +{ #category : #tests } +BlGridLayoutTest >> testExampleGridLayoutArrayFillOutOfBoundsInFourElements1 [ + + + | grid array | + grid := BlGridLayoutImpl new. + array := Array new: 4 withAll: 0. + + self + should: [ + grid + fill: array + from: -1 + to: 3 + with: 1 ] + raise: SubscriptOutOfBounds + description: 'Should raise SubscriptOutOfBounds'. + ^ grid +] + +{ #category : #tests } +BlGridLayoutTest >> testExampleGridLayoutArrayFillOutOfBoundsInFourElements2 [ + + + | grid array | + grid := BlGridLayoutImpl new. + array := Array new: 4 withAll: 0. + + self + should: [ + grid + fill: array + from: -1 + to: 6 + with: 1 ] + raise: SubscriptOutOfBounds + description: 'Should raise SubscriptOutOfBounds'. + ^ grid +] + +{ #category : #tests } +BlGridLayoutTest >> testExampleGridLayoutArrayFillOutOfBoundsInFourElements3 [ + + + | grid array | + grid := BlGridLayoutImpl new. + array := Array new: 4 withAll: 0. + grid + fill: array + from: 4 + to: 6 + with: 1. + self assert: array equals: #( 0 0 0 0 ). + ^ grid +] + +{ #category : #tests } +BlGridLayoutTest >> testExampleGridLayoutArrayFillSecondInFourElements [ + + + | grid array | + grid := BlGridLayoutImpl new. + array := Array new: 4 withAll: 0. + + grid + fill: array + from: 1 + to: 2 + with: 1. + + self assert: array equals: #( 0 1 0 0 ). + ^ grid +] + +{ #category : #tests } +BlGridLayoutTest >> testExampleGridLayoutArrayFillThreeElements [ + + + | grid array | + grid := BlGridLayoutImpl new. + array := Array new: 3 withAll: 0. + + grid + fill: array + from: 0 + to: 3 + with: 1. + + self assert: array equals: #( 1 1 1 ). + ^ grid +] + +{ #category : #tests } +BlGridLayoutTest >> testExampleGridLayoutArrayFillTwoElements [ + + + | grid array | + grid := BlGridLayoutImpl new. + array := Array new: 2 withAll: 0. + + grid + fill: array + from: 0 + to: 2 + with: 1. + + self assert: array equals: #( 1 1 ). + ^ grid +] + +{ #category : #tests } +BlGridLayoutTest >> testExampleGridLayoutArrayFillTwoInFourElements1 [ + + + | grid array | + grid := BlGridLayoutImpl new. + array := Array new: 4 withAll: 0. + + grid + fill: array + from: 0 + to: 2 + with: 1. + + self assert: array equals: #( 1 1 0 0 ). + ^ grid +] + +{ #category : #tests } +BlGridLayoutTest >> testExampleGridLayoutArrayFillTwoInFourElements2 [ + + + | grid array | + grid := BlGridLayoutImpl new. + array := Array new: 4 withAll: 0. + + grid + fill: array + from: 1 + to: 3 + with: 1. + + self assert: array equals: #( 0 1 1 0 ). + ^ grid +] + +{ #category : #tests } +BlGridLayoutTest >> testExampleGridLayoutArrayFillTwoInFourElements3 [ + + + | grid array | + grid := BlGridLayoutImpl new. + array := Array new: 4 withAll: 0. + + grid + fill: array + from: 2 + to: 4 + with: 1. + + self assert: array equals: #( 0 0 1 1 ). + ^ grid +] + +{ #category : #tests } +BlGridLayoutTest >> testExampleOneCellExactChildInExactParent [ + + + | parent child | + child := self childExact: 200 @ 300. + + parent := self testParentWithGridHorizontalLayout. + parent constraints horizontal exact: 300. + parent constraints vertical exact: 400. + + parent addChild: child. + parent forceLayout. + + self assert: child extent equals: 200 @ 300. + self assert: child position equals: 0 @ 0. + + self assert: parent extent equals: 300 @ 400. + self assert: parent position equals: 0 @ 0. + ^ parent +] + +{ #category : #tests } +BlGridLayoutTest >> testExampleOneCellExactChildInFitParent [ + + + | parent child | + child := self childExact: 200 @ 300. + + parent := self testParentWithGridHorizontalLayout. + parent constraints horizontal fitContent. + parent constraints vertical fitContent. + + parent addChild: child. + parent forceLayout. + + self assert: child extent equals: 200 @ 300. + self assert: child position equals: 0 @ 0. + + self assert: parent extent equals: 200 @ 300. + self assert: parent position equals: 0 @ 0. + ^ parent +] + +{ #category : #tests } +BlGridLayoutTest >> testExampleOneCellMatchChildInExactParent [ + + + | parent child | + child := self testChildElementMatchingParent. + + parent := self testParentWithGridHorizontalLayout. + parent constraints horizontal exact: 400. + parent constraints vertical exact: 300. + + parent addChild: child. + parent forceLayout. + + self assert: child extent equals: 400 @ 300. + self assert: child position equals: 0 @ 0. + + self assert: parent extent equals: 400 @ 300. + self assert: parent position equals: 0 @ 0. + ^ parent +] + +{ #category : #tests } +BlGridLayoutTest >> testExampleSpanDistributeOneColumn [ + + + | parent childA childB childC | + childA := self testChildElementMatchingParent. + childB := self testChildElementMatchingParent. + childC := self testChildElementMatchingParent. + + parent := self testParentWithGridHorizontalLayout. + parent constraints horizontal exact: 400. + parent constraints vertical exact: 400. + parent layout columnCount: 1. + + parent addChildren: { + childA. + childB. + childC }. + parent forceLayout. + + self + assert: childA constraints grid horizontal spec span + equals: (BlGridLayoutInterval min: 0 max: 1). + self + assert: childA constraints grid vertical spec span + equals: (BlGridLayoutInterval min: 0 max: 1). + + self + assert: childB constraints grid horizontal spec span + equals: (BlGridLayoutInterval min: 0 max: 1). + self + assert: childB constraints grid vertical spec span + equals: (BlGridLayoutInterval min: 1 max: 2). + + self + assert: childC constraints grid horizontal spec span + equals: (BlGridLayoutInterval min: 0 max: 1). + self + assert: childC constraints grid vertical spec span + equals: (BlGridLayoutInterval min: 2 max: 3). + + ^ parent +] + +{ #category : #tests } +BlGridLayoutTest >> testExampleSpanDistributeOneRow [ + + + | parent childA childB childC | + childA := self testChildElementMatchingParent. + childB := self testChildElementMatchingParent. + childC := self testChildElementMatchingParent. + + parent := self testParentWithGridHorizontalLayout. + parent constraints horizontal exact: 400. + parent constraints vertical exact: 400. + parent layout rowCount: 1. + + parent addChildren: { + childA. + childB. + childC }. + parent forceLayout. + + self + assert: childA constraints grid horizontal spec span + equals: (BlGridLayoutInterval min: 0 max: 1). + self + assert: childA constraints grid vertical spec span + equals: (BlGridLayoutInterval min: 0 max: 1). + + self + assert: childB constraints grid horizontal spec span + equals: (BlGridLayoutInterval min: 1 max: 2). + self + assert: childB constraints grid vertical spec span + equals: (BlGridLayoutInterval min: 0 max: 1). + + self + assert: childC constraints grid horizontal spec span + equals: (BlGridLayoutInterval min: 2 max: 3). + self + assert: childC constraints grid vertical spec span + equals: (BlGridLayoutInterval min: 0 max: 1). + ^ parent +] + +{ #category : #tests } +BlGridLayoutTest >> testParentWithGridHorizontalLayout [ + + + | element | + element := BlElement new + border: (BlBorder builder + dashed; + paint: Color red; + width: 3; + build); + layout: BlGridLayout horizontal. + + self assert: element layout class equals: BlGridLayout. + + ^ element +] From e93029c815579de36c1cabd89e56c35a71b744e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Wed, 12 Apr 2023 09:07:15 +0200 Subject: [PATCH 2/8] BlFitChildrenLayoutExamples -> BlFitLayoutTest --- .../BlFitChildrenLayoutExamples.class.st | 409 ------------------ .../BlFitChildrenLayoutTest.class.st | 407 +++++++++++++++++ 2 files changed, 407 insertions(+), 409 deletions(-) delete mode 100644 src/Bloc-Layout-Examples/BlFitChildrenLayoutExamples.class.st create mode 100644 src/Bloc-Layout-Tests/BlFitChildrenLayoutTest.class.st diff --git a/src/Bloc-Layout-Examples/BlFitChildrenLayoutExamples.class.st b/src/Bloc-Layout-Examples/BlFitChildrenLayoutExamples.class.st deleted file mode 100644 index ce4eb1fc1..000000000 --- a/src/Bloc-Layout-Examples/BlFitChildrenLayoutExamples.class.st +++ /dev/null @@ -1,409 +0,0 @@ -Class { - #name : #BlFitChildrenLayoutExamples, - #superclass : #Object, - #category : #'Bloc-Layout-Examples-Fit' -} - -{ #category : #'examples - fit children' } -BlFitChildrenLayoutExamples >> atMost_one_child_at_50x50_negated [ - - | aParentNode aLayout | - - aParentNode := BlLayoutParentNode new - constraints: (BlLayoutCommonConstraints new); - extentSpec: (BlExtentMeasurementSpec atMost: 500@400); - children: { - BlLayoutChildNode new - constraints: BlLayoutCommonConstraints new; - measurement: (BlLayoutNodeComputedMeasurement new - position: (50@50) negated; - extent: 100@100). - }. - - aLayout := BlFitChildrenLayout new. - aLayout measure: aParentNode. - - self assert: aParentNode children layoutBounds equals: { - (50@50) negated corner: (50@50) - }. - self assert: aParentNode extent equals: 100@100. - - aLayout layout: aParentNode. - - self assert: aParentNode children layoutBounds equals: { - (0@0) corner: (100@100) - }. - - ^ aParentNode -] - -{ #category : #'examples - fit children' } -BlFitChildrenLayoutExamples >> exact_one_child_at_50x50_negated [ - - | aParentNode aLayout | - - aParentNode := BlLayoutParentNode new - constraints: (BlLayoutCommonConstraints new); - extentSpec: (BlExtentMeasurementSpec exact: 500@400); - children: { - BlLayoutChildNode new - constraints: BlLayoutCommonConstraints new; - measurement: (BlLayoutNodeComputedMeasurement new - position: (50@50) negated; - extent: 100@100). - }. - - aLayout := BlFitChildrenLayout new. - aLayout measure: aParentNode. - - self assert: aParentNode children layoutBounds equals: { - (50@50) negated corner: (50@50) - }. - self assert: aParentNode extent equals: 500@400. - - aLayout layout: aParentNode. - - self assert: aParentNode children layoutBounds equals: { - (200@150) corner: (300@250) - }. - - ^ aParentNode -] - -{ #category : #'examples - graph' } -BlFitChildrenLayoutExamples >> fitContent_graph [ - - | aParentNode aLayout | - - aParentNode := BlLayoutParentNode new - constraints: (BlLayoutCommonConstraints new); - extentSpec: (BlExtentMeasurementSpec unspecified); - children: (self graphNodesDataRaw collect: [ :bounds | - BlLayoutChildNode new - constraints: BlLayoutCommonConstraints new; - measurement: (BlLayoutNodeComputedMeasurement new - position: bounds origin; - extent: bounds extent) ]). - - aLayout := BlFitChildrenLayout new. - aLayout measure: aParentNode. - aLayout layout: aParentNode. - - self assert: aParentNode extent equals: (966.0@126.0). - self - assert: aParentNode children layoutBounds - equals: self graphNodesDataLayedOut. - - ^ aParentNode -] - -{ #category : #'examples - fit children' } -BlFitChildrenLayoutExamples >> fitContent_one_child_at_0x0 [ - - | aParentNode aLayout | - - aParentNode := BlLayoutParentNode new - constraints: (BlLayoutCommonConstraints new); - extentSpec: (BlExtentMeasurementSpec unspecified); - children: { - BlLayoutChildNode new - constraints: BlLayoutCommonConstraints new; - measurement: (BlLayoutNodeComputedMeasurement new - position: 0@0; - extent: 100@100). - }. - - aLayout := BlFitChildrenLayout new. - aLayout measure: aParentNode. - - self assert: aParentNode children layoutBounds equals: { - (0@0) corner: (100@100) - }. - self assert: aParentNode extent equals: 100@100. - - aLayout layout: aParentNode. - - self assert: aParentNode children layoutBounds equals: { - (0@0) corner: (100@100) - }. - - ^ aParentNode -] - -{ #category : #'examples - fit children' } -BlFitChildrenLayoutExamples >> fitContent_one_child_at_50x50 [ - - | aParentNode aLayout | - - aParentNode := BlLayoutParentNode new - constraints: (BlLayoutCommonConstraints new); - extentSpec: (BlExtentMeasurementSpec unspecified); - children: { - BlLayoutChildNode new - constraints: BlLayoutCommonConstraints new; - measurement: (BlLayoutNodeComputedMeasurement new - position: 50@50; - extent: 100@100). - }. - - aLayout := BlFitChildrenLayout new. - aLayout measure: aParentNode. - - self assert: aParentNode children layoutBounds equals: { - (50@50) corner: (150@150) - }. - self assert: aParentNode extent equals: 100@100. - - aLayout layout: aParentNode. - - self assert: aParentNode children layoutBounds equals: { - (0@0) corner: (100@100) - }. - - ^ aParentNode -] - -{ #category : #'examples - fit children' } -BlFitChildrenLayoutExamples >> fitContent_one_child_at_50x50_negated [ - - | aParentNode aLayout | - - aParentNode := BlLayoutParentNode new - constraints: (BlLayoutCommonConstraints new); - extentSpec: (BlExtentMeasurementSpec unspecified); - children: { - BlLayoutChildNode new - constraints: BlLayoutCommonConstraints new; - measurement: (BlLayoutNodeComputedMeasurement new - position: (50@50) negated; - extent: 100@100). - }. - - aLayout := BlFitChildrenLayout new. - aLayout measure: aParentNode. - - self assert: aParentNode children layoutBounds equals: { - (50@50) negated corner: (50@50) - }. - self assert: aParentNode extent equals: 100@100. - - aLayout layout: aParentNode. - - self assert: aParentNode children layoutBounds equals: { - (0@0) corner: (100@100) - }. - - ^ aParentNode -] - -{ #category : #'examples - graph' } -BlFitChildrenLayoutExamples >> graphNodesDataLayedOut [ - ^ { - (610.5@0.5) corner: (615.5@5.5). - (460.5@20.5) corner: (465.5@25.5). - (730.5@20.5) corner: (735.5@25.5). - (230.5@40.5) corner: (235.5@45.5). - (460.5@40.5) corner: (465.5@45.5). - (730.5@40.5) corner: (735.5@45.5). - (850.5@40.5) corner: (855.5@45.5). - (110.5@60.5) corner: (115.5@65.5). - (230.5@60.5) corner: (235.5@65.5). - (430.5@60.5) corner: (435.5@65.5). - (510.5@60.5) corner: (515.5@65.5). - (710.5@60.5) corner: (715.5@65.5). - (750.5@60.5) corner: (755.5@65.5). - (850.5@60.5) corner: (855.5@65.5). - (910.5@60.5) corner: (915.5@65.5). - (50.5@80.5) corner: (55.5@85.5). - (110.5@80.5) corner: (115.5@85.5). - (210.5@80.5) corner: (215.5@85.5). - (250.5@80.5) corner: (255.5@85.5). - (370.5@80.5) corner: (375.5@85.5). - (430.5@80.5) corner: (435.5@85.5). - (510.5@80.5) corner: (515.5@85.5). - (570.5@80.5) corner: (575.5@85.5). - (680.5@80.5) corner: (685.5@85.5). - (710.5@80.5) corner: (715.5@85.5). - (750.5@80.5) corner: (755.5@85.5). - (780.5@80.5) corner: (785.5@85.5). - (840.5@80.5) corner: (845.5@85.5). - (860.5@80.5) corner: (865.5@85.5). - (910.5@80.5) corner: (915.5@85.5). - (940.5@80.5) corner: (945.5@85.5). - (20.5@100.5) corner: (25.5@105.5). - (50.5@100.5) corner: (55.5@105.5). - (100.5@100.5) corner: (105.5@105.5). - (120.5@100.5) corner: (125.5@105.5). - (180.5@100.5) corner: (185.5@105.5). - (210.5@100.5) corner: (215.5@105.5). - (250.5@100.5) corner: (255.5@105.5). - (280.5@100.5) corner: (285.5@105.5). - (340.5@100.5) corner: (345.5@105.5). - (370.5@100.5) corner: (375.5@105.5). - (420.5@100.5) corner: (425.5@105.5). - (440.5@100.5) corner: (445.5@105.5). - (500.5@100.5) corner: (505.5@105.5). - (520.5@100.5) corner: (525.5@105.5). - (570.5@100.5) corner: (575.5@105.5). - (600.5@100.5) corner: (605.5@105.5). - (660.5@100.5) corner: (665.5@105.5). - (680.5@100.5) corner: (685.5@105.5). - (700.5@100.5) corner: (705.5@105.5). - (720.5@100.5) corner: (725.5@105.5). - (740.5@100.5) corner: (745.5@105.5). - (760.5@100.5) corner: (765.5@105.5). - (780.5@100.5) corner: (785.5@105.5). - (800.5@100.5) corner: (805.5@105.5). - (820.5@100.5) corner: (825.5@105.5). - (840.5@100.5) corner: (845.5@105.5). - (860.5@100.5) corner: (865.5@105.5). - (880.5@100.5) corner: (885.5@105.5). - (900.5@100.5) corner: (905.5@105.5). - (920.5@100.5) corner: (925.5@105.5). - (940.5@100.5) corner: (945.5@105.5). - (960.5@100.5) corner: (965.5@105.5). - (0.5@120.5) corner: (5.5@125.5). - (20.5@120.5) corner: (25.5@125.5). - (40.5@120.5) corner: (45.5@125.5). - (60.5@120.5) corner: (65.5@125.5). - (80.5@120.5) corner: (85.5@125.5). - (100.5@120.5) corner: (105.5@125.5). - (120.5@120.5) corner: (125.5@125.5). - (140.5@120.5) corner: (145.5@125.5). - (160.5@120.5) corner: (165.5@125.5). - (180.5@120.5) corner: (185.5@125.5). - (200.5@120.5) corner: (205.5@125.5). - (220.5@120.5) corner: (225.5@125.5). - (240.5@120.5) corner: (245.5@125.5). - (260.5@120.5) corner: (265.5@125.5). - (280.5@120.5) corner: (285.5@125.5). - (300.5@120.5) corner: (305.5@125.5). - (320.5@120.5) corner: (325.5@125.5). - (340.5@120.5) corner: (345.5@125.5). - (360.5@120.5) corner: (365.5@125.5). - (380.5@120.5) corner: (385.5@125.5). - (400.5@120.5) corner: (405.5@125.5). - (420.5@120.5) corner: (425.5@125.5). - (440.5@120.5) corner: (445.5@125.5). - (460.5@120.5) corner: (465.5@125.5). - (480.5@120.5) corner: (485.5@125.5). - (500.5@120.5) corner: (505.5@125.5). - (520.5@120.5) corner: (525.5@125.5). - (540.5@120.5) corner: (545.5@125.5). - (560.5@120.5) corner: (565.5@125.5). - (580.5@120.5) corner: (585.5@125.5). - (600.5@120.5) corner: (605.5@125.5). - (620.5@120.5) corner: (625.5@125.5). - (640.5@120.5) corner: (645.5@125.5). - (660.5@120.5) corner: (665.5@125.5). - (680.5@120.5) corner: (685.5@125.5). - (700.5@120.5) corner: (705.5@125.5). - (720.5@120.5) corner: (725.5@125.5) - } -] - -{ #category : #'examples - graph' } -BlFitChildrenLayoutExamples >> graphNodesDataRaw [ - ^ { - (180.5@ -9.5) corner: (185.5@ -4.5). - (30.5@10.5) corner: (35.5@15.5). - (300.5@10.5) corner: (305.5@15.5). - (-199.5@30.5) corner: (-194.5@35.5). - (30.5@30.5) corner: (35.5@35.5). - (300.5@30.5) corner: (305.5@35.5). - (420.5@30.5) corner: (425.5@35.5). - (-319.5@50.5) corner: (-314.5@55.5). - (-199.5@50.5) corner: (-194.5@55.5). - (0.5@50.5) corner: (5.5@55.5). - (80.5@50.5) corner: (85.5@55.5). - (280.5@50.5) corner: (285.5@55.5). - (320.5@50.5) corner: (325.5@55.5). - (420.5@50.5) corner: (425.5@55.5). - (480.5@50.5) corner: (485.5@55.5). - (-379.5@70.5) corner: (-374.5@75.5). - (-319.5@70.5) corner: (-314.5@75.5). - (-219.5@70.5) corner: (-214.5@75.5). - (-179.5@70.5) corner: (-174.5@75.5). - (-59.5@70.5) corner: (-54.5@75.5). - (0.5@70.5) corner: (5.5@75.5). - (80.5@70.5) corner: (85.5@75.5). - (140.5@70.5) corner: (145.5@75.5). - (250.5@70.5) corner: (255.5@75.5). - (280.5@70.5) corner: (285.5@75.5). - (320.5@70.5) corner: (325.5@75.5). - (350.5@70.5) corner: (355.5@75.5). - (410.5@70.5) corner: (415.5@75.5). - (430.5@70.5) corner: (435.5@75.5). - (480.5@70.5) corner: (485.5@75.5). - (510.5@70.5) corner: (515.5@75.5). - (-409.5@90.5) corner: (-404.5@95.5). - (-379.5@90.5) corner: (-374.5@95.5). - (-329.5@90.5) corner: (-324.5@95.5). - (-309.5@90.5) corner: (-304.5@95.5). - (-249.5@90.5) corner: (-244.5@95.5). - (-219.5@90.5) corner: (-214.5@95.5). - (-179.5@90.5) corner: (-174.5@95.5). - (-149.5@90.5) corner: (-144.5@95.5). - (-89.5@90.5) corner: (-84.5@95.5). - (-59.5@90.5) corner: (-54.5@95.5). - (-9.5@90.5) corner: (-4.5@95.5). - (10.5@90.5) corner: (15.5@95.5). - (70.5@90.5) corner: (75.5@95.5). - (90.5@90.5) corner: (95.5@95.5). - (140.5@90.5) corner: (145.5@95.5). - (170.5@90.5) corner: (175.5@95.5). - (230.5@90.5) corner: (235.5@95.5). - (250.5@90.5) corner: (255.5@95.5). - (270.5@90.5) corner: (275.5@95.5). - (290.5@90.5) corner: (295.5@95.5). - (310.5@90.5) corner: (315.5@95.5). - (330.5@90.5) corner: (335.5@95.5). - (350.5@90.5) corner: (355.5@95.5). - (370.5@90.5) corner: (375.5@95.5). - (390.5@90.5) corner: (395.5@95.5). - (410.5@90.5) corner: (415.5@95.5). - (430.5@90.5) corner: (435.5@95.5). - (450.5@90.5) corner: (455.5@95.5). - (470.5@90.5) corner: (475.5@95.5). - (490.5@90.5) corner: (495.5@95.5). - (510.5@90.5) corner: (515.5@95.5). - (530.5@90.5) corner: (535.5@95.5). - (-429.5@110.5) corner: (-424.5@115.5). - (-409.5@110.5) corner: (-404.5@115.5). - (-389.5@110.5) corner: (-384.5@115.5). - (-369.5@110.5) corner: (-364.5@115.5). - (-349.5@110.5) corner: (-344.5@115.5). - (-329.5@110.5) corner: (-324.5@115.5). - (-309.5@110.5) corner: (-304.5@115.5). - (-289.5@110.5) corner: (-284.5@115.5). - (-269.5@110.5) corner: (-264.5@115.5). - (-249.5@110.5) corner: (-244.5@115.5). - (-229.5@110.5) corner: (-224.5@115.5). - (-209.5@110.5) corner: (-204.5@115.5). - (-189.5@110.5) corner: (-184.5@115.5). - (-169.5@110.5) corner: (-164.5@115.5). - (-149.5@110.5) corner: (-144.5@115.5). - (-129.5@110.5) corner: (-124.5@115.5). - (-109.5@110.5) corner: (-104.5@115.5). - (-89.5@110.5) corner: (-84.5@115.5). - (-69.5@110.5) corner: (-64.5@115.5). - (-49.5@110.5) corner: (-44.5@115.5). - (-29.5@110.5) corner: (-24.5@115.5). - (-9.5@110.5) corner: (-4.5@115.5). - (10.5@110.5) corner: (15.5@115.5). - (30.5@110.5) corner: (35.5@115.5). - (50.5@110.5) corner: (55.5@115.5). - (70.5@110.5) corner: (75.5@115.5). - (90.5@110.5) corner: (95.5@115.5). - (110.5@110.5) corner: (115.5@115.5). - (130.5@110.5) corner: (135.5@115.5). - (150.5@110.5) corner: (155.5@115.5). - (170.5@110.5) corner: (175.5@115.5). - (190.5@110.5) corner: (195.5@115.5). - (210.5@110.5) corner: (215.5@115.5). - (230.5@110.5) corner: (235.5@115.5). - (250.5@110.5) corner: (255.5@115.5). - (270.5@110.5) corner: (275.5@115.5). - (290.5@110.5) corner: (295.5@115.5) - } -] diff --git a/src/Bloc-Layout-Tests/BlFitChildrenLayoutTest.class.st b/src/Bloc-Layout-Tests/BlFitChildrenLayoutTest.class.st new file mode 100644 index 000000000..bfebf8cfd --- /dev/null +++ b/src/Bloc-Layout-Tests/BlFitChildrenLayoutTest.class.st @@ -0,0 +1,407 @@ +" +I have been automatically converted and probably manually tweaked from BlFitChildrenLayoutExamples. 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 : #BlFitChildrenLayoutTest, + #superclass : #TestCase, + #category : #'Bloc-Layout-Tests' +} + +{ #category : #fixture } +BlFitChildrenLayoutTest >> graphNodesDataLayedOut [ + + ^ { + (610.5 @ 0.5 corner: 615.5 @ 5.5). + (460.5 @ 20.5 corner: 465.5 @ 25.5). + (730.5 @ 20.5 corner: 735.5 @ 25.5). + (230.5 @ 40.5 corner: 235.5 @ 45.5). + (460.5 @ 40.5 corner: 465.5 @ 45.5). + (730.5 @ 40.5 corner: 735.5 @ 45.5). + (850.5 @ 40.5 corner: 855.5 @ 45.5). + (110.5 @ 60.5 corner: 115.5 @ 65.5). + (230.5 @ 60.5 corner: 235.5 @ 65.5). + (430.5 @ 60.5 corner: 435.5 @ 65.5). + (510.5 @ 60.5 corner: 515.5 @ 65.5). + (710.5 @ 60.5 corner: 715.5 @ 65.5). + (750.5 @ 60.5 corner: 755.5 @ 65.5). + (850.5 @ 60.5 corner: 855.5 @ 65.5). + (910.5 @ 60.5 corner: 915.5 @ 65.5). + (50.5 @ 80.5 corner: 55.5 @ 85.5). + (110.5 @ 80.5 corner: 115.5 @ 85.5). + (210.5 @ 80.5 corner: 215.5 @ 85.5). + (250.5 @ 80.5 corner: 255.5 @ 85.5). + (370.5 @ 80.5 corner: 375.5 @ 85.5). + (430.5 @ 80.5 corner: 435.5 @ 85.5). + (510.5 @ 80.5 corner: 515.5 @ 85.5). + (570.5 @ 80.5 corner: 575.5 @ 85.5). + (680.5 @ 80.5 corner: 685.5 @ 85.5). + (710.5 @ 80.5 corner: 715.5 @ 85.5). + (750.5 @ 80.5 corner: 755.5 @ 85.5). + (780.5 @ 80.5 corner: 785.5 @ 85.5). + (840.5 @ 80.5 corner: 845.5 @ 85.5). + (860.5 @ 80.5 corner: 865.5 @ 85.5). + (910.5 @ 80.5 corner: 915.5 @ 85.5). + (940.5 @ 80.5 corner: 945.5 @ 85.5). + (20.5 @ 100.5 corner: 25.5 @ 105.5). + (50.5 @ 100.5 corner: 55.5 @ 105.5). + (100.5 @ 100.5 corner: 105.5 @ 105.5). + (120.5 @ 100.5 corner: 125.5 @ 105.5). + (180.5 @ 100.5 corner: 185.5 @ 105.5). + (210.5 @ 100.5 corner: 215.5 @ 105.5). + (250.5 @ 100.5 corner: 255.5 @ 105.5). + (280.5 @ 100.5 corner: 285.5 @ 105.5). + (340.5 @ 100.5 corner: 345.5 @ 105.5). + (370.5 @ 100.5 corner: 375.5 @ 105.5). + (420.5 @ 100.5 corner: 425.5 @ 105.5). + (440.5 @ 100.5 corner: 445.5 @ 105.5). + (500.5 @ 100.5 corner: 505.5 @ 105.5). + (520.5 @ 100.5 corner: 525.5 @ 105.5). + (570.5 @ 100.5 corner: 575.5 @ 105.5). + (600.5 @ 100.5 corner: 605.5 @ 105.5). + (660.5 @ 100.5 corner: 665.5 @ 105.5). + (680.5 @ 100.5 corner: 685.5 @ 105.5). + (700.5 @ 100.5 corner: 705.5 @ 105.5). + (720.5 @ 100.5 corner: 725.5 @ 105.5). + (740.5 @ 100.5 corner: 745.5 @ 105.5). + (760.5 @ 100.5 corner: 765.5 @ 105.5). + (780.5 @ 100.5 corner: 785.5 @ 105.5). + (800.5 @ 100.5 corner: 805.5 @ 105.5). + (820.5 @ 100.5 corner: 825.5 @ 105.5). + (840.5 @ 100.5 corner: 845.5 @ 105.5). + (860.5 @ 100.5 corner: 865.5 @ 105.5). + (880.5 @ 100.5 corner: 885.5 @ 105.5). + (900.5 @ 100.5 corner: 905.5 @ 105.5). + (920.5 @ 100.5 corner: 925.5 @ 105.5). + (940.5 @ 100.5 corner: 945.5 @ 105.5). + (960.5 @ 100.5 corner: 965.5 @ 105.5). + (0.5 @ 120.5 corner: 5.5 @ 125.5). + (20.5 @ 120.5 corner: 25.5 @ 125.5). + (40.5 @ 120.5 corner: 45.5 @ 125.5). + (60.5 @ 120.5 corner: 65.5 @ 125.5). + (80.5 @ 120.5 corner: 85.5 @ 125.5). + (100.5 @ 120.5 corner: 105.5 @ 125.5). + (120.5 @ 120.5 corner: 125.5 @ 125.5). + (140.5 @ 120.5 corner: 145.5 @ 125.5). + (160.5 @ 120.5 corner: 165.5 @ 125.5). + (180.5 @ 120.5 corner: 185.5 @ 125.5). + (200.5 @ 120.5 corner: 205.5 @ 125.5). + (220.5 @ 120.5 corner: 225.5 @ 125.5). + (240.5 @ 120.5 corner: 245.5 @ 125.5). + (260.5 @ 120.5 corner: 265.5 @ 125.5). + (280.5 @ 120.5 corner: 285.5 @ 125.5). + (300.5 @ 120.5 corner: 305.5 @ 125.5). + (320.5 @ 120.5 corner: 325.5 @ 125.5). + (340.5 @ 120.5 corner: 345.5 @ 125.5). + (360.5 @ 120.5 corner: 365.5 @ 125.5). + (380.5 @ 120.5 corner: 385.5 @ 125.5). + (400.5 @ 120.5 corner: 405.5 @ 125.5). + (420.5 @ 120.5 corner: 425.5 @ 125.5). + (440.5 @ 120.5 corner: 445.5 @ 125.5). + (460.5 @ 120.5 corner: 465.5 @ 125.5). + (480.5 @ 120.5 corner: 485.5 @ 125.5). + (500.5 @ 120.5 corner: 505.5 @ 125.5). + (520.5 @ 120.5 corner: 525.5 @ 125.5). + (540.5 @ 120.5 corner: 545.5 @ 125.5). + (560.5 @ 120.5 corner: 565.5 @ 125.5). + (580.5 @ 120.5 corner: 585.5 @ 125.5). + (600.5 @ 120.5 corner: 605.5 @ 125.5). + (620.5 @ 120.5 corner: 625.5 @ 125.5). + (640.5 @ 120.5 corner: 645.5 @ 125.5). + (660.5 @ 120.5 corner: 665.5 @ 125.5). + (680.5 @ 120.5 corner: 685.5 @ 125.5). + (700.5 @ 120.5 corner: 705.5 @ 125.5). + (720.5 @ 120.5 corner: 725.5 @ 125.5) } +] + +{ #category : #fixture } +BlFitChildrenLayoutTest >> graphNodesDataRaw [ + + ^ { + (180.5 @ -9.5 corner: 185.5 @ -4.5). + (30.5 @ 10.5 corner: 35.5 @ 15.5). + (300.5 @ 10.5 corner: 305.5 @ 15.5). + (-199.5 @ 30.5 corner: -194.5 @ 35.5). + (30.5 @ 30.5 corner: 35.5 @ 35.5). + (300.5 @ 30.5 corner: 305.5 @ 35.5). + (420.5 @ 30.5 corner: 425.5 @ 35.5). + (-319.5 @ 50.5 corner: -314.5 @ 55.5). + (-199.5 @ 50.5 corner: -194.5 @ 55.5). + (0.5 @ 50.5 corner: 5.5 @ 55.5). + (80.5 @ 50.5 corner: 85.5 @ 55.5). + (280.5 @ 50.5 corner: 285.5 @ 55.5). + (320.5 @ 50.5 corner: 325.5 @ 55.5). + (420.5 @ 50.5 corner: 425.5 @ 55.5). + (480.5 @ 50.5 corner: 485.5 @ 55.5). + (-379.5 @ 70.5 corner: -374.5 @ 75.5). + (-319.5 @ 70.5 corner: -314.5 @ 75.5). + (-219.5 @ 70.5 corner: -214.5 @ 75.5). + (-179.5 @ 70.5 corner: -174.5 @ 75.5). + (-59.5 @ 70.5 corner: -54.5 @ 75.5). + (0.5 @ 70.5 corner: 5.5 @ 75.5). + (80.5 @ 70.5 corner: 85.5 @ 75.5). + (140.5 @ 70.5 corner: 145.5 @ 75.5). + (250.5 @ 70.5 corner: 255.5 @ 75.5). + (280.5 @ 70.5 corner: 285.5 @ 75.5). + (320.5 @ 70.5 corner: 325.5 @ 75.5). + (350.5 @ 70.5 corner: 355.5 @ 75.5). + (410.5 @ 70.5 corner: 415.5 @ 75.5). + (430.5 @ 70.5 corner: 435.5 @ 75.5). + (480.5 @ 70.5 corner: 485.5 @ 75.5). + (510.5 @ 70.5 corner: 515.5 @ 75.5). + (-409.5 @ 90.5 corner: -404.5 @ 95.5). + (-379.5 @ 90.5 corner: -374.5 @ 95.5). + (-329.5 @ 90.5 corner: -324.5 @ 95.5). + (-309.5 @ 90.5 corner: -304.5 @ 95.5). + (-249.5 @ 90.5 corner: -244.5 @ 95.5). + (-219.5 @ 90.5 corner: -214.5 @ 95.5). + (-179.5 @ 90.5 corner: -174.5 @ 95.5). + (-149.5 @ 90.5 corner: -144.5 @ 95.5). + (-89.5 @ 90.5 corner: -84.5 @ 95.5). + (-59.5 @ 90.5 corner: -54.5 @ 95.5). + (-9.5 @ 90.5 corner: -4.5 @ 95.5). + (10.5 @ 90.5 corner: 15.5 @ 95.5). + (70.5 @ 90.5 corner: 75.5 @ 95.5). + (90.5 @ 90.5 corner: 95.5 @ 95.5). + (140.5 @ 90.5 corner: 145.5 @ 95.5). + (170.5 @ 90.5 corner: 175.5 @ 95.5). + (230.5 @ 90.5 corner: 235.5 @ 95.5). + (250.5 @ 90.5 corner: 255.5 @ 95.5). + (270.5 @ 90.5 corner: 275.5 @ 95.5). + (290.5 @ 90.5 corner: 295.5 @ 95.5). + (310.5 @ 90.5 corner: 315.5 @ 95.5). + (330.5 @ 90.5 corner: 335.5 @ 95.5). + (350.5 @ 90.5 corner: 355.5 @ 95.5). + (370.5 @ 90.5 corner: 375.5 @ 95.5). + (390.5 @ 90.5 corner: 395.5 @ 95.5). + (410.5 @ 90.5 corner: 415.5 @ 95.5). + (430.5 @ 90.5 corner: 435.5 @ 95.5). + (450.5 @ 90.5 corner: 455.5 @ 95.5). + (470.5 @ 90.5 corner: 475.5 @ 95.5). + (490.5 @ 90.5 corner: 495.5 @ 95.5). + (510.5 @ 90.5 corner: 515.5 @ 95.5). + (530.5 @ 90.5 corner: 535.5 @ 95.5). + (-429.5 @ 110.5 corner: -424.5 @ 115.5). + (-409.5 @ 110.5 corner: -404.5 @ 115.5). + (-389.5 @ 110.5 corner: -384.5 @ 115.5). + (-369.5 @ 110.5 corner: -364.5 @ 115.5). + (-349.5 @ 110.5 corner: -344.5 @ 115.5). + (-329.5 @ 110.5 corner: -324.5 @ 115.5). + (-309.5 @ 110.5 corner: -304.5 @ 115.5). + (-289.5 @ 110.5 corner: -284.5 @ 115.5). + (-269.5 @ 110.5 corner: -264.5 @ 115.5). + (-249.5 @ 110.5 corner: -244.5 @ 115.5). + (-229.5 @ 110.5 corner: -224.5 @ 115.5). + (-209.5 @ 110.5 corner: -204.5 @ 115.5). + (-189.5 @ 110.5 corner: -184.5 @ 115.5). + (-169.5 @ 110.5 corner: -164.5 @ 115.5). + (-149.5 @ 110.5 corner: -144.5 @ 115.5). + (-129.5 @ 110.5 corner: -124.5 @ 115.5). + (-109.5 @ 110.5 corner: -104.5 @ 115.5). + (-89.5 @ 110.5 corner: -84.5 @ 115.5). + (-69.5 @ 110.5 corner: -64.5 @ 115.5). + (-49.5 @ 110.5 corner: -44.5 @ 115.5). + (-29.5 @ 110.5 corner: -24.5 @ 115.5). + (-9.5 @ 110.5 corner: -4.5 @ 115.5). + (10.5 @ 110.5 corner: 15.5 @ 115.5). + (30.5 @ 110.5 corner: 35.5 @ 115.5). + (50.5 @ 110.5 corner: 55.5 @ 115.5). + (70.5 @ 110.5 corner: 75.5 @ 115.5). + (90.5 @ 110.5 corner: 95.5 @ 115.5). + (110.5 @ 110.5 corner: 115.5 @ 115.5). + (130.5 @ 110.5 corner: 135.5 @ 115.5). + (150.5 @ 110.5 corner: 155.5 @ 115.5). + (170.5 @ 110.5 corner: 175.5 @ 115.5). + (190.5 @ 110.5 corner: 195.5 @ 115.5). + (210.5 @ 110.5 corner: 215.5 @ 115.5). + (230.5 @ 110.5 corner: 235.5 @ 115.5). + (250.5 @ 110.5 corner: 255.5 @ 115.5). + (270.5 @ 110.5 corner: 275.5 @ 115.5). + (290.5 @ 110.5 corner: 295.5 @ 115.5) } +] + +{ #category : #tests } +BlFitChildrenLayoutTest >> testAtMostOneChildAt50x50Negated [ + + + | aParentNode aLayout | + aParentNode := BlLayoutParentNode new + constraints: BlLayoutCommonConstraints new; + extentSpec: + (BlExtentMeasurementSpec atMost: 500 @ 400); + children: { (BlLayoutChildNode new + constraints: BlLayoutCommonConstraints new; + measurement: (BlLayoutNodeComputedMeasurement new + position: (50 @ 50) negated; + extent: 100 @ 100)) }. + + aLayout := BlFitChildrenLayout new. + aLayout measure: aParentNode. + + self + assert: aParentNode children layoutBounds + equals: { ((50 @ 50) negated corner: 50 @ 50) }. + self assert: aParentNode extent equals: 100 @ 100. + + aLayout layout: aParentNode. + + self + assert: aParentNode children layoutBounds + equals: { (0 @ 0 corner: 100 @ 100) }. + + ^ aParentNode +] + +{ #category : #tests } +BlFitChildrenLayoutTest >> testExactOneChildAt50x50Negated [ + + + | aParentNode aLayout | + aParentNode := BlLayoutParentNode new + constraints: BlLayoutCommonConstraints new; + extentSpec: + (BlExtentMeasurementSpec exact: 500 @ 400); + children: { (BlLayoutChildNode new + constraints: BlLayoutCommonConstraints new; + measurement: (BlLayoutNodeComputedMeasurement new + position: (50 @ 50) negated; + extent: 100 @ 100)) }. + + aLayout := BlFitChildrenLayout new. + aLayout measure: aParentNode. + + self + assert: aParentNode children layoutBounds + equals: { ((50 @ 50) negated corner: 50 @ 50) }. + self assert: aParentNode extent equals: 500 @ 400. + + aLayout layout: aParentNode. + + self + assert: aParentNode children layoutBounds + equals: { (200 @ 150 corner: 300 @ 250) }. + + ^ aParentNode +] + +{ #category : #tests } +BlFitChildrenLayoutTest >> testFitContentGraph [ + + + | aParentNode aLayout | + aParentNode := BlLayoutParentNode new + constraints: BlLayoutCommonConstraints new; + extentSpec: BlExtentMeasurementSpec unspecified; + children: + (self graphNodesDataRaw collect: [ :bounds | + BlLayoutChildNode new + constraints: BlLayoutCommonConstraints new; + measurement: + (BlLayoutNodeComputedMeasurement new + position: bounds origin; + extent: bounds extent) ]). + + aLayout := BlFitChildrenLayout new. + aLayout measure: aParentNode. + aLayout layout: aParentNode. + + self assert: aParentNode extent equals: 966.0 @ 126.0. + self + assert: aParentNode children layoutBounds + equals: self graphNodesDataLayedOut. + + ^ aParentNode +] + +{ #category : #tests } +BlFitChildrenLayoutTest >> testFitContentOneChildAt0x0 [ + + + | aParentNode aLayout | + aParentNode := BlLayoutParentNode new + constraints: BlLayoutCommonConstraints new; + extentSpec: BlExtentMeasurementSpec unspecified; + children: { (BlLayoutChildNode new + constraints: BlLayoutCommonConstraints new; + measurement: (BlLayoutNodeComputedMeasurement new + position: 0 @ 0; + extent: 100 @ 100)) }. + + aLayout := BlFitChildrenLayout new. + aLayout measure: aParentNode. + + self + assert: aParentNode children layoutBounds + equals: { (0 @ 0 corner: 100 @ 100) }. + self assert: aParentNode extent equals: 100 @ 100. + + aLayout layout: aParentNode. + + self + assert: aParentNode children layoutBounds + equals: { (0 @ 0 corner: 100 @ 100) }. + + ^ aParentNode +] + +{ #category : #tests } +BlFitChildrenLayoutTest >> testFitContentOneChildAt50x50 [ + + + | aParentNode aLayout | + aParentNode := BlLayoutParentNode new + constraints: BlLayoutCommonConstraints new; + extentSpec: BlExtentMeasurementSpec unspecified; + children: { (BlLayoutChildNode new + constraints: BlLayoutCommonConstraints new; + measurement: (BlLayoutNodeComputedMeasurement new + position: 50 @ 50; + extent: 100 @ 100)) }. + + aLayout := BlFitChildrenLayout new. + aLayout measure: aParentNode. + + self + assert: aParentNode children layoutBounds + equals: { (50 @ 50 corner: 150 @ 150) }. + self assert: aParentNode extent equals: 100 @ 100. + + aLayout layout: aParentNode. + + self + assert: aParentNode children layoutBounds + equals: { (0 @ 0 corner: 100 @ 100) }. + + ^ aParentNode +] + +{ #category : #tests } +BlFitChildrenLayoutTest >> testFitContentOneChildAt50x50Negated [ + + + | aParentNode aLayout | + aParentNode := BlLayoutParentNode new + constraints: BlLayoutCommonConstraints new; + extentSpec: BlExtentMeasurementSpec unspecified; + children: { (BlLayoutChildNode new + constraints: BlLayoutCommonConstraints new; + measurement: (BlLayoutNodeComputedMeasurement new + position: (50 @ 50) negated; + extent: 100 @ 100)) }. + + aLayout := BlFitChildrenLayout new. + aLayout measure: aParentNode. + + self + assert: aParentNode children layoutBounds + equals: { ((50 @ 50) negated corner: 50 @ 50) }. + self assert: aParentNode extent equals: 100 @ 100. + + aLayout layout: aParentNode. + + self + assert: aParentNode children layoutBounds + equals: { (0 @ 0 corner: 100 @ 100) }. + + ^ aParentNode +] From b6c9221ba36d1aea88c6c5e5d96ef142bdda6d49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Wed, 12 Apr 2023 09:12:48 +0200 Subject: [PATCH 3/8] BlFitContent... Examples -> Test --- ...icallyInHorizontalLayoutsExamples.class.st | 613 ---------------- ...VerticallyInHorizontalLayoutsTest.class.st | 684 ++++++++++++++++++ 2 files changed, 684 insertions(+), 613 deletions(-) delete mode 100644 src/Bloc-Layout-Examples/BlFitContentVerticallyInHorizontalLayoutsExamples.class.st create mode 100644 src/Bloc-Layout-Tests/BlFitContentVerticallyInHorizontalLayoutsTest.class.st diff --git a/src/Bloc-Layout-Examples/BlFitContentVerticallyInHorizontalLayoutsExamples.class.st b/src/Bloc-Layout-Examples/BlFitContentVerticallyInHorizontalLayoutsExamples.class.st deleted file mode 100644 index 4cf1656f6..000000000 --- a/src/Bloc-Layout-Examples/BlFitContentVerticallyInHorizontalLayoutsExamples.class.st +++ /dev/null @@ -1,613 +0,0 @@ -" -I exemplify what happens if we compose horizontal grid, linear and flow layout and configure them to fit content vertically. - -This is a very important use case for complex UIs that involve vertical lists -" -Class { - #name : #BlFitContentVerticallyInHorizontalLayoutsExamples, - #superclass : #BlExampleTest, - #category : #'Bloc-Layout-Examples-Fit' -} - -{ #category : #'instance creation' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> blue [ - - - ^ self box - size: self blueWidth @ self blueHeight; - border: (BlBorder paint: (Color blue alpha: 0.6) width: 1); - background: (Color blue alpha: 0.3); - margin: self blueMargin -] - -{ #category : #'private - configuration' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> blueHeight [ - ^ 100 -] - -{ #category : #'private - configuration' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> blueMargin [ - ^ BlInsets right: self boxMargin -] - -{ #category : #'private - configuration' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> blueWidth [ - ^ 75 -] - -{ #category : #'instance creation' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> box [ - - - ^ BlElement new -] - -{ #category : #'private - configuration' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> boxMargin [ - ^ 15 -] - -{ #category : #'instance creation' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> container [ - - - ^ BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical fitContent ]; - background: (Color gray alpha: 0.2); - padding: (BlInsets all: self containerPadding) -] - -{ #category : #'private - configuration' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> containerPadding [ - ^ 25 -] - -{ #category : #'instance creation' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> flow [ - - - ^ self container - layout: BlFlowLayout horizontal; - addChild: (self layoutLabel: 'Flow') -] - -{ #category : #'instance creation' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> green [ - - - ^ self box - size: self greenWidth @ self greenHeight; - border: (BlBorder paint: (Color green muchDarker alpha: 0.6) width: 1); - background: (Color green darker alpha: 0.3); - margin: self greenMargin -] - -{ #category : #'private - configuration' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> greenHeight [ - ^ 80 -] - -{ #category : #'private - configuration' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> greenMargin [ - ^ BlInsets top: self boxMargin -] - -{ #category : #'private - configuration' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> greenWidth [ - ^ 150 -] - -{ #category : #'instance creation' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> grid [ - - - ^ self container - layout: BlGridLayout horizontal; - addChild: (self layoutLabel: 'Grid') -] - -{ #category : #'private - helpers' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> layoutLabel: aString [ - ^ BlTextElement new - text: (aString asRopedText thin fontSize: 10); - padding: (BlInsets top: 5); - constraintsDo: [ :c | - c ignoreByLayout. - c ignored horizontal alignCenter ] -] - -{ #category : #'instance creation' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> list [ - - - ^ self container - layout: BlLinearLayout horizontal; - addChild: (self layoutLabel: 'List') -] - -{ #category : #'private - measurement' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> oneColumnExtentDepth: aNumber [ - - ^ (self oneColumnWidthDepth: aNumber) @ (self oneColumnHeightDepth: aNumber) -] - -{ #category : #examples } -BlFitContentVerticallyInHorizontalLayoutsExamples >> oneColumnFlow [ - - | flow | - - flow := self flow. - flow width: (self oneColumnWidthDepth: 1). - flow addChildren: { self red. self blue. self green }. - flow forceLayout. - - self assert: flow extent equals: (self oneColumnExtentDepth: 1). - - ^ flow -] - -{ #category : #examples } -BlFitContentVerticallyInHorizontalLayoutsExamples >> oneColumnFlowGridGrid [ - - | flow firstGrid secondGrid | - - flow := self flow. - flow addChildren: { self red. self blue. self green }. - - firstGrid := self grid. - firstGrid addChild: flow. - - secondGrid := self grid. - secondGrid width: (self oneColumnWidthDepth: 3). - secondGrid addChild: firstGrid. - secondGrid forceLayout. - - self assert: flow extent equals: (self oneColumnExtentDepth: 1). - self assert: firstGrid extent equals: (self oneColumnExtentDepth: 2). - self assert: secondGrid extent equals: (self oneColumnExtentDepth: 3). - - ^ secondGrid -] - -{ #category : #examples } -BlFitContentVerticallyInHorizontalLayoutsExamples >> oneColumnFlowList [ - - | flow list | - - flow := self flow. - flow addChildren: { self red. self blue. self green }. - - list := self list. - list width: (self oneColumnWidthDepth: 2) + 1. - list addChild: flow. - - list forceLayout. - list width: (self oneColumnWidthDepth: 2). - list forceLayout. - - self assert: flow extent equals: (self oneColumnExtentDepth: 1). - self assert: list extent equals: (self oneColumnExtentDepth: 2). - - ^ list -] - -{ #category : #examples } -BlFitContentVerticallyInHorizontalLayoutsExamples >> oneColumnFlowListGrid [ - - | flow list grid | - - flow := self flow. - flow addChildren: { self red. self blue. self green }. - - list := self list. - list addChild: flow. - - grid := self grid. - grid width: (self oneColumnWidthDepth: 3). - grid addChild: list. - grid forceLayout. - - self assert: flow extent equals: (self oneColumnExtentDepth: 1). - self assert: list extent equals: (self oneColumnExtentDepth: 2). - self assert: grid extent equals: (self oneColumnExtentDepth: 3). - - ^ grid -] - -{ #category : #examples } -BlFitContentVerticallyInHorizontalLayoutsExamples >> oneColumnFlowListList [ - - | flow firstList secondList | - - flow := self flow. - flow addChildren: { self red. self blue. self green }. - - firstList := self list. - firstList addChild: flow. - - secondList := self list. - secondList width: (self oneColumnWidthDepth: 3). - secondList addChild: firstList. - secondList forceLayout. - - self assert: flow extent equals: (self oneColumnExtentDepth: 1). - self assert: firstList extent equals: (self oneColumnExtentDepth: 2). - self assert: secondList extent equals: (self oneColumnExtentDepth: 3). - - ^ secondList -] - -{ #category : #'private - measurement' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> oneColumnHeight [ - - ^ { - self redHeight + self redMargin height. - self blueHeight + self blueMargin height. - self greenHeight + self greenMargin height. - } sum -] - -{ #category : #'private - measurement' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> oneColumnHeightDepth: aNumber [ - - ^ self oneColumnHeight + ((self containerPadding * 2) * aNumber) -] - -{ #category : #'private - measurement' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> oneColumnWidth [ - - ^ { - self redWidth + self redMargin width. - self blueWidth + self blueMargin width. - self greenWidth + self greenMargin width. - } max -] - -{ #category : #'private - measurement' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> oneColumnWidthDepth: aNumber [ - - ^ self oneColumnWidth + ((self containerPadding * 2) * aNumber) -] - -{ #category : #'instance creation' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> red [ - - - ^ self box - size: self redWidth @ self redHeight; - background: (Color red alpha: 0.3); - border: (BlBorder paint: (Color red alpha: 0.6) width: 1); - margin: self redMargin -] - -{ #category : #'private - configuration' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> redHeight [ - ^ 75 -] - -{ #category : #'private - configuration' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> redMargin [ - ^ (BlInsets top: 0 right: self boxMargin bottom: self boxMargin left: 0) -] - -{ #category : #'private - configuration' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> redWidth [ - ^ 100 -] - -{ #category : #'private - measurement' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> threeColumnExtentDepth: aNumber [ - - ^ (self threeColumnWidthDepth: aNumber) @ (self threeColumnHeightDepth: aNumber) -] - -{ #category : #examples } -BlFitContentVerticallyInHorizontalLayoutsExamples >> threeColumnFlowGridGrid [ - - | flow firstGrid secondGrid | - - flow := self flow. - flow addChildren: { self red. self blue. self green }. - - firstGrid := self grid. - firstGrid addChild: flow. - - secondGrid := self grid. - secondGrid width: (self threeColumnWidthDepth: 3). - secondGrid addChild: firstGrid. - secondGrid forceLayout. - - self assert: flow extent equals: (self threeColumnExtentDepth: 1). - self assert: firstGrid extent equals: (self threeColumnExtentDepth: 2). - self assert: secondGrid extent equals: (self threeColumnExtentDepth: 3). - - ^ secondGrid -] - -{ #category : #examples } -BlFitContentVerticallyInHorizontalLayoutsExamples >> threeColumnFlowListGrid [ - - | flow list grid | - - flow := self flow. - flow addChildren: { self red. self blue. self green }. - - list := self list. - list addChild: flow. - - grid := self grid. - grid width: (self threeColumnWidthDepth: 3). - grid addChild: list. - grid forceLayout. - - self assert: flow extent equals: (self threeColumnExtentDepth: 1). - self assert: list extent equals: (self threeColumnExtentDepth: 2). - self assert: grid extent equals: (self threeColumnExtentDepth: 3). - - ^ grid -] - -{ #category : #examples } -BlFitContentVerticallyInHorizontalLayoutsExamples >> threeColumnFlowListList [ - - | flow firstList secondList | - - flow := self flow. - flow addChildren: { self red. self blue. self green }. - - firstList := self list. - firstList addChild: flow. - - secondList := self list. - secondList width: (self threeColumnWidthDepth: 3). - secondList addChild: firstList. - secondList forceLayout. - - self assert: flow extent equals: (self threeColumnExtentDepth: 1). - self assert: firstList extent equals: (self threeColumnExtentDepth: 2). - self assert: secondList extent equals: (self threeColumnExtentDepth: 3). - - ^ secondList -] - -{ #category : #'private - measurement' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> threeColumnHeight [ - - ^ { - self redHeight + self redMargin height. - self blueHeight + self blueMargin height. - self greenHeight + self greenMargin height - } max -] - -{ #category : #'private - measurement' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> threeColumnHeightDepth: aNumber [ - - ^ self threeColumnHeight + ((self containerPadding * 2) * aNumber) -] - -{ #category : #'private - measurement' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> threeColumnWidth [ - - ^ { - self redWidth + self redMargin width. - self blueWidth + self blueMargin width. - self greenWidth + self greenMargin width. - } sum -] - -{ #category : #'private - measurement' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> threeColumnWidthDepth: aNumber [ - - ^ self threeColumnWidth + ((self containerPadding * 2) * aNumber) -] - -{ #category : #'private - measurement' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> twoColumnExtentDepth: aNumber [ - - ^ (self twoColumnWidthDepth: aNumber) @ (self twoColumnHeightDepth: aNumber) -] - -{ #category : #examples } -BlFitContentVerticallyInHorizontalLayoutsExamples >> twoColumnFlow [ - - | flow | - - flow := self flow. - flow width: (self twoColumnWidthDepth: 1). - flow addChildren: { self red. self blue. self green }. - flow forceLayout. - - self assert: flow extent equals: (self twoColumnExtentDepth: 1). - - ^ flow -] - -{ #category : #examples } -BlFitContentVerticallyInHorizontalLayoutsExamples >> twoColumnFlowFlowFlow [ - - | firstFlow secondFlow thirdFlow | - - firstFlow := self flow. - firstFlow addChildren: { self red. self blue. self green }. - - secondFlow := self flow. - secondFlow addChild: firstFlow. - - thirdFlow := self flow. - thirdFlow width: (self twoColumnWidthDepth: 3). - thirdFlow addChild: secondFlow. - thirdFlow forceLayout. - - self assert: firstFlow extent equals: (self twoColumnExtentDepth: 1). - self assert: secondFlow extent equals: (self twoColumnExtentDepth: 2). - self assert: thirdFlow extent equals: (self twoColumnExtentDepth: 3). - - ^ thirdFlow -] - -{ #category : #examples } -BlFitContentVerticallyInHorizontalLayoutsExamples >> twoColumnFlowFlowList [ - - | firstFlow secondFlow list | - - firstFlow := self flow. - firstFlow addChildren: { self red. self blue. self green }. - - secondFlow := self flow. - secondFlow addChild: firstFlow. - - list := self list. - list width: (self twoColumnWidthDepth: 3). - list addChild: secondFlow. - list forceLayout. - - self assert: firstFlow extent equals: (self twoColumnExtentDepth: 1). - self assert: secondFlow extent equals: (self twoColumnExtentDepth: 2). - self assert: list extent equals: (self twoColumnExtentDepth: 3). - - ^ list -] - -{ #category : #examples } -BlFitContentVerticallyInHorizontalLayoutsExamples >> twoColumnFlowGridGrid [ - - | flow firstGrid secondGrid | - - flow := self flow. - flow addChildren: { self red. self blue. self green }. - - firstGrid := self grid. - firstGrid addChild: flow. - - secondGrid := self grid. - secondGrid width: (self twoColumnWidthDepth: 3). - secondGrid addChild: firstGrid. - secondGrid forceLayout. - - self assert: flow extent equals: (self twoColumnExtentDepth: 1). - self assert: firstGrid extent equals: (self twoColumnExtentDepth: 2). - self assert: secondGrid extent equals: (self twoColumnExtentDepth: 3). - - ^ secondGrid -] - -{ #category : #examples } -BlFitContentVerticallyInHorizontalLayoutsExamples >> twoColumnFlowGridList [ - - | flow grid list | - - flow := self flow. - flow addChildren: { self red. self blue. self green }. - - grid := self grid. - grid addChild: flow. - - list := self list. - list width: (self twoColumnWidthDepth: 3). - list addChild: grid. - list forceLayout. - - self assert: flow extent equals: (self twoColumnExtentDepth: 1). - self assert: grid extent equals: (self twoColumnExtentDepth: 2). - self assert: list extent equals: (self twoColumnExtentDepth: 3). - - ^ list -] - -{ #category : #examples } -BlFitContentVerticallyInHorizontalLayoutsExamples >> twoColumnFlowList [ - - | flow list | - - flow := self flow. - flow addChildren: { self red. self blue. self green }. - - list := self list. - list width: (self twoColumnWidthDepth: 2). - list addChild: flow. - list forceLayout. - - self assert: flow extent equals: (self twoColumnExtentDepth: 1). - self assert: list extent equals: (self twoColumnExtentDepth: 2). - - ^ list -] - -{ #category : #examples } -BlFitContentVerticallyInHorizontalLayoutsExamples >> twoColumnFlowListGrid [ - - | flow list grid | - - flow := self flow. - flow addChildren: { self red. self blue. self green }. - - list := self list. - list addChild: flow. - - grid := self grid. - grid width: (self twoColumnWidthDepth: 3). - grid addChild: list. - grid forceLayout. - - self assert: flow extent equals: (self twoColumnExtentDepth: 1). - self assert: list extent equals: (self twoColumnExtentDepth: 2). - self assert: grid extent equals: (self twoColumnExtentDepth: 3). - - ^ grid -] - -{ #category : #examples } -BlFitContentVerticallyInHorizontalLayoutsExamples >> twoColumnFlowListList [ - - | flow firstList secondList | - - flow := self flow. - flow addChildren: { self red. self blue. self green }. - - firstList := self list. - firstList addChild: flow. - - secondList := self list. - secondList width: (self twoColumnWidthDepth: 3). - secondList addChild: firstList. - secondList forceLayout. - - self assert: flow extent equals: (self twoColumnExtentDepth: 1). - self assert: firstList extent equals: (self twoColumnExtentDepth: 2). - self assert: secondList extent equals: (self twoColumnExtentDepth: 3). - - ^ secondList -] - -{ #category : #'private - measurement' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> twoColumnHeight [ - - ^ { - self redHeight + self redMargin height. - self blueHeight + self blueMargin height. - } max + self greenHeight + self greenMargin height -] - -{ #category : #'private - measurement' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> twoColumnHeightDepth: aNumber [ - - ^ self twoColumnHeight + ((self containerPadding * 2) * aNumber) -] - -{ #category : #'private - measurement' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> twoColumnWidth [ - - ^ { - self redWidth + self redMargin width + self blueWidth + self blueMargin width. - self greenWidth + self greenMargin width. - } max -] - -{ #category : #'private - measurement' } -BlFitContentVerticallyInHorizontalLayoutsExamples >> twoColumnWidthDepth: aNumber [ - - ^ self twoColumnWidth + ((self containerPadding * 2) * aNumber) -] diff --git a/src/Bloc-Layout-Tests/BlFitContentVerticallyInHorizontalLayoutsTest.class.st b/src/Bloc-Layout-Tests/BlFitContentVerticallyInHorizontalLayoutsTest.class.st new file mode 100644 index 000000000..6c700bdc7 --- /dev/null +++ b/src/Bloc-Layout-Tests/BlFitContentVerticallyInHorizontalLayoutsTest.class.st @@ -0,0 +1,684 @@ +" +I have been automatically converted and probably manually tweaked from BlFitContentVerticallyInHorizontalLayoutsExamples. 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 : #BlFitContentVerticallyInHorizontalLayoutsTest, + #superclass : #TestCase, + #category : #'Bloc-Layout-Tests' +} + +{ #category : #tests } +BlFitContentVerticallyInHorizontalLayoutsTest >> blue [ + + + ^ self box + size: self blueWidth @ self blueHeight; + border: (BlBorder paint: (Color blue alpha: 0.6) width: 1); + background: (Color blue alpha: 0.3); + margin: self blueMargin +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> blueHeight [ + + ^ 100 +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> blueMargin [ + + ^ BlInsets right: self boxMargin +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> blueWidth [ + + ^ 75 +] + +{ #category : #tests } +BlFitContentVerticallyInHorizontalLayoutsTest >> box [ + + + ^ BlElement new +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> boxMargin [ + + ^ 15 +] + +{ #category : #tests } +BlFitContentVerticallyInHorizontalLayoutsTest >> container [ + + + ^ BlElement new + constraintsDo: [ :c | + c horizontal matchParent. + c vertical fitContent ]; + background: (Color gray alpha: 0.2); + padding: (BlInsets all: self containerPadding) +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> containerPadding [ + + ^ 25 +] + +{ #category : #tests } +BlFitContentVerticallyInHorizontalLayoutsTest >> flow [ + + + ^ self container + layout: BlFlowLayout horizontal; + addChild: (self layoutLabel: 'Flow') +] + +{ #category : #tests } +BlFitContentVerticallyInHorizontalLayoutsTest >> green [ + + + ^ self box + size: self greenWidth @ self greenHeight; + border: + (BlBorder paint: (Color green muchDarker alpha: 0.6) width: 1); + background: (Color green darker alpha: 0.3); + margin: self greenMargin +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> greenHeight [ + + ^ 80 +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> greenMargin [ + + ^ BlInsets top: self boxMargin +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> greenWidth [ + + ^ 150 +] + +{ #category : #tests } +BlFitContentVerticallyInHorizontalLayoutsTest >> grid [ + + + ^ self container + layout: BlGridLayout horizontal; + addChild: (self layoutLabel: 'Grid') +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> layoutLabel: aString [ + + ^ BlTextElement new + text: (aString asRopedText thin fontSize: 10); + padding: (BlInsets top: 5); + constraintsDo: [ :c | + c ignoreByLayout. + c ignored horizontal alignCenter ] +] + +{ #category : #tests } +BlFitContentVerticallyInHorizontalLayoutsTest >> list [ + + + ^ self container + layout: BlLinearLayout horizontal; + addChild: (self layoutLabel: 'List') +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> oneColumnExtentDepth: aNumber [ + + ^ (self oneColumnWidthDepth: aNumber) + @ (self oneColumnHeightDepth: aNumber) +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> oneColumnHeight [ + + ^ { + (self redHeight + self redMargin height). + (self blueHeight + self blueMargin height). + (self greenHeight + self greenMargin height) } sum +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> oneColumnHeightDepth: aNumber [ + + ^ self oneColumnHeight + (self containerPadding * 2 * aNumber) +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> oneColumnWidth [ + + ^ { + (self redWidth + self redMargin width). + (self blueWidth + self blueMargin width). + (self greenWidth + self greenMargin width) } max +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> oneColumnWidthDepth: aNumber [ + + ^ self oneColumnWidth + (self containerPadding * 2 * aNumber) +] + +{ #category : #tests } +BlFitContentVerticallyInHorizontalLayoutsTest >> red [ + + + ^ self box + size: self redWidth @ self redHeight; + background: (Color red alpha: 0.3); + border: (BlBorder paint: (Color red alpha: 0.6) width: 1); + margin: self redMargin +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> redHeight [ + + ^ 75 +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> redMargin [ + + ^ BlInsets + top: 0 + right: self boxMargin + bottom: self boxMargin + left: 0 +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> redWidth [ + + ^ 100 +] + +{ #category : #tests } +BlFitContentVerticallyInHorizontalLayoutsTest >> testOneColumnFlow [ + + + | flow | + flow := self flow. + flow width: (self oneColumnWidthDepth: 1). + flow addChildren: { + self red. + self blue. + self green }. + flow forceLayout. + + self assert: flow extent equals: (self oneColumnExtentDepth: 1). + + ^ flow +] + +{ #category : #tests } +BlFitContentVerticallyInHorizontalLayoutsTest >> testOneColumnFlowGridGrid [ + + + | flow firstGrid secondGrid | + flow := self flow. + flow addChildren: { + self red. + self blue. + self green }. + + firstGrid := self grid. + firstGrid addChild: flow. + + secondGrid := self grid. + secondGrid width: (self oneColumnWidthDepth: 3). + secondGrid addChild: firstGrid. + secondGrid forceLayout. + + self assert: flow extent equals: (self oneColumnExtentDepth: 1). + self assert: firstGrid extent equals: (self oneColumnExtentDepth: 2). + self assert: secondGrid extent equals: (self oneColumnExtentDepth: 3). + + ^ secondGrid +] + +{ #category : #tests } +BlFitContentVerticallyInHorizontalLayoutsTest >> testOneColumnFlowList [ + + + | flow list | + flow := self flow. + flow addChildren: { + self red. + self blue. + self green }. + + list := self list. + list width: (self oneColumnWidthDepth: 2) + 1. + list addChild: flow. + + list forceLayout. + list width: (self oneColumnWidthDepth: 2). + list forceLayout. + + self assert: flow extent equals: (self oneColumnExtentDepth: 1). + self assert: list extent equals: (self oneColumnExtentDepth: 2). + + ^ list +] + +{ #category : #tests } +BlFitContentVerticallyInHorizontalLayoutsTest >> testOneColumnFlowListGrid [ + + + | flow list grid | + flow := self flow. + flow addChildren: { + self red. + self blue. + self green }. + + list := self list. + list addChild: flow. + + grid := self grid. + grid width: (self oneColumnWidthDepth: 3). + grid addChild: list. + grid forceLayout. + + self assert: flow extent equals: (self oneColumnExtentDepth: 1). + self assert: list extent equals: (self oneColumnExtentDepth: 2). + self assert: grid extent equals: (self oneColumnExtentDepth: 3). + + ^ grid +] + +{ #category : #tests } +BlFitContentVerticallyInHorizontalLayoutsTest >> testOneColumnFlowListList [ + + + | flow firstList secondList | + flow := self flow. + flow addChildren: { + self red. + self blue. + self green }. + + firstList := self list. + firstList addChild: flow. + + secondList := self list. + secondList width: (self oneColumnWidthDepth: 3). + secondList addChild: firstList. + secondList forceLayout. + + self assert: flow extent equals: (self oneColumnExtentDepth: 1). + self assert: firstList extent equals: (self oneColumnExtentDepth: 2). + self assert: secondList extent equals: (self oneColumnExtentDepth: 3). + + ^ secondList +] + +{ #category : #tests } +BlFitContentVerticallyInHorizontalLayoutsTest >> testThreeColumnFlowGridGrid [ + + + | flow firstGrid secondGrid | + flow := self flow. + flow addChildren: { + self red. + self blue. + self green }. + + firstGrid := self grid. + firstGrid addChild: flow. + + secondGrid := self grid. + secondGrid width: (self threeColumnWidthDepth: 3). + secondGrid addChild: firstGrid. + secondGrid forceLayout. + + self assert: flow extent equals: (self threeColumnExtentDepth: 1). + self + assert: firstGrid extent + equals: (self threeColumnExtentDepth: 2). + self + assert: secondGrid extent + equals: (self threeColumnExtentDepth: 3). + + ^ secondGrid +] + +{ #category : #tests } +BlFitContentVerticallyInHorizontalLayoutsTest >> testThreeColumnFlowListGrid [ + + + | flow list grid | + flow := self flow. + flow addChildren: { + self red. + self blue. + self green }. + + list := self list. + list addChild: flow. + + grid := self grid. + grid width: (self threeColumnWidthDepth: 3). + grid addChild: list. + grid forceLayout. + + self assert: flow extent equals: (self threeColumnExtentDepth: 1). + self assert: list extent equals: (self threeColumnExtentDepth: 2). + self assert: grid extent equals: (self threeColumnExtentDepth: 3). + + ^ grid +] + +{ #category : #tests } +BlFitContentVerticallyInHorizontalLayoutsTest >> testThreeColumnFlowListList [ + + + | flow firstList secondList | + flow := self flow. + flow addChildren: { + self red. + self blue. + self green }. + + firstList := self list. + firstList addChild: flow. + + secondList := self list. + secondList width: (self threeColumnWidthDepth: 3). + secondList addChild: firstList. + secondList forceLayout. + + self assert: flow extent equals: (self threeColumnExtentDepth: 1). + self + assert: firstList extent + equals: (self threeColumnExtentDepth: 2). + self + assert: secondList extent + equals: (self threeColumnExtentDepth: 3). + + ^ secondList +] + +{ #category : #tests } +BlFitContentVerticallyInHorizontalLayoutsTest >> testTwoColumnFlow [ + + + | flow | + flow := self flow. + flow width: (self twoColumnWidthDepth: 1). + flow addChildren: { + self red. + self blue. + self green }. + flow forceLayout. + + self assert: flow extent equals: (self twoColumnExtentDepth: 1). + + ^ flow +] + +{ #category : #tests } +BlFitContentVerticallyInHorizontalLayoutsTest >> testTwoColumnFlowFlowFlow [ + + + | firstFlow secondFlow thirdFlow | + firstFlow := self flow. + firstFlow addChildren: { + self red. + self blue. + self green }. + + secondFlow := self flow. + secondFlow addChild: firstFlow. + + thirdFlow := self flow. + thirdFlow width: (self twoColumnWidthDepth: 3). + thirdFlow addChild: secondFlow. + thirdFlow forceLayout. + + self assert: firstFlow extent equals: (self twoColumnExtentDepth: 1). + self assert: secondFlow extent equals: (self twoColumnExtentDepth: 2). + self assert: thirdFlow extent equals: (self twoColumnExtentDepth: 3). + + ^ thirdFlow +] + +{ #category : #tests } +BlFitContentVerticallyInHorizontalLayoutsTest >> testTwoColumnFlowFlowList [ + + + | firstFlow secondFlow list | + firstFlow := self flow. + firstFlow addChildren: { + self red. + self blue. + self green }. + + secondFlow := self flow. + secondFlow addChild: firstFlow. + + list := self list. + list width: (self twoColumnWidthDepth: 3). + list addChild: secondFlow. + list forceLayout. + + self assert: firstFlow extent equals: (self twoColumnExtentDepth: 1). + self assert: secondFlow extent equals: (self twoColumnExtentDepth: 2). + self assert: list extent equals: (self twoColumnExtentDepth: 3). + + ^ list +] + +{ #category : #tests } +BlFitContentVerticallyInHorizontalLayoutsTest >> testTwoColumnFlowGridGrid [ + + + | flow firstGrid secondGrid | + flow := self flow. + flow addChildren: { + self red. + self blue. + self green }. + + firstGrid := self grid. + firstGrid addChild: flow. + + secondGrid := self grid. + secondGrid width: (self twoColumnWidthDepth: 3). + secondGrid addChild: firstGrid. + secondGrid forceLayout. + + self assert: flow extent equals: (self twoColumnExtentDepth: 1). + self assert: firstGrid extent equals: (self twoColumnExtentDepth: 2). + self assert: secondGrid extent equals: (self twoColumnExtentDepth: 3). + + ^ secondGrid +] + +{ #category : #tests } +BlFitContentVerticallyInHorizontalLayoutsTest >> testTwoColumnFlowGridList [ + + + | flow grid list | + flow := self flow. + flow addChildren: { + self red. + self blue. + self green }. + + grid := self grid. + grid addChild: flow. + + list := self list. + list width: (self twoColumnWidthDepth: 3). + list addChild: grid. + list forceLayout. + + self assert: flow extent equals: (self twoColumnExtentDepth: 1). + self assert: grid extent equals: (self twoColumnExtentDepth: 2). + self assert: list extent equals: (self twoColumnExtentDepth: 3). + + ^ list +] + +{ #category : #tests } +BlFitContentVerticallyInHorizontalLayoutsTest >> testTwoColumnFlowList [ + + + | flow list | + flow := self flow. + flow addChildren: { + self red. + self blue. + self green }. + + list := self list. + list width: (self twoColumnWidthDepth: 2). + list addChild: flow. + list forceLayout. + + self assert: flow extent equals: (self twoColumnExtentDepth: 1). + self assert: list extent equals: (self twoColumnExtentDepth: 2). + + ^ list +] + +{ #category : #tests } +BlFitContentVerticallyInHorizontalLayoutsTest >> testTwoColumnFlowListGrid [ + + + | flow list grid | + flow := self flow. + flow addChildren: { + self red. + self blue. + self green }. + + list := self list. + list addChild: flow. + + grid := self grid. + grid width: (self twoColumnWidthDepth: 3). + grid addChild: list. + grid forceLayout. + + self assert: flow extent equals: (self twoColumnExtentDepth: 1). + self assert: list extent equals: (self twoColumnExtentDepth: 2). + self assert: grid extent equals: (self twoColumnExtentDepth: 3). + + ^ grid +] + +{ #category : #tests } +BlFitContentVerticallyInHorizontalLayoutsTest >> testTwoColumnFlowListList [ + + + | flow firstList secondList | + flow := self flow. + flow addChildren: { + self red. + self blue. + self green }. + + firstList := self list. + firstList addChild: flow. + + secondList := self list. + secondList width: (self twoColumnWidthDepth: 3). + secondList addChild: firstList. + secondList forceLayout. + + self assert: flow extent equals: (self twoColumnExtentDepth: 1). + self assert: firstList extent equals: (self twoColumnExtentDepth: 2). + self assert: secondList extent equals: (self twoColumnExtentDepth: 3). + + ^ secondList +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> threeColumnExtentDepth: aNumber [ + + ^ (self threeColumnWidthDepth: aNumber) + @ (self threeColumnHeightDepth: aNumber) +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> threeColumnHeight [ + + ^ { + (self redHeight + self redMargin height). + (self blueHeight + self blueMargin height). + (self greenHeight + self greenMargin height) } max +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> threeColumnHeightDepth: aNumber [ + + ^ self threeColumnHeight + (self containerPadding * 2 * aNumber) +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> threeColumnWidth [ + + ^ { + (self redWidth + self redMargin width). + (self blueWidth + self blueMargin width). + (self greenWidth + self greenMargin width) } sum +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> threeColumnWidthDepth: aNumber [ + + ^ self threeColumnWidth + (self containerPadding * 2 * aNumber) +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> twoColumnExtentDepth: aNumber [ + + ^ (self twoColumnWidthDepth: aNumber) + @ (self twoColumnHeightDepth: aNumber) +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> twoColumnHeight [ + + ^ { + (self redHeight + self redMargin height). + (self blueHeight + self blueMargin height) } max + + self greenHeight + self greenMargin height +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> twoColumnHeightDepth: aNumber [ + + ^ self twoColumnHeight + (self containerPadding * 2 * aNumber) +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> twoColumnWidth [ + + ^ { + (self redWidth + self redMargin width + self blueWidth + + self blueMargin width). + (self greenWidth + self greenMargin width) } max +] + +{ #category : #fixture } +BlFitContentVerticallyInHorizontalLayoutsTest >> twoColumnWidthDepth: aNumber [ + + ^ self twoColumnWidth + (self containerPadding * 2 * aNumber) +] From b31f9ea894a9678249d4f5616e23434a5c7dab5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Wed, 12 Apr 2023 09:13:12 +0200 Subject: [PATCH 4/8] --- ...VerticallyInHorizontalLayoutTest.class.st} | 104 +++++++++--------- 1 file changed, 52 insertions(+), 52 deletions(-) rename src/Bloc-Layout-Tests/{BlFitContentVerticallyInHorizontalLayoutsTest.class.st => BlFitContentVerticallyInHorizontalLayoutTest.class.st} (78%) diff --git a/src/Bloc-Layout-Tests/BlFitContentVerticallyInHorizontalLayoutsTest.class.st b/src/Bloc-Layout-Tests/BlFitContentVerticallyInHorizontalLayoutTest.class.st similarity index 78% rename from src/Bloc-Layout-Tests/BlFitContentVerticallyInHorizontalLayoutsTest.class.st rename to src/Bloc-Layout-Tests/BlFitContentVerticallyInHorizontalLayoutTest.class.st index 6c700bdc7..758cb699c 100644 --- a/src/Bloc-Layout-Tests/BlFitContentVerticallyInHorizontalLayoutsTest.class.st +++ b/src/Bloc-Layout-Tests/BlFitContentVerticallyInHorizontalLayoutTest.class.st @@ -3,13 +3,13 @@ I have been automatically converted and probably manually tweaked from BlFitCont 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 : #BlFitContentVerticallyInHorizontalLayoutsTest, + #name : #BlFitContentVerticallyInHorizontalLayoutTest, #superclass : #TestCase, #category : #'Bloc-Layout-Tests' } { #category : #tests } -BlFitContentVerticallyInHorizontalLayoutsTest >> blue [ +BlFitContentVerticallyInHorizontalLayoutTest >> blue [ ^ self box @@ -20,38 +20,38 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> blue [ ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> blueHeight [ +BlFitContentVerticallyInHorizontalLayoutTest >> blueHeight [ ^ 100 ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> blueMargin [ +BlFitContentVerticallyInHorizontalLayoutTest >> blueMargin [ ^ BlInsets right: self boxMargin ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> blueWidth [ +BlFitContentVerticallyInHorizontalLayoutTest >> blueWidth [ ^ 75 ] { #category : #tests } -BlFitContentVerticallyInHorizontalLayoutsTest >> box [ +BlFitContentVerticallyInHorizontalLayoutTest >> box [ ^ BlElement new ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> boxMargin [ +BlFitContentVerticallyInHorizontalLayoutTest >> boxMargin [ ^ 15 ] { #category : #tests } -BlFitContentVerticallyInHorizontalLayoutsTest >> container [ +BlFitContentVerticallyInHorizontalLayoutTest >> container [ ^ BlElement new @@ -63,13 +63,13 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> container [ ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> containerPadding [ +BlFitContentVerticallyInHorizontalLayoutTest >> containerPadding [ ^ 25 ] { #category : #tests } -BlFitContentVerticallyInHorizontalLayoutsTest >> flow [ +BlFitContentVerticallyInHorizontalLayoutTest >> flow [ ^ self container @@ -78,7 +78,7 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> flow [ ] { #category : #tests } -BlFitContentVerticallyInHorizontalLayoutsTest >> green [ +BlFitContentVerticallyInHorizontalLayoutTest >> green [ ^ self box @@ -90,25 +90,25 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> green [ ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> greenHeight [ +BlFitContentVerticallyInHorizontalLayoutTest >> greenHeight [ ^ 80 ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> greenMargin [ +BlFitContentVerticallyInHorizontalLayoutTest >> greenMargin [ ^ BlInsets top: self boxMargin ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> greenWidth [ +BlFitContentVerticallyInHorizontalLayoutTest >> greenWidth [ ^ 150 ] { #category : #tests } -BlFitContentVerticallyInHorizontalLayoutsTest >> grid [ +BlFitContentVerticallyInHorizontalLayoutTest >> grid [ ^ self container @@ -117,7 +117,7 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> grid [ ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> layoutLabel: aString [ +BlFitContentVerticallyInHorizontalLayoutTest >> layoutLabel: aString [ ^ BlTextElement new text: (aString asRopedText thin fontSize: 10); @@ -128,7 +128,7 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> layoutLabel: aString [ ] { #category : #tests } -BlFitContentVerticallyInHorizontalLayoutsTest >> list [ +BlFitContentVerticallyInHorizontalLayoutTest >> list [ ^ self container @@ -137,14 +137,14 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> list [ ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> oneColumnExtentDepth: aNumber [ +BlFitContentVerticallyInHorizontalLayoutTest >> oneColumnExtentDepth: aNumber [ ^ (self oneColumnWidthDepth: aNumber) @ (self oneColumnHeightDepth: aNumber) ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> oneColumnHeight [ +BlFitContentVerticallyInHorizontalLayoutTest >> oneColumnHeight [ ^ { (self redHeight + self redMargin height). @@ -153,13 +153,13 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> oneColumnHeight [ ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> oneColumnHeightDepth: aNumber [ +BlFitContentVerticallyInHorizontalLayoutTest >> oneColumnHeightDepth: aNumber [ ^ self oneColumnHeight + (self containerPadding * 2 * aNumber) ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> oneColumnWidth [ +BlFitContentVerticallyInHorizontalLayoutTest >> oneColumnWidth [ ^ { (self redWidth + self redMargin width). @@ -168,13 +168,13 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> oneColumnWidth [ ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> oneColumnWidthDepth: aNumber [ +BlFitContentVerticallyInHorizontalLayoutTest >> oneColumnWidthDepth: aNumber [ ^ self oneColumnWidth + (self containerPadding * 2 * aNumber) ] { #category : #tests } -BlFitContentVerticallyInHorizontalLayoutsTest >> red [ +BlFitContentVerticallyInHorizontalLayoutTest >> red [ ^ self box @@ -185,13 +185,13 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> red [ ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> redHeight [ +BlFitContentVerticallyInHorizontalLayoutTest >> redHeight [ ^ 75 ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> redMargin [ +BlFitContentVerticallyInHorizontalLayoutTest >> redMargin [ ^ BlInsets top: 0 @@ -201,13 +201,13 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> redMargin [ ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> redWidth [ +BlFitContentVerticallyInHorizontalLayoutTest >> redWidth [ ^ 100 ] { #category : #tests } -BlFitContentVerticallyInHorizontalLayoutsTest >> testOneColumnFlow [ +BlFitContentVerticallyInHorizontalLayoutTest >> testOneColumnFlow [ | flow | @@ -225,7 +225,7 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> testOneColumnFlow [ ] { #category : #tests } -BlFitContentVerticallyInHorizontalLayoutsTest >> testOneColumnFlowGridGrid [ +BlFitContentVerticallyInHorizontalLayoutTest >> testOneColumnFlowGridGrid [ | flow firstGrid secondGrid | @@ -251,7 +251,7 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> testOneColumnFlowGridGrid [ ] { #category : #tests } -BlFitContentVerticallyInHorizontalLayoutsTest >> testOneColumnFlowList [ +BlFitContentVerticallyInHorizontalLayoutTest >> testOneColumnFlowList [ | flow list | @@ -276,7 +276,7 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> testOneColumnFlowList [ ] { #category : #tests } -BlFitContentVerticallyInHorizontalLayoutsTest >> testOneColumnFlowListGrid [ +BlFitContentVerticallyInHorizontalLayoutTest >> testOneColumnFlowListGrid [ | flow list grid | @@ -302,7 +302,7 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> testOneColumnFlowListGrid [ ] { #category : #tests } -BlFitContentVerticallyInHorizontalLayoutsTest >> testOneColumnFlowListList [ +BlFitContentVerticallyInHorizontalLayoutTest >> testOneColumnFlowListList [ | flow firstList secondList | @@ -328,7 +328,7 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> testOneColumnFlowListList [ ] { #category : #tests } -BlFitContentVerticallyInHorizontalLayoutsTest >> testThreeColumnFlowGridGrid [ +BlFitContentVerticallyInHorizontalLayoutTest >> testThreeColumnFlowGridGrid [ | flow firstGrid secondGrid | @@ -358,7 +358,7 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> testThreeColumnFlowGridGrid [ ] { #category : #tests } -BlFitContentVerticallyInHorizontalLayoutsTest >> testThreeColumnFlowListGrid [ +BlFitContentVerticallyInHorizontalLayoutTest >> testThreeColumnFlowListGrid [ | flow list grid | @@ -384,7 +384,7 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> testThreeColumnFlowListGrid [ ] { #category : #tests } -BlFitContentVerticallyInHorizontalLayoutsTest >> testThreeColumnFlowListList [ +BlFitContentVerticallyInHorizontalLayoutTest >> testThreeColumnFlowListList [ | flow firstList secondList | @@ -414,7 +414,7 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> testThreeColumnFlowListList [ ] { #category : #tests } -BlFitContentVerticallyInHorizontalLayoutsTest >> testTwoColumnFlow [ +BlFitContentVerticallyInHorizontalLayoutTest >> testTwoColumnFlow [ | flow | @@ -432,7 +432,7 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> testTwoColumnFlow [ ] { #category : #tests } -BlFitContentVerticallyInHorizontalLayoutsTest >> testTwoColumnFlowFlowFlow [ +BlFitContentVerticallyInHorizontalLayoutTest >> testTwoColumnFlowFlowFlow [ | firstFlow secondFlow thirdFlow | @@ -458,7 +458,7 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> testTwoColumnFlowFlowFlow [ ] { #category : #tests } -BlFitContentVerticallyInHorizontalLayoutsTest >> testTwoColumnFlowFlowList [ +BlFitContentVerticallyInHorizontalLayoutTest >> testTwoColumnFlowFlowList [ | firstFlow secondFlow list | @@ -484,7 +484,7 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> testTwoColumnFlowFlowList [ ] { #category : #tests } -BlFitContentVerticallyInHorizontalLayoutsTest >> testTwoColumnFlowGridGrid [ +BlFitContentVerticallyInHorizontalLayoutTest >> testTwoColumnFlowGridGrid [ | flow firstGrid secondGrid | @@ -510,7 +510,7 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> testTwoColumnFlowGridGrid [ ] { #category : #tests } -BlFitContentVerticallyInHorizontalLayoutsTest >> testTwoColumnFlowGridList [ +BlFitContentVerticallyInHorizontalLayoutTest >> testTwoColumnFlowGridList [ | flow grid list | @@ -536,7 +536,7 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> testTwoColumnFlowGridList [ ] { #category : #tests } -BlFitContentVerticallyInHorizontalLayoutsTest >> testTwoColumnFlowList [ +BlFitContentVerticallyInHorizontalLayoutTest >> testTwoColumnFlowList [ | flow list | @@ -558,7 +558,7 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> testTwoColumnFlowList [ ] { #category : #tests } -BlFitContentVerticallyInHorizontalLayoutsTest >> testTwoColumnFlowListGrid [ +BlFitContentVerticallyInHorizontalLayoutTest >> testTwoColumnFlowListGrid [ | flow list grid | @@ -584,7 +584,7 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> testTwoColumnFlowListGrid [ ] { #category : #tests } -BlFitContentVerticallyInHorizontalLayoutsTest >> testTwoColumnFlowListList [ +BlFitContentVerticallyInHorizontalLayoutTest >> testTwoColumnFlowListList [ | flow firstList secondList | @@ -610,14 +610,14 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> testTwoColumnFlowListList [ ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> threeColumnExtentDepth: aNumber [ +BlFitContentVerticallyInHorizontalLayoutTest >> threeColumnExtentDepth: aNumber [ ^ (self threeColumnWidthDepth: aNumber) @ (self threeColumnHeightDepth: aNumber) ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> threeColumnHeight [ +BlFitContentVerticallyInHorizontalLayoutTest >> threeColumnHeight [ ^ { (self redHeight + self redMargin height). @@ -626,13 +626,13 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> threeColumnHeight [ ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> threeColumnHeightDepth: aNumber [ +BlFitContentVerticallyInHorizontalLayoutTest >> threeColumnHeightDepth: aNumber [ ^ self threeColumnHeight + (self containerPadding * 2 * aNumber) ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> threeColumnWidth [ +BlFitContentVerticallyInHorizontalLayoutTest >> threeColumnWidth [ ^ { (self redWidth + self redMargin width). @@ -641,20 +641,20 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> threeColumnWidth [ ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> threeColumnWidthDepth: aNumber [ +BlFitContentVerticallyInHorizontalLayoutTest >> threeColumnWidthDepth: aNumber [ ^ self threeColumnWidth + (self containerPadding * 2 * aNumber) ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> twoColumnExtentDepth: aNumber [ +BlFitContentVerticallyInHorizontalLayoutTest >> twoColumnExtentDepth: aNumber [ ^ (self twoColumnWidthDepth: aNumber) @ (self twoColumnHeightDepth: aNumber) ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> twoColumnHeight [ +BlFitContentVerticallyInHorizontalLayoutTest >> twoColumnHeight [ ^ { (self redHeight + self redMargin height). @@ -663,13 +663,13 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> twoColumnHeight [ ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> twoColumnHeightDepth: aNumber [ +BlFitContentVerticallyInHorizontalLayoutTest >> twoColumnHeightDepth: aNumber [ ^ self twoColumnHeight + (self containerPadding * 2 * aNumber) ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> twoColumnWidth [ +BlFitContentVerticallyInHorizontalLayoutTest >> twoColumnWidth [ ^ { (self redWidth + self redMargin width + self blueWidth @@ -678,7 +678,7 @@ BlFitContentVerticallyInHorizontalLayoutsTest >> twoColumnWidth [ ] { #category : #fixture } -BlFitContentVerticallyInHorizontalLayoutsTest >> twoColumnWidthDepth: aNumber [ +BlFitContentVerticallyInHorizontalLayoutTest >> twoColumnWidthDepth: aNumber [ ^ self twoColumnWidth + (self containerPadding * 2 * aNumber) ] From b3c54536eaf496ec76ab929361a792c62c02951d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Wed, 12 Apr 2023 09:41:19 +0200 Subject: [PATCH 5/8] repackage BlIgnoredLayoutTest --- .../BlIgnoredLayoutTest.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/{Bloc-Layout-Examples => Bloc-Layout-Tests}/BlIgnoredLayoutTest.class.st (95%) diff --git a/src/Bloc-Layout-Examples/BlIgnoredLayoutTest.class.st b/src/Bloc-Layout-Tests/BlIgnoredLayoutTest.class.st similarity index 95% rename from src/Bloc-Layout-Examples/BlIgnoredLayoutTest.class.st rename to src/Bloc-Layout-Tests/BlIgnoredLayoutTest.class.st index aba639a89..2a12b075b 100644 --- a/src/Bloc-Layout-Examples/BlIgnoredLayoutTest.class.st +++ b/src/Bloc-Layout-Tests/BlIgnoredLayoutTest.class.st @@ -1,7 +1,7 @@ Class { #name : #BlIgnoredLayoutTest, #superclass : #TestCase, - #category : #'Bloc-Layout-Examples-Ignored' + #category : #'Bloc-Layout-Tests' } { #category : #'examples - alignment' } From eb401cdc675487ef40c9ffe6bcc503129ca75685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Wed, 12 Apr 2023 09:46:27 +0200 Subject: [PATCH 6/8] BlLayoutChildNodeWithTransformationTest --- ...ildNodeWithTransformationExamples.class.st | 54 --------------- .../BlLayoutNodeExamples.class.st | 5 -- ...utChildNodeWithTransformationTest.class.st | 65 +++++++++++++++++++ 3 files changed, 65 insertions(+), 59 deletions(-) delete mode 100644 src/Bloc-Layout-Examples/BlLayoutChildNodeWithTransformationExamples.class.st delete mode 100644 src/Bloc-Layout-Examples/BlLayoutNodeExamples.class.st create mode 100644 src/Bloc-Layout-Tests/BlLayoutChildNodeWithTransformationTest.class.st diff --git a/src/Bloc-Layout-Examples/BlLayoutChildNodeWithTransformationExamples.class.st b/src/Bloc-Layout-Examples/BlLayoutChildNodeWithTransformationExamples.class.st deleted file mode 100644 index 882c74fb8..000000000 --- a/src/Bloc-Layout-Examples/BlLayoutChildNodeWithTransformationExamples.class.st +++ /dev/null @@ -1,54 +0,0 @@ -Class { - #name : #BlLayoutChildNodeWithTransformationExamples, - #superclass : #BlLayoutNodeExamples, - #category : #'Bloc-Layout-Examples-Core' -} - -{ #category : #'examples - transformation' } -BlLayoutChildNodeWithTransformationExamples >> nodeWithScale [ - - | aTransformation aChildNode aChildNodeWithTransformation | - - aTransformation := self scaleTransformation. - - aChildNode := BlLayoutChildNode new - constraints: BlLayoutCommonConstraints new; - measurement: (BlLayoutNodeComputedMeasurement new extent: 100@100). - - aChildNodeWithTransformation := aChildNode withTransformation: aTransformation. - - self assert: aChildNodeWithTransformation position equals: (50@50) negated. - self assert: aChildNodeWithTransformation extent equals: (200@200). - - ^ aChildNodeWithTransformation -] - -{ #category : #'examples - instance creation' } -BlLayoutChildNodeWithTransformationExamples >> scaleTransformation [ - - | aScaleTransformation aTransformation | - - aScaleTransformation := BlScalingTransformation new - origin: BlAffineTransformationCenterOrigin new; - scale: (BlVector x: 2 y: 2). - - aTransformation := (BlElementLocalTransformation with: aScaleTransformation). - - ^ aTransformation -] - -{ #category : #'examples - transformation' } -BlLayoutChildNodeWithTransformationExamples >> setPositionNodeWithScale [ - - | aChildNodeWithTransformation | - - aChildNodeWithTransformation := self nodeWithScale. - - aChildNodeWithTransformation position: 0@0. - self assert: aChildNodeWithTransformation position equals: 0@0. - - aChildNodeWithTransformation position: 20@30. - self assert: aChildNodeWithTransformation position equals: 20@30. - - ^ aChildNodeWithTransformation -] diff --git a/src/Bloc-Layout-Examples/BlLayoutNodeExamples.class.st b/src/Bloc-Layout-Examples/BlLayoutNodeExamples.class.st deleted file mode 100644 index 63adc0441..000000000 --- a/src/Bloc-Layout-Examples/BlLayoutNodeExamples.class.st +++ /dev/null @@ -1,5 +0,0 @@ -Class { - #name : #BlLayoutNodeExamples, - #superclass : #Object, - #category : #'Bloc-Layout-Examples-Core' -} diff --git a/src/Bloc-Layout-Tests/BlLayoutChildNodeWithTransformationTest.class.st b/src/Bloc-Layout-Tests/BlLayoutChildNodeWithTransformationTest.class.st new file mode 100644 index 000000000..a996d9740 --- /dev/null +++ b/src/Bloc-Layout-Tests/BlLayoutChildNodeWithTransformationTest.class.st @@ -0,0 +1,65 @@ +" +I have been automatically converted and probably manually tweaked from BlLayoutChildNodeWithTransformationExamples. 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 : #BlLayoutChildNodeWithTransformationTest, + #superclass : #TestCase, + #category : #'Bloc-Layout-Tests' +} + +{ #category : #tests } +BlLayoutChildNodeWithTransformationTest >> testNodeWithScale [ + + + | aTransformation aChildNode aChildNodeWithTransformation | + aTransformation := self testScaleTransformation. + + aChildNode := BlLayoutChildNode new + constraints: BlLayoutCommonConstraints new; + measurement: + (BlLayoutNodeComputedMeasurement new extent: + 100 @ 100). + + aChildNodeWithTransformation := aChildNode withTransformation: + aTransformation. + + self + assert: aChildNodeWithTransformation position + equals: (50 @ 50) negated. + self assert: aChildNodeWithTransformation extent equals: 200 @ 200. + + ^ aChildNodeWithTransformation +] + +{ #category : #tests } +BlLayoutChildNodeWithTransformationTest >> testScaleTransformation [ + + + | aScaleTransformation aTransformation | + aScaleTransformation := BlScalingTransformation new + origin: + BlAffineTransformationCenterOrigin new; + scale: (BlVector x: 2 y: 2). + + aTransformation := BlElementLocalTransformation newWith: + aScaleTransformation. + + ^ aTransformation +] + +{ #category : #tests } +BlLayoutChildNodeWithTransformationTest >> testSetPositionNodeWithScale [ + + + | aChildNodeWithTransformation | + aChildNodeWithTransformation := self testNodeWithScale. + + aChildNodeWithTransformation position: 0 @ 0. + self assert: aChildNodeWithTransformation position equals: 0 @ 0. + + aChildNodeWithTransformation position: 20 @ 30. + self assert: aChildNodeWithTransformation position equals: 20 @ 30. + + ^ aChildNodeWithTransformation +] From dd06a55b84df5cc302d8eac53000e3e427bba30b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Wed, 12 Apr 2023 09:52:09 +0200 Subject: [PATCH 7/8] BlWrap... --- ...lWrapAroundChildrenLayoutExamples.class.st | 68 -------------- .../BlWrapAroundChildrenLayoutTest.class.st | 90 +++++++++++++++++++ ...ayoutParentNodeWithTransformation.class.st | 13 ++- 3 files changed, 100 insertions(+), 71 deletions(-) delete mode 100644 src/Bloc-Layout-Examples/BlWrapAroundChildrenLayoutExamples.class.st create mode 100644 src/Bloc-Layout-Tests/BlWrapAroundChildrenLayoutTest.class.st diff --git a/src/Bloc-Layout-Examples/BlWrapAroundChildrenLayoutExamples.class.st b/src/Bloc-Layout-Examples/BlWrapAroundChildrenLayoutExamples.class.st deleted file mode 100644 index dc0341de7..000000000 --- a/src/Bloc-Layout-Examples/BlWrapAroundChildrenLayoutExamples.class.st +++ /dev/null @@ -1,68 +0,0 @@ -Class { - #name : #BlWrapAroundChildrenLayoutExamples, - #superclass : #BlExampleTest, - #category : #'Bloc-Layout-Examples-Fit' -} - -{ #category : #'instance creation' } -BlWrapAroundChildrenLayoutExamples >> container [ - - - ^ BlElement new - layout: (BlWrapAroundChildrenLayout new addLayout: BlBasicNodeBasedLayout new); - constraintsDo: [ :c | - c horizontal fitContent. - c vertical fitContent ]; - padding: (BlInsets all: 20); - background: (Color gray alpha: 0.2) -] - -{ #category : #examples } -BlWrapAroundChildrenLayoutExamples >> containerScaledWithNodes [ - - | aContainer aChildA aChildB aChildC | - - aContainer := self container. - aContainer transformDo: [ :t | t scaleBy: 0.5 ]. - aContainer addChild: (aChildA := self node position: 150@50). - aContainer addChild: (aChildB := self node position: 50@150). - aContainer addChild: (aChildC := self node position: 250@250). - - aContainer forceLayout. - self assert: aContainer bounds asRectangle equals: ((30@30) negated extent: 260@260). - self assert: aChildA bounds asRectangle equals: (120@20 extent: 20@20). - self assert: aChildB bounds asRectangle equals: (20@120 extent: 20@20). - self assert: aChildC bounds asRectangle equals: (220@220 extent: 20@20). - - ^ aContainer -] - -{ #category : #examples } -BlWrapAroundChildrenLayoutExamples >> containerWithNodes [ - - | aContainer aChildA aChildB aChildC | - - aContainer := self container. - aContainer addChild: (aChildA := self node position: 150@50). - aContainer addChild: (aChildB := self node position: 50@150). - aContainer addChild: (aChildC := self node position: 250@250). - - aContainer forceLayout. - self assert: aContainer bounds asRectangle equals: (30@30 extent: 260@260). - self assert: aChildA bounds asRectangle equals: (120@20 extent: 20@20). - self assert: aChildB bounds asRectangle equals: (20@120 extent: 20@20). - self assert: aChildC bounds asRectangle equals: (220@220 extent: 20@20). - - ^ aContainer -] - -{ #category : #'instance creation' } -BlWrapAroundChildrenLayoutExamples >> node [ - - - ^ BlElement new - geometry: (BlRoundedRectangleGeometry cornerRadius: 4); - border: (BlBorder paint: Color black width: 2); - background: Color white; - size: 20@20 -] diff --git a/src/Bloc-Layout-Tests/BlWrapAroundChildrenLayoutTest.class.st b/src/Bloc-Layout-Tests/BlWrapAroundChildrenLayoutTest.class.st new file mode 100644 index 000000000..1c7771b41 --- /dev/null +++ b/src/Bloc-Layout-Tests/BlWrapAroundChildrenLayoutTest.class.st @@ -0,0 +1,90 @@ +" +I have been automatically converted and probably manually tweaked from BlWrapAroundChildrenLayoutExamples. 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 : #BlWrapAroundChildrenLayoutTest, + #superclass : #TestCase, + #category : #'Bloc-Layout-Tests' +} + +{ #category : #tests } +BlWrapAroundChildrenLayoutTest >> container [ + + + ^ BlElement new + layout: + (BlWrapAroundChildrenLayout new addLayout: + BlBasicNodeBasedLayout new); + constraintsDo: [ :c | + c horizontal fitContent. + c vertical fitContent ]; + padding: (BlInsets all: 20); + background: (Color gray alpha: 0.2) +] + +{ #category : #tests } +BlWrapAroundChildrenLayoutTest >> node [ + + + ^ BlElement new + geometry: (BlRoundedRectangleGeometry cornerRadius: 4); + border: (BlBorder paint: Color black width: 2); + background: Color white; + size: 20 @ 20 +] + +{ #category : #tests } +BlWrapAroundChildrenLayoutTest >> testContainerScaledWithNodes [ + + + | aContainer aChildA aChildB aChildC | + aContainer := self container. + aContainer transformDo: [ :t | t scaleBy: 0.5 ]. + aContainer addChild: (aChildA := self node position: 150 @ 50). + aContainer addChild: (aChildB := self node position: 50 @ 150). + aContainer addChild: (aChildC := self node position: 250 @ 250). + + aContainer forceLayout. + self + assert: aContainer bounds asRectangle + equals: ((30 @ 30) negated extent: 260 @ 260). + self + assert: aChildA bounds asRectangle + equals: (120 @ 20 extent: 20 @ 20). + self + assert: aChildB bounds asRectangle + equals: (20 @ 120 extent: 20 @ 20). + self + assert: aChildC bounds asRectangle + equals: (220 @ 220 extent: 20 @ 20). + + ^ aContainer +] + +{ #category : #tests } +BlWrapAroundChildrenLayoutTest >> testContainerWithNodes [ + + + | aContainer aChildA aChildB aChildC | + aContainer := self container. + aContainer addChild: (aChildA := self node position: 150 @ 50). + aContainer addChild: (aChildB := self node position: 50 @ 150). + aContainer addChild: (aChildC := self node position: 250 @ 250). + + aContainer forceLayout. + self + assert: aContainer bounds asRectangle + equals: (30 @ 30 extent: 260 @ 260). + self + assert: aChildA bounds asRectangle + equals: (120 @ 20 extent: 20 @ 20). + self + assert: aChildB bounds asRectangle + equals: (20 @ 120 extent: 20 @ 20). + self + assert: aChildC bounds asRectangle + equals: (220 @ 220 extent: 20 @ 20). + + ^ aContainer +] diff --git a/src/Bloc/BlLayoutParentNodeWithTransformation.class.st b/src/Bloc/BlLayoutParentNodeWithTransformation.class.st index a86fc128a..f7be1e10f 100644 --- a/src/Bloc/BlLayoutParentNodeWithTransformation.class.st +++ b/src/Bloc/BlLayoutParentNodeWithTransformation.class.st @@ -39,8 +39,10 @@ BlLayoutParentNodeWithTransformation >> extent [ { #category : #'api - geometry' } BlLayoutParentNodeWithTransformation >> extent: aPoint [ + parentNode extent: aPoint. - self transformation bounds: (BlBounds origin: self position extent: aPoint) + self transformation boundingRectangle: + (BlBounds origin: self position extent: aPoint) ] { #category : #'api - extent spec' } @@ -77,8 +79,10 @@ BlLayoutParentNodeWithTransformation >> position [ { #category : #accessing } BlLayoutParentNodeWithTransformation >> position: aPoint [ + parentNode position: aPoint. - self transformation bounds: (BlBounds origin: aPoint extent: self extent) + self transformation boundingRectangle: + (BlBounds origin: aPoint extent: self extent) ] { #category : #accessing } @@ -95,7 +99,10 @@ BlLayoutParentNodeWithTransformation >> transformation [ BlLayoutParentNodeWithTransformation >> transformation: aBlElementTransformation [ transformation := aBlElementTransformation asCachedTransformation - bounds: (BlBounds origin: self position extent: self extent) + boundingRectangle: + (BlBounds + origin: self position + extent: self extent) ] { #category : #accessing } From 7e1d184037af8690bf1d134ee74d2ea1473443c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Wed, 12 Apr 2023 10:34:23 +0200 Subject: [PATCH 8/8] Layout examples fully converted --- src/BaselineOfBloc/BaselineOfBloc.class.st | 4 +- .../BlLinearLayoutHorizontalTest.class.st | 179 ++-- .../BlLinearLayoutTest.class.st | 5 + .../BlLinearLayoutUsageTest.class.st | 940 +++++++++--------- .../BlLinearLayoutVerticalTest.class.st | 136 ++- 5 files changed, 613 insertions(+), 651 deletions(-) create mode 100644 src/Bloc-Layout-Tests/BlLinearLayoutTest.class.st diff --git a/src/BaselineOfBloc/BaselineOfBloc.class.st b/src/BaselineOfBloc/BaselineOfBloc.class.st index 9af46ef83..11931d6a2 100644 --- a/src/BaselineOfBloc/BaselineOfBloc.class.st +++ b/src/BaselineOfBloc/BaselineOfBloc.class.st @@ -108,9 +108,7 @@ BaselineOfBloc >> baseline: spec [ package: #'Bloc-Text-Examples' with: [ spec requires: #(#'Bloc-Examples') ]; package: #'Bloc-Layout-Tests' with: [ - spec requires: #('Bloc-Layout' 'Bloc-Text' 'Bloc-DevTool') ]; - package: #'Bloc-Layout-Examples' with: [ - spec requires: #('Bloc-Layout') ]. + spec requires: #('Bloc-Layout' 'Bloc-Text' 'Bloc-DevTool') ]. ]. ] diff --git a/src/Bloc-Layout-Tests/BlLinearLayoutHorizontalTest.class.st b/src/Bloc-Layout-Tests/BlLinearLayoutHorizontalTest.class.st index da358f9f6..59b7a21ef 100644 --- a/src/Bloc-Layout-Tests/BlLinearLayoutHorizontalTest.class.st +++ b/src/Bloc-Layout-Tests/BlLinearLayoutHorizontalTest.class.st @@ -4,27 +4,23 @@ I have been automatically converted and probably manually tweaked from BlLinearL " Class { #name : #BlLinearLayoutHorizontalTest, - #superclass : #BlRootLayoutTest, + #superclass : #BlLinearLayoutTest, #category : #'Bloc-Layout-Tests' } -{ #category : #metadata } -BlLinearLayoutHorizontalTest >> originClassName [ - "This test was generated from..." - ^ 'BlLinearLayoutHorizontalExamples' -] - { #category : #tests } BlLinearLayoutHorizontalTest >> testElementWithOneChildMatchInExactParentPadding [ - - + + + | parent child | child := self testChildElementMatchingParent. parent := self testParentWithLinearHorizontalLayout. parent constraints horizontal exact: 400. parent constraints vertical exact: 600. parent constraints padding: (BlInsets all: 20). - parent addChildren: {child}. + parent addChildren: { child }. parent forceLayout. self assert: child extent equals: 360 @ 560. self assert: child position equals: 20 @ 20. @@ -37,7 +33,7 @@ BlLinearLayoutHorizontalTest >> testElementWithOneChildMatchInExactParentPadding BlLinearLayoutHorizontalTest >> testElementWithOneChildMatchOneExactInFitParent [ "All children are distributed equally within parent's bounds" - + | parent childA childB | childA := self childExact: 300 @ 200. childB := self childExactWidth: 200. @@ -45,10 +41,9 @@ BlLinearLayoutHorizontalTest >> testElementWithOneChildMatchOneExactInFitParent parent := self testParentWithLinearHorizontalLayout. parent constraints horizontal fitContent. parent constraints vertical fitContent. - parent - addChildren: - {childA. - childB}. + parent addChildren: { + childA. + childB }. parent forceLayout. self assert: childA extent equals: 300 @ 200. self assert: childA position equals: 0 @ 0. @@ -63,20 +58,18 @@ BlLinearLayoutHorizontalTest >> testElementWithOneChildMatchOneExactInFitParent BlLinearLayoutHorizontalTest >> testElementWithOneExactChildInExactParentMargin [ "All children are distributed equally within parent's bounds" - + | parent childA | childA := self childExact: 20 @ 20. - childA - margin: - (BlInsets - top: 15 - right: 0 - bottom: 0 - left: 10). + childA margin: (BlInsets + top: 15 + right: 0 + bottom: 0 + left: 10). parent := self testParentWithLinearHorizontalLayout. parent constraints horizontal exact: 50. parent constraints vertical exact: 50. - parent addChildren: {childA}. + parent addChildren: { childA }. parent forceLayout. self assert: childA extent equals: 20 @ 20. self assert: childA position equals: 10 @ 15. @@ -89,7 +82,7 @@ BlLinearLayoutHorizontalTest >> testElementWithOneExactChildInExactParentMargin BlLinearLayoutHorizontalTest >> testElementWithThreeMatchChildrenInExactParent [ "All children are distributed equally within parent's bounds" - + | parent childA childB childC | childA := self testChildElementMatchingParent. childB := self testChildElementMatchingParent. @@ -97,11 +90,10 @@ BlLinearLayoutHorizontalTest >> testElementWithThreeMatchChildrenInExactParent [ parent := self testParentWithLinearHorizontalLayout. parent constraints horizontal exact: 600. parent constraints vertical exact: 200. - parent - addChildren: - {childA. + parent addChildren: { + childA. childB. - childC}. + childC }. parent forceLayout. self assert: childA extent equals: 200 @ 200. self assert: childA position equals: 0 @ 0. @@ -118,7 +110,7 @@ BlLinearLayoutHorizontalTest >> testElementWithThreeMatchChildrenInExactParent [ BlLinearLayoutHorizontalTest >> testElementWithThreeMatchChildrenInExactParentRTL [ "All children are distributed equally within parent's bounds" - + | parent childA childB childC | childA := self testChildElementMatchingParent. childB := self testChildElementMatchingParent. @@ -127,11 +119,10 @@ BlLinearLayoutHorizontalTest >> testElementWithThreeMatchChildrenInExactParentRT parent layout rightToLeft. parent constraints horizontal exact: 600. parent constraints vertical exact: 200. - parent - addChildren: - {childA. + parent addChildren: { + childA. childB. - childC}. + childC }. parent forceLayout. self assert: childC extent equals: 200 @ 200. self assert: childC position equals: 0 @ 0. @@ -148,7 +139,7 @@ BlLinearLayoutHorizontalTest >> testElementWithThreeMatchChildrenInExactParentRT BlLinearLayoutHorizontalTest >> testElementWithTwoChildrenMatchInExactParentPadding [ "All children are distributed equally within parent's bounds" - + | parent childA childB | childA := self testChildElementMatchingParent. childB := self testChildElementMatchingParent. @@ -156,10 +147,9 @@ BlLinearLayoutHorizontalTest >> testElementWithTwoChildrenMatchInExactParentPadd parent constraints horizontal exact: 400. parent constraints vertical exact: 600. parent constraints padding: (BlInsets all: 20). - parent - addChildren: - {childA. - childB}. + parent addChildren: { + childA. + childB }. parent forceLayout. self assert: childA extent equals: 180 @ 560. self assert: childA position equals: 20 @ 20. @@ -174,17 +164,16 @@ BlLinearLayoutHorizontalTest >> testElementWithTwoChildrenMatchInExactParentPadd BlLinearLayoutHorizontalTest >> testElementWithTwoExactChildrenInFitContent [ "Parent resizes to fit children" - + | parent childA childB | childA := self childExact: 200 @ 100. childB := self childExact: 100 @ 200. parent := self testParentWithLinearHorizontalLayout. parent constraints horizontal fitContent. parent constraints vertical fitContent. - parent - addChildren: - {childA. - childB}. + parent addChildren: { + childA. + childB }. parent forceLayout. self assert: childA extent equals: 200 @ 100. self assert: childA position equals: 0 @ 0. @@ -199,17 +188,16 @@ BlLinearLayoutHorizontalTest >> testElementWithTwoExactChildrenInFitContent [ BlLinearLayoutHorizontalTest >> testElementWithTwoMatchChildrenInExactParent [ "All children are distributed equally within parent's bounds" - + | parent childA childB | childA := self testChildElementMatchingParent. childB := self testChildElementMatchingParent. parent := self testParentWithLinearHorizontalLayout. parent constraints horizontal exact: 500. parent constraints vertical exact: 200. - parent - addChildren: - {childA. - childB}. + parent addChildren: { + childA. + childB }. parent forceLayout. self assert: childA extent equals: 250 @ 200. self assert: childA position equals: 0 @ 0. @@ -222,28 +210,28 @@ BlLinearLayoutHorizontalTest >> testElementWithTwoMatchChildrenInExactParent [ { #category : #tests } BlLinearLayoutHorizontalTest >> testOneChildSetVisibilityGone [ - + + | aContainer aRed aBlue | aContainer := BlElement new - layout: (BlLinearLayout horizontal cellSpacing: 20); - padding: (BlInsets top: 10 bottom: 10); - size: 500 @ 400. + layout: (BlLinearLayout horizontal cellSpacing: 20); + padding: (BlInsets top: 10 bottom: 10); + size: 500 @ 400. aRed := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - border: (BlBorder paint: Color red darker width: 1); - background: (Color red alpha: 0.3). + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + border: (BlBorder paint: Color red darker width: 1); + background: (Color red alpha: 0.3). aBlue := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - border: (BlBorder paint: Color blue darker width: 1); - background: (Color blue alpha: 0.3). - aContainer - addChildren: - {aRed. - aBlue}. + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + border: (BlBorder paint: Color blue darker width: 1); + background: (Color blue alpha: 0.3). + aContainer addChildren: { + aRed. + aBlue }. aContainer forceLayout. self assert: aContainer extent equals: 500 @ 400. self assert: aRed position equals: 20 @ 10. @@ -263,16 +251,16 @@ BlLinearLayoutHorizontalTest >> testOneChildSetVisibilityGone [ { #category : #tests } BlLinearLayoutHorizontalTest >> testParentWithLinearHorizontalLayout [ - + + | element | element := BlElement new - border: - (BlBorder builder - dashed; - paint: Color red; - width: 3; - build); - layout: BlLinearLayout horizontal. + border: (BlBorder builder + dashed; + paint: Color red; + width: 3; + build); + layout: BlLinearLayout horizontal. self assert: element layout class equals: BlLinearLayout. self assert: element layout isHorizontal. ^ element @@ -280,6 +268,7 @@ BlLinearLayoutHorizontalTest >> testParentWithLinearHorizontalLayout [ { #category : #tests } BlLinearLayoutHorizontalTest >> testParentWithLinearHorizontalLayoutWithCellSpacing [ + | element child1 child2 | element := BlElement new layout: BlLinearLayout horizontal. self assert: element layout class equals: BlLinearLayout. @@ -295,12 +284,12 @@ BlLinearLayoutHorizontalTest >> testParentWithLinearHorizontalLayoutWithCellSpac element forceLayout. self assert: element width equals: 15. self assert: child1 position x equals: 5. - self assert: child2 position x equals: 10. - + self assert: child2 position x equals: 10 ] { #category : #tests } BlLinearLayoutHorizontalTest >> testParentWithLinearLayoutWithCellSpacing [ + | element child1 child2 | element := BlElement new layout: BlLinearLayout vertical. self assert: element layout class equals: BlLinearLayout. @@ -325,21 +314,25 @@ BlLinearLayoutHorizontalTest >> testParentWithLinearLayoutWithCellSpacing [ element layout: (BlLinearLayout vertical cellSpacing: 5). element forceLayout. self assert: child1 position y equals: 5. - self assert: child2 position y equals: 10. - - - + self assert: child2 position y equals: 10 ] { #category : #tests } BlLinearLayoutHorizontalTest >> testParentWithLinearLayoutWithCellSpacingChangingDirection [ + | element child1 child2 | element := BlElement new layout: BlLinearLayout vertical. self assert: element layout class equals: BlLinearLayout. self assert: element layout isVertical. - element constraintsDo: [ :c | c vertical fitContent. c horizontal fitContent]. - child1 := BlElement new height: 0; width: 0. - child2 := BlElement new height: 0; width: 0. + element constraintsDo: [ :c | + c vertical fitContent. + c horizontal fitContent ]. + child1 := BlElement new + height: 0; + width: 0. + child2 := BlElement new + height: 0; + width: 0. element addChild: child1. element addChild: child2. element forceLayout. @@ -367,20 +360,17 @@ BlLinearLayoutHorizontalTest >> testParentWithLinearLayoutWithCellSpacingChangin element forceLayout. self assert: element width equals: 15. self assert: child1 position x equals: 5. - self assert: child2 position x equals: 10. - - - - - - + self assert: child2 position x equals: 10 ] { #category : #tests } BlLinearLayoutHorizontalTest >> testParentWithLinearVerticalLayoutWithCellSpacing [ + | element child1 child2 | element := BlElement new layout: BlLinearLayout vertical. - element constraintsDo: [ :c | c linear vertical alignCenter. c linear horizontal alignCenter]. + element constraintsDo: [ :c | + c linear vertical alignCenter. + c linear horizontal alignCenter ]. self assert: element layout class equals: BlLinearLayout. self assert: element layout isVertical. element constraintsDo: [ :c | c vertical fitContent ]. @@ -403,8 +393,5 @@ BlLinearLayoutHorizontalTest >> testParentWithLinearVerticalLayoutWithCellSpacin element layout: (BlLinearLayout vertical cellSpacing: 5). element forceLayout. self assert: child1 position y equals: 5. - self assert: child2 position y equals: 10. - - - + self assert: child2 position y equals: 10 ] diff --git a/src/Bloc-Layout-Tests/BlLinearLayoutTest.class.st b/src/Bloc-Layout-Tests/BlLinearLayoutTest.class.st new file mode 100644 index 000000000..b3fc9ff12 --- /dev/null +++ b/src/Bloc-Layout-Tests/BlLinearLayoutTest.class.st @@ -0,0 +1,5 @@ +Class { + #name : #BlLinearLayoutTest, + #superclass : #BlRootLayoutTest, + #category : #'Bloc-Layout-Tests' +} diff --git a/src/Bloc-Layout-Tests/BlLinearLayoutUsageTest.class.st b/src/Bloc-Layout-Tests/BlLinearLayoutUsageTest.class.st index dd286c93a..5ecd8eaff 100644 --- a/src/Bloc-Layout-Tests/BlLinearLayoutUsageTest.class.st +++ b/src/Bloc-Layout-Tests/BlLinearLayoutUsageTest.class.st @@ -4,19 +4,14 @@ I have been automatically converted and probably manually tweaked from BlLinearL " Class { #name : #BlLinearLayoutUsageTest, - #superclass : #BlRootLayoutTest, + #superclass : #BlLinearLayoutTest, #category : #'Bloc-Layout-Tests' } -{ #category : #metadata } -BlLinearLayoutUsageTest >> originClassName [ - "This test was generated from..." - ^ 'BlLinearLayoutUsageExamples' -] - { #category : #tests } BlLinearLayoutUsageTest >> testEqualizingHeighAndWidth [ - + + | parent | parent := self twoChildrenMatchParentInFitContent. parent layoutDo: [ :aLayout | aLayout withSpaceEqualization ]. @@ -25,7 +20,8 @@ BlLinearLayoutUsageTest >> testEqualizingHeighAndWidth [ { #category : #tests } BlLinearLayoutUsageTest >> testEqualizingWidth [ - + + | parent | "width is by default equalized" parent := self twoChildrenMatchParentInFitContent. @@ -34,400 +30,411 @@ BlLinearLayoutUsageTest >> testEqualizingWidth [ { #category : #tests } BlLinearLayoutUsageTest >> testExampleHorizontalListFixedWidthLTR [ - + + | e1 e2 e3 el space | e1 := BlElement new - border: (BlBorder paint: Color darkGray width: 4); - constraintsDo: [ :c | - c horizontal exact: 80. - c vertical matchParent ]; - background: Color red. + border: (BlBorder paint: Color darkGray width: 4); + constraintsDo: [ :c | + c horizontal exact: 80. + c vertical matchParent ]; + background: Color red. e2 := BlElement new - border: (BlBorder paint: Color black width: 4); - constraintsDo: [ :c | - c horizontal exact: 80. - c vertical matchParent ]; - background: Color green. + border: (BlBorder paint: Color black width: 4); + constraintsDo: [ :c | + c horizontal exact: 80. + c vertical matchParent ]; + background: Color green. e3 := BlElement new - border: (BlBorder paint: Color lightGray width: 4); - constraintsDo: [ :c | - c horizontal exact: 80. - c vertical matchParent ]; - background: Color yellow. + border: (BlBorder paint: Color lightGray width: 4); + constraintsDo: [ :c | + c horizontal exact: 80. + c vertical matchParent ]; + background: Color yellow. el := BlElement new - layout: BlLinearLayout horizontal; - size: 450 @ 150; - position: 200 @ 100; - padding: (BlInsets all: 10); - background: Color blue; - addChildren: - {e1. - e2. - e3}. + layout: BlLinearLayout horizontal; + size: 450 @ 150; + position: 200 @ 100; + padding: (BlInsets all: 10); + background: Color blue; + addChildren: { + e1. + e2. + e3 }. ^ el ] { #category : #tests } BlLinearLayoutUsageTest >> testExampleHorizontalListFixedWidthRTL [ - - | e1 e2 e3 el space | + + + | e1 e2 e3 el | e1 := BlElement new - border: (BlBorder paint: Color darkGray width: 4); - constraintsDo: [ :c | - c horizontal exact: 80. - c vertical matchParent ]; - background: Color red. + border: (BlBorder paint: Color darkGray width: 4); + constraintsDo: [ :c | + c horizontal exact: 80. + c vertical matchParent ]; + background: Color red. e2 := BlElement new - border: (BlBorder paint: Color black width: 4); - constraintsDo: [ :c | - c horizontal exact: 80. - c vertical matchParent ]; - background: Color green. + border: (BlBorder paint: Color black width: 4); + constraintsDo: [ :c | + c horizontal exact: 80. + c vertical matchParent ]; + background: Color green. e3 := BlElement new - border: (BlBorder paint: Color lightGray width: 4); - constraintsDo: [ :c | - c horizontal exact: 80. - c vertical matchParent ]; - background: Color yellow. + border: (BlBorder paint: Color lightGray width: 4); + constraintsDo: [ :c | + c horizontal exact: 80. + c vertical matchParent ]; + background: Color yellow. el := BlElement new - layout: BlLinearLayout horizontal rightToLeft; - size: 450 @ 150; - position: 200 @ 100; - padding: (BlInsets all: 10); - background: Color blue; - addChildren: - {e1. - e2. - e3}. + layout: BlLinearLayout horizontal rightToLeft; + size: 450 @ 150; + position: 200 @ 100; + padding: (BlInsets all: 10); + background: Color blue; + addChildren: { + e1. + e2. + e3 }. ^ el ] { #category : #tests } BlLinearLayoutUsageTest >> testExampleHorizontalListLTR [ - - | e1 e2 e3 el space | + + + | e1 e2 e3 el | e1 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - background: Color red. + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + background: Color red. e2 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - background: Color green. + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + background: Color green. e3 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - background: Color yellow. + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + background: Color yellow. el := BlElement new - layout: BlLinearLayout horizontal; - size: 300 @ 80; - position: 200 @ 100; - background: Color blue; - addChildren: - {e1. - e2. - e3}. + layout: BlLinearLayout horizontal; + size: 300 @ 80; + position: 200 @ 100; + background: Color blue; + addChildren: { + e1. + e2. + e3 }. ^ el ] { #category : #tests } BlLinearLayoutUsageTest >> testExampleHorizontalListRTL [ - - | e1 e2 e3 el space | + + + | e1 e2 e3 el | e1 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - background: Color red. + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + background: Color red. e2 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - background: Color green. + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + background: Color green. e3 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - background: Color yellow. + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + background: Color yellow. el := BlElement new - layout: BlLinearLayout horizontal rightToLeft; - size: 300 @ 80; - position: 200 @ 100; - background: Color veryVeryLightGray; - addChildren: - {e1. - e2. - e3}. + layout: BlLinearLayout horizontal rightToLeft; + size: 300 @ 80; + position: 200 @ 100; + background: Color veryVeryLightGray; + addChildren: { + e1. + e2. + e3 }. ^ el ] { #category : #tests } BlLinearLayoutUsageTest >> testExampleHorizontalTopCenterBottomLTR [ - - | e1 e2 e3 el space | + + + | e1 e2 e3 el | e1 := BlElement new - constraintsDo: [ :c | c linear vertical alignTop ]; - background: Color red. + constraintsDo: [ :c | c linear vertical alignTop ]; + background: Color red. e2 := BlElement new - constraintsDo: [ :c | c linear vertical alignCenter ]; - background: Color green. + constraintsDo: [ :c | c linear vertical alignCenter ]; + background: Color green. e3 := BlElement new - constraintsDo: [ :c | c linear vertical alignBottom ]; - background: Color yellow. + constraintsDo: [ :c | c linear vertical alignBottom ]; + background: Color yellow. el := BlElement new - layout: BlLinearLayout horizontal; - size: 300 @ 80; - position: 200 @ 100; - background: Color blue; - addChildren: - {e1. - e2. - e3}. + layout: BlLinearLayout horizontal; + size: 300 @ 80; + position: 200 @ 100; + background: Color blue; + addChildren: { + e1. + e2. + e3 }. ^ el ] { #category : #tests } BlLinearLayoutUsageTest >> testExampleHorizontalTopCenterBottomRTL [ - - | e1 e2 e3 el space | + + + | e1 e2 e3 el | e1 := BlElement new - constraintsDo: [ :c | c linear vertical alignTop ]; - background: Color red. + constraintsDo: [ :c | c linear vertical alignTop ]; + background: Color red. e2 := BlElement new - constraintsDo: [ :c | c linear vertical alignCenter ]; - background: Color green. + constraintsDo: [ :c | c linear vertical alignCenter ]; + background: Color green. e3 := BlElement new - constraintsDo: [ :c | c linear vertical alignBottom ]; - background: Color yellow. + constraintsDo: [ :c | c linear vertical alignBottom ]; + background: Color yellow. el := BlElement new - layout: BlLinearLayout horizontal rightToLeft; - size: 300 @ 80; - position: 200 @ 100; - background: Color blue; - addChildren: - {e1. - e2. - e3}. + layout: BlLinearLayout horizontal rightToLeft; + size: 300 @ 80; + position: 200 @ 100; + background: Color blue; + addChildren: { + e1. + e2. + e3 }. ^ el ] { #category : #tests } BlLinearLayoutUsageTest >> testExampleHorizontalUsingWeightLTR [ - - | e1 e2 e3 el space | + + + | e1 e2 e3 el | e1 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent. - c linear weight: 1 ]; - background: Color red. + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent. + c linear weight: 1 ]; + background: Color red. e2 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent. - c linear weight: 2 ]; - background: Color green. + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent. + c linear weight: 2 ]; + background: Color green. e3 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent. - c linear weight: 3 ]; - background: Color yellow. + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent. + c linear weight: 3 ]; + background: Color yellow. el := BlElement new - layout: BlLinearLayout horizontal; - size: 300 @ 80; - position: 200 @ 100; - background: Color blue; - addChildren: - {e1. - e2. - e3}. + layout: BlLinearLayout horizontal; + size: 300 @ 80; + position: 200 @ 100; + background: Color blue; + addChildren: { + e1. + e2. + e3 }. ^ el ] { #category : #tests } BlLinearLayoutUsageTest >> testExampleHorizontalUsingWeightRTL [ - - | e1 e2 e3 el space | + + + | e1 e2 e3 el | e1 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent. - c linear weight: 1 ]; - background: Color red. + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent. + c linear weight: 1 ]; + background: Color red. e2 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent. - c linear weight: 2 ]; - background: Color green. + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent. + c linear weight: 2 ]; + background: Color green. e3 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent. - c linear weight: 3 ]; - background: Color yellow. + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent. + c linear weight: 3 ]; + background: Color yellow. el := BlElement new - layout: BlLinearLayout horizontal rightToLeft; - size: 300 @ 80; - position: 200 @ 100; - background: Color blue; - addChildren: - {e1. - e2. - e3}. + layout: BlLinearLayout horizontal rightToLeft; + size: 300 @ 80; + position: 200 @ 100; + background: Color blue; + addChildren: { + e1. + e2. + e3 }. ^ el ] { #category : #tests } BlLinearLayoutUsageTest >> testExampleVerticalLeftCenterRightLRT [ - - | e1 e2 e3 el space | + + + | e1 e2 e3 el | e1 := BlElement new - constraintsDo: [ :c | - c linear horizontal alignLeft. - c vertical exact: 100 ]; - background: Color red. + constraintsDo: [ :c | + c linear horizontal alignLeft. + c vertical exact: 100 ]; + background: Color red. e2 := BlElement new - constraintsDo: [ :c | - c horizontal exact: 100. - c linear horizontal alignCenter ]; - background: Color green. + constraintsDo: [ :c | + c horizontal exact: 100. + c linear horizontal alignCenter ]; + background: Color green. e3 := BlElement new - size: 50 @ 50; - constraintsDo: [ :c | c linear horizontal alignRight ]; - background: Color yellow. + size: 50 @ 50; + constraintsDo: [ :c | c linear horizontal alignRight ]; + background: Color yellow. el := BlElement new - layout: BlLinearLayout vertical; - size: 200 @ 300; - position: 200 @ 100; - background: Color blue; - addChildren: - {e1. - e2. - e3}. + layout: BlLinearLayout vertical; + size: 200 @ 300; + position: 200 @ 100; + background: Color blue; + addChildren: { + e1. + e2. + e3 }. ^ el ] { #category : #tests } BlLinearLayoutUsageTest >> testExampleVerticalLeftCenterRightRTL [ - - | e1 e2 e3 el space | + + + | e1 e2 e3 el | e1 := BlElement new - constraintsDo: [ :c | - c vertical exact: 100. - c linear horizontal alignLeft ]; - background: Color red. + constraintsDo: [ :c | + c vertical exact: 100. + c linear horizontal alignLeft ]; + background: Color red. e2 := BlElement new - constraintsDo: [ :c | - c horizontal exact: 100. - c linear horizontal alignCenter ]; - background: Color green. + constraintsDo: [ :c | + c horizontal exact: 100. + c linear horizontal alignCenter ]; + background: Color green. e3 := BlElement new - size: 50 @ 50; - constraintsDo: [ :c | c linear horizontal alignRight ]; - background: Color yellow. + size: 50 @ 50; + constraintsDo: [ :c | c linear horizontal alignRight ]; + background: Color yellow. el := BlElement new - layout: BlLinearLayout vertical rightToLeft; - size: 200 @ 300; - position: 200 @ 100; - background: Color blue; - addChildren: - {e1. - e2. - e3}. + layout: BlLinearLayout vertical rightToLeft; + size: 200 @ 300; + position: 200 @ 100; + background: Color blue; + addChildren: { + e1. + e2. + e3 }. ^ el ] { #category : #tests } BlLinearLayoutUsageTest >> testExampleVerticalList [ - - | e1 e2 e3 el space | + + + | e1 e2 e3 el | e1 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - border: (BlBorder paint: Color darkGray width: 4); - background: Color red. + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + border: (BlBorder paint: Color darkGray width: 4); + background: Color red. e2 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - border: (BlBorder paint: Color black width: 4); - background: Color yellow. + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + border: (BlBorder paint: Color black width: 4); + background: Color yellow. e3 := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - border: (BlBorder paint: Color lightGray width: 4); - background: Color green. + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + border: (BlBorder paint: Color lightGray width: 4); + background: Color green. el := BlElement new - layout: BlLinearLayout vertical; - size: 80 @ 300; - position: 200 @ 100; - padding: (BlInsets all: 10); - background: Color blue; - addChildren: - {e1. - e2. - e3}. + layout: BlLinearLayout vertical; + size: 80 @ 300; + position: 200 @ 100; + padding: (BlInsets all: 10); + background: Color blue; + addChildren: { + e1. + e2. + e3 }. ^ el ] { #category : #tests } BlLinearLayoutUsageTest >> testExampleVerticalListFixedHeight [ - - | e1 e2 e3 el space | + + + | e1 e2 e3 el | e1 := BlElement new - constraintsDo: [ :c | c horizontal matchParent ]; - border: (BlBorder paint: Color darkGray width: 4); - background: Color red. + constraintsDo: [ :c | c horizontal matchParent ]; + border: (BlBorder paint: Color darkGray width: 4); + background: Color red. e2 := BlElement new - constraintsDo: [ :c | c horizontal matchParent ]; - border: (BlBorder paint: Color black width: 4); - background: Color yellow. + constraintsDo: [ :c | c horizontal matchParent ]; + border: (BlBorder paint: Color black width: 4); + background: Color yellow. e3 := BlElement new - constraintsDo: [ :c | c horizontal matchParent ]; - border: (BlBorder paint: Color lightGray width: 4); - background: Color green. + constraintsDo: [ :c | c horizontal matchParent ]; + border: (BlBorder paint: Color lightGray width: 4); + background: Color green. el := BlElement new - layout: BlLinearLayout vertical; - size: 80 @ 300; - position: 200 @ 100; - padding: (BlInsets all: 10); - background: Color blue; - addChildren: - {e1. - e2. - e3}. + layout: BlLinearLayout vertical; + size: 80 @ 300; + position: 200 @ 100; + padding: (BlInsets all: 10); + background: Color blue; + addChildren: { + e1. + e2. + e3 }. ^ el ] { #category : #tests } BlLinearLayoutUsageTest >> testMatchParentInFitContent [ - - + + + "If all children in the parent that fits content match parent then they should be measured with 0 size" + | child parent | child := BlElement new. child layout: BlBasicLayout new. child background: (Color red alpha: 0.3). child border: (BlBorder paint: Color red width: 1). - child - constraintsDo: [ :c | - c horizontal exact: 100. - c vertical matchParent ]. + child constraintsDo: [ :c | + c horizontal exact: 100. + c vertical matchParent ]. parent := BlElement new. parent layout: BlLinearLayout horizontal. parent background: (Color gray alpha: 0.3). parent padding: (BlInsets all: 25). - parent - constraintsDo: [ :c | - c horizontal exact: 300. - c vertical fitContent ]. + parent constraintsDo: [ :c | + c horizontal exact: 300. + c vertical fitContent ]. parent addChild: child. parent forceLayout. self assert: parent extent equals: 300 @ 50. @@ -437,8 +444,9 @@ BlLinearLayoutUsageTest >> testMatchParentInFitContent [ { #category : #tests } BlLinearLayoutUsageTest >> testMatchParentInFitContentChangeBackToMatchParent [ - - + + + "Changing back to match parent should reset size to 0" | parent child | parent := self testMatchParentInFitContentChangeToExact. child := parent children first. @@ -451,8 +459,9 @@ BlLinearLayoutUsageTest >> testMatchParentInFitContentChangeBackToMatchParent [ { #category : #tests } BlLinearLayoutUsageTest >> testMatchParentInFitContentChangeToExact [ - - + + + "Now we change size to exact and expect parent to resize" | parent child | parent := self testMatchParentInFitContent. child := parent children first. @@ -465,29 +474,28 @@ BlLinearLayoutUsageTest >> testMatchParentInFitContentChangeToExact [ { #category : #tests } BlLinearLayoutUsageTest >> testOneChildWithFitContentLimited [ - + + | subChildren child parent | - subChildren := 4 - timesCollect: [ BlElement new - background: Color blue; - margin: (BlInsets all: 10); - size: 200 @ 150 ]. + subChildren := 4 timesCollect: [ + BlElement new + background: Color blue; + margin: (BlInsets all: 10); + size: 200 @ 150 ]. child := BlElement new. child layout: BlLinearLayout vertical. child background: (Color red alpha: 0.3). child border: (BlBorder paint: Color red width: 2). - child - constraintsDo: [ :c | - c horizontal matchParent. - c vertical fitContentLimited ]. + child constraintsDo: [ :c | + c horizontal matchParent. + c vertical fitContentLimited ]. child addChildren: subChildren. parent := BlElement new. parent background: (Color gray alpha: 0.3). parent padding: (BlInsets all: 25). - parent - constraintsDo: [ :c | - c horizontal exact: 300. - c vertical exact: 400 ]. + parent constraintsDo: [ :c | + c horizontal exact: 300. + c vertical exact: 400 ]. parent addChild: child. parent forceLayout. self assert: parent extent equals: 300 @ 400. @@ -497,21 +505,21 @@ BlLinearLayoutUsageTest >> testOneChildWithFitContentLimited [ { #category : #tests } BlLinearLayoutUsageTest >> testOneChildWithFitContentLimitedAndAnotherChild [ - + + | subChildren childA childB parent | - subChildren := 4 - timesCollect: [ BlElement new - background: Color blue; - margin: (BlInsets all: 10); - size: 200 @ 150 ]. + subChildren := 4 timesCollect: [ + BlElement new + background: Color blue; + margin: (BlInsets all: 10); + size: 200 @ 150 ]. childA := BlElement new. childA layout: BlLinearLayout vertical. childA background: (Color red alpha: 0.3). childA border: (BlBorder paint: Color red width: 2). - childA - constraintsDo: [ :c | - c horizontal matchParent. - c vertical fitContentLimited ]. + childA constraintsDo: [ :c | + c horizontal matchParent. + c vertical fitContentLimited ]. childA addChildren: subChildren. childB := BlElement new. childB background: (Color blue alpha: 0.3). @@ -520,14 +528,12 @@ BlLinearLayoutUsageTest >> testOneChildWithFitContentLimitedAndAnotherChild [ parent := BlElement new. parent layout: BlLinearLayout vertical. parent background: (Color gray alpha: 0.3). - parent - constraintsDo: [ :c | - c horizontal exact: 300. - c vertical exact: 400 ]. - parent - addChildren: - {childA. - childB}. + parent constraintsDo: [ :c | + c horizontal exact: 300. + c vertical exact: 400 ]. + parent addChildren: { + childA. + childB }. parent forceLayout. self assert: parent extent equals: 300 @ 400. self assert: childA extent equals: 300 @ 325. @@ -537,21 +543,21 @@ BlLinearLayoutUsageTest >> testOneChildWithFitContentLimitedAndAnotherChild [ { #category : #tests } BlLinearLayoutUsageTest >> testOneChildWithFitContentLimitedAndAnotherChildFitContent [ - + + | subChildren childA childB subChildB parent | - subChildren := 4 - timesCollect: [ BlElement new - background: Color blue; - margin: (BlInsets all: 10); - size: 200 @ 150 ]. + subChildren := 4 timesCollect: [ + BlElement new + background: Color blue; + margin: (BlInsets all: 10); + size: 200 @ 150 ]. childA := BlElement new. childA layout: BlLinearLayout vertical. childA background: (Color red alpha: 0.3). childA border: (BlBorder paint: Color red width: 2). - childA - constraintsDo: [ :c | - c horizontal matchParent. - c vertical fitContentLimited ]. + childA constraintsDo: [ :c | + c horizontal matchParent. + c vertical fitContentLimited ]. childA addChildren: subChildren. subChildB := BlElement new. subChildB background: (Color blue alpha: 0.3). @@ -560,22 +566,19 @@ BlLinearLayoutUsageTest >> testOneChildWithFitContentLimitedAndAnotherChildFitCo childB := BlElement new. childB layout: BlLinearLayout vertical. childB border: (BlBorder paint: Color blue width: 2). - childB - constraintsDo: [ :c | - c horizontal matchParent. - c vertical fitContent ]. + childB constraintsDo: [ :c | + c horizontal matchParent. + c vertical fitContent ]. childB addChild: subChildB. parent := BlElement new. parent layout: BlLinearLayout vertical. parent background: (Color gray alpha: 0.3). - parent - constraintsDo: [ :c | - c horizontal exact: 300. - c vertical exact: 400 ]. - parent - addChildren: - {childA. - childB}. + parent constraintsDo: [ :c | + c horizontal exact: 300. + c vertical exact: 400 ]. + parent addChildren: { + childA. + childB }. parent forceLayout. self assert: parent extent equals: 300 @ 400. self assert: childA extent equals: 300 @ 325. @@ -586,21 +589,21 @@ BlLinearLayoutUsageTest >> testOneChildWithFitContentLimitedAndAnotherChildFitCo { #category : #tests } BlLinearLayoutUsageTest >> testOneChildWithFitContentLimitedExceedsAndThreeChildlren [ - + + | subChildren childA childB childC childD parent | - subChildren := 4 - timesCollect: [ BlElement new - background: (Color red alpha: 0.5); - margin: (BlInsets all: 20); - size: 200 @ 100 ]. + subChildren := 4 timesCollect: [ + BlElement new + background: (Color red alpha: 0.5); + margin: (BlInsets all: 20); + size: 200 @ 100 ]. childA := BlElement new. childA layout: BlLinearLayout vertical. childA background: (Color red alpha: 0.3). childA border: (BlBorder paint: Color red width: 2). - childA - constraintsDo: [ :c | - c horizontal matchParent. - c vertical fitContentLimited ]. + childA constraintsDo: [ :c | + c horizontal matchParent. + c vertical fitContentLimited ]. childA addChildren: subChildren. childB := BlElement new. childB background: (Color blue alpha: 0.3). @@ -613,23 +616,20 @@ BlLinearLayoutUsageTest >> testOneChildWithFitContentLimitedExceedsAndThreeChild childD := BlElement new. childD background: (Color green darker alpha: 0.3). childD border: (BlBorder paint: Color green muchDarker width: 2). - childD - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]. + childD constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]. parent := BlElement new. parent layout: (BlLinearLayout vertical cellSpacing: 20). parent background: (Color gray alpha: 0.3). - parent - constraintsDo: [ :c | - c horizontal exact: 300. - c vertical exact: 400 ]. - parent - addChildren: - {childC. + parent constraintsDo: [ :c | + c horizontal exact: 300. + c vertical exact: 400 ]. + parent addChildren: { + childC. childA. childB. - childD}. + childD }. parent padding: (BlInsets left: 20 right: 20). parent forceLayout. self assert: parent extent equals: 300 @ 400. @@ -642,21 +642,21 @@ BlLinearLayoutUsageTest >> testOneChildWithFitContentLimitedExceedsAndThreeChild { #category : #tests } BlLinearLayoutUsageTest >> testOneChildWithFitContentLimitedExceedsAndTwoChildlren [ - + + | subChildren childA childB childC parent | - subChildren := 4 - timesCollect: [ BlElement new - background: (Color red alpha: 0.5); - margin: (BlInsets all: 20); - size: 200 @ 100 ]. + subChildren := 4 timesCollect: [ + BlElement new + background: (Color red alpha: 0.5); + margin: (BlInsets all: 20); + size: 200 @ 100 ]. childA := BlElement new. childA layout: BlLinearLayout vertical. childA background: (Color red alpha: 0.3). childA border: (BlBorder paint: Color red width: 2). - childA - constraintsDo: [ :c | - c horizontal matchParent. - c vertical fitContentLimited ]. + childA constraintsDo: [ :c | + c horizontal matchParent. + c vertical fitContentLimited ]. childA addChildren: subChildren. childB := BlElement new. childB background: (Color blue alpha: 0.3). @@ -669,15 +669,13 @@ BlLinearLayoutUsageTest >> testOneChildWithFitContentLimitedExceedsAndTwoChildlr parent := BlElement new. parent layout: (BlLinearLayout vertical cellSpacing: 20). parent background: (Color gray alpha: 0.3). - parent - constraintsDo: [ :c | - c horizontal exact: 300. - c vertical exact: 400 ]. - parent - addChildren: - {childC. + parent constraintsDo: [ :c | + c horizontal exact: 300. + c vertical exact: 400 ]. + parent addChildren: { + childC. childA. - childB}. + childB }. parent padding: (BlInsets left: 20 right: 20). parent forceLayout. self assert: parent extent equals: 300 @ 400. @@ -689,21 +687,21 @@ BlLinearLayoutUsageTest >> testOneChildWithFitContentLimitedExceedsAndTwoChildlr { #category : #tests } BlLinearLayoutUsageTest >> testOneChildWithFitContentLimitedExceedsNotAndThreeChildlren [ - + + | subChildren childA childB childC childD parent | - subChildren := 1 - timesCollect: [ BlElement new - background: (Color red alpha: 0.5); - margin: (BlInsets all: 20); - size: 200 @ 100 ]. + subChildren := 1 timesCollect: [ + BlElement new + background: (Color red alpha: 0.5); + margin: (BlInsets all: 20); + size: 200 @ 100 ]. childA := BlElement new. childA layout: BlLinearLayout vertical. childA background: (Color red alpha: 0.3). childA border: (BlBorder paint: Color red width: 2). - childA - constraintsDo: [ :c | - c horizontal matchParent. - c vertical fitContentLimited ]. + childA constraintsDo: [ :c | + c horizontal matchParent. + c vertical fitContentLimited ]. childA addChildren: subChildren. childB := BlElement new. childB background: (Color blue alpha: 0.3). @@ -716,23 +714,20 @@ BlLinearLayoutUsageTest >> testOneChildWithFitContentLimitedExceedsNotAndThreeCh childD := BlElement new. childD background: (Color green darker alpha: 0.3). childD border: (BlBorder paint: Color green muchDarker width: 2). - childD - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]. + childD constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]. parent := BlElement new. parent layout: (BlLinearLayout vertical cellSpacing: 20). parent background: (Color gray alpha: 0.3). - parent - constraintsDo: [ :c | - c horizontal exact: 300. - c vertical exact: 400 ]. - parent - addChildren: - {childC. + parent constraintsDo: [ :c | + c horizontal exact: 300. + c vertical exact: 400 ]. + parent addChildren: { + childC. childA. childB. - childD}. + childD }. parent padding: (BlInsets left: 20 right: 20). parent forceLayout. self assert: parent extent equals: 300 @ 400. @@ -745,21 +740,21 @@ BlLinearLayoutUsageTest >> testOneChildWithFitContentLimitedExceedsNotAndThreeCh { #category : #tests } BlLinearLayoutUsageTest >> testOneChildWithFitContentLimitedExceedsNotAndTwoChildlren [ - + + | subChildren childA childB childC parent | - subChildren := 1 - timesCollect: [ BlElement new - background: (Color red alpha: 0.5); - margin: (BlInsets all: 20); - size: 200 @ 100 ]. + subChildren := 1 timesCollect: [ + BlElement new + background: (Color red alpha: 0.5); + margin: (BlInsets all: 20); + size: 200 @ 100 ]. childA := BlElement new. childA layout: BlLinearLayout vertical. childA background: (Color red alpha: 0.3). childA border: (BlBorder paint: Color red width: 2). - childA - constraintsDo: [ :c | - c horizontal matchParent. - c vertical fitContentLimited ]. + childA constraintsDo: [ :c | + c horizontal matchParent. + c vertical fitContentLimited ]. childA addChildren: subChildren. childB := BlElement new. childB background: (Color blue alpha: 0.3). @@ -772,15 +767,13 @@ BlLinearLayoutUsageTest >> testOneChildWithFitContentLimitedExceedsNotAndTwoChil parent := BlElement new. parent layout: (BlLinearLayout vertical cellSpacing: 20). parent background: (Color gray alpha: 0.3). - parent - constraintsDo: [ :c | - c horizontal exact: 300. - c vertical exact: 400 ]. - parent - addChildren: - {childC. + parent constraintsDo: [ :c | + c horizontal exact: 300. + c vertical exact: 400 ]. + parent addChildren: { + childC. childA. - childB}. + childB }. parent padding: (BlInsets left: 20 right: 20). parent forceLayout. self assert: parent extent equals: 300 @ 400. @@ -792,34 +785,32 @@ BlLinearLayoutUsageTest >> testOneChildWithFitContentLimitedExceedsNotAndTwoChil { #category : #tests } BlLinearLayoutUsageTest >> testTwoChildrenMatchParentInFitContent [ - + + | parent child child2 | parent := BlElement new. parent layout: BlLinearLayout vertical. parent background: (Color gray alpha: 0.3). parent padding: (BlInsets all: 25). - parent - constraintsDo: [ :c | - c horizontal fitContent. - c vertical fitContent ]. + parent constraintsDo: [ :c | + c horizontal fitContent. + c vertical fitContent ]. child := BlTextElement new. child text: ('Hello world haba' asRopedText fontSize: 40). child background: (Color red alpha: 0.3). child margin: (BlInsets all: 5). child border: (BlBorder paint: Color red width: 1). - child - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]. + child constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]. child2 := BlTextElement new. child2 text: ('Hello' asRopedText fontSize: 15). child2 background: (Color blue alpha: 0.3). child2 margin: (BlInsets all: 5). child2 border: (BlBorder paint: Color blue width: 1). - child2 - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]. + child2 constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]. parent addChild: child. parent addChild: child2. parent forceLayout. @@ -828,83 +819,76 @@ BlLinearLayoutUsageTest >> testTwoChildrenMatchParentInFitContent [ { #category : #tests } BlLinearLayoutUsageTest >> testTwoChildrenOnOppositeSidesWithSpan [ - + + | parent left span right | parent := BlElement new. parent background: (Color gray alpha: 0.3). parent layout: BlLinearLayout horizontal. - parent - constraintsDo: [ :c | - c horizontal matchParent. - c vertical fitContent ]. + parent constraintsDo: [ :c | + c horizontal matchParent. + c vertical fitContent ]. left := BlElement new. left background: (Color red alpha: 0.3). left border: (BlBorder paint: Color red width: 1). left margin: (BlInsets all: 5). - left - constraintsDo: [ :c | - c horizontal exact: 200. - c vertical exact: 50. - c grid vertical alignCenter. - c grid horizontal alignLeft ]. + left constraintsDo: [ :c | + c horizontal exact: 200. + c vertical exact: 50. + c grid vertical alignCenter. + c grid horizontal alignLeft ]. span := BlElement new. - span - border: - (BlBorder builder dashed - width: 1; - paint: Color gray; - build). + span border: (BlBorder builder dashed + width: 1; + paint: Color gray; + build). span margin: (BlInsets all: 5). - span - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]. + span constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]. right := BlElement new. right margin: (BlInsets all: 5). right background: (Color blue alpha: 0.3). right border: (BlBorder paint: Color blue width: 1). - right - constraintsDo: [ :c | - c horizontal exact: 300. - c vertical exact: 30. - c linear vertical alignCenter ]. - parent - addChildren: - {left. + right constraintsDo: [ :c | + c horizontal exact: 300. + c vertical exact: 30. + c linear vertical alignCenter ]. + parent addChildren: { + left. span. - right}. + right }. ^ parent ] { #category : #tests } BlLinearLayoutUsageTest >> twoChildrenMatchParentInFitContent [ + + | parent child child2 | parent := BlElement new. parent layout: BlLinearLayout vertical. parent background: (Color gray alpha: 0.3). parent padding: (BlInsets all: 25). - parent - constraintsDo: [ :c | - c horizontal fitContent. - c vertical fitContent ]. + parent constraintsDo: [ :c | + c horizontal fitContent. + c vertical fitContent ]. child := BlTextElement new. child text: ('Hello world haba' asRopedText fontSize: 40). child background: (Color red alpha: 0.3). child margin: (BlInsets all: 5). child border: (BlBorder paint: Color red width: 1). - child - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]. + child constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]. child2 := BlTextElement new. child2 text: ('Hello' asRopedText fontSize: 15). child2 background: (Color blue alpha: 0.3). child2 margin: (BlInsets all: 5). child2 border: (BlBorder paint: Color blue width: 1). - child2 - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]. + child2 constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]. parent addChild: child. parent addChild: child2. parent forceLayout. diff --git a/src/Bloc-Layout-Tests/BlLinearLayoutVerticalTest.class.st b/src/Bloc-Layout-Tests/BlLinearLayoutVerticalTest.class.st index cc9f0d8bc..c3ad63e06 100644 --- a/src/Bloc-Layout-Tests/BlLinearLayoutVerticalTest.class.st +++ b/src/Bloc-Layout-Tests/BlLinearLayoutVerticalTest.class.st @@ -4,28 +4,22 @@ I have been automatically converted and probably manually tweaked from BlLinearL " Class { #name : #BlLinearLayoutVerticalTest, - #superclass : #BlRootLayoutTest, + #superclass : #BlLinearLayoutTest, #category : #'Bloc-Layout-Tests' } -{ #category : #metadata } -BlLinearLayoutVerticalTest >> originClassName [ - "This test was generated from..." - ^ 'BlLinearLayoutVerticalExamples' -] - { #category : #tests } BlLinearLayoutVerticalTest >> testElementWithChildMatchInExactParentPadding [ "All children are distributed equally within parent's bounds" - + | parent childA | childA := self testChildElementMatchingParent. parent := self testParentWithLinearHorizontalLayout. parent constraints horizontal exact: 400. parent constraints vertical exact: 600. parent constraints padding: (BlInsets all: 20). - parent addChildren: {childA}. + parent addChildren: { childA }. parent forceLayout. self assert: childA extent equals: 360 @ 560. self assert: childA position equals: 20 @ 20. @@ -38,7 +32,7 @@ BlLinearLayoutVerticalTest >> testElementWithChildMatchInExactParentPadding [ BlLinearLayoutVerticalTest >> testElementWithChildrenMatchInExactParentPadding [ "All children are distributed equally within parent's bounds" - + | parent childA childB | childA := self testChildElementMatchingParent. childB := self testChildElementMatchingParent. @@ -46,10 +40,9 @@ BlLinearLayoutVerticalTest >> testElementWithChildrenMatchInExactParentPadding [ parent constraints horizontal exact: 600. parent constraints vertical exact: 400. parent constraints padding: (BlInsets all: 20). - parent - addChildren: - {childA. - childB}. + parent addChildren: { + childA. + childB }. parent forceLayout. self assert: childA extent equals: 560 @ 180. self assert: childA position equals: 20 @ 20. @@ -64,17 +57,16 @@ BlLinearLayoutVerticalTest >> testElementWithChildrenMatchInExactParentPadding [ BlLinearLayoutVerticalTest >> testElementWithExactChildrenInFitContent [ "Parent resizes to fit children" - + | parent childA childB | childA := self childExact: 200 @ 100. childB := self childExact: 100 @ 200. parent := self testParentWithLinearHorizontalLayout. parent constraints horizontal fitContent. parent constraints vertical fitContent. - parent - addChildren: - {childA. - childB}. + parent addChildren: { + childA. + childB }. parent forceLayout. self assert: childA extent equals: 200 @ 100. self assert: childA position equals: 0 @ 0. @@ -89,7 +81,7 @@ BlLinearLayoutVerticalTest >> testElementWithExactChildrenInFitContent [ BlLinearLayoutVerticalTest >> testElementWithMatchChildrenInExactParent [ "All children are distributed equally within parent's bounds" - + | parent childA childB childC | childA := self testChildElementMatchingParent. childB := self testChildElementMatchingParent. @@ -97,11 +89,10 @@ BlLinearLayoutVerticalTest >> testElementWithMatchChildrenInExactParent [ parent := self testParentWithLinearHorizontalLayout. parent constraints horizontal exact: 200. parent constraints vertical exact: 600. - parent - addChildren: - {childA. + parent addChildren: { + childA. childB. - childC}. + childC }. parent forceLayout. self assert: childA extent equals: 200 @ 200. self assert: childA position equals: 0 @ 0. @@ -118,7 +109,7 @@ BlLinearLayoutVerticalTest >> testElementWithMatchChildrenInExactParent [ BlLinearLayoutVerticalTest >> testElementWithOneChildMatchOneExactInFitParent [ "All children are distributed equally within parent's bounds" - + | parent childA childB | childA := self childExact: 200 @ 300. childB := self childExactHeight: 200. @@ -126,10 +117,9 @@ BlLinearLayoutVerticalTest >> testElementWithOneChildMatchOneExactInFitParent [ parent := self testParentWithLinearHorizontalLayout. parent constraints horizontal fitContent. parent constraints vertical fitContent. - parent - addChildren: - {childA. - childB}. + parent addChildren: { + childA. + childB }. parent forceLayout. self assert: childA extent equals: 200 @ 300. self assert: childA position equals: 0 @ 0. @@ -144,20 +134,18 @@ BlLinearLayoutVerticalTest >> testElementWithOneChildMatchOneExactInFitParent [ BlLinearLayoutVerticalTest >> testElementWithOneExactChildInExactParentMargin [ "All children are distributed equally within parent's bounds" - + | parent childA | childA := self childExact: 20 @ 20. - childA - margin: - (BlInsets - top: 15 - right: 0 - bottom: 0 - left: 10). + childA margin: (BlInsets + top: 15 + right: 0 + bottom: 0 + left: 10). parent := self testParentWithLinearHorizontalLayout. parent constraints horizontal exact: 50. parent constraints vertical exact: 50. - parent addChildren: {childA}. + parent addChildren: { childA }. parent forceLayout. self assert: childA extent equals: 20 @ 20. self assert: childA position equals: 10 @ 15. @@ -168,7 +156,8 @@ BlLinearLayoutVerticalTest >> testElementWithOneExactChildInExactParentMargin [ { #category : #tests } BlLinearLayoutVerticalTest >> testElementWithThreeExactChildrenAlignInExactParentLTR [ - + + | parent childA childB childC | childA := self childExact: 100 @ 100. childB := self childExact: 200 @ 100. @@ -179,11 +168,10 @@ BlLinearLayoutVerticalTest >> testElementWithThreeExactChildrenAlignInExactParen parent := self testParentWithLinearHorizontalLayout. parent constraints horizontal exact: 500. parent constraints vertical exact: 600. - parent - addChildren: - {childA. + parent addChildren: { + childA. childB. - childC}. + childC }. parent forceLayout. self assert: childA extent equals: 100 @ 100. self assert: childA position equals: 0 @ 0. @@ -198,7 +186,8 @@ BlLinearLayoutVerticalTest >> testElementWithThreeExactChildrenAlignInExactParen { #category : #tests } BlLinearLayoutVerticalTest >> testElementWithThreeExactChildrenAlignInExactParentRTL [ - + + | parent childA childB childC | childA := self childExact: 100 @ 100. childB := self childExact: 200 @ 100. @@ -210,11 +199,10 @@ BlLinearLayoutVerticalTest >> testElementWithThreeExactChildrenAlignInExactParen parent layout rightToLeft. parent constraints horizontal exact: 500. parent constraints vertical exact: 600. - parent - addChildren: - {childA. + parent addChildren: { + childA. childB. - childC}. + childC }. parent forceLayout. self assert: childA extent equals: 100 @ 100. self assert: childA position equals: 400 @ 0. @@ -229,28 +217,28 @@ BlLinearLayoutVerticalTest >> testElementWithThreeExactChildrenAlignInExactParen { #category : #tests } BlLinearLayoutVerticalTest >> testOneChildSetVisibilityGone [ - + + | aContainer aRed aBlue | aContainer := BlElement new - layout: (BlLinearLayout vertical cellSpacing: 20); - padding: (BlInsets left: 10 right: 10); - size: 400 @ 500. + layout: (BlLinearLayout vertical cellSpacing: 20); + padding: (BlInsets left: 10 right: 10); + size: 400 @ 500. aRed := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - border: (BlBorder paint: Color red darker width: 1); - background: (Color red alpha: 0.3). + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + border: (BlBorder paint: Color red darker width: 1); + background: (Color red alpha: 0.3). aBlue := BlElement new - constraintsDo: [ :c | - c horizontal matchParent. - c vertical matchParent ]; - border: (BlBorder paint: Color blue darker width: 1); - background: (Color blue alpha: 0.3). - aContainer - addChildren: - {aRed. - aBlue}. + constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ]; + border: (BlBorder paint: Color blue darker width: 1); + background: (Color blue alpha: 0.3). + aContainer addChildren: { + aRed. + aBlue }. aContainer forceLayout. self assert: aContainer extent equals: 400 @ 500. self assert: aRed position equals: 10 @ 20. @@ -270,16 +258,16 @@ BlLinearLayoutVerticalTest >> testOneChildSetVisibilityGone [ { #category : #tests } BlLinearLayoutVerticalTest >> testParentWithLinearHorizontalLayout [ - + + | element | element := BlElement new - border: - (BlBorder builder - dashed; - paint: Color red; - width: 3; - build); - layout: BlLinearLayout vertical. + border: (BlBorder builder + dashed; + paint: Color red; + width: 3; + build); + layout: BlLinearLayout vertical. self assert: element layout class equals: BlLinearLayout. self assert: element layout isVertical. ^ element