[fuchsia_services] Make Outgoing compatible with `$out/svc`
This is part of the `public` -> `svc` migration.
CF-540 #comment dart Outgoing is compatible with `$out/svc`
Change-Id: I9e5f5f552ef374626de96fc30cd00d055fd2596a
diff --git a/public/dart/fuchsia_services/lib/src/outgoing.dart b/public/dart/fuchsia_services/lib/src/outgoing.dart
index 45b615c..f260ffc 100644
--- a/public/dart/fuchsia_services/lib/src/outgoing.dart
+++ b/public/dart/fuchsia_services/lib/src/outgoing.dart
@@ -21,8 +21,10 @@
/// This class will throw an Exception if its methods are called
/// after it is closed. Calling close twice doesn't cause exception.
Outgoing() {
+ // TODO(CF-540): remove 'public' after transition is complete
_root
..addNode('public', _public)
+ ..addNode('svc', _public)
..addNode('debug', _debug)
..addNode('ctrl', _ctrl);
}
diff --git a/public/dart/fuchsia_services/test/outgoing_test.dart b/public/dart/fuchsia_services/test/outgoing_test.dart
index 8e95b46..73c96e9 100644
--- a/public/dart/fuchsia_services/test/outgoing_test.dart
+++ b/public/dart/fuchsia_services/test/outgoing_test.dart
@@ -10,26 +10,41 @@
import 'package:test/test.dart';
void main() {
+ StreamController<bool> _streamController;
+ Stream<bool> _stream;
+
+ setUp(() {
+ _streamController = StreamController<bool>.broadcast();
+ _stream = _streamController.stream;
+ });
+
+ tearDown(() {
+ _streamController.close();
+ });
+
group('outgoing', () {
test('connect to service calls correct service', () async {
final outgoingImpl = Outgoing();
final dirProxy = DirectoryProxy();
- final nodeProxy = NodeProxy();
- final streamController = StreamController<bool>.broadcast();
- final stream = streamController.stream;
-
outgoingImpl
- ..addPublicService((_) {
- streamController
- ..add(true)
- ..close();
- }, 'foo',)
+ ..addPublicService(
+ (_) {
+ _streamController.add(true);
+ },
+ 'foo',
+ )
..serve(InterfaceRequest(dirProxy.ctrl.request().passChannel()));
-
- await dirProxy.open(0, 0, 'public/foo', nodeProxy.ctrl.request());
- stream.listen(expectAsync1((response) {
+ {
+ final nodeProxy = NodeProxy();
+ await dirProxy.open(0, 0, 'public/foo', nodeProxy.ctrl.request());
+ }
+ {
+ final nodeProxy = NodeProxy();
+ await dirProxy.open(0, 0, 'svc/foo', nodeProxy.ctrl.request());
+ }
+ _stream.listen(expectAsync1((response) {
expect(response, true);
- }));
+ }, count: 2));
});
});
}