Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2018-05-25 03:21:32 -0400
committerCamille Letavernier2018-06-04 10:50:13 -0400
commit9ff5fff7785695f43ee84facab4ae4f02800bb6f (patch)
tree8caf82e151021df6d4df05f15909c08ad4b1f020
parentdb58f7f654e9e175c1ef6fad69fd325c382cd846 (diff)
downloadorg.eclipse.papyrus-9ff5fff7785695f43ee84facab4ae4f02800bb6f.tar.gz
org.eclipse.papyrus-9ff5fff7785695f43ee84facab4ae4f02800bb6f.tar.xz
org.eclipse.papyrus-9ff5fff7785695f43ee84facab4ae4f02800bb6f.zip
Bug 535061: [Sequence Diagram - Tests] 1px layout delta on Jenkins
https://bugs.eclipse.org/bugs/show_bug.cgi?id=535061 - Workaround: add a minor layout tolerance (2px) to the Operands Layout Tests Change-Id: Ie897db06dc0adced1ecb866a60ba3bd8a121199d Signed-off-by: Camille Letavernier <cletavernier@eclipsesource.com>
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCombinedFragmentOperandsLayout.java29
1 files changed, 28 insertions, 1 deletions
diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCombinedFragmentOperandsLayout.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCombinedFragmentOperandsLayout.java
index 2e9ac91f655..493b009369e 100644
--- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCombinedFragmentOperandsLayout.java
+++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestCombinedFragmentOperandsLayout.java
@@ -56,6 +56,22 @@ import org.junit.Test;
public class TestCombinedFragmentOperandsLayout extends AbstractPapyrusTest {
/**
+ * <p>
+ * Bug 535061: Even though we're using a fixed font, the Font Renderer
+ * may still cause minor layout differences (1-2 pixels). This constant
+ * is a workaround, so that the test can ignore these minor layout diffs.
+ * </p>
+ * <p>
+ * A value of 0 means we expect a pixel-perfect layout. A value of 1-2 means
+ * we ignore minor layout differences (Typically due to a different rendered font height)
+ * </p>
+ * <p>
+ * The value is specified in Pixels.
+ * </p>
+ */
+ private static final int LAYOUT_TOLERANCE = 2; // FIXME: When Bug 535061 is fixed, we should be able to set this to 0.
+
+ /**
* Size of the CF Label (It is fixed on all platforms, because we use a font explicitly shipped with Papyrus)
*/
private static final int CF_LABEL_HEIGHT = 19;
@@ -408,7 +424,18 @@ public class TestCombinedFragmentOperandsLayout extends AbstractPapyrusTest {
}
private void assertSize(int width, int height, Dimension actual) {
- Assert.assertEquals(new Dimension(width, height), actual);
+ Dimension expected = new Dimension(width, height);
+ String message = String.format("Expected %s (with a %spx tolerance); got %s", expected, LAYOUT_TOLERANCE, actual);
+ // Note: This test only works at 100% DPI Scaling. This is a general SeqD issue
+ // that needs to be solved properly. If you're using a 1440p or 4K screen, errors
+ // are expected.
+ Assert.assertTrue(message, getDelta(expected, actual) <= LAYOUT_TOLERANCE);
+ }
+
+ // The delta is the max difference between the expected width/height and the actual values
+ private int getDelta(Dimension expected, Dimension actual) {
+ Dimension shrinked = expected.getCopy().getShrinked(actual);
+ return Math.max(Math.abs(shrinked.width()), Math.abs(shrinked.height()));
}
}

Back to the top