From 9a7d1778c01f2080ce2ae7e4197204bf36f4bc71 Mon Sep 17 00:00:00 2001 From: prmr Date: Wed, 17 Feb 2021 19:01:17 -0500 Subject: [PATCH] #413 Fix geometry tests for windows --- .../persistence/TestPersistenceService.java | 62 +++++++++---------- .../viewers/nodes/TestFieldNodeViewer.java | 44 ++++++------- .../viewers/nodes/TestObjectNodeViewer.java | 6 +- .../viewers/nodes/TestPackageNodeViewer.java | 4 +- .../viewers/nodes/TestTypeNodeViewer.java | 2 +- .../cs/jetuml/views/TestFontMetrics.java | 10 +-- 6 files changed, 64 insertions(+), 64 deletions(-) diff --git a/test/ca/mcgill/cs/jetuml/persistence/TestPersistenceService.java b/test/ca/mcgill/cs/jetuml/persistence/TestPersistenceService.java index 0bfe50065..e1718c07b 100644 --- a/test/ca/mcgill/cs/jetuml/persistence/TestPersistenceService.java +++ b/test/ca/mcgill/cs/jetuml/persistence/TestPersistenceService.java @@ -204,10 +204,10 @@ private void verifyUseCaseDiagram(Diagram pDiagram) assertEquals(new Rectangle(460, 230, 110, 40), NodeViewerRegistry.getBounds(u3)); assertEquals("Use case 3", u3.getName().toString()); - assertTrue(new Rectangle(270, 50, 48, 90).equals(NodeViewerRegistry.getBounds(a1)) || new Rectangle(270, 50, 48, 87).equals(NodeViewerRegistry.getBounds(a1))); + assertEquals(new Rectangle(270, 50, 48, osDependent(91, 87, 87)), NodeViewerRegistry.getBounds(a1)); assertEquals("Actor", a1.getName().toString()); - assertTrue(new Rectangle(280, 230, 48, 90).equals(NodeViewerRegistry.getBounds(a2)) || new Rectangle(280, 230, 48, 87).equals(NodeViewerRegistry.getBounds(a2))); + assertEquals(new Rectangle(280, 230, 49, 91), NodeViewerRegistry.getBounds(a2)); assertEquals("Actor2", a2.getName().toString()); assertEquals("A note", n1.getName()); @@ -218,7 +218,7 @@ private void verifyUseCaseDiagram(Diagram pDiagram) assertEquals(new Rectangle(650, 150, 110, 40), NodeViewerRegistry.getBounds(u4)); assertEquals("Use case 4", u4.getName().toString()); - assertTrue(new Rectangle(190, 140, 48, 90).equals(NodeViewerRegistry.getBounds(a3)) || new Rectangle(190, 140, 48, 87).equals(NodeViewerRegistry.getBounds(a3))); + assertEquals(new Rectangle(650, 150, 110, 40), NodeViewerRegistry.getBounds(u4)); assertEquals("Actor3", a3.getName().toString()); assertEquals(10, numberOfEdges(pDiagram)); @@ -239,11 +239,11 @@ private void verifyUseCaseDiagram(Diagram pDiagram) assertTrue(cr1.getStart() == n1); assertTrue(cr1.getEnd() == p1); - assertEquals(new Rectangle(236, 120, 34, 38), getBounds(cr2)); + assertEquals(new Rectangle(osDependent(237, 236, 236), 120, osDependent(33, 34, 34), 38), getBounds(cr2)); assertTrue(cr2.getStart() == a3); assertTrue(cr2.getEnd() == a1); - assertEquals(new Rectangle(osDependent(229,228, 229), 207, osDependent(61,63, 61), 44), getBounds(cr3)); + assertEquals(new Rectangle(osDependent(228,228, 229), 207, osDependent(62,63, 61), 44), getBounds(cr3)); assertTrue( cr3.getStart() == a3); assertTrue( cr3.getEnd() == a2); assertTrue( cr3.properties().get("Dependency Type").get() == UseCaseDependencyEdge.Type.Extend); @@ -252,11 +252,11 @@ private void verifyUseCaseDiagram(Diagram pDiagram) assertTrue( cr4.getStart() == a1 ); assertTrue( cr4.getEnd() == u1 ); - assertEquals(new Rectangle(326, 158, 142, 103), getBounds(cr5)); + assertEquals(new Rectangle(osDependent(327, 326, 326), 158, osDependent(141, 142, 142), 103), getBounds(cr5)); assertTrue( cr5.getStart() == a2 ); assertTrue( cr5.getEnd() == u2 ); - assertEquals(new Rectangle(326, 250, 134, 22), getBounds(cr6)); + assertEquals(new Rectangle(osDependent(327, 326, 326), 250, osDependent(133, 134, 134), 22), getBounds(cr6)); assertTrue( cr6.getStart() == a2 ); assertTrue( cr6.getEnd() == u3 ); @@ -264,12 +264,12 @@ private void verifyUseCaseDiagram(Diagram pDiagram) assertTrue( cr7.getStart() == u2 ); assertTrue( cr7.getEnd() == u1 ); - assertEquals(new Rectangle(osDependent(484,483, 484),169,osDependent(63,65, 62),62), getBounds(cr8)); + assertEquals(new Rectangle(osDependent(483,483, 484),169,osDependent(64,65, 62),62), getBounds(cr8)); assertTrue( cr8.getStart() == u2 ); assertTrue( cr8.getEnd() == u3 ); assertTrue( cr8.properties().get("Dependency Type").get() == UseCaseDependencyEdge.Type.Include); - assertEquals(new Rectangle(568,150,82,26), getBounds(cr9)); + assertEquals(new Rectangle(568,150,82,osDependent(27, 26, 26)), getBounds(cr9)); assertTrue( cr9.getStart() == u2 ); assertTrue( cr9.getEnd() == u4 ); assertTrue( cr9.properties().get("Dependency Type").get() == UseCaseDependencyEdge.Type.Extend); @@ -370,7 +370,7 @@ private void verifyClassDiagram(Diagram pDiagram) assertEquals("bar", node3.getMethods()); assertEquals("Class2", node3.getName()); assertFalse(node3.hasParent()); - assertEquals(new Rectangle(460, 520, 100, 78), NodeViewerRegistry.getBounds(node3)); + assertEquals(new Rectangle(460, 520, 100, osDependent(81, 78, 78)), NodeViewerRegistry.getBounds(node3)); assertEquals("", node4.getAttributes()); assertEquals("", node4.getMethods()); @@ -404,7 +404,7 @@ private void verifyClassDiagram(Diagram pDiagram) assertEquals(node8, edge5.getEnd()); DependencyEdge edge6 = (DependencyEdge) eIterator.next(); - assertEquals(new Rectangle(378, osDependent(390,390, 384), 83, osDependent(23,26, 21)), getBounds(edge6)); + assertEquals(new Rectangle(378, osDependent(390,390, 384), 83, osDependent(27,26, 21)), getBounds(edge6)); assertEquals(node7, edge6.getEnd()); assertEquals("e1", edge6.getMiddleLabel()); assertEquals(node1, edge6.getStart()); @@ -420,7 +420,7 @@ private void verifyClassDiagram(Diagram pDiagram) assertEquals(node3, edge2.getStart()); AggregationEdge edge3 = (AggregationEdge) eIterator.next(); - assertEquals(new Rectangle(558, osDependent(377,380, 379), 72, osDependent(23,20, 21)), getBounds(edge3)); + assertEquals(new Rectangle(558, osDependent(379,380, 379), 72, osDependent(21,20, 21)), getBounds(edge3)); assertEquals(node4, edge3.getEnd()); assertEquals("*", edge3.getEndLabel()); assertEquals("e4", edge3.getMiddleLabel()); @@ -428,7 +428,7 @@ private void verifyClassDiagram(Diagram pDiagram) assertEquals("1", edge3.getStartLabel()); AggregationEdge edge4 = (AggregationEdge) eIterator.next(); - assertEquals(new Rectangle(559, 399, 72, 160), getBounds(edge4)); + assertEquals(new Rectangle(559, 399, 72, osDependent(161, 160, 160)), getBounds(edge4)); assertEquals(node3, edge4.getEnd()); assertEquals("", edge4.getEndLabel()); assertEquals("e5", edge4.getMiddleLabel()); @@ -496,26 +496,26 @@ private void verifySequenceDiagram(Diagram pDiagram) ReturnEdge retC = (ReturnEdge) eIterator.next(); NoteEdge nedge = (NoteEdge) eIterator.next(); - assertEquals(new Rectangle(osDependent(214,212, 216), 85, 86, 26), getBounds(self)); + assertEquals(new Rectangle(osDependent(214,212, 216), 85, 86, osDependent(27, 26, 26)), getBounds(self)); assertEquals(selfCall, self.getEnd()); assertEquals("selfCall()", self.getMiddleLabel()); assertEquals(init, self.getStart()); assertFalse(self.isSignal()); assertEquals(new Rectangle(osDependent(224,222, 226), 100, osDependent(179, 181, 177), - 26), getBounds(signal)); + osDependent(27, 26, 26)), getBounds(signal)); assertEquals(o2Call, signal.getEnd()); assertEquals("signal", signal.getMiddleLabel()); assertEquals(selfCall, signal.getStart()); assertTrue(signal.isSignal()); - assertEquals(new Rectangle(417, 120, 206, 26), getBounds(call1)); + assertEquals(new Rectangle(417, 120, 206, osDependent(27, 26, 26)), getBounds(call1)); assertEquals(o3Call, call1.getEnd()); assertEquals("call1()", call1.getMiddleLabel()); assertEquals(o2Call, call1.getStart()); assertFalse(call1.isSignal()); - assertEquals(new Rectangle(416, 160, 207, osDependent(23,26, 23)), getBounds(ret1)); + assertEquals(new Rectangle(416, 160, 207, osDependent(27,26, 23)), getBounds(ret1)); assertEquals(o2Call, ret1.getEnd()); assertEquals("r1", ret1.getMiddleLabel()); assertEquals(o3Call, ret1.getStart()); @@ -556,7 +556,7 @@ private void verifyStateDiagram(Diagram pDiagram) assertEquals(new Rectangle(640, 230, 20, 20), NodeViewerRegistry.getBounds(end)); assertEquals("A note\non two lines", note.getName()); - assertEquals(new Rectangle(690, 320, osDependent(86,81, 86), 40), NodeViewerRegistry.getBounds(note)); + assertEquals(new Rectangle(690, 320, osDependent(86,81, 86), osDependent(43, 40, 40)), NodeViewerRegistry.getBounds(note)); assertEquals(new Rectangle(576, 339, 0, 0), NodeViewerRegistry.getBounds(point)); @@ -575,17 +575,17 @@ private void verifyStateDiagram(Diagram pDiagram) assertEquals(note, ne.getStart()); assertEquals(point, ne.getEnd()); - assertEquals(new Rectangle(168, osDependent(73,76, 75), 82, osDependent(37,34, 35)), getBounds(fromStart)); + assertEquals(new Rectangle(168, osDependent(75,76, 75), 82, osDependent(35,34, 35)), getBounds(fromStart)); assertEquals(start, fromStart.getStart()); assertEquals(s1, fromStart.getEnd()); assertEquals("start", fromStart.getMiddleLabel().toString()); - assertEquals(new Rectangle(328, osDependent(100,103, 101), 182, osDependent(28,25, 26)), getBounds(e1)); + assertEquals(new Rectangle(328, osDependent(102,103, 101), 182, osDependent(26,25, 26)), getBounds(e1)); assertEquals(s1, e1.getStart()); assertEquals(s2, e1.getEnd()); assertEquals("e1", e1.getMiddleLabel().toString()); - assertEquals(new Rectangle(328, 131, 182, osDependent(27,24, 25)), getBounds(e2)); + assertEquals(new Rectangle(328, 131, 182, osDependent(25,24, 25)), getBounds(e2)); assertEquals(s2, e2.getStart()); assertEquals(s1, e2.getEnd()); assertEquals("e2", e2.getMiddleLabel().toString()); @@ -618,18 +618,18 @@ private void verifyObjectDiagram(Diagram pDiagram) PointNode p1 = (PointNode) findRootNode(pDiagram, PointNode.class, build("x", 281)); PointNode p2 = (PointNode) findRootNode(pDiagram, PointNode.class, build("x", 474)); - assertEquals(new Rectangle(240, 130, osDependent(110, 110, 100), osDependent(90, 100, 100)), NodeViewerRegistry.getBounds(type1)); + assertEquals(new Rectangle(240, 130, osDependent(120, 110, 100), osDependent(100, 100, 100)), NodeViewerRegistry.getBounds(type1)); List children = type1.getChildren(); assertEquals(1, children.size()); assertEquals(":Type1", type1.getName().toString()); FieldNode name = (FieldNode) children.get(0); - assertEquals(new Rectangle(245, 200, osDependent(100, 100, 90), osDependent(20, 26, 21)), NodeViewerRegistry.getBounds(name)); + assertEquals(new Rectangle(245, 200, osDependent(110, 100, 90), osDependent(27, 26, 21)), NodeViewerRegistry.getBounds(name)); assertEquals("name", name.getName().toString()); assertEquals(type1, name.getParent()); assertEquals("", name.getValue().toString()); - assertEquals(new Rectangle(440, 290, osDependent(120, 130, 110), 160), NodeViewerRegistry.getBounds(blank)); + assertEquals(new Rectangle(440, 290, osDependent(130, 130, 110), osDependent(170, 160, 160)), NodeViewerRegistry.getBounds(blank)); children = blank.getChildren(); assertEquals(3, children.size()); assertEquals("", blank.getName().toString()); @@ -637,17 +637,17 @@ private void verifyObjectDiagram(Diagram pDiagram) FieldNode name3 = (FieldNode) children.get(1); FieldNode name4 = (FieldNode) children.get(2); - assertEquals(new Rectangle(445, 360, osDependent(110, 120, 100), 26), NodeViewerRegistry.getBounds(name2)); + assertEquals(new Rectangle(445, 360, osDependent(120, 120, 100), osDependent(27, 26, 26)), NodeViewerRegistry.getBounds(name2)); assertEquals("name2", name2.getName().toString()); assertEquals(blank, name2.getParent()); assertEquals("value", name2.getValue().toString()); - assertEquals(new Rectangle(445, 391, osDependent(110, 120, 100), 26), NodeViewerRegistry.getBounds(name3)); + assertEquals(new Rectangle(445, osDependent(392, 391, 391), osDependent(120, 120, 100), osDependent(27, 26, 26)), NodeViewerRegistry.getBounds(name3)); assertEquals("name3", name3.getName().toString()); assertEquals(blank, name3.getParent()); assertEquals("value", name3.getValue().toString()); - assertEquals(new Rectangle(445, 422, osDependent(110, 120, 100), 26), NodeViewerRegistry.getBounds(name4)); + assertEquals(new Rectangle(445, osDependent(424, 422, 422), osDependent(120, 120, 100), osDependent(27,26,26)), NodeViewerRegistry.getBounds(name4)); assertEquals("name4", name4.getName().toString()); assertEquals(blank, name4.getParent()); assertEquals("", name4.getValue().toString()); @@ -678,20 +678,20 @@ private void verifyObjectDiagram(Diagram pDiagram) NoteEdge ne2 = (NoteEdge) eIt.next(); ObjectCollaborationEdge cr1 = (ObjectCollaborationEdge) eIt.next(); - assertEquals(new Rectangle(osDependent(339, 339, 329), osDependent(174, 179, 179), 32, osDependent(37, 35, 32)), getBounds(o1)); + assertEquals(new Rectangle(osDependent(349, 339, 329), osDependent(179, 179, 179), 32, osDependent(35, 35, 32)), getBounds(o1)); assertEquals(name, o1.getStart()); assertEquals(type1, o1.getEnd()); - assertEquals(new Rectangle(osDependent(339, 339, 329), 212, osDependent(102, 102, 112), 159), getBounds(o2)); + assertEquals(new Rectangle(osDependent(349, 339, 329), 212, osDependent(92, 102, 112), osDependent(164, 159, 159)), getBounds(o2)); assertEquals(name, o2.getStart()); assertEquals(blank, o2.getEnd()); - assertEquals(new Rectangle(osDependent(530, 535, 527), 208, osDependent(37, 33, 39), 82), getBounds(cr1)); + assertEquals(new Rectangle(osDependent(536, 535, 527), 208, osDependent(32, 33, 39), 82), getBounds(cr1)); assertEquals(object2, cr1.getEnd()); assertEquals("e1", cr1.getMiddleLabel().toString()); assertEquals(blank, cr1.getStart()); - assertEquals(new Rectangle(osDependent(549, 559, 539), 329, osDependent(62, 52, 72), 107), getBounds(o3)); + assertEquals(new Rectangle(osDependent(559, 559, 539), 329, osDependent(52, 52, 72), osDependent(109, 107, 107)), getBounds(o3)); assertEquals(name4, o3.getStart()); assertEquals(type3, o3.getEnd()); diff --git a/test/ca/mcgill/cs/jetuml/viewers/nodes/TestFieldNodeViewer.java b/test/ca/mcgill/cs/jetuml/viewers/nodes/TestFieldNodeViewer.java index b9bb8a7c9..dac925e22 100644 --- a/test/ca/mcgill/cs/jetuml/viewers/nodes/TestFieldNodeViewer.java +++ b/test/ca/mcgill/cs/jetuml/viewers/nodes/TestFieldNodeViewer.java @@ -70,18 +70,18 @@ public void setup() public void testDimensionsUnattachedWithNameString() { aFieldNode1.setName("XXXXX"); - assertEquals(osDependent(59, 65, 53), aFieldNodeViewer.leftWidth(aFieldNode1)); // The length of the string - assertEquals(osDependent(40, 43, 37), aFieldNodeViewer.rightWidth(aFieldNode1)); // Half the default width + mid offset. - assertEquals(osDependent(22, 26, 23), aFieldNodeViewer.getHeight(aFieldNode1)); // The height of the string + assertEquals(osDependent(63, 65, 53), aFieldNodeViewer.leftWidth(aFieldNode1)); // The length of the string + assertEquals(osDependent(44, 43, 37), aFieldNodeViewer.rightWidth(aFieldNode1)); // Half the default width + mid offset. + assertEquals(osDependent(27, 26, 23), aFieldNodeViewer.getHeight(aFieldNode1)); // The height of the string } @Test public void testDimensionsUnattachedWithValueString() { aFieldNode1.setValue("XXXXX"); - assertEquals(osDependent(10, 13, 7), aFieldNodeViewer.leftWidth(aFieldNode1)); // Just the length of the mid offset - assertEquals(osDependent(59, 65, 53), aFieldNodeViewer.rightWidth(aFieldNode1)); // The length of the string - assertEquals(osDependent(22, 26, 23), aFieldNodeViewer.getHeight(aFieldNode1)); // The height of the string + assertEquals(osDependent(14, 13, 7), aFieldNodeViewer.leftWidth(aFieldNode1)); // Just the length of the mid offset + assertEquals(osDependent(63, 65, 53), aFieldNodeViewer.rightWidth(aFieldNode1)); // The length of the string + assertEquals(osDependent(27, 26, 23), aFieldNodeViewer.getHeight(aFieldNode1)); // The height of the string } @Test @@ -91,7 +91,7 @@ public void testGetBoundsUnattachedNoStrings() // y = 0 // w = default length (30)/2 + 2* offset (6) = 42 // h = default height = 20 - assertEquals( new Rectangle(osDependent(20, 17, 23),0,osDependent(50, 56, 44),26), NodeViewerRegistry.getBounds(aFieldNode1)); + assertEquals( new Rectangle(osDependent(16, 17, 23),0,osDependent(58, 56, 44), osDependent(27,26,26)), NodeViewerRegistry.getBounds(aFieldNode1)); } @Test @@ -103,7 +103,7 @@ public void testGetBoundsUnattachedNameValueString() // y = 0 // w = 47 * 2 // h = text height 22 - assertEquals( new Rectangle(osDependent(-29, -35, -23), 0, osDependent(118, 130, 106), osDependent(22, 26, 23)), NodeViewerRegistry.getBounds(aFieldNode1)); + assertEquals( new Rectangle(osDependent(-33, -35, -23), 0, osDependent(126, 130, 106), osDependent(27, 26, 23)), NodeViewerRegistry.getBounds(aFieldNode1)); } @Test @@ -111,7 +111,7 @@ public void testGetConnectionPointsUnattached() { // x = max x of the node bounds - x gap // y = half-point of the default height - assertEquals( new Point(osDependent(65, 68, 62),13), NodeViewerRegistry.getConnectionPoints(aFieldNode1, Direction.EAST)); + assertEquals( new Point(osDependent(69, 68, 62),13), NodeViewerRegistry.getConnectionPoints(aFieldNode1, Direction.EAST)); } // NEW @@ -120,9 +120,9 @@ public void testGetConnectionPointsUnattached() public void testDimensionsAttachedNoStrings() { aObjectNode1.addChild(aFieldNode1); - assertEquals(osDependent(10, 13, 7), aFieldNodeViewer.leftWidth(aFieldNode1)); // Just the length of the mid offset - assertEquals(osDependent(40, 43, 37), aFieldNodeViewer.rightWidth(aFieldNode1)); // Half the default width + mid offset. - assertEquals(26, aFieldNodeViewer.getHeight(aFieldNode1)); // Default height + assertEquals(osDependent(14, 13, 7), aFieldNodeViewer.leftWidth(aFieldNode1)); // Just the length of the mid offset + assertEquals(osDependent(44, 43, 37), aFieldNodeViewer.rightWidth(aFieldNode1)); // Half the default width + mid offset. + assertEquals(osDependent(27, 26,26), aFieldNodeViewer.getHeight(aFieldNode1)); // Default height } @Test @@ -130,9 +130,9 @@ public void testDimensionsAttachedObjectString() { aObjectNode1.addChild(aFieldNode1); aObjectNode1.setName("XXXXXXXXXXXXXXXXXXX"); - assertEquals(osDependent(10, 13, 7), aFieldNodeViewer.leftWidth(aFieldNode1)); // Just the length of the mid offset - assertEquals(osDependent(40, 43, 37), aFieldNodeViewer.rightWidth(aFieldNode1)); // Half the default width + mid offset. - assertEquals(26, aFieldNodeViewer.getHeight(aFieldNode1)); // Default height + assertEquals(osDependent(14, 13, 7), aFieldNodeViewer.leftWidth(aFieldNode1)); // Just the length of the mid offset + assertEquals(osDependent(44, 43, 37), aFieldNodeViewer.rightWidth(aFieldNode1)); // Half the default width + mid offset. + assertEquals(osDependent(27,26,26), aFieldNodeViewer.getHeight(aFieldNode1)); // Default height } @Test @@ -140,9 +140,9 @@ public void testDimensionsAttachedWithNameString() { aObjectNode1.addChild(aFieldNode1); aFieldNode1.setName("XXXXX"); - assertEquals(osDependent(59, 65, 53), aFieldNodeViewer.leftWidth(aFieldNode1)); // The length of the string - assertEquals(osDependent(40, 43, 37), aFieldNodeViewer.rightWidth(aFieldNode1)); // Half the default width + mid offset. - assertEquals(osDependent(22, 26, 23), aFieldNodeViewer.getHeight(aFieldNode1)); // The height of the string + assertEquals(osDependent(63, 65, 53), aFieldNodeViewer.leftWidth(aFieldNode1)); // The length of the string + assertEquals(osDependent(44, 43, 37), aFieldNodeViewer.rightWidth(aFieldNode1)); // Half the default width + mid offset. + assertEquals(osDependent(27, 26, 23), aFieldNodeViewer.getHeight(aFieldNode1)); // The height of the string } @Test @@ -150,9 +150,9 @@ public void testDimensionsAttachedWithValueString() { aObjectNode1.addChild(aFieldNode1); aFieldNode1.setValue("XXXXX"); - assertEquals(osDependent(10, 13, 7), aFieldNodeViewer.leftWidth(aFieldNode1)); // Just the length of the mid offset - assertEquals(osDependent(59, 65, 53), aFieldNodeViewer.rightWidth(aFieldNode1)); // The length of the string - assertEquals(osDependent(22, 26, 23), aFieldNodeViewer.getHeight(aFieldNode1)); // The height of the string + assertEquals(osDependent(14, 13, 7), aFieldNodeViewer.leftWidth(aFieldNode1)); // Just the length of the mid offset + assertEquals(osDependent(63, 65, 53), aFieldNodeViewer.rightWidth(aFieldNode1)); // The length of the string + assertEquals(osDependent(27, 26, 23), aFieldNodeViewer.getHeight(aFieldNode1)); // The height of the string } @Test @@ -163,7 +163,7 @@ public void testGetBoundsAttachedNoStrings() // y = top node height // w = left + right // h = default height - assertEquals( new Rectangle(5,70,70,26), NodeViewerRegistry.getBounds(aFieldNode1)); + assertEquals( new Rectangle(5,70,70, osDependent(27,26,26)), NodeViewerRegistry.getBounds(aFieldNode1)); } @AfterEach diff --git a/test/ca/mcgill/cs/jetuml/viewers/nodes/TestObjectNodeViewer.java b/test/ca/mcgill/cs/jetuml/viewers/nodes/TestObjectNodeViewer.java index 868b9a36a..30b558c93 100644 --- a/test/ca/mcgill/cs/jetuml/viewers/nodes/TestObjectNodeViewer.java +++ b/test/ca/mcgill/cs/jetuml/viewers/nodes/TestObjectNodeViewer.java @@ -75,7 +75,7 @@ public void testGetSplitPosition_NoField() public void testGetSplitPosition_OneField() { aNode.addChild(aField1); - assertEquals(osDependent(15, 18, 12), aViewer.getSplitPosition(aNode)); + assertEquals(osDependent(19, 18, 12), aViewer.getSplitPosition(aNode)); } @Test @@ -84,7 +84,7 @@ public void testGetSplitPosition_TwoFields() aNode.addChild(aField1); aNode.addChild(aField2); aField2.setName("XXXXX"); - assertEquals(osDependent(64, 70, 58), aViewer.getSplitPosition(aNode)); + assertEquals(osDependent(68, 70, 58), aViewer.getSplitPosition(aNode)); } @Test @@ -100,7 +100,7 @@ public void testGetYPosition_TwoFields() aNode.addChild(aField1); aNode.addChild(aField2); assertEquals(70, aViewer.getYPosition(aNode, aField1)); - assertEquals(101, aViewer.getYPosition(aNode, aField2)); + assertEquals(osDependent(102, 101, 101), aViewer.getYPosition(aNode, aField2)); } @Test diff --git a/test/ca/mcgill/cs/jetuml/viewers/nodes/TestPackageNodeViewer.java b/test/ca/mcgill/cs/jetuml/viewers/nodes/TestPackageNodeViewer.java index 766e1112f..e7f10e801 100644 --- a/test/ca/mcgill/cs/jetuml/viewers/nodes/TestPackageNodeViewer.java +++ b/test/ca/mcgill/cs/jetuml/viewers/nodes/TestPackageNodeViewer.java @@ -117,7 +117,7 @@ public void testGetBoundsOffset() public void testGetBoundsNameNoContent() { aPackageNode1.setName("Package"); - assertEqualRectangles(0,0, osDependent(102,104,101),80, NodeViewerRegistry.getBounds(aPackageNode1)); + assertEqualRectangles(0,0, osDependent(104,104,101),80, NodeViewerRegistry.getBounds(aPackageNode1)); } @Test @@ -130,7 +130,7 @@ public void testGetTopBoundsDefault() public void testGetTopBoundsName() { aPackageNode1.setName("Package"); - assertEqualRectangles(0,0,osDependent(62, 64, 61),20, getTopBounds(aPackageNode1)); + assertEqualRectangles(0,0,osDependent(64, 64, 61),20, getTopBounds(aPackageNode1)); } @Test diff --git a/test/ca/mcgill/cs/jetuml/viewers/nodes/TestTypeNodeViewer.java b/test/ca/mcgill/cs/jetuml/viewers/nodes/TestTypeNodeViewer.java index 09902347b..5102e82b8 100644 --- a/test/ca/mcgill/cs/jetuml/viewers/nodes/TestTypeNodeViewer.java +++ b/test/ca/mcgill/cs/jetuml/viewers/nodes/TestTypeNodeViewer.java @@ -130,7 +130,7 @@ private static Arguments createClassNode5() ClassNode node = new ClassNode(); node.setName("NAME1\nNAME2\nNAME3\nNAME4"); return Arguments.of(node, - new Rectangle(0, 0, 100, osDependent(70, 68, 65))); // Default width and additional height + new Rectangle(0, 0, 100, osDependent(75, 68, 65))); // Default width and additional height } // Name is just the interface prototype, one methods diff --git a/test/ca/mcgill/cs/jetuml/views/TestFontMetrics.java b/test/ca/mcgill/cs/jetuml/views/TestFontMetrics.java index bb710f2aa..ba2c461c6 100644 --- a/test/ca/mcgill/cs/jetuml/views/TestFontMetrics.java +++ b/test/ca/mcgill/cs/jetuml/views/TestFontMetrics.java @@ -1,12 +1,12 @@ package ca.mcgill.cs.jetuml.views; +import static ca.mcgill.cs.jetuml.testutils.GeometryUtils.osDependent; +import static ca.mcgill.cs.jetuml.views.StringViewer.FONT; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import java.util.stream.Stream; -import static ca.mcgill.cs.jetuml.views.StringViewer.FONT; - import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -39,8 +39,8 @@ private static Stream stringPairParameters() { @Test public void testGetDimensions() { - assertEquals(new Dimension(0, 12), aMetrics.getDimension("")); - assertEquals(new Dimension(92, 12), aMetrics.getDimension("Single-Line-String")); - assertEquals(new Dimension(30, 40), aMetrics.getDimension("Multi\nLine\nString")); + assertEquals(new Dimension(0, osDependent(13,12,12)), aMetrics.getDimension("")); + assertEquals(new Dimension(osDependent(95, 92, 92), osDependent(13, 12, 12)), aMetrics.getDimension("Single-Line-String")); + assertEquals(new Dimension(osDependent(31, 30, 30), osDependent(45, 40, 45)), aMetrics.getDimension("Multi\nLine\nString")); } }