From 253481b5901d07e7cb027008970020322f45d3c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Bl=C3=A4sing?= Date: Fri, 4 Aug 2017 21:39:07 +0200 Subject: [PATCH] Fix unittests (IShellFolderTest#testEnumObjects) still fails on amd64) - MonitorFromPoint takes a structure, not a reference to a structure, so function definition was wrong - The last to "KnownFolters" don't resolve on Win10 --- CHANGES.md | 1 + .../com/sun/jna/platform/win32/User32.java | 2 +- .../com/sun/jna/platform/win32/WinDef.java | 29 +++++++++++++++++++ .../platform/win32/Kernel32ConsoleTest.java | 3 ++ .../jna/platform/win32/Shell32UtilTest.java | 5 ++-- .../sun/jna/platform/win32/User32Test.java | 2 +- 6 files changed, 38 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index c2318f506e..dc58f18b76 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -20,6 +20,7 @@ Bug Fixes * [#785](https://github.com/java-native-access/jna/issues/785): OaIdlUtil#toPrimitiveArray fails if dimension bounds are not 0-based - [@matthiasblaesing](https://github.com/matthiasblaesing). * [#795](https://github.com/java-native-access/jna/issues/795): com.sun.jna.platform.win32.WinDef.WORDByReference holds a WORD which is defined to 16 bit on windows, so it needs to be accessed as short (getShort()). Fix suggested by - [@kdeines](https://github.com/kdeines). * [#804](https://github.com/java-native-access/jna/pull/804) Main-Class in jna-platform.jar collides with java 9 module system - [@matthiasblaesing](https://github.com/matthiasblaesing). +* [#???](https://github.com/java-native-access/jna/pull/???): Fix binding of `com.sun.jna.platform.win32.User32#MonitorFromPoint` - [@matthiasblaesing](https://github.com/matthiasblaesing). Release 4.4.0 ============= diff --git a/contrib/platform/src/com/sun/jna/platform/win32/User32.java b/contrib/platform/src/com/sun/jna/platform/win32/User32.java index 3db2945593..c2adbf9554 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/User32.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/User32.java @@ -1731,7 +1731,7 @@ HWND CreateWindowEx(int dwExStyle, String lpClassName, * handle to that display monitor. If the point is not contained by a display monitor, * the return value depends on the value of dwFlags. */ - HMONITOR MonitorFromPoint(POINT pt, int dwFlags); + HMONITOR MonitorFromPoint(POINT.ByValue pt, int dwFlags); /** * Retrieves a handle to the display monitor that has the largest area of intersection with diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinDef.java b/contrib/platform/src/com/sun/jna/platform/win32/WinDef.java index 7029b85cff..069eab539a 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinDef.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinDef.java @@ -1068,6 +1068,35 @@ public class POINT extends Structure { */ public static class ByReference extends POINT implements Structure.ByReference { + public ByReference() { + } + + public ByReference(Pointer memory) { + super(memory); + } + + public ByReference(int x, int y) { + super(x, y); + } + + } + + /** + * The Class ByValue. + */ + public static class ByValue extends POINT implements Structure.ByValue { + + public ByValue() { + } + + public ByValue(Pointer memory) { + super(memory); + } + + public ByValue(int x, int y) { + super(x, y); + } + } public static final List FIELDS = createFieldsOrder("x", "y"); diff --git a/contrib/platform/test/com/sun/jna/platform/win32/Kernel32ConsoleTest.java b/contrib/platform/test/com/sun/jna/platform/win32/Kernel32ConsoleTest.java index eb6e21268c..030adf58ee 100644 --- a/contrib/platform/test/com/sun/jna/platform/win32/Kernel32ConsoleTest.java +++ b/contrib/platform/test/com/sun/jna/platform/win32/Kernel32ConsoleTest.java @@ -20,6 +20,7 @@ import com.sun.jna.platform.win32.WinDef.HWND; import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.ptr.IntByReference; +import org.junit.Assume; /** * @author lgoldstein @@ -29,6 +30,8 @@ public class Kernel32ConsoleTest extends AbstractWin32TestSupport { @Test public void testGetConsoleDisplayMode() { + // If there is no console window, it can't be queried + Assume.assumeNotNull(INSTANCE.GetConsoleWindow()); IntByReference curMode=new IntByReference(); assertCallSucceeded("Initial display mode value retrieval", INSTANCE.GetConsoleDisplayMode(curMode)); } diff --git a/contrib/platform/test/com/sun/jna/platform/win32/Shell32UtilTest.java b/contrib/platform/test/com/sun/jna/platform/win32/Shell32UtilTest.java index c8a0976987..1cd0da1685 100644 --- a/contrib/platform/test/com/sun/jna/platform/win32/Shell32UtilTest.java +++ b/contrib/platform/test/com/sun/jna/platform/win32/Shell32UtilTest.java @@ -70,7 +70,8 @@ public void testGetKnownFolderPath() assertNotNull(Shell32Util.getKnownFolderPath(KnownFolders.FOLDERID_Libraries)); assertNotNull(Shell32Util.getKnownFolderPath(KnownFolders.FOLDERID_RoamingAppData)); assertNotNull(Shell32Util.getKnownFolderPath(KnownFolders.FOLDERID_UserProfiles)); - assertNotNull(Shell32Util.getKnownFolderPath(KnownFolders.FOLDERID_UserProgramFiles)); - assertNotNull(Shell32Util.getKnownFolderPath(KnownFolders.FOLDERID_UserProgramFilesCommon)); + // This is unstable: + // assertNotNull(Shell32Util.getKnownFolderPath(KnownFolders.FOLDERID_UserProgramFiles)); + // assertNotNull(Shell32Util.getKnownFolderPath(KnownFolders.FOLDERID_UserProgramFilesCommon)); } } diff --git a/contrib/platform/test/com/sun/jna/platform/win32/User32Test.java b/contrib/platform/test/com/sun/jna/platform/win32/User32Test.java index b311638627..ba7d3ffc1c 100644 --- a/contrib/platform/test/com/sun/jna/platform/win32/User32Test.java +++ b/contrib/platform/test/com/sun/jna/platform/win32/User32Test.java @@ -184,7 +184,7 @@ public final void testRegisterWindowMessage() { public final void testMonitorFromPoint() { int dwFlags = WinUser.MONITOR_DEFAULTTOPRIMARY; - POINT pt = new POINT(0, 0); + POINT.ByValue pt = new POINT.ByValue(0, 0); assertNotNull(User32.INSTANCE.MonitorFromPoint(pt, dwFlags)); }