Search in sources :

Example 1 with IONameT

use of net.pms.util.jna.macos.types.IONameT in project UniversalMediaServer by UniversalMediaServer.

the class IOKitTest method testIONameT.

/**
 * Tests {@link IONameT}.
 *
 * @throws Throwable if an error occurs during the test.
 */
@Test
public void testIONameT() throws Throwable {
    IONameT name = new IONameT("abcdefghijklmnopqrstuvwxyz!.? abcdefghijklmnopqrstuvwxyz!.? abcdefghijklmnopqrstuvwxyz!.? " + "abcdefghijklmnopqrstuvwxyz!.? abcdefghijklmnopqrstuvwxyz!.? ", StandardCharsets.US_ASCII);
    assertEquals("abcdefghijklmnopqrstuvwxyz!.? abcdefghijklmnopqrstuvwxyz!.? abcdefghijklmnopqrstuvwxyz!.? " + "abcdefghijklmnopqrstuvwxyz!.? abcdefgh", name.getString(StandardCharsets.US_ASCII));
    name = new IONameT("abcdefghijklmnopqrstuvwxyz\u00F8\u00E6\u00E5 abcdefghijklmnopqrstuvwxyz\u00F8\u00E6\u00E5 " + "abcdefghijklmnopqrstuvwxyz\u00F8\u00E6\u00E5 abcdefghijklmnopqrstuvwxyz\u00F8\u00E6\u00E5 " + "abcdefghijklmnopqrstuvwxyz\u00F8\u00E6\u00E5 ", StandardCharsets.UTF_8);
    assertEquals("abcdefghijklmnopqrstuvwxyz\u00F8\u00E6\u00E5 abcdefghijklmnopqrstuvwxyz\u00F8\u00E6\u00E5 " + "abcdefghijklmnopqrstuvwxyz\u00F8\u00E6\u00E5 abcdefghijklmnopqrstuvwxyz\u00F8?", name.getString(StandardCharsets.UTF_8));
}
Also used : IONameT(net.pms.util.jna.macos.types.IONameT) Test(org.junit.Test)

Example 2 with IONameT

use of net.pms.util.jna.macos.types.IONameT in project UniversalMediaServer by UniversalMediaServer.

the class IOKitTest method testIOKit.

/**
 * Tests some {@link IOKit} mappings.
 *
 * @throws Throwable if an error occurs during the test.
 */
@Test
public void testIOKit() throws Throwable {
    CFDictionaryRef dictionaryRef = IO.IOServiceMatching("IOHIDSystem");
    IOIteratorTRef iteratorRef = new IOIteratorTRef(true);
    assertEquals(DefaultKernReturnT.SUCCESS, IO.IOServiceGetMatchingServices(IOKit.kIOMasterPortDefault, dictionaryRef, iteratorRef));
    IOIteratorT iterator = iteratorRef.getValue();
    IONameT name = new IONameT(true);
    assertEquals(DefaultKernReturnT.SUCCESS, IO.IOObjectGetClass(iterator, name));
    assertEquals("IOUserIterator", name.getString(StandardCharsets.UTF_8));
    IOObjectT object = IO.IOIteratorNext(iterator);
    assertEquals(DefaultKernReturnT.SUCCESS, IO.IOObjectGetClass(object, name));
    assertEquals("IOHIDSystem", name.getString(StandardCharsets.UTF_8));
    IORegistryEntryT registryEntry = IORegistryEntryT.toIORegistryT(object);
    CFMutableDictionaryRefByReference dictionaryRefRef = new CFMutableDictionaryRefByReference();
    assertEquals(DefaultKernReturnT.SUCCESS, IO.IORegistryEntryCreateCFProperties(registryEntry, dictionaryRefRef, CoreFoundation.ALLOCATOR, 0));
    CFStringRef key = CFStringRef.toCFStringRef("IOClass");
    assertTrue(CF.CFDictionaryContainsKey(dictionaryRefRef.getCFMutableDictionaryRef(), key));
    CFStringRef value = new CFStringRef(CF.CFDictionaryGetValue(dictionaryRefRef.getCFMutableDictionaryRef(), key));
    assertEquals("IOHIDSystem", value.toString());
    CF.CFRelease(key);
    key = CFStringRef.toCFStringRef("IOProviderClass");
    value = new CFStringRef(CF.CFDictionaryGetValue(dictionaryRefRef.getCFMutableDictionaryRef(), key));
    assertEquals("IOResources", value.toString());
    CF.CFRelease(key);
    IO.IOObjectRelease(object);
    object = IO.IOIteratorNext(iterator);
    assertEquals(0, object.intValue());
    assertTrue(IO.IOIteratorIsValid(iterator));
    IO.IOObjectRelease(iterator);
    CF.CFRelease(dictionaryRefRef.getCFMutableDictionaryRef());
}
Also used : CFDictionaryRef(net.pms.util.jna.macos.corefoundation.CoreFoundation.CFDictionaryRef) IOObjectT(net.pms.util.jna.macos.types.IOObjectT) IOIteratorTRef(net.pms.util.jna.macos.types.IOIteratorTRef) CFStringRef(net.pms.util.jna.macos.corefoundation.CoreFoundation.CFStringRef) IOIteratorT(net.pms.util.jna.macos.types.IOIteratorT) IORegistryEntryT(net.pms.util.jna.macos.types.IORegistryEntryT) CFMutableDictionaryRefByReference(net.pms.util.jna.macos.corefoundation.CoreFoundation.CFMutableDictionaryRefByReference) IONameT(net.pms.util.jna.macos.types.IONameT) Test(org.junit.Test)

Aggregations

IONameT (net.pms.util.jna.macos.types.IONameT)2 Test (org.junit.Test)2 CFDictionaryRef (net.pms.util.jna.macos.corefoundation.CoreFoundation.CFDictionaryRef)1 CFMutableDictionaryRefByReference (net.pms.util.jna.macos.corefoundation.CoreFoundation.CFMutableDictionaryRefByReference)1 CFStringRef (net.pms.util.jna.macos.corefoundation.CoreFoundation.CFStringRef)1 IOIteratorT (net.pms.util.jna.macos.types.IOIteratorT)1 IOIteratorTRef (net.pms.util.jna.macos.types.IOIteratorTRef)1 IOObjectT (net.pms.util.jna.macos.types.IOObjectT)1 IORegistryEntryT (net.pms.util.jna.macos.types.IORegistryEntryT)1