|
1 | 1 | import 'dart:ffi'; |
| 2 | +import 'dart:io' show Platform; |
2 | 3 |
|
3 | 4 | import 'package:ffi/ffi.dart'; |
4 | 5 | import 'package:hidapi/hidapi.dart'; |
@@ -87,4 +88,55 @@ void main() { |
87 | 88 | } |
88 | 89 | }); |
89 | 90 | }); |
| 91 | + |
| 92 | + group('darwin exclusive mode', () { |
| 93 | + test('hidDarwinGetOpenExclusive returns bool', () { |
| 94 | + hidInit(); |
| 95 | + try { |
| 96 | + final val = hidDarwinGetOpenExclusive(); |
| 97 | + expect(val, isA<bool>()); |
| 98 | + } finally { |
| 99 | + hidExit(); |
| 100 | + } |
| 101 | + }); |
| 102 | + |
| 103 | + test('hidDarwinSetOpenExclusive accepts bool without throwing', () { |
| 104 | + hidInit(); |
| 105 | + try { |
| 106 | + expect(() => hidDarwinSetOpenExclusive(false), returnsNormally); |
| 107 | + } finally { |
| 108 | + hidExit(); |
| 109 | + } |
| 110 | + }); |
| 111 | + |
| 112 | + test( |
| 113 | + 'hidDarwinSetOpenExclusive round-trips value', |
| 114 | + () { |
| 115 | + hidInit(); |
| 116 | + try { |
| 117 | + hidDarwinSetOpenExclusive(false); |
| 118 | + expect(hidDarwinGetOpenExclusive(), isFalse); |
| 119 | + hidDarwinSetOpenExclusive(true); |
| 120 | + expect(hidDarwinGetOpenExclusive(), isTrue); |
| 121 | + } finally { |
| 122 | + hidExit(); |
| 123 | + } |
| 124 | + }, |
| 125 | + skip: !Platform.isMacOS ? 'macOS-only' : null, |
| 126 | + ); |
| 127 | + |
| 128 | + test( |
| 129 | + 'hidDarwinGetOpenExclusive defaults to true after init', |
| 130 | + () { |
| 131 | + hidInit(); |
| 132 | + try { |
| 133 | + // Per upstream docs, hid_init sets exclusive mode to true. |
| 134 | + expect(hidDarwinGetOpenExclusive(), isTrue); |
| 135 | + } finally { |
| 136 | + hidExit(); |
| 137 | + } |
| 138 | + }, |
| 139 | + skip: !Platform.isMacOS ? 'macOS-only' : null, |
| 140 | + ); |
| 141 | + }); |
90 | 142 | } |
0 commit comments