The Trunk: MorphicTests-mt.70.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: MorphicTests-mt.70.mcz

commits-2
Marcel Taeumel uploaded a new version of MorphicTests to project The Trunk:
http://source.squeak.org/trunk/MorphicTests-mt.70.mcz

==================== Summary ====================

Name: MorphicTests-mt.70
Author: mt
Time: 26 February 2021, 3:44:25.553955 pm
UUID: 6872ad63-f538-cf4a-b162-e1a236b6604b
Ancestors: MorphicTests-mt.69

Complements Morphic-mt.1726 with tests.

=============== Diff against MorphicTests-mt.69 ===============

Item was added:
+ ----- Method: MorphTest>>test01LayerNumberDefault (in category 'tests - submorphs - layers') -----
+ test01LayerNumberDefault
+
+ self assert: Morph new morphicLayerNumber isNumber.!

Item was added:
+ ----- Method: MorphTest>>test02LayerNumberCustom (in category 'tests - submorphs - layers') -----
+ test02LayerNumberCustom
+
+ | m |
+ m := Morph new.
+ self deny: 50 equals: m morphicLayerNumber.
+ m morphicLayerNumber: 50.
+ self assert: 50 equals: m morphicLayerNumber.!

Item was added:
+ ----- Method: MorphTest>>test03LayerNumberFromOwner (in category 'tests - submorphs - layers') -----
+ test03LayerNumberFromOwner
+ "If not specified, inherit the owner's layer number."
+
+ | m1 m2 |
+ m1 := Morph new.
+ m2 := Morph new.
+ m1 addMorph: m2.
+
+ m1 morphicLayerNumber: 50.
+ self assert: 50 equals: m2 morphicLayerNumber.
+
+ m2 morphicLayerNumber: 25.
+ self assert: 25 equals: m2 morphicLayerNumber.
+ !

Item was added:
+ ----- Method: MorphTest>>test04AddMorphInLayer (in category 'tests - submorphs - layers') -----
+ test04AddMorphInLayer
+
+ | container builder unordered ordered |
+ container := Morph new.
+ builder := [Morph new].
+
+ unordered := #(6.5 100 20 15 5.0 6 7 100 20 -10).
+ unordered := unordered collect: [:layerNumber |
+ {layerNumber . builder value morphicLayerNumber: layerNumber}].
+ unordered do: [:spec |
+ container addMorphBackInLayer: spec second].
+
+ ordered := unordered. "No need to reverse the list because add-to-back directly maps to the resulting submorph order."
+ ordered := ordered sorted: [:a :b | a first <= b first]. "Must be stable."
+ ordered := ordered collect: [:spec | spec second]. "Just the morphs."
+
+ self assert: (ordered hasEqualElements: container submorphs).!

Item was added:
+ ----- Method: MorphTest>>test05AddMorphFrontInLayer (in category 'tests - submorphs - layers') -----
+ test05AddMorphFrontInLayer
+
+ | container builder unordered ordered |
+ container := Morph new.
+ builder := [Morph new].
+
+ unordered := #(6.5 100 20 15 5.0 6 7 100 20 -10).
+ unordered := unordered collect: [:layerNumber |
+ {layerNumber . builder value morphicLayerNumber: layerNumber}].
+ unordered do: [:spec |
+ container addMorphFrontInLayer: spec second].
+
+ ordered := unordered reversed. "Submorph order will be reversed due to add-to-front."
+ ordered := ordered sorted: [:a :b | a first <= b first]. "Must be stable."
+ ordered := ordered collect: [:spec | spec second]. "Just the morphs."
+
+ self assert: (ordered hasEqualElements: container submorphs).!

Item was added:
+ ----- Method: MorphTest>>test06AddMorphBackInLayer (in category 'tests - submorphs - layers') -----
+ test06AddMorphBackInLayer
+
+ | container builder unordered ordered |
+ container := Morph new.
+ builder := [Morph new].
+
+ unordered := #(6.5 100 20 15 5.0 6 7 100 20 -10).
+ unordered := unordered collect: [:layerNumber |
+ {layerNumber . builder value morphicLayerNumber: layerNumber}].
+ unordered do: [:spec |
+ container addMorphBackInLayer: spec second].
+
+ ordered := unordered. "No need to reverse the list because add-to-back directly maps to the resulting submorph order."
+ ordered := ordered sorted: [:a :b | a first <= b first]. "Must be stable."
+ ordered := ordered collect: [:spec | spec second]. "Just the morphs."
+
+ self assert: (ordered hasEqualElements: container submorphs).!

Item was added:
+ ----- Method: MorphTest>>test07ChangeLayerNumber (in category 'tests - submorphs - layers') -----
+ test07ChangeLayerNumber
+
+ | container m1 m2 |
+ container := Morph new.
+ m1 := Morph new.
+ m2 := Morph new.
+
+ m1 morphicLayerNumber: 20. "behind m2"
+ m2 morphicLayerNumber: 10. "in front of m1"
+
+ container addMorphInLayer: m1.
+ container addMorphInLayer: m2.
+ self assert: ({m2 . m1} hasEqualElements: container submorphs).
+
+ m1 morphicLayerNumber: 5. "go in front of m2"
+ container addMorphInLayer: m1.
+ self assert: ({m1 . m2} hasEqualElements: container submorphs).
+
+ m1 morphicLayerNumber: 50. "go behind m2 again"
+ container addMorphInLayer: m1.
+ self assert: ({m2 . m1} hasEqualElements: container submorphs).
+ !

Item was added:
+ ----- Method: MorphTest>>test08ChangeLayerNumberAuto (in category 'tests - submorphs - layers') -----
+ test08ChangeLayerNumberAuto
+
+ | container m1 m2 |
+ container := Morph new.
+ m1 := Morph new.
+ m2 := Morph new.
+
+ m1 morphicLayerNumber: 20. "behind m2"
+ m2 morphicLayerNumber: 10. "in front of m1"
+
+ container addMorphInLayer: m1.
+ container addMorphInLayer: m2.
+ self assert: ({m2 . m1} hasEqualElements: container submorphs).
+
+ m1 morphicLayerNumber: 5. "go in front of m2"
+ self assert: ({m1 . m2} hasEqualElements: container submorphs).
+
+ m1 morphicLayerNumber: 50. "go behind m2 again"
+ self assert: ({m2 . m1} hasEqualElements: container submorphs).!

Item was added:
+ ----- Method: MorphTest>>test09IgnoreLayer (in category 'tests - submorphs - layers') -----
+ test09IgnoreLayer
+
+ | container m1 m2 |
+ container := Morph new.
+ m1 := Morph new.
+ m2 := Morph new.
+
+ m1 morphicLayerNumber: 1.
+ m2 morphicLayerNumber: 999.
+
+ container addMorphFrontInLayer: m1.
+ container addMorphFront: m2. "Ignore the layer of m1."
+ self assert: ({m2 . m1} hasEqualElements: container submorphs).
+
+ container addMorphFrontInLayer: m1.
+ self assert: ({m1 . m2} hasEqualElements: container submorphs).!

Item was added:
+ ----- Method: MorphTest>>test10TransformKeepsLayer (in category 'tests - submorphs - layers') -----
+ test10TransformKeepsLayer
+
+ | morph transform |
+ morph := Morph new.
+ transform := morph addFlexShell.
+
+ morph morphicLayerNumber: 50.
+ self assert: 50 equals: transform morphicLayerNumber.
+
+ transform morphicLayerNumber: 20.
+ self assert: 20 equals: transform morphicLayerNumber.
+
+ transform removeMorph: morph.
+ transform morphicLayerNumber: 50.
+ self
+ assert: 20 equals: morph morphicLayerNumber;
+ assert: 50 equals: transform morphicLayerNumber.!

Item was added:
+ ----- Method: MorphTest>>test11NamedLayers (in category 'tests - submorphs - layers') -----
+ test11NamedLayers
+
+ #(
+ frontmostLayer
+
+ balloonLayer
+ haloLayer
+ menuLayer
+
+ progressLayer
+
+ dialogLayer
+ navigatorLayer
+ windowLayer
+
+ defaultLayer
+
+ backmostLayer
+
+ ) overlappingPairsDo: [:a :b |
+ self assert: (Morph perform: a) <= (Morph perform: b)]!

Item was added:
+ ----- Method: MorphTest>>test12ResetLayerToDefault (in category 'tests - submorphs - layers') -----
+ test12ResetLayerToDefault
+
+ | morph default |
+ morph := Morph new.
+ default := morph morphicLayerNumber.
+
+ morph morphicLayerNumber: default * 2.
+ self deny: default equals: morph morphicLayerNumber.
+
+ morph morphicLayerNumber: nil.
+ self assert: default equals: morph morphicLayerNumber.!

Item was changed:
+ ----- Method: MorphTest>>testAddAllMorphs (in category 'tests - submorphs - add/remove') -----
- ----- Method: MorphTest>>testAddAllMorphs (in category 'testing - add/remove submorphs') -----
  testAddAllMorphs
 
  self createAndAddMorphs: #(a b).
  self assert: #(a b) equals: self getSubmorphNames.
 
  morph addAllMorphs: (self createMorphs: #(x y)).
  self assert: #(a b x y) equals: self getSubmorphNames.
 
  morph removeAllMorphs.
  morph addAllMorphs: (self createMorphs: #(x y)).
  self assert: #(x y) equals: self getSubmorphNames.!

Item was changed:
+ ----- Method: MorphTest>>testAddAllMorphsAfter (in category 'tests - submorphs - add/remove') -----
- ----- Method: MorphTest>>testAddAllMorphsAfter (in category 'testing - add/remove submorphs') -----
  testAddAllMorphsAfter
 
  self createAndAddMorphs: #(a b).
  self assert: #(a b) equals: self getSubmorphNames.
 
  morph
  addAllMorphs: (self createMorphs: #(x y))
  after: (self getSubmorph: #a).
  self assert: #(a x y b) equals: self getSubmorphNames.
 
  morph
  addAllMorphs: (self getSubmorphs: #(x y))
  after: (self getSubmorph: #b).
  self assert: #(a b x y) equals: self getSubmorphNames.
 
  morph
  addAllMorphs: (self getSubmorphs: #(a x))
  after: (self getSubmorph: #y).
  self assert: #(b y a x) equals: self getSubmorphNames.
 
  morph
  addAllMorphs: (self getSubmorphs: #(x y))
  after: (self getSubmorph: #a).
  self assert: #(b a x y) equals: self getSubmorphNames.!

Item was changed:
+ ----- Method: MorphTest>>testAddAllMorphsInFrontOf (in category 'tests - submorphs - add/remove') -----
- ----- Method: MorphTest>>testAddAllMorphsInFrontOf (in category 'testing - add/remove submorphs') -----
  testAddAllMorphsInFrontOf
 
  self createAndAddMorphs: #(a b).
  self assert: #(a b) equals: self getSubmorphNames.
 
  morph
  addAllMorphs: (self createMorphs: #(x y))
  inFrontOf: (self getSubmorph: #b).
  self assert: #(a x y b) equals: self getSubmorphNames.
 
  morph
  addAllMorphs: (self getSubmorphs: #(x y))
  inFrontOf: (self getSubmorph: #a).
  self assert: #(x y a b) equals: self getSubmorphNames.
 
  morph
  addAllMorphs: (self getSubmorphs: #(y b))
  inFrontOf: (self getSubmorph: #x).
  self assert: #(y b x a) equals: self getSubmorphNames.
 
  morph
  addAllMorphs: (self getSubmorphs: #(x y))
  inFrontOf: (self getSubmorph: #b).
  self assert: #(x y b a) equals: self getSubmorphNames.!

Item was changed:
+ ----- Method: MorphTest>>testIntoWorldCollapseOutOfWorld (in category 'tests - into/outOf World') -----
- ----- Method: MorphTest>>testIntoWorldCollapseOutOfWorld (in category 'testing - into/outOf World') -----
  testIntoWorldCollapseOutOfWorld
  | m1 m2 collapsed |
  "Create the guys"
  m1 := TestInWorldMorph new.
  m2 := TestInWorldMorph new.
  self assert: (m1 intoWorldCount = 0).
  self assert: (m1 outOfWorldCount = 0).
  self assert: (m2 intoWorldCount = 0).
  self assert: (m2 outOfWorldCount = 0).
 
  "add them to basic morph"
  morph addMorphFront: m1.
  m1 addMorphFront: m2.
  self assert: (m1 intoWorldCount = 0).
  self assert: (m1 outOfWorldCount = 0).
  self assert: (m2 intoWorldCount = 0).
  self assert: (m2 outOfWorldCount = 0).
 
  "open the guy"
  morph openInWorld.
  self assert: (m1 intoWorldCount = 1).
  self assert: (m1 outOfWorldCount = 0).
  self assert: (m2 intoWorldCount = 1).
  self assert: (m2 outOfWorldCount = 0).
 
  "collapse it"
  collapsed := CollapsedMorph new beReplacementFor: morph.
  self assert: (m1 intoWorldCount = 1).
  self assert: (m1 outOfWorldCount = 1).
  self assert: (m2 intoWorldCount = 1).
  self assert: (m2 outOfWorldCount = 1).
 
  "expand it"
  collapsed collapseOrExpand.
  self assert: (m1 intoWorldCount = 2).
  self assert: (m1 outOfWorldCount = 1).
  self assert: (m2 intoWorldCount = 2).
  self assert: (m2 outOfWorldCount = 1).
 
  "delete it"
  morph delete.
  self assert: (m1 intoWorldCount = 2).
  self assert: (m1 outOfWorldCount = 2).
  self assert: (m2 intoWorldCount = 2).
  self assert: (m2 outOfWorldCount = 2).
  !

Item was changed:
+ ----- Method: MorphTest>>testIntoWorldDeleteOutOfWorld (in category 'tests - into/outOf World') -----
- ----- Method: MorphTest>>testIntoWorldDeleteOutOfWorld (in category 'testing - into/outOf World') -----
  testIntoWorldDeleteOutOfWorld
  | m1 m2 |
  "Create the guys"
  m1 := TestInWorldMorph new.
  m2 := TestInWorldMorph new.
  self assert: (m1 intoWorldCount = 0).
  self assert: (m1 outOfWorldCount = 0).
  self assert: (m2 intoWorldCount = 0).
  self assert: (m2 outOfWorldCount = 0).
 
  morph addMorphFront: m1.
  m1 addMorphFront:  m2.
  self assert: (m1 intoWorldCount = 0).
  self assert: (m1 outOfWorldCount = 0).
  self assert: (m2 intoWorldCount = 0).
  self assert: (m2 outOfWorldCount = 0).
 
  morph openInWorld.
  self assert: (m1 intoWorldCount = 1).
  self assert: (m1 outOfWorldCount = 0).
  self assert: (m2 intoWorldCount = 1).
  self assert: (m2 outOfWorldCount = 0).
 
  morph delete.
  self assert: (m1 intoWorldCount = 1).
  self assert: (m1 outOfWorldCount = 1).
  self assert: (m2 intoWorldCount = 1).
  self assert: (m2 outOfWorldCount = 1).
  !

Item was changed:
+ ----- Method: MorphTest>>testIntoWorldTransferToNewGuy (in category 'tests - into/outOf World') -----
- ----- Method: MorphTest>>testIntoWorldTransferToNewGuy (in category 'testing - into/outOf World') -----
  testIntoWorldTransferToNewGuy
  | m1 m2 |
  "Create the guys"
  m1 := TestInWorldMorph new.
  m2 := TestInWorldMorph new.
  self assert: (m1 intoWorldCount = 0).
  self assert: (m1 outOfWorldCount = 0).
  self assert: (m2 intoWorldCount = 0).
  self assert: (m2 outOfWorldCount = 0).
 
  morph addMorphFront: m1.
  m1 addMorphFront:  m2.
  self assert: (m1 intoWorldCount = 0).
  self assert: (m1 outOfWorldCount = 0).
  self assert: (m2 intoWorldCount = 0).
  self assert: (m2 outOfWorldCount = 0).
 
  morph openInWorld.
  self assert: (m1 intoWorldCount = 1).
  self assert: (m1 outOfWorldCount = 0).
  self assert: (m2 intoWorldCount = 1).
  self assert: (m2 outOfWorldCount = 0).
 
  morph addMorphFront: m2.
  self assert: (m1 intoWorldCount = 1).
  self assert: (m1 outOfWorldCount = 0).
  self assert: (m2 intoWorldCount = 1).
  self assert: (m2 outOfWorldCount = 0).
 
  morph addMorphFront: m1.
  self assert: (m1 intoWorldCount = 1).
  self assert: (m1 outOfWorldCount = 0).
  self assert: (m2 intoWorldCount = 1).
  self assert: (m2 outOfWorldCount = 0).
 
  m2 addMorphFront: m1.
  self assert: (m1 intoWorldCount = 1).
  self assert: (m1 outOfWorldCount = 0).
  self assert: (m2 intoWorldCount = 1).
  self assert: (m2 outOfWorldCount = 0).
 
  morph delete.
  self assert: (m1 intoWorldCount = 1).
  self assert: (m1 outOfWorldCount = 1).
  self assert: (m2 intoWorldCount = 1).
  self assert: (m2 outOfWorldCount = 1).
  !

Item was changed:
+ ----- Method: MorphTest>>testIsMorph (in category 'tests - classification') -----
- ----- Method: MorphTest>>testIsMorph (in category 'testing - classification') -----
  testIsMorph
  self assert: (morph isMorph).!

Item was changed:
+ ----- Method: MorphTest>>testOpenInWorld (in category 'tests - initialization') -----
- ----- Method: MorphTest>>testOpenInWorld (in category 'testing - initialization') -----
  testOpenInWorld
  "This should not throw an exception."
  morph openInWorld.!