Skip to content

Commit

Permalink
- test refactoring
Browse files Browse the repository at this point in the history
- added more tests
  • Loading branch information
Max Hoffmann committed May 20, 2021
1 parent b477da0 commit 6f76170
Show file tree
Hide file tree
Showing 20 changed files with 184 additions and 124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ createStartInformation: aMorph
with: #name -> 'rotation'
with: #value -> aMorph rotationDegrees.
Dictionary
with: #name -> 'positionx'
with: #name -> 'positionX'
with: #value -> aMorph x.
Dictionary
with: #name -> 'positiony'
with: #name -> 'positionY'
with: #value -> aMorph y.
Dictionary
with: #name -> 'width'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/20/2021 09:30",
"createStartInformation:" : "MH 5/20/2021 11:24",
"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
@@ -0,0 +1,10 @@
saveJson
colorFrameDictionary

^ Dictionary
with: #frame->500
with: #properties->{
Dictionary
with: #name->'color'
with: #value-> #(1.0 0.0 0.0).
}.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
saveJson
colorTreeNode
| aTreeNode animationsEditorProperty |

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'.

^ aTreeNode.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
saveJson
positionFrameDictionary
^ Dictionary
with: #frame -> 500
with: #properties -> {
Dictionary
with: #name -> 'positionX'
with: #value -> 100.
Dictionary
with: #name -> 'positionY'
with: #value -> 200.
}.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
saveJson
positionTreeNode
| aTreeNode animationsEditorProperty |

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.

^ aTreeNode.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
saveJson
rotationFrameDictionary
^ Dictionary
with: #frame -> 500
with: #properties -> {
Dictionary
with: #name -> 'rotation'
with: #value -> 70.
}.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
saveJson
rotationTreeNode
| aTreeNode animationsEditorProperty |

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.

^ aTreeNode.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
saveJson
sizeFrameDictionary
^ Dictionary
with: #frame -> 500
with: #properties -> {
Dictionary
with: #name -> 'width'
with: #value -> 100.
Dictionary
with: #name -> 'height'
with: #value -> 200.
}.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
saveJson
sizeTreeNode
| aTreeNode animationsEditorProperty |

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.

^ aTreeNode.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
saveJson
startInformationDictionary: aMorph
^ Dictionary
with: #type -> 'Morph'
with: #properties -> {
Dictionary
with: #name -> 'rotation'
with: #value -> aMorph rotationDegrees.
Dictionary
with: #name -> 'positionX'
with: #value -> aMorph x.
Dictionary
with: #name -> 'positionY'
with: #value -> aMorph y.
Dictionary
with: #name -> 'width'
with: #value -> aMorph width.
Dictionary
with: #name -> 'height'
with: #value -> aMorph height.
Dictionary
with: #name -> 'color'
with: #value -> aMorph color rgbTriplet.
}.

Original file line number Diff line number Diff line change
@@ -1,27 +1,9 @@
saveJson
testAddColorFrame
| 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 aTreeNode testFrame |

aTreeNode := self colorTreeNode.
jsonFrame := self animationsEditorInstance addColorFrame: aTreeNode.
self halt.
"also extract instantiation of testFrame"
testFrame := Dictionary
with: #frame->500
with: #properties->{
Dictionary
with: #name->'color'
with: #value-> #(1.0 0.0 0.0).
}.
testFrame := self colorFrameDictionary.

self assert: jsonFrame equals: testFrame.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
saveJson
testAddFrameForColor
| aDictionary aProperty |

aDictionary := ((self animationsEditorInstance addFrame: self colorTreeNode) at: self colorTreeNode title asSymbol) value.
aProperty := (aDictionary at: #properties) first.

self assert: (aProperty at: #name) equals: 'color'.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
saveJson
testAddMorphToJson
| aJsonStructure aDictionary anEntry |

aDictionary := Dictionary
with: #morphs -> {}.
aJsonStructure := self animationsEditorInstance addMorphToJson: aDictionary with: self colorTreeNode.
anEntry := (aJsonStructure at: #morphs) first.

self assert: (aJsonStructure at: #morphs) size > 0.
self assert: (anEntry at: #properties) size > 0.

Original file line number Diff line number Diff line change
@@ -1,30 +1,9 @@
saveJson
testAddPositionFrame
| jsonFrame aTreeNode animationsEditorProperty testFrame |

"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 aTreeNode testFrame |

aTreeNode := self positionTreeNode.
jsonFrame := self animationsEditorInstance addPositionFrame: aTreeNode.

"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.
}.
testFrame := self positionFrameDictionary.

self assert: jsonFrame equals: testFrame.
Original file line number Diff line number Diff line change
@@ -1,27 +1,9 @@
saveJson
testAddRotationFrame
| jsonFrame aTreeNode animationsEditorProperty testFrame |

"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 aTreeNode testFrame |

aTreeNode := self rotationTreeNode.
jsonFrame := self animationsEditorInstance addRotationFrame: aTreeNode.

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

self assert: jsonFrame equals: testFrame.
Original file line number Diff line number Diff line change
@@ -1,30 +1,9 @@
saveJson
testAddSizeFrame
| jsonFrame aTreeNode animationsEditorProperty testFrame |

"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 aTreeNode testFrame |

aTreeNode := self sizeTreeNode.
jsonFrame := self animationsEditorInstance addSizeFrame: aTreeNode.

"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.
}.
testFrame := self sizeFrameDictionary.

self assert: jsonFrame equals: testFrame.
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,7 @@ testCreateStartInformation

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 -> aMorph rotationDegrees.
Dictionary
with: #name -> 'positionx'
with: #value -> aMorph x.
Dictionary
with: #name -> 'positiony'
with: #value -> aMorph y.
Dictionary
with: #name -> 'width'
with: #value -> aMorph width.
Dictionary
with: #name -> 'height'
with: #value -> aMorph height.
Dictionary
with: #name -> 'color'
with: #value -> (aMorph color) asString.
}.
testJson := self startInformationDictionary: aMorph.

self assert: json equals: testJson.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ testDictionaryToJson

json := Dictionary
with: #Test -> 100.

jsonString := '{
"Test" : 100
}'.
Expand Down
Loading

0 comments on commit 6f76170

Please sign in to comment.