Skip to content

Commit

Permalink
Merge d620e4c
Browse files Browse the repository at this point in the history
  • Loading branch information
JanBliznicenko committed Nov 13, 2024
2 parents dcf05f0 + d620e4c commit 7ce6832
Show file tree
Hide file tree
Showing 19 changed files with 149 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,40 +1,62 @@
Class {
#name : 'OPAbstractShapeTest',
#name : 'OPAbstractDiagramElementTest',
#superclass : 'TestCase',
#instVars : [
'canvas',
'shape'
'shape',
'model'
],
#category : 'OpenPonk-Core-Tests',
#package : 'OpenPonk-Core',
#tag : 'Tests'
}

{ #category : 'testing' }
OPAbstractShapeTest class >> isAbstract [
OPAbstractDiagramElementTest class >> isAbstract [
^ self name includesSubstring: 'Abstract'
]

{ #category : 'instance creation' }
OPAbstractShapeTest >> newShapeInstance [
OPAbstractDiagramElementTest >> modelClass [

^ self subclassResponsibility
]

{ #category : 'instance creation' }
OPAbstractDiagramElementTest >> newModelInstance [

^ self modelClass new
]

{ #category : 'instance creation' }
OPAbstractDiagramElementTest >> newShapeInstance [
^ self shapeClass new
]

{ #category : 'running' }
OPAbstractShapeTest >> setUp [
OPAbstractDiagramElementTest >> setUp [

super setUp.
shape := self newShapeInstance.
model := self newModelInstance.
shape modelElement: model.
canvas := RSCanvas new
]

{ #category : 'hooks' }
OPAbstractShapeTest >> shapeClass [
OPAbstractDiagramElementTest >> shapeClass [
^ self subclassResponsibility
]

{ #category : 'running' }
OPAbstractDiagramElementTest >> testEmpty [

self assert: shape modelElement equals: model.
self assertCollection: shape modelElements hasSameElements: { model }
]

{ #category : 'tests' }
OPAbstractShapeTest >> testRenderSimplifiedForController [
OPAbstractDiagramElementTest >> testRenderSimplifiedForController [

| diagramController controller |
canvas := RSCanvas new.
Expand Down
2 changes: 1 addition & 1 deletion repository/OpenPonk-Core/OPAbstractEdgeTest.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : 'OPAbstractEdgeTest',
#superclass : 'OPAbstractShapeTest',
#superclass : 'OPAbstractDiagramElementTest',
#category : 'OpenPonk-Core-Tests',
#package : 'OpenPonk-Core',
#tag : 'Tests'
Expand Down
2 changes: 1 addition & 1 deletion repository/OpenPonk-Core/OPAbstractLabelTest.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : 'OPAbstractLabelTest',
#superclass : 'OPAbstractShapeTest',
#superclass : 'OPAbstractNodeTest',
#category : 'OpenPonk-Core-Tests',
#package : 'OpenPonk-Core',
#tag : 'Tests'
Expand Down
51 changes: 51 additions & 0 deletions repository/OpenPonk-Core/OPAbstractNodeTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Class {
#name : 'OPAbstractNodeTest',
#superclass : 'OPAbstractDiagramElementTest',
#category : 'OpenPonk-Core-Tests',
#package : 'OpenPonk-Core',
#tag : 'Tests'
}

{ #category : 'tests' }
OPAbstractNodeTest >> testDoesNotMoveOnShapeCreation [

| diagram originalRoassalPosition movedRoassalPosition newShape |
diagram := OPDiagram new.
diagram renderIn: canvas.
shape owningElement: diagram.
shape modelElement: model.
shape renderIn: canvas.
shape isPositionableByUser ifFalse: [ ^ self ].
originalRoassalPosition := shape roassalShape position.
shape updateFromRender.
self assert: shape bounds position equals: originalRoassalPosition.
shape roassalShape translateBy: 100 @ 50.
movedRoassalPosition := shape roassalShape position.
self
assert: movedRoassalPosition
equals: originalRoassalPosition + (100 @ 50).
self assert: shape bounds position equals: originalRoassalPosition.
newShape := OPTestLabel in: diagram.
newShape renderIn: canvas.
self assert: shape bounds position equals: originalRoassalPosition.
self assert: shape roassalShape position equals: movedRoassalPosition
]

{ #category : 'tests' }
OPAbstractNodeTest >> testUpdateFromRender [

| originalBounds movedBounds |
self assert: shape bounds equals: nil.
shape modelElement: model.
shape renderIn: canvas.
shape updateFromRender.
shape isPositionableByUser ifFalse: [ ^ self ].
originalBounds := shape bounds veryDeepCopy.
shape roassalShape translateBy: 100 @ 50.
self assert: shape bounds position equals: originalBounds position.
shape updateFromRender.
movedBounds := shape bounds veryDeepCopy.
self deny: movedBounds position equals: originalBounds position.
self assert: movedBounds position equals: originalBounds position + (100 @ 50).

]
2 changes: 1 addition & 1 deletion repository/OpenPonk-Core/OPBoundNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ OPBoundNode >> renderIn: aCanvas [
{ #category : 'as yet unclassified' }
OPBoundNode >> updateFromRender [

self isResizableByUser | self isPositionableByUser ifTrue: [
(self isResizableByUser or: [ self isPositionableByUser ]) ifTrue: [
self bounds: (OPNodeBounds new
position: roassalShape position
extent: roassalShape extent) ].
Expand Down
3 changes: 2 additions & 1 deletion repository/OpenPonk-Core/OPDiagram.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ OPDiagram >> canvas: aCanvas [
self
assert: roassalShape canvas = aCanvas
description:
'Reusing same diagram element for 2 canvases not allowed' ].
'Reusing same diagram element for 2 canvases not allowed'.
^ self ].
roassalShape := aCanvas.
self updateRenderFromSelf
]
Expand Down
4 changes: 2 additions & 2 deletions repository/OpenPonk-Core/OPDiagramInfo.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Class {
'order',
'diagramName'
],
#category : 'OpenPonk-Core-Diagrams',
#category : 'OpenPonk-Core-LegacySupport-Diagrams',
#package : 'OpenPonk-Core',
#tag : 'Diagrams'
#tag : 'LegacySupport-Diagrams'
}

{ #category : 'testing' }
Expand Down
4 changes: 2 additions & 2 deletions repository/OpenPonk-Core/OPDiagramView.class.st
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Class {
#name : 'OPDiagramView',
#superclass : 'OPLegacyDiagram',
#category : 'OpenPonk-Core-Diagrams',
#category : 'OpenPonk-Core-LegacySupport-Diagrams',
#package : 'OpenPonk-Core',
#tag : 'Diagrams'
#tag : 'LegacySupport-Diagrams'
}
4 changes: 2 additions & 2 deletions repository/OpenPonk-Core/OPDiagramViewCamera.class.st
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Class {
#name : 'OPDiagramViewCamera',
#superclass : 'OPLegacyDiagramCamera',
#category : 'OpenPonk-Core-Diagrams',
#category : 'OpenPonk-Core-LegacySupport-Diagrams',
#package : 'OpenPonk-Core',
#tag : 'Diagrams'
#tag : 'LegacySupport-Diagrams'
}

{ #category : 'testing' }
Expand Down
4 changes: 2 additions & 2 deletions repository/OpenPonk-Core/OPDiagramViewInfo.class.st
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Class {
#name : 'OPDiagramViewInfo',
#superclass : 'OPDiagramInfo',
#category : 'OpenPonk-Core-Diagrams',
#category : 'OpenPonk-Core-LegacySupport-Diagrams',
#package : 'OpenPonk-Core',
#tag : 'Diagrams'
#tag : 'LegacySupport-Diagrams'
}
6 changes: 6 additions & 0 deletions repository/OpenPonk-Core/OPLabelTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ Class {
#package : 'OpenPonk-Core',
#tag : 'Tests'
}

{ #category : 'instance creation' }
OPLabelTest >> modelClass [

^ Mock
]
10 changes: 8 additions & 2 deletions repository/OpenPonk-Core/OPLegacyDiagram.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ Class {
'model',
'commonElements'
],
#category : 'OpenPonk-Core-Diagrams',
#category : 'OpenPonk-Core-LegacySupport-Diagrams',
#package : 'OpenPonk-Core',
#tag : 'Diagrams'
#tag : 'LegacySupport-Diagrams'
}

{ #category : 'instance creation' }
Expand Down Expand Up @@ -231,6 +231,12 @@ OPLegacyDiagram >> commonElements: anObject [
commonElements := anObject
]

{ #category : 'comparing' }
OPLegacyDiagram >> hash [

^ self asJson hash
]

{ #category : 'initialization' }
OPLegacyDiagram >> initialize [
super initialize.
Expand Down
4 changes: 2 additions & 2 deletions repository/OpenPonk-Core/OPLegacyDiagramCamera.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ Class {
'offset',
'zoom'
],
#category : 'OpenPonk-Core-Diagrams',
#category : 'OpenPonk-Core-LegacySupport-Diagrams',
#package : 'OpenPonk-Core',
#tag : 'Diagrams'
#tag : 'LegacySupport-Diagrams'
}

{ #category : 'testing' }
Expand Down
4 changes: 2 additions & 2 deletions repository/OpenPonk-Core/OPLegacyDiagramTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Class {
#instVars : [
'view'
],
#category : 'OpenPonk-Core-Diagrams',
#category : 'OpenPonk-Core-LegacySupport-Diagrams',
#package : 'OpenPonk-Core',
#tag : 'Diagrams'
#tag : 'LegacySupport-Diagrams'
}

{ #category : 'tests' }
Expand Down
4 changes: 2 additions & 2 deletions repository/OpenPonk-Core/OPLegacyElementLayout.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Class {
#classInstVars : [
'none'
],
#category : 'OpenPonk-Core-Diagrams',
#category : 'OpenPonk-Core-LegacySupport-Diagrams',
#package : 'OpenPonk-Core',
#tag : 'Diagrams'
#tag : 'LegacySupport-Diagrams'
}

{ #category : 'testing' }
Expand Down
4 changes: 2 additions & 2 deletions repository/OpenPonk-Core/OPLegacyRelationshipPath.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Class {
'source',
'points'
],
#category : 'OpenPonk-Core-Diagrams',
#category : 'OpenPonk-Core-LegacySupport-Diagrams',
#package : 'OpenPonk-Core',
#tag : 'Diagrams'
#tag : 'LegacySupport-Diagrams'
}

{ #category : 'instance creation' }
Expand Down
10 changes: 8 additions & 2 deletions repository/OpenPonk-Core/OPModelObjectReference.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Class {
#instVars : [
'uuid'
],
#category : 'OpenPonk-Core-Diagrams',
#category : 'OpenPonk-Core-LegacySupport-Diagrams',
#package : 'OpenPonk-Core',
#tag : 'Diagrams'
#tag : 'LegacySupport-Diagrams'
}

{ #category : 'as yet unclassified' }
Expand All @@ -21,6 +21,12 @@ OPModelObjectReference >> = otherModelObject [
^ self references: otherModelObject
]

{ #category : 'comparing' }
OPModelObjectReference >> hash [

^ self uuid hash
]

{ #category : 'comparing' }
OPModelObjectReference >> modelObjectFrom: aCollection [

Expand Down
6 changes: 2 additions & 4 deletions repository/OpenPonk-Core/OPNodeBounds.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,20 @@ OPNodeBounds >> origin: aPoint [

{ #category : 'accessing' }
OPNodeBounds >> position [

"center point"

^ self origin + (self extent / 2)
^ self origin + (self extent / 2) rounded
]

{ #category : 'accessing' }
OPNodeBounds >> position: aPoint [

"center point"

self
assert: self extent isNotNil
description:
'Extent (width and height) must be set before setting position (origin x and y)'.
self origin: aPoint - (self extent / 2)
self origin: aPoint - (self extent / 2) rounded
]

{ #category : 'accessing' }
Expand Down
24 changes: 24 additions & 0 deletions repository/OpenPonk-Core/OPNoteTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Class {
#name : 'OPNoteTest',
#superclass : 'OPAbstractNodeTest',
#category : 'OpenPonk-Core-Tests',
#package : 'OpenPonk-Core',
#tag : 'Tests'
}

{ #category : 'instance creation' }
OPNoteTest >> newModelInstance [

^ nil
]

{ #category : 'hooks' }
OPNoteTest >> shapeClass [
^ OPNote
]

{ #category : 'instance creation' }
OPNoteTest >> testEmpty [

self skip
]

0 comments on commit 7ce6832

Please sign in to comment.