Skip to content

Commit

Permalink
Merge pull request #838 from matthiasblaesing/fix_unittests
Browse files Browse the repository at this point in the history
 Fix unittests (IShellFolderTest#testEnumObjects) still fails on amd64)
  • Loading branch information
dblock authored Aug 6, 2017
2 parents 805e5c6 + 08d3e3f commit e4dd7bb
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 26 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 @@ -32,8 +32,12 @@
/**
* Wrapper class for the ITypeInfo interface
*
* Method Name V-Table Offset IUnknown.QueryInterface 0 IUnknown.AddRef 4
* IUnknown.Release 8
* <table>
* <tr><th>Method Name</th><th>V-Table Offset</th></tr>
* <tr><td>IUnknown.QueryInterface</td><td>0</td></tr>
* <tr><td>IUnknown.AddRef</td><td>4</td></tr>
* <tr><td>IUnknown.Release</td><td>8</td></tr>
* </table>
*
* @author Tobias Wolf, [email protected]
*/
Expand Down
2 changes: 1 addition & 1 deletion contrib/platform/src/com/sun/jna/platform/win32/Ole32.java
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ HRESULT CoCreateInstance(GUID rclsid, Pointer pUnkOuter, int dwClsContext,

/**
* Puts an OLE compound document object into the running state.
* @param pUnknown [in] Pointer to the {@link IUnknown IUnknown} interface
* @param pUnknown [in] Pointer to the {@link com.sun.jna.platform.win32.COM.IUnknown IUnknown} interface
* on the object, with which it will query for a pointer to
* the IRunnableObject interface, and then call its Run method.
* @return This function returns on success.
Expand Down
17 changes: 17 additions & 0 deletions contrib/platform/src/com/sun/jna/platform/win32/User32.java
Original file line number Diff line number Diff line change
Expand Up @@ -1730,8 +1730,25 @@ HWND CreateWindowEx(int dwExStyle, String lpClassName,
* @return If the point is contained by a display monitor, the return value is an HMONITOR
* handle to that display monitor. If the point is not contained by a display monitor,
* the return value depends on the value of dwFlags.
* @deprecated Use {@link #MonitorFromPoint(com.sun.jna.platform.win32.WinDef.POINT.ByValue, int)}
*/
@Deprecated
HMONITOR MonitorFromPoint(POINT pt, int dwFlags);

/**
* Retrieves a handle to the display monitor that contains a specified point.
* @param pt A POINT structure that specifies the point of interest in virtual-screen
* coordinates.
* @param dwFlags Determines the function's return value if the window does not intersect
* any display monitor. This parameter can be one of the following values.
* <ul><li>MONITOR_DEFAULTTONEAREST</li>
* <li>MONITOR_DEFAULTTONULL</li>
* <li>MONITOR_DEFAULTTOPRIMARY</li></ul>
* @return If the point is contained by a display monitor, the return value is an HMONITOR
* 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.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
40 changes: 20 additions & 20 deletions contrib/platform/src/com/sun/jna/platform/win32/WinNT.java
Original file line number Diff line number Diff line change
Expand Up @@ -3528,9 +3528,9 @@ private static final int _MAKELCID(int lgid, int srtid) {
/**
* construct the locale id from a language id and a sort id.
*
* @param lgid
* @param srtid
* @return
* @param lgid language id
* @param srtid sort id
* @return locale id derived from ldig and srtid
*/
public static final LCID MAKELCID(int lgid, int srtid) {
return new LCID(_MAKELCID(lgid, srtid));
Expand All @@ -3539,10 +3539,10 @@ public static final LCID MAKELCID(int lgid, int srtid) {
/**
* construct the locale id from a language id, sort id, and sort version.
*
* @param lgid
* @param srtid
* @param ver
* @return
* @param lgid locale id
* @param srtid sort id
* @param ver sort version
* @return locale id derviced from a language id, sort id, and sort version.
*/
public static final LCID MAKESORTLCID(int lgid, int srtid, int ver) {
return new LCID(_MAKELCID(lgid, srtid) | (ver << 20));
Expand All @@ -3551,8 +3551,8 @@ public static final LCID MAKESORTLCID(int lgid, int srtid, int ver) {
/**
* extract the language id from a locale id.
*
* @param lcid
* @return
* @param lcid locale id
* @return extracted language id
*/
public static final int LANGIDFROMLCID(LCID lcid) {
return lcid.intValue() & 0xFFFF;
Expand All @@ -3561,8 +3561,8 @@ public static final int LANGIDFROMLCID(LCID lcid) {
/**
* extract the sort id from a locale id.
*
* @param lcid
* @return
* @param lcid locale id
* @return extracted sort id
*/
public static final int SORTIDFROMLCID(LCID lcid) {
return (lcid.intValue() >>> 16) & 0xf;
Expand All @@ -3571,8 +3571,8 @@ public static final int SORTIDFROMLCID(LCID lcid) {
/**
* extract the sort version from a locale id.
*
* @param lcid
* @return
* @param lcid locale id
* @return extracted sort version
*/
public static final int SORTVERSIONFROMLCID(LCID lcid) {
return (lcid.intValue() >>> 20) & 0xf;
Expand All @@ -3581,9 +3581,9 @@ public static final int SORTVERSIONFROMLCID(LCID lcid) {
/**
* Construct language id from a primary language id and a sublanguage id.
*
* @param p Language ID
* @param s Sublanguage ID
* @return
* @param p primary language ID
* @param s sublanguage ID
* @return constructed language id
*/
public static final int MAKELANGID(int p, int s) {
return (s << 10) | (p & 0xFFFF);
Expand All @@ -3592,8 +3592,8 @@ public static final int MAKELANGID(int p, int s) {
/**
* Extract primary language id from a language id.
*
* @param lgid Language ID
* @return
* @param lgid language ID
* @return extracted primary language id
*/
public static final int PRIMARYLANGID(int lgid) {
return lgid & 0x3ff;
Expand All @@ -3602,8 +3602,8 @@ public static final int PRIMARYLANGID(int lgid) {
/**
* Extract sublanguage id from a language id.
*
* @param lgid Language ID
* @return
* @param lgid language ID
* @return extracted sublanguage id
*/
public static final int SUBLANGID(int lgid) {
return (lgid & 0xFFFF) >>> 10;
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 @@ -88,6 +88,8 @@ public void testNoDuplicateMethodsNames() {
for (String name : new String[] {
// has 2 overloads since the original API accepts both MONITORINFO and MONITORINFOEX
"GetMonitorInfo"
// has 2 overloads since there was a broken binding for MonitorFromPoint
,"MonitorFromPoint"
}) {
dupSet.remove(name);
}
Expand Down Expand Up @@ -184,7 +186,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 e4dd7bb

Please sign in to comment.