Skip to content

Commit

Permalink
- changed some formattings (e.g. lowerCase titles in Dictionaries)
Browse files Browse the repository at this point in the history
- changed the current test structure (now: instantiation of the selectedTreeNode in the respective test Method)
- changed line-by-line asserts to Dictionary comparison
- WIP: extracting the instantiation
  • Loading branch information
nick-bessin committed May 19, 2021
1 parent e3e3e64 commit 43f83eb
Show file tree
Hide file tree
Showing 13 changed files with 146 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ addColorFrame: aTreeNode
with: #frame -> aTreeNode targetDuration
with: #properties -> {
Dictionary
with: #name -> aTreeNode title
with: #value -> aTreeNode targetColorAsString
with: #name -> aTreeNode title asLowercase
with: #value -> aTreeNode targetColorAsString.
}.

^ jsonFrame.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ addPositionFrame: aTreeNode
with: #frame -> aTreeNode targetDuration
with: #properties -> {
Dictionary
with: #name -> (aTreeNode title, 'X')
with: #value -> aTreeNode targetPosition x .
with: #name -> (aTreeNode title, 'X') asLowercase
with: #value -> aTreeNode targetPosition x.
Dictionary
with: #name -> (aTreeNode title, 'Y')
with: #value -> aTreeNode targetPosition y
with: #name -> (aTreeNode title, 'Y') asLowercase
with: #value -> aTreeNode targetPosition y.
}.

^ jsonFrame.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ addRotationFrame: aTreeNode
with: #frame -> aTreeNode targetDuration
with: #properties -> {
Dictionary
with: #name -> aTreeNode title
with: #value -> aTreeNode targetRotation
with: #name -> aTreeNode title asLowercase
with: #value -> aTreeNode targetRotation.
}.

^ jsonFrame.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ addSizeFrame: aTreeNode
with: #frame -> aTreeNode targetDuration
with: #properties -> {
Dictionary
with: #name -> 'Width'
with: #name -> 'width'
with: #value -> aTreeNode targetSize x.
Dictionary
with: #name -> 'Height'
with: #value -> aTreeNode targetSize y
with: #name -> 'height'
with: #value -> aTreeNode targetSize y.
}.

^ jsonFrame.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ saveJson
createStartInformation: aMorph

^ Dictionary
with: #type -> (aMorph class) asString
with: #type -> aMorph class asString
with: #properties -> {
Dictionary
with: #name -> 'rotation'
Expand All @@ -21,5 +21,5 @@ createStartInformation: aMorph
with: #value -> aMorph height.
Dictionary
with: #name -> 'color'
with: #value -> (aMorph color) asString
with: #value -> aMorph color asString.
}.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"class" : {
"open" : "DM 8/4/2020 13:18" },
"instance" : {
"addColorFrame:" : "MH 5/13/2021 11:46",
"addColorFrame:" : "NB 5/19/2021 12:43",
"addFrame:" : "NB 5/12/2021 09:25",
"addMorphToJson:with:" : "MH 5/15/2021 11:15",
"addPositionFrame:" : "NB 5/12/2021 10:00",
"addRotationFrame:" : "NB 5/12/2021 10:00",
"addPositionFrame:" : "NB 5/19/2021 12:43",
"addRotationFrame:" : "NB 5/19/2021 12:43",
"addSelectedMorphFor:" : "DM 8/5/2020 21:11",
"addSizeFrame:" : "MH 5/15/2021 09:59",
"addSizeFrame:" : "NB 5/19/2021 12:43",
"addTargetMorph:" : "MH 5/13/2021 11:32",
"addTimeline" : "DM 8/7/2020 21:26",
"buildAddMorphButtonWith:" : "LH 8/4/2020 15:42",
Expand All @@ -29,7 +29,7 @@
"createPositionPropertyFrom:" : "DM 8/6/2020 10:09",
"createRotationPropertyFrom:" : "DM 7/8/2020 14:29",
"createSizePropertyFrom:" : "DM 7/8/2020 14:29",
"createStartInformation:" : "MH 5/15/2021 11:15",
"createStartInformation:" : "NB 5/19/2021 12:36",
"createStructure:with:" : "NB 5/13/2021 10:25",
"defaultEmptyPanels" : "DM 8/7/2020 17:37",
"defaultPropertyPanelPosition" : "DM 8/6/2020 10:38",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ saveJson
setUp
| morph |

super setUp.
self animationsEditorInstance: AnimationsEditor open.
morph := Morph new.
morph openInWorld.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
saveJson
testAddColorFrame
| colorProperty jsonFrame aTreeNode |

colorProperty := ((self animationsEditorInstance propertyList at: 2) subproperties at: 2). "1: Rotation, 2: Color, 3: Position, 4: Size"
colorProperty targetColor: 'red'.

self animationsEditorInstance selectedTreeNode: colorProperty.
self animationsEditorInstance playAnimations.
aTreeNode := self animationsEditorInstance selectedTreeNode.
| jsonFrame aTreeNode animationsEditorProperty testFrame |

"still need to extract instantiation of the TreeNode"
animationsEditorProperty := self animationsEditorInstance propertyList at: 2.
aTreeNode := AnimationsEditorPropertyColor new.
aTreeNode
copyOfTargetMorph: animationsEditorProperty targetMorph;
targetMorph: aTreeNode copyOfTargetMorph copy.
aTreeNode targetMorph color: Color red.
aTreeNode
targetDuration: animationsEditorProperty defaultTargetDuration;
targetColor: 'red'.

jsonFrame := self animationsEditorInstance addColorFrame: aTreeNode.
self assert: (jsonFrame at: #frame) equals: aTreeNode targetDuration.
self assert: (((jsonFrame at: #properties) at: 1) at: #name) equals: 'Color'.
self assert: (((jsonFrame at: #properties) at: 1) at: #value) equals: 'Color red'.

"also extract instantiation of testFrame"
testFrame := Dictionary
with: #frame->500
with: #properties->{
Dictionary
with: #name->'Color'
with: #value->'Color red'.
}.

self assert: (jsonFrame = testFrame).
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
saveJson
testAddPositionFrame
| positionProperty jsonFrame aTreeNode |
| jsonFrame aTreeNode animationsEditorProperty testFrame |

positionProperty := ((self animationsEditorInstance propertyList at: 2) subproperties at: 3). "1: Rotation, 2: Color, 3: Position, 4: Size"
positionProperty targetPosition: 100 @ 200.

self animationsEditorInstance selectedTreeNode: positionProperty.
self animationsEditorInstance playAnimations.
aTreeNode := self animationsEditorInstance selectedTreeNode.
"still need to extract instantiation of the TreeNode"
animationsEditorProperty := self animationsEditorInstance propertyList at: 2.
aTreeNode := AnimationsEditorPropertyPosition new.
aTreeNode
copyOfTargetMorph: animationsEditorProperty targetMorph;
targetMorph: aTreeNode copyOfTargetMorph copy.
aTreeNode targetMorph position: 100 @ 200.
aTreeNode
targetDuration: animationsEditorProperty defaultTargetDuration;
targetPosition: 100 @ 200.

jsonFrame := self animationsEditorInstance addPositionFrame: aTreeNode.
self assert: (jsonFrame at: #frame) equals: aTreeNode targetDuration.
self assert: (((jsonFrame at: #properties) at: 1) at: #name) equals: 'PositionX'.
self assert: (((jsonFrame at: #properties) at: 1) at: #value) equals: 100.
self assert: (((jsonFrame at: #properties) at: 2) at: #name) equals: 'PositionY'.
self assert: (((jsonFrame at: #properties) at: 2) at: #value) equals: 200.

"also extract instantiation of testFrame"
testFrame := Dictionary
with: #frame -> 500
with: #properties -> {
Dictionary
with: #name -> 'PositionX'
with: #value -> 100.
Dictionary
with: #name -> 'PositionY'
with: #value -> 200.
}.

self assert: (jsonFrame = testFrame).
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
saveJson
testAddRotationFrame
| rotationProperty jsonFrame aTreeNode |
| jsonFrame aTreeNode animationsEditorProperty testFrame |

rotationProperty := ((self animationsEditorInstance propertyList at: 2) subproperties at: 1). "1: Rotation, 2: Color, 3: Position, 4: Size"
rotationProperty targetRotation: 45.

self animationsEditorInstance selectedTreeNode: rotationProperty.
self animationsEditorInstance playAnimations.
aTreeNode := self animationsEditorInstance selectedTreeNode.
"still need to extract instantiation of the TreeNode"
animationsEditorProperty := self animationsEditorInstance propertyList at: 2.
aTreeNode := AnimationsEditorPropertyRotation new.
aTreeNode
copyOfTargetMorph: animationsEditorProperty targetMorph;
targetMorph: aTreeNode copyOfTargetMorph copy.
aTreeNode targetMorph rotationDegrees: 70.
aTreeNode
targetDuration: animationsEditorProperty defaultTargetDuration;
targetRotation: 70.

jsonFrame := self animationsEditorInstance addRotationFrame: aTreeNode.
self assert: (jsonFrame at: #frame) equals: aTreeNode targetDuration.
self assert: (((jsonFrame at: #properties) at: 1) at: #name) equals: 'Rotation'.
self assert: (((jsonFrame at: #properties) at: 1) at: #value) equals: 45.

"also extract instantiation of testFrame"
testFrame := Dictionary
with: #frame -> 500
with: #properties -> {
Dictionary
with: #name -> 'Rotation'
with: #value -> 70.
}.

self assert: (jsonFrame = testFrame).
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
saveJson
testAddSizeFrame
| sizeProperty jsonFrame aTreeNode |
| jsonFrame aTreeNode animationsEditorProperty testFrame |

sizeProperty := ((self animationsEditorInstance propertyList at: 2) subproperties at: 4). "1: Rotation, 2: Color, 3: Position, 4: Size"
sizeProperty targetSize: 200 @ 100.

self animationsEditorInstance selectedTreeNode: sizeProperty.
self animationsEditorInstance playAnimations.
aTreeNode := self animationsEditorInstance selectedTreeNode.
"still need to extract instantiation of the TreeNode"
animationsEditorProperty := self animationsEditorInstance propertyList at: 2.
aTreeNode := AnimationsEditorPropertySize new.
aTreeNode
copyOfTargetMorph: animationsEditorProperty targetMorph;
targetMorph: aTreeNode copyOfTargetMorph copy.
aTreeNode targetMorph extent: 100 @ 200.
aTreeNode
targetDuration: animationsEditorProperty defaultTargetDuration;
targetSize: 100 @ 200.

jsonFrame := self animationsEditorInstance addSizeFrame: aTreeNode.
self assert: (jsonFrame at: #frame) equals: aTreeNode targetDuration.
self assert: (((jsonFrame at: #properties) at: 1) at: #name) equals: 'Width'.
self assert: (((jsonFrame at: #properties) at: 1) at: #value) equals: 200.
self assert: (((jsonFrame at: #properties) at: 2) at: #name) equals: 'Height'.
self assert: (((jsonFrame at: #properties) at: 2) at: #value) equals: 100.

"also extract instantiation of testFrame"
testFrame := Dictionary
with: #frame -> 500
with: #properties -> {
Dictionary
with: #name -> 'width'
with: #value -> 100.
Dictionary
with: #name -> 'height'
with: #value -> 200.
}.

self assert: (jsonFrame = testFrame).
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
saveJson
testCreateStartInformation
| json aMorph |
| json aMorph testJson |

aMorph := (self animationsEditorInstance propertyList at: 2) targetMorph.
json := self animationsEditorInstance createStartInformation: aMorph.

"also extract instantiation of testFrame"
testJson := Dictionary
with: #type -> 'Morph'
with: #properties -> {
Dictionary
with: #name -> 'rotation'
with: #value -> 0.
Dictionary
with: #name -> 'positionX'
with: #value -> 25.
Dictionary
with: #name -> 'positionY'
with: #value -> 974.
Dictionary
with: #name -> 'width'
with: #value -> 50.
Dictionary
with: #name -> 'height'
with: #value -> 40.
Dictionary
with: #name -> 'color'
with: #value -> 'Color blue'.
}.

"maby it's better to compare two dicts"
self assert: (json at: #type) equals: (aMorph class) asString.
self assert: (((json at: #properties) at: 1) at: #name) equals: 'rotation'.
self assert: (((json at: #properties) at: 1) at: #value) equals: aMorph rotationDegrees.
self assert: (((json at: #properties) at: 2) at: #name) equals: 'positionX'.
self assert: (((json at: #properties) at: 2) at: #value) equals: aMorph x.
self assert: (((json at: #properties) at: 3) at: #name) equals: 'positionY'.
self assert: (((json at: #properties) at: 3) at: #value) equals: aMorph y.
self assert: (((json at: #properties) at: 4) at: #name) equals: 'width'.
self assert: (((json at: #properties) at: 4) at: #value) equals: aMorph width.
self assert: (((json at: #properties) at: 5) at: #name) equals: 'height'.
self assert: (((json at: #properties) at: 5) at: #value) equals: aMorph height.
self assert: (((json at: #properties) at: 6) at: #name) equals: 'color'.
self assert: (((json at: #properties) at: 6) at: #value) equals: (aMorph color) asString.
self assert: (json = testJson)

Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"instance" : {
"animationsEditorInstance" : "MH 5/13/2021 13:19",
"animationsEditorInstance:" : "MH 5/13/2021 13:19",
"setUp" : "MH 5/15/2021 09:23",
"setUp" : "NB 5/19/2021 10:25",
"tearDown" : "MH 5/15/2021 10:33",
"testAddColorFrame" : "MH 5/15/2021 09:53",
"testAddPositionFrame" : "MH 5/15/2021 09:55",
"testAddRotationFrame" : "MH 5/15/2021 09:56",
"testAddSizeFrame" : "MH 5/15/2021 09:59",
"testCreateStartInformation" : "MH 5/15/2021 11:11",
"testAddColorFrame" : "NB 5/19/2021 12:25",
"testAddPositionFrame" : "NB 5/19/2021 12:22",
"testAddRotationFrame" : "NB 5/19/2021 12:25",
"testAddSizeFrame" : "NB 5/19/2021 12:33",
"testCreateStartInformation" : "NB 5/19/2021 12:42",
"testCreateStructure" : "MH 5/15/2021 11:24",
"testDictionaryToJson" : "MH 5/15/2021 10:35",
"testEmptyPanelsGetter" : "DM 8/7/2020 17:52",
Expand Down

0 comments on commit 43f83eb

Please sign in to comment.