use of com.sun.jna.platform.win32.WinDef.BOOL in project jna by java-native-access.
the class Dxva2Test method testCapabilitiesRequestAndCapabilitiesReply.
@Test
public void testCapabilitiesRequestAndCapabilitiesReply() {
HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor;
// the method returns FALSE if the monitor driver doesn't support it,
// but verifies that the JNA mapping is correct (no exception)
DWORDByReference pdwCapabilitiesStringLengthInCharacters = new DWORDByReference();
BOOL success = Dxva2.INSTANCE.GetCapabilitiesStringLength(hPhysicalMonitor, pdwCapabilitiesStringLengthInCharacters);
if (success.booleanValue()) {
// VirtualBox is known to report an empty string
DWORD capStrLen = pdwCapabilitiesStringLengthInCharacters.getValue();
LPSTR pszASCIICapabilitiesString = new LPSTR(new Memory(capStrLen.intValue()));
Dxva2.INSTANCE.CapabilitiesRequestAndCapabilitiesReply(hPhysicalMonitor, pszASCIICapabilitiesString, capStrLen);
} else {
System.err.println("GetCapabilitiesStringLength failed with errorcode: " + Kernel32.INSTANCE.GetLastError());
}
}
use of com.sun.jna.platform.win32.WinDef.BOOL in project jna by java-native-access.
the class WinDefTypesTest method testComparableBOOL.
@Test
public void testComparableBOOL() {
assertEquals("Mismatched null/null comparison", 0, BOOL.compare(null, null));
BOOL FALSE = new BOOL(false);
BOOL TRUE = new BOOL(true);
for (BOOL v : new BOOL[] { FALSE, TRUE }) {
assertEquals("Mismatched null/" + v + " object comparison", 1, BOOL.compare(null, v));
assertEquals("Mismatched null/" + v + " value comparison", 1, BOOL.compare(null, v.booleanValue()));
assertEquals("Mismatched self/" + v + " comparison", 0, BOOL.compare(v, v.booleanValue()));
assertEquals("Mismatched self " + v + "#compareTo() result", 0, v.compareTo(v));
assertEquals("Mismatched null " + v + "#compareTo() result", (-1), v.compareTo(null));
}
assertEquals("Mismatched natural order comparison", (-1), FALSE.compareTo(TRUE));
assertEquals("Mismatched reversed order comparison", 1, TRUE.compareTo(FALSE));
}
use of com.sun.jna.platform.win32.WinDef.BOOL in project jna by java-native-access.
the class VariantTest method testVariantConstructors.
public void testVariantConstructors() {
VARIANT variant;
// skipped: BSTRByReference constructor
// skipped: empty constructor
// skipped: pointer constructor
// skipped: IDispatch constructor
String testString = "TeST$รถ";
BSTR bstr = OleAuto.INSTANCE.SysAllocString(testString);
variant = new VARIANT(bstr);
assertThat(variant.getValue(), instanceOf(BSTR.class));
assertThat(((BSTR) variant.getValue()).getValue(), equalTo(testString));
assertThat(variant.stringValue(), equalTo(testString));
variant = new VARIANT(testString);
assertThat(variant.getValue(), instanceOf(BSTR.class));
assertThat(((BSTR) variant.getValue()).getValue(), equalTo(testString));
assertThat(variant.stringValue(), equalTo(testString));
OleAuto.INSTANCE.SysFreeString(bstr);
OleAuto.INSTANCE.SysFreeString((BSTR) variant.getValue());
BOOL boolTrue = new WinDef.BOOL(true);
variant = new VARIANT(Variant.VARIANT_TRUE);
assertThat(variant.getValue(), instanceOf(VARIANT_BOOL.class));
assertThat(((VARIANT_BOOL) variant.getValue()).shortValue(), equalTo((short) 0xFFFF));
assertThat(variant.booleanValue(), equalTo(true));
variant = new VARIANT(boolTrue);
assertThat(variant.getValue(), instanceOf(VARIANT_BOOL.class));
assertThat(((VARIANT_BOOL) variant.getValue()).shortValue(), equalTo((short) 0xFFFF));
assertThat(variant.booleanValue(), equalTo(true));
int testInt = 4223;
LONG testIntWin = new LONG(testInt);
variant = new VARIANT(testIntWin);
assertThat(variant.getValue(), instanceOf(LONG.class));
assertThat(((LONG) variant.getValue()).intValue(), equalTo(testInt));
assertThat(variant.intValue(), equalTo(testInt));
variant = new VARIANT(testInt);
assertThat(variant.getValue(), instanceOf(LONG.class));
assertThat(((LONG) variant.getValue()).intValue(), equalTo(testInt));
assertThat(variant.intValue(), equalTo(testInt));
short testShort = 23;
SHORT testShortWin = new SHORT(testShort);
variant = new VARIANT(testShortWin);
assertThat(variant.getValue(), instanceOf(SHORT.class));
assertThat(((SHORT) variant.getValue()).shortValue(), equalTo(testShort));
assertThat(variant.shortValue(), equalTo(testShort));
variant = new VARIANT(testShort);
assertThat(variant.getValue(), instanceOf(SHORT.class));
assertThat(((SHORT) variant.getValue()).shortValue(), equalTo(testShort));
assertThat(variant.shortValue(), equalTo(testShort));
long testLong = 4223L + Integer.MAX_VALUE;
variant = new VARIANT(testLong);
assertThat(variant.getValue(), instanceOf(LONGLONG.class));
assertThat(((LONGLONG) variant.getValue()).longValue(), equalTo(testLong));
assertThat(variant.longValue(), equalTo(testLong));
Date testDate = new Date(2042 - 1900, 2, 3, 23, 0, 0);
variant = new VARIANT(testDate);
assertThat(variant.getValue(), instanceOf(DATE.class));
assertThat(variant.dateValue(), equalTo(testDate));
byte testByte = 42;
BYTE testByteWin = new BYTE(testByte);
CHAR testByteWin2 = new CHAR(testByte);
variant = new VARIANT(testByte);
assertThat(variant.getValue(), instanceOf(BYTE.class));
assertThat(((BYTE) variant.getValue()).byteValue(), equalTo(testByte));
assertThat(variant.byteValue(), equalTo(testByte));
variant = new VARIANT(testByteWin);
assertThat(variant.getValue(), instanceOf(BYTE.class));
assertThat(((BYTE) variant.getValue()).byteValue(), equalTo(testByte));
assertThat(variant.byteValue(), equalTo(testByte));
variant = new VARIANT(testByteWin2);
assertThat(variant.getValue(), instanceOf(CHAR.class));
assertThat(((CHAR) variant.getValue()).byteValue(), equalTo(testByte));
assertThat(variant.byteValue(), equalTo(testByte));
variant = new VARIANT(testByteWin2);
assertThat(variant.getValue(), instanceOf(CHAR.class));
assertThat(((CHAR) variant.getValue()).byteValue(), equalTo(testByte));
assertThat(variant.byteValue(), equalTo(testByte));
double testDouble = 42.23;
variant = new VARIANT(testDouble);
assertThat(variant.getValue(), instanceOf(Double.class));
// If this fails introduce comparison with range
assertThat(variant.doubleValue(), equalTo(testDouble));
float testFloat = 42.23f;
variant = new VARIANT(testFloat);
assertThat(variant.getValue(), instanceOf(Float.class));
// If this fails introduce comparison with range
assertThat(variant.floatValue(), equalTo(testFloat));
char testChar = 42 + Short.MAX_VALUE;
variant = new VARIANT(testChar);
assertThat(variant.getValue(), instanceOf(USHORT.class));
assertThat(((USHORT) variant.getValue()).intValue(), equalTo((int) testChar));
assertThat(variant.intValue(), equalTo((int) testChar));
}
use of com.sun.jna.platform.win32.WinDef.BOOL in project jna by java-native-access.
the class User32Test method testAdjustWindowRect.
@Test
public final void testAdjustWindowRect() {
RECT lpRect = new RECT();
lpRect.left = 100;
lpRect.top = 200;
lpRect.bottom = 300;
lpRect.right = 500;
assertTrue(User32.INSTANCE.AdjustWindowRect(lpRect, new DWORD(WinUser.WS_THICKFRAME), new BOOL(1)).booleanValue());
assertTrue(lpRect.left < 100);
assertTrue(lpRect.top < 200);
assertTrue(lpRect.bottom > 300);
assertTrue(lpRect.right > 500);
}
Aggregations