From 6f7c0515ad2665708a50716eef4a655c04d2e057 Mon Sep 17 00:00:00 2001 From: Patrick Ziegler Date: Wed, 30 Jul 2025 16:05:50 +0200 Subject: [PATCH 1/2] Repair and execute Editor tests --- .../model/layouts/AbsoluteLayoutSelectionActionsTest.java | 8 ++++---- .../wb/tests/designer/swt/model/menu/MenuItemTest.java | 4 +--- .../wb/tests/designer/swt/model/widgets/TableTest.java | 3 --- .../tests/designer/swt/support/CoordinateUtilsTest.java | 6 +----- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/layouts/AbsoluteLayoutSelectionActionsTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/layouts/AbsoluteLayoutSelectionActionsTest.java index 6f0ada8a0..49897fc97 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/layouts/AbsoluteLayoutSelectionActionsTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/layouts/AbsoluteLayoutSelectionActionsTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Google, Inc. + * Copyright (c) 2011, 2025 Google, Inc. and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -23,7 +23,6 @@ import org.eclipse.wb.tests.designer.core.model.TestObjectInfo; import org.eclipse.wb.tests.designer.rcp.RcpModelTest; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.util.ArrayList; @@ -1043,13 +1042,13 @@ public void test_align_space_equally_2() throws Exception { // Center in window // //////////////////////////////////////////////////////////////////////////// - @Disabled @Test public void test_align_center_in_window() throws Exception { CompositeInfo shell = parseComposite( "class Test extends Shell {", " Test() {", + " super(SWT.NO_TRIM);", " setSize(600, 400);", " {", " Button button = new Button(this, SWT.NONE);", @@ -1073,10 +1072,11 @@ public void test_align_center_in_window() throws Exception { assertEditor( "class Test extends Shell {", " Test() {", + " super(SWT.NO_TRIM);", " setSize(600, 400);", " {", " Button button = new Button(this, SWT.NONE);", - " button.setBounds(262, 180, 60, 40);", + " button.setBounds(270, 180, 60, 40);", " button.setText('000');", " }", " }", diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/menu/MenuItemTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/menu/MenuItemTest.java index ee2920cad..17020628f 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/menu/MenuItemTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/menu/MenuItemTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2023 Google, Inc. + * Copyright (c) 2011, 2025 Google, Inc. and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -32,7 +32,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.mockito.ArgumentMatchers; @@ -487,7 +486,6 @@ public void test_setStyle_fromCascade_toSeparator() throws Exception { /** * Test adding a selection listener to menu item. */ - @Disabled @Test public void test_addSelectionListener() throws Exception { CompositeInfo shell = diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/widgets/TableTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/widgets/TableTest.java index a14d53d2c..e60ec2258 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/widgets/TableTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/widgets/TableTest.java @@ -32,7 +32,6 @@ import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.util.List; @@ -186,8 +185,6 @@ public void test_add_TableItem() throws Exception { * In SWT Cocoa and Linux GTK, the column headers are excluded from the client * area, hence why we have to adjust them for the tests. */ - // Disabled because of https://github.com/eclipse-windowbuilder/windowbuilder/issues/389 - @Disabled @Test public void test_TableColumn() throws Exception { CompositeInfo shell = diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/support/CoordinateUtilsTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/support/CoordinateUtilsTest.java index 3ed157682..d9eb37dd4 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/support/CoordinateUtilsTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/support/CoordinateUtilsTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2024 Google, Inc. and others. + * Copyright (c) 2011, 2025 Google, Inc. and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -28,7 +28,6 @@ import org.eclipse.swt.widgets.Shell; import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; /** @@ -51,8 +50,6 @@ public void _test_exit() throws Exception { // Tests // //////////////////////////////////////////////////////////////////////////// - // Disabled because of https://github.com/eclipse-windowbuilder/windowbuilder/issues/389 - @Disabled @Test public void test_1() throws Exception { ShellInfo shell = (ShellInfo) parseComposite( @@ -100,7 +97,6 @@ public void test_1() throws Exception { /** * Test for {@link CoordinateUtils#getClientAreaInsets2(Object)} for {@link Group}. */ - @Disabled @Test public void test_withGroup() throws Exception { CompositeInfo shell = From 9087e211f587e752306824ae69cc7aa1d37b5b62 Mon Sep 17 00:00:00 2001 From: Patrick Ziegler Date: Wed, 30 Jul 2025 17:47:06 +0200 Subject: [PATCH 2/2] Try to stabilize image tests --- .../property/ImagePropertyEditorTest.java | 9 +++- .../ImagePropertyEditorTestNoManager.java | 17 +++---- .../ImagePropertyEditorTestWithManager.java | 33 +++++++------- .../property/SWTResourceManagerTest.java | 45 ++++++++++--------- 4 files changed, 55 insertions(+), 49 deletions(-) diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/property/ImagePropertyEditorTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/property/ImagePropertyEditorTest.java index 85f4e2fce..07f2e9fda 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/property/ImagePropertyEditorTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/property/ImagePropertyEditorTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2024 Google, Inc. and others. + * Copyright (c) 2011, 2025 Google, Inc. and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -31,6 +31,13 @@ * @author lobas_av */ public abstract class ImagePropertyEditorTest extends RcpModelTest { + + @Override + protected void configureNewProject() throws Exception { + super.configureNewProject(); + m_testProject.addPlugin("org.eclipse.wb.core"); + } + //////////////////////////////////////////////////////////////////////////// // // Utils diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/property/ImagePropertyEditorTestNoManager.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/property/ImagePropertyEditorTestNoManager.java index 9c6bab830..48cb4b990 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/property/ImagePropertyEditorTestNoManager.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/property/ImagePropertyEditorTestNoManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2023 Google, Inc. + * Copyright (c) 2011, 2025 Google, Inc. and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -22,7 +22,6 @@ import org.apache.commons.io.FilenameUtils; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.io.File; @@ -97,24 +96,22 @@ public void test_textSource_absolutePath() throws Exception { /** * Image creation using constructor with input stream (over class resource). */ - @Disabled @Test public void test_textSource_image_over_classpath() throws Exception { assert_getText_getClipboardSource_forSource( - "new Image(null, getClass().getResourceAsStream(\"/javax/swing/plaf/basic/icons/JavaCup16.png\"))", - "Classpath: /javax/swing/plaf/basic/icons/JavaCup16.png", - "new org.eclipse.swt.graphics.Image(null, {wbp_classTop}.getResourceAsStream(\"/javax/swing/plaf/basic/icons/JavaCup16.png\"))"); + "new Image(null, getClass().getResourceAsStream(\"/org/eclipse/wb/core/controls/flyout/icons/arrow_bottom.gif\"))", + "Classpath: /org/eclipse/wb/core/controls/flyout/icons/arrow_bottom.gif", + "new org.eclipse.swt.graphics.Image(null, {wbp_classTop}.getResourceAsStream(\"/org/eclipse/wb/core/controls/flyout/icons/arrow_bottom.gif\"))"); } /** * Image creation using constructor with input stream (over class resource). */ - @Disabled @Test public void test_textSource_image_over_classpath_OtherClass() throws Exception { assert_getText_getClipboardSource_forSource( - "new Image(null, java.lang.String.class.getResourceAsStream(\"/javax/swing/plaf/basic/icons/JavaCup16.png\"))", - "Classpath: /javax/swing/plaf/basic/icons/JavaCup16.png", - "new org.eclipse.swt.graphics.Image(null, {wbp_classTop}.getResourceAsStream(\"/javax/swing/plaf/basic/icons/JavaCup16.png\"))"); + "new Image(null, org.eclipse.wb.core.editor.constants.CoreImages.class.getResourceAsStream(\"/org/eclipse/wb/core/controls/flyout/icons/arrow_bottom.gif\"))", + "Classpath: /org/eclipse/wb/core/controls/flyout/icons/arrow_bottom.gif", + "new org.eclipse.swt.graphics.Image(null, {wbp_classTop}.getResourceAsStream(\"/org/eclipse/wb/core/controls/flyout/icons/arrow_bottom.gif\"))"); } } \ No newline at end of file diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/property/ImagePropertyEditorTestWithManager.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/property/ImagePropertyEditorTestWithManager.java index 6e7e1d67a..8480d41fe 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/property/ImagePropertyEditorTestWithManager.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/property/ImagePropertyEditorTestWithManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2023 Google, Inc. + * Copyright (c) 2011, 2025 Google, Inc. and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -26,7 +26,6 @@ import org.apache.commons.io.FilenameUtils; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.io.File; @@ -103,25 +102,23 @@ public void test_textSource_absolutePath() throws Exception { /** * Image creation using constructor with input stream (over class resource). */ - @Disabled @Test public void test_textSource_image_over_classpath() throws Exception { assert_getText_getClipboardSource_forSource( - "new Image(null, getClass().getResourceAsStream(\"/javax/swing/plaf/basic/icons/JavaCup16.png\"))", - "Classpath: /javax/swing/plaf/basic/icons/JavaCup16.png", - getInvocationSource(shell(), "{wbp_classTop}", "/javax/swing/plaf/basic/icons/JavaCup16.png")); + "new Image(null, getClass().getResourceAsStream(\"/org/eclipse/wb/core/controls/flyout/icons/arrow_bottom.gif\"))", + "Classpath: /org/eclipse/wb/core/controls/flyout/icons/arrow_bottom.gif", + getInvocationSource(shell(), "{wbp_classTop}", "\"/org/eclipse/wb/core/controls/flyout/icons/arrow_bottom.gif\"")); } /** * Image creation using constructor with input stream (over class resource). */ - @Disabled @Test public void test_textSource_image_over_classpath_OtherClass() throws Exception { assert_getText_getClipboardSource_forSource( - "new Image(null, java.lang.String.class.getResourceAsStream(\"/javax/swing/plaf/basic/icons/JavaCup16.png\"))", - "Classpath: /javax/swing/plaf/basic/icons/JavaCup16.png", - getInvocationSource(shell(), "{wbp_classTop}", "/javax/swing/plaf/basic/icons/JavaCup16.png")); + "new Image(null, org.eclipse.wb.core.editor.constants.CoreImages.class.getResourceAsStream(\"/org/eclipse/wb/core/controls/flyout/icons/arrow_bottom.gif\"))", + "Classpath: /org/eclipse/wb/core/controls/flyout/icons/arrow_bottom.gif", + getInvocationSource(shell(), "{wbp_classTop}", "\"/org/eclipse/wb/core/controls/flyout/icons/arrow_bottom.gif\"")); } //////////////////////////////////////////////////////////////////////////// @@ -154,9 +151,9 @@ public void test_textSource_absolutePath2() throws Exception { public void test_textSource_image_over_classpath2() throws Exception { CompositeInfo shell = shell(); assert_getText_getClipboardSource_forSource2( - getInvocationSource(shell, "getClass()", "\"/javax/swing/plaf/basic/icons/JavaCup16.png\""), - "Classpath: /javax/swing/plaf/basic/icons/JavaCup16.png", - getInvocationSource(shell, "{wbp_classTop}", "\"/javax/swing/plaf/basic/icons/JavaCup16.png\"")); + getInvocationSource(shell, "getClass()", "\"/org/eclipse/wb/core/controls/flyout/icons/arrow_bottom.gif\""), + "Classpath: /org/eclipse/wb/core/controls/flyout/icons/arrow_bottom.gif", + getInvocationSource(shell, "{wbp_classTop}", "\"/org/eclipse/wb/core/controls/flyout/icons/arrow_bottom.gif\"")); } /** @@ -166,9 +163,9 @@ public void test_textSource_image_over_classpath2() throws Exception { public void test_textSource_image_over_classpath_OtherClass2() throws Exception { CompositeInfo shell = shell(); assert_getText_getClipboardSource_forSource2( - getInvocationSource(shell, "java.lang.String.class", "\"/javax/swing/plaf/basic/icons/JavaCup16.png\""), - "Classpath: /javax/swing/plaf/basic/icons/JavaCup16.png", - getInvocationSource(shell, "{wbp_classTop}", "\"/javax/swing/plaf/basic/icons/JavaCup16.png\"")); + getInvocationSource(shell, "java.lang.String.class", "\"/org/eclipse/wb/core/controls/flyout/icons/arrow_bottom.gif\""), + "Classpath: /org/eclipse/wb/core/controls/flyout/icons/arrow_bottom.gif", + getInvocationSource(shell, "{wbp_classTop}", "\"/org/eclipse/wb/core/controls/flyout/icons/arrow_bottom.gif\"")); } /** @@ -210,7 +207,7 @@ public void test_textSource_order() throws Exception { "}"); ManagerContainerInfo.getResourceManagerInfo(shell); shell.addMethodInvocation("setImage(org.eclipse.swt.graphics.Image)", - getInvocationSource(shell, "java.lang.String.class", "\"/javax/swing/plaf/basic/icons/JavaCup16.png\"")); + getInvocationSource(shell, "java.lang.String.class", "\"/org/eclipse/wb/core/controls/flyout/icons/arrow_bottom.gif\"")); shell.refresh(); assertEditor( "// filler filler filler", @@ -218,7 +215,7 @@ public void test_textSource_order() throws Exception { " private LocalResourceManager localResourceManager;", " public Test() {", " createResourceManager();", - " setImage(localResourceManager.create(ImageDescriptor.createFromFile(String.class, \"/javax/swing/plaf/basic/icons/JavaCup16.png\")));", + " setImage(localResourceManager.create(ImageDescriptor.createFromFile(String.class, \"/org/eclipse/wb/core/controls/flyout/icons/arrow_bottom.gif\")));", " }", " private void createResourceManager() {", " localResourceManager = new LocalResourceManager(JFaceResources.getResources(),this);", diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/property/SWTResourceManagerTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/property/SWTResourceManagerTest.java index aa9a5727b..290fded48 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/property/SWTResourceManagerTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/swt/model/property/SWTResourceManagerTest.java @@ -12,6 +12,7 @@ *******************************************************************************/ package org.eclipse.wb.tests.designer.swt.model.property; +import org.eclipse.wb.core.editor.constants.CoreImages; import org.eclipse.wb.internal.core.utils.reflect.ReflectionUtils; import org.eclipse.wb.internal.swt.model.widgets.CompositeInfo; import org.eclipse.wb.internal.swt.utils.ManagerUtils; @@ -23,7 +24,6 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.io.File; @@ -41,6 +41,12 @@ public class SWTResourceManagerTest extends RcpModelTest { private Class SWTManagerClass; private Class ImageClass; + @Override + protected void configureNewProject() throws Exception { + super.configureNewProject(); + m_testProject.addPlugin("org.eclipse.wb.core"); + } + //////////////////////////////////////////////////////////////////////////// // // Life cycle @@ -212,7 +218,6 @@ public void test_getImage_absolute() throws Exception { } } - @Disabled @Test public void test_getImage_classpath() throws Exception { // create image over SWTResourceManager @@ -221,7 +226,7 @@ public void test_getImage_classpath() throws Exception { SWTManagerClass, "getImage(java.lang.Class,java.lang.String)", SWTManagerClass, - "/javax/swing/plaf/basic/icons/JavaCup16.png"); + "/org/eclipse/wb/core/controls/flyout/icons/arrow_bottom.gif"); // check create assertNotNull(image); // check state @@ -230,10 +235,11 @@ public void test_getImage_classpath() throws Exception { SWTManagerClass, "getImage(java.lang.Class,java.lang.String)", SWTManagerClass, - "/javax/swing/plaf/basic/icons/JavaCup16.png")); + "/org/eclipse/wb/core/controls/flyout/icons/arrow_bottom.gif")); // load image directly over Image - Image directImage = new Image(null, - getClass().getResourceAsStream("/javax/swing/plaf/basic/icons/JavaCup16.png")); + ImageData directImageData = new ImageData( + CoreImages.class.getResourceAsStream("/org/eclipse/wb/core/controls/flyout/icons/arrow_bottom.gif")); + Image directImage = new Image(null, directImageData); // check equals images try { assertEqualsImage(image, directImage); @@ -246,14 +252,14 @@ public void test_getImage_classpath() throws Exception { SWTManagerClass, "getImage(java.lang.Class,java.lang.String)", SWTManagerClass, - "/javax/swing/plaf/basic/icons/image-failed.png"); + "/org/eclipse/wb/core/controls/flyout/icons/arrow_top.gif"); assertNotNull(image1); assertFalse(image1.isDisposed()); assertSame(image1, ReflectionUtils.invokeMethod( SWTManagerClass, "getImage(java.lang.Class,java.lang.String)", SWTManagerClass, - "/javax/swing/plaf/basic/icons/image-failed.png")); + "/org/eclipse/wb/core/controls/flyout/icons/arrow_top.gif")); assertNotSame(image, image1); } @@ -314,18 +320,17 @@ private static void assertEqualsImage(Image image1, Image image2) throws Excepti ImageData data1 = image1.getImageData(); ImageData data2 = image2.getImageData(); - assertEquals(data1.width, data2.width); - assertEquals(data1.height, data2.height); - assertEquals(data1.depth, data2.depth); - assertEquals(data1.scanlinePad, data2.scanlinePad); - assertEquals(data1.bytesPerLine, data2.bytesPerLine); - assertEquals(data1.transparentPixel, data2.transparentPixel); - assertEquals(data1.maskPad, data2.maskPad); - assertEquals(data1.alpha, data2.alpha); - // Type is only set when image was created via ImageData (Windows) -// assertEquals(data1.type, data2.type); - assertEquals(data1.x, data2.x); - assertEquals(data1.y, data2.y); + assertEquals(data1.width, data2.width, "width"); + assertEquals(data1.height, data2.height, "height"); + assertEquals(data1.depth, data2.depth, "depth"); + assertEquals(data1.scanlinePad, data2.scanlinePad, "scanline pad"); + assertEquals(data1.bytesPerLine, data2.bytesPerLine, "bytes per line"); + assertEquals(data1.transparentPixel, data2.transparentPixel, "transparent pixel"); + assertEquals(data1.maskPad, data2.maskPad, "mask pad"); + assertEquals(data1.alpha, data2.alpha, "alpha"); + assertEquals(data1.type, data2.type); + assertEquals(data1.x, data2.x, "x"); + assertEquals(data1.y, data2.y, "y"); } ////////////////////////////////////////////////////////////////////////////