Revert "[dart sdk] remove connectToEnvironmentService"
This reverts commit a4c06c094bd8274a47e53bc198d493314e201b6c.
Reason for revert: Breaks build.
Original change's description:
> [dart sdk] remove connectToEnvironmentService
>
> MS-2335 #done
>
> Change-Id: I41a4271111d43eab882b6a37e351f5dd157c11ca
TBR=chaselatta@google.com,nkorsote@google.com
Change-Id: I3cb464e68dcb8bdecc7736d56060be82ac58db78
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
diff --git a/public/dart/fuchsia_services/BUILD.gn b/public/dart/fuchsia_services/BUILD.gn
index 4c5d6cc..de06885 100644
--- a/public/dart/fuchsia_services/BUILD.gn
+++ b/public/dart/fuchsia_services/BUILD.gn
@@ -15,6 +15,7 @@
sources = [
"services.dart",
+ "src/environment_service_connection.dart",
"src/incoming.dart",
"src/internal/_startup_context_impl.dart",
"src/outgoing.dart",
@@ -35,6 +36,7 @@
flutter_test("fuchsia_services_package_unittests") {
sources = [
+ "environment_service_connection_test.dart",
"service_provider_impl_test.dart",
"startup_context_test.dart",
]
diff --git a/public/dart/fuchsia_services/lib/services.dart b/public/dart/fuchsia_services/lib/services.dart
index 3a6db80..9fdac2c 100644
--- a/public/dart/fuchsia_services/lib/services.dart
+++ b/public/dart/fuchsia_services/lib/services.dart
@@ -3,6 +3,7 @@
// found in the LICENSE file.
/// The base-level functionality required by any component on Fuchsia.
+export 'src/environment_service_connection.dart';
export 'src/incoming.dart';
export 'src/outgoing.dart';
export 'src/service_provider_impl.dart';
diff --git a/public/dart/fuchsia_services/lib/src/environment_service_connection.dart b/public/dart/fuchsia_services/lib/src/environment_service_connection.dart
new file mode 100644
index 0000000..68a6209
--- /dev/null
+++ b/public/dart/fuchsia_services/lib/src/environment_service_connection.dart
@@ -0,0 +1,19 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'package:fidl/fidl.dart';
+
+import 'startup_context.dart';
+
+/// Deprecated: Connects to the environment service specified by [serviceProxy].
+///
+/// Environment services are services that are implemented by the framework
+/// itself.
+///
+/// Deprecated, instead use
+/// `StartupContext.fromStartupInfo().incoming.connectToService`
+// TODO(MS-2335) remove this class
+void connectToEnvironmentService<T>(AsyncProxy<T> serviceProxy) {
+ StartupContext.fromStartupInfo().incoming.connectToService(serviceProxy);
+}
diff --git a/public/dart/fuchsia_services/test/environment_service_connection_test.dart b/public/dart/fuchsia_services/test/environment_service_connection_test.dart
new file mode 100644
index 0000000..0ef8a86
--- /dev/null
+++ b/public/dart/fuchsia_services/test/environment_service_connection_test.dart
@@ -0,0 +1,29 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// ignore_for_file: implementation_imports
+import 'package:fidl/fidl.dart';
+import 'package:fuchsia_services/services.dart';
+import 'package:test/test.dart';
+
+void main() {
+ group('connectToEnvironmentService', () {
+ test('throws if serviceProxy is null', () {
+ expect(
+ () =>
+ StartupContext.fromStartupInfo().incoming.connectToService(null),
+ throwsArgumentError);
+ });
+ });
+}
+
+class FakeAsyncProxy<T> extends AsyncProxy<T> {
+ String serviceName;
+ String interfaceName;
+ FakeAsyncProxy(this.serviceName, this.interfaceName)
+ : super(AsyncProxyController(
+ $serviceName: serviceName,
+ $interfaceName: interfaceName,
+ ));
+}