Skip to content

Commit

Permalink
Fix unittests (IShellFolderTest#testEnumObjects) still fails on amd64)
Browse files Browse the repository at this point in the history
- MonitorFromPoint takes a structure, not a reference to a structure,
  so function definition was wrong
- The last to "KnownFolters" don't resolve on Win10
  • Loading branch information
matthiasblaesing committed Aug 5, 2017
1 parent d63dbfc commit 4be3006
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
* [#838](https://github.com/java-native-access/jna/pull/838): Fix binding of `com.sun.jna.platform.win32.User32#MonitorFromPoint` - [@matthiasblaesing](https://github.com/matthiasblaesing).

Release 4.4.0
=============
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 29 additions & 0 deletions contrib/platform/src/com/sun/jna/platform/win32/WinDef.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> FIELDS = createFieldsOrder("x", "y");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down

0 comments on commit 4be3006

Please sign in to comment.