Skip to content

Commit

Permalink
Regenerate
Browse files Browse the repository at this point in the history
  • Loading branch information
brianquinlan committed Sep 30, 2024
1 parent 5b35857 commit c9e17ad
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ external ffi.Pointer<objc.ObjCBlockImpl> _wrapListenerBlock_sjfpmz(
ffi.Pointer<objc.ObjCBlockImpl> block,
);

/// Helper class to adapt a Dart stream into a `NSInputStream`
/// Helper class to adapt a Dart stream into a `NSInputStream`.
class DartInputStreamAdapter extends NSInputStream {
DartInputStreamAdapter._(ffi.Pointer<objc.ObjCObject> pointer,
{bool retain = false, bool release = false})
Expand Down
28 changes: 28 additions & 0 deletions pkgs/objective_c/test/ns_input_stream_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,32 @@ void main() {
.having((e) => e.domain.toString(), 'domain', 'DartError'));
});
});

group('assign delegate', () {
late NSInputStream inputStream;

setUp(() {
inputStream = Stream.fromIterable([
[1, 2, 3],
]).toNSInputStream();
});

test('self', () async {
inputStream.open();
inputStream.delegate = inputStream;
final (count, data, hasBytesAvailable, status, error) =
await read(inputStream, 3);
expect(count, 3);
expect(error, null);
});

test('non-self', () async {
inputStream.open();
inputStream.delegate = [1, 2, 3].toNSData();
final (count, data, hasBytesAvailable, status, error) =
await read(inputStream, 3);
expect(count, 3);
expect(error, null);
});
});
}

0 comments on commit c9e17ad

Please sign in to comment.