diff --git a/.gitignore b/.gitignore index 6391d781c3a..57348d5f8f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ bin/ +bin_test/ *.log target/ /.project diff --git a/binaries/.classpath_win32 b/binaries/.classpath_win32 index 983fe4f4ad8..f4f589476b1 100644 --- a/binaries/.classpath_win32 +++ b/binaries/.classpath_win32 @@ -25,5 +25,11 @@ + + + + + + diff --git a/binaries/org.eclipse.swt.win32.win32.aarch64/.project b/binaries/org.eclipse.swt.win32.win32.aarch64/.project index b90f3ddaf24..7899ce83721 100644 --- a/binaries/org.eclipse.swt.win32.win32.aarch64/.project +++ b/binaries/org.eclipse.swt.win32.win32.aarch64/.project @@ -107,6 +107,11 @@ 2 SWT_HOST_PLUGIN/Eclipse%20SWT%20WebKit + + Eclipse SWT Tests + 2 + SWT_HOST_PLUGIN/Eclipse%20SWT%20Tests + diff --git a/binaries/org.eclipse.swt.win32.win32.aarch64/build.properties b/binaries/org.eclipse.swt.win32.win32.aarch64/build.properties index a229d438259..cbb0ab9f145 100644 --- a/binaries/org.eclipse.swt.win32.win32.aarch64/build.properties +++ b/binaries/org.eclipse.swt.win32.win32.aarch64/build.properties @@ -39,3 +39,6 @@ output.. = bin/ pom.model.property.os=win32 pom.model.property.ws=win32 pom.model.property.arch=aarch64 + +# To be removed once linked .classpath files are supported by Tycho, see https://github.com/eclipse-tycho/tycho/issues/3803 +pom.model.property.localTestsSourceDirectory=../../bundles/org.eclipse.swt/Eclipse SWT Tests/win32 diff --git a/binaries/org.eclipse.swt.win32.win32.x86_64/.project b/binaries/org.eclipse.swt.win32.win32.x86_64/.project index 5814b16ab64..31f4e76bce5 100644 --- a/binaries/org.eclipse.swt.win32.win32.x86_64/.project +++ b/binaries/org.eclipse.swt.win32.win32.x86_64/.project @@ -107,6 +107,11 @@ 2 SWT_HOST_PLUGIN/Eclipse%20SWT%20WebKit + + Eclipse SWT Tests + 2 + SWT_HOST_PLUGIN/Eclipse%20SWT%20Tests + diff --git a/binaries/org.eclipse.swt.win32.win32.x86_64/build.properties b/binaries/org.eclipse.swt.win32.win32.x86_64/build.properties index cebb4bfdddf..104724f5487 100644 --- a/binaries/org.eclipse.swt.win32.win32.x86_64/build.properties +++ b/binaries/org.eclipse.swt.win32.win32.x86_64/build.properties @@ -40,3 +40,6 @@ output.. = bin/ pom.model.property.os=win32 pom.model.property.ws=win32 pom.model.property.arch=x86_64 + +# To be removed once linked .classpath files are supported by Tycho, see https://github.com/eclipse-tycho/tycho/issues/3803 +pom.model.property.localTestsSourceDirectory=../../bundles/org.eclipse.swt/Eclipse SWT Tests/win32 diff --git a/binaries/pom.xml b/binaries/pom.xml index 3c90d81a1ce..0c29dd6f749 100644 --- a/binaries/pom.xml +++ b/binaries/pom.xml @@ -30,6 +30,7 @@ ${buildId} 17 ${project.basedir}/../../bundles/org.eclipse.swt + @@ -42,8 +43,31 @@ org.eclipse.swt.win32.win32.x86_64 + + + + junit + junit + 4.13.2 + test + + + + ${localTestsSourceDirectory} + + org.apache.maven.plugins + maven-surefire-plugin + + + execute-tests + + test + + + + org.eclipse.tycho tycho-apitools-plugin diff --git a/tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/internal/DefaultSWTFontRegistryTests.java b/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/internal/DefaultSWTFontRegistryTests.java similarity index 96% rename from tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/internal/DefaultSWTFontRegistryTests.java rename to bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/internal/DefaultSWTFontRegistryTests.java index ce5ebb55c8f..e15eacc413d 100644 --- a/tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/internal/DefaultSWTFontRegistryTests.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/internal/DefaultSWTFontRegistryTests.java @@ -22,6 +22,7 @@ import org.eclipse.swt.widgets.Display; import org.junit.After; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; public class DefaultSWTFontRegistryTests { @@ -29,6 +30,11 @@ public class DefaultSWTFontRegistryTests { private Display display; private SWTFontRegistry fontRegistry; + @BeforeClass + public static void assumeIsWindows() { + PlatformSpecificExecution.assumeIsFittingPlatform(); + } + @Before public void setUp() { this.display = Display.getDefault(); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/internal/PlatformSpecificExecution.java b/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/internal/PlatformSpecificExecution.java new file mode 100644 index 00000000000..550f06c29c7 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/internal/PlatformSpecificExecution.java @@ -0,0 +1,28 @@ +package org.eclipse.swt.internal; + +import static org.junit.Assume.assumeTrue; + +import java.net.*; + +public final class PlatformSpecificExecution { + private PlatformSpecificExecution() { + } + + public static void assumeIsFittingPlatform() { + assumeTrue("test is specific for Windows", isFittingOS()); + assumeTrue("architecture of platform does not match", isFittingArchitecture()); + } + + private static boolean isFittingOS() { + return System.getProperty("os.name").toLowerCase().startsWith("win"); + } + + private static boolean isFittingArchitecture() { + Class thisClass = PlatformSpecificExecution.class; + String thisClassResourcePath = thisClass.getName().replace('.', '/') + ".class"; + URL thisClassURL = thisClass.getClassLoader().getResource(thisClassResourcePath); //$NON-NLS-1$ + return thisClassURL.toString().contains(Library.arch()); + } + +} + diff --git a/tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/internal/ScalingSWTFontRegistryTests.java b/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/internal/ScalingSWTFontRegistryTests.java similarity index 96% rename from tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/internal/ScalingSWTFontRegistryTests.java rename to bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/internal/ScalingSWTFontRegistryTests.java index dcaf0e709e0..e6ed8c9ed28 100644 --- a/tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/internal/ScalingSWTFontRegistryTests.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/internal/ScalingSWTFontRegistryTests.java @@ -23,12 +23,18 @@ import org.eclipse.swt.widgets.Display; import org.junit.After; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; public class ScalingSWTFontRegistryTests { private static String TEST_FONT = "Helvetica"; private SWTFontRegistry fontRegistry; + @BeforeClass + public static void assumeIsWindows() { + PlatformSpecificExecution.assumeIsFittingPlatform(); + } + @Before public void setUp() { this.fontRegistry = new ScalingSWTFontRegistry(Display.getDefault()); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/DefaultSWTFontRegistry.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/DefaultSWTFontRegistry.java index 5113b14108d..e1b031de031 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/DefaultSWTFontRegistry.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/DefaultSWTFontRegistry.java @@ -25,16 +25,13 @@ * As this class is only intended to be used internally via {@code SWTFontProvider}, * it should neither be instantiated nor referenced in a client application. * The behavior can change any time in a future release. - * - * @noreference This class is not intended to be referenced by clients. - * @noinstantiate This class is not intended to be instantiated by clients. */ -public final class DefaultSWTFontRegistry implements SWTFontRegistry { +final class DefaultSWTFontRegistry implements SWTFontRegistry { private static FontData KEY_SYSTEM_FONTS = new FontData(); private Map fontsMap = new HashMap<>(); private Device device; - public DefaultSWTFontRegistry(Device device) { + DefaultSWTFontRegistry(Device device) { this.device = device; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ScalingSWTFontRegistry.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ScalingSWTFontRegistry.java index 0b7a5a6f6dd..0fd4b9aec2e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ScalingSWTFontRegistry.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ScalingSWTFontRegistry.java @@ -26,11 +26,8 @@ * As this class is only intended to be used internally via {@code SWTFontProvider}, * it should neither be instantiated nor referenced in a client application. * The behavior can change any time in a future release. - * - * @noreference This class is not intended to be referenced by clients. - * @noinstantiate This class is not intended to be instantiated by clients. */ -public final class ScalingSWTFontRegistry implements SWTFontRegistry { +final class ScalingSWTFontRegistry implements SWTFontRegistry { private class ScaledFontContainer { // the first (unknown) font to be requested as scaled variant // usually it is scaled to the primary monitor zoom, but that is not guaranteed @@ -72,7 +69,7 @@ private void addScaledFont(int targetZoom, Font scaledFont) { private Map fontKeyMap = new HashMap<>(); private Device device; - public ScalingSWTFontRegistry(Device device) { + ScalingSWTFontRegistry(Device device) { this.device = device; } diff --git a/tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/tests/win32/AllWin32Tests.java b/tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/tests/win32/AllWin32Tests.java index ec36dc88fac..ac8f13bb787 100644 --- a/tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/tests/win32/AllWin32Tests.java +++ b/tests/org.eclipse.swt.tests.win32/JUnit Tests/org/eclipse/swt/tests/win32/AllWin32Tests.java @@ -15,20 +15,15 @@ package org.eclipse.swt.tests.win32; import org.eclipse.swt.graphics.ImageWin32Tests; -import org.eclipse.swt.internal.DefaultSWTFontRegistryTests; -import org.eclipse.swt.internal.ScalingSWTFontRegistryTests; import org.eclipse.swt.tests.win32.widgets.TestTreeColumn; import org.eclipse.swt.tests.win32.widgets.Test_org_eclipse_swt_widgets_Display; import org.junit.runner.JUnitCore; import org.junit.runner.RunWith; import org.junit.runners.Suite; - @RunWith(Suite.class) @Suite.SuiteClasses({ - DefaultSWTFontRegistryTests.class, ImageWin32Tests.class, - ScalingSWTFontRegistryTests.class, Test_org_eclipse_swt_dnd_DND.class, Test_org_eclipse_swt_events_KeyEvent.class, Test_org_eclipse_swt_widgets_Display.class,