[cleanup][fidl] Remove last usages of sync dart fidl bindings
Change-Id: Ie0da08ad932af991d3750e4679cc888e95992064
diff --git a/BUILD.gn b/BUILD.gn
index c2f5409..9e26875 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -8,7 +8,6 @@
deps = [
"examples/test/flutter_widget_test:flutter_widget_test",
"public/dart/sledge:dart_sledge_tests",
- "public/lib/app/dart:dart_app_tests",
"shell:tests",
]
}
diff --git a/README.md b/README.md
index a561f9d..5d7f48d 100644
--- a/README.md
+++ b/README.md
@@ -47,3 +47,7 @@
* topaz/public/lib/schemas: e5810dfa1
* topaz/public/lib/entity: e5810dfa1
* topaz/public/lib/component: e5810dfa1
+* public/lib/app/dart: 12404bc
+* examples/fidl/echo_client_dart: 12404bc
+* examples/fidl/echo_server_dart: 12404bc
+* examples/fidl/fidl_bindings_performance: 12404bc
diff --git a/bin/dart_fidl_json/json.fidlmerge b/bin/dart_fidl_json/json.fidlmerge
index 29cacc3..318b587 100644
--- a/bin/dart_fidl_json/json.fidlmerge
+++ b/bin/dart_fidl_json/json.fidlmerge
@@ -19,7 +19,7 @@
{{- define "FidlInclude" }}
import 'dart:typed_data';
-import 'package:fidl{{- range .Name.Parts }}_{{ . }}{{ end }}/fidl.dart';
+import 'package:fidl{{- range .Name.Parts }}_{{ . }}{{ end }}/fidl_async.dart';
{{ end }}
{{/*
diff --git a/bin/dart_fidl_json/test/test/json_test.dart b/bin/dart_fidl_json/test/test/json_test.dart
index ab35544..b6de337 100644
--- a/bin/dart_fidl_json/test/test/json_test.dart
+++ b/bin/dart_fidl_json/test/test/json_test.dart
@@ -5,7 +5,7 @@
import 'dart:typed_data';
import 'package:fidl_dart_fidl_json_test_fidl_json/json.dart';
-import 'package:fidl_test_dart_fidl_json/fidl.dart';
+import 'package:fidl_test_dart_fidl_json/fidl_async.dart';
import 'package:test/test.dart';
void main() {
@@ -14,9 +14,9 @@
const ExampleEnum sourceEnum = ExampleEnum.val1;
expect(
- sourceEnum,
ExampleEnumConverter.fromJson(
- jsonDecode(jsonEncode(ExampleEnumConverter.toJson(sourceEnum)))));
+ jsonDecode(jsonEncode(ExampleEnumConverter.toJson(sourceEnum)))),
+ sourceEnum);
});
// Ensure struct encode/decode.
diff --git a/bin/fidl_bindings_test/test/test/failure_test.dart b/bin/fidl_bindings_test/test/test/failure_test.dart
index f8360fda..838c195 100644
--- a/bin/fidl_bindings_test/test/test/failure_test.dart
+++ b/bin/fidl_bindings_test/test/test/failure_test.dart
@@ -2,10 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import 'dart:async';
-import 'package:fidl/fidl.dart';
-import 'package:fidl_fidl_examples_bindingstest/fidl.dart' as fidlgen;
import 'package:fidl_fidl_examples_bindingstest/fidl_async.dart';
import 'package:test/test.dart';
@@ -60,20 +57,6 @@
expect(server.proxy.emptyEvent.first, throwsA(anything));
server.proxy.ctrl.close();
});
-
- test('binding closes immediately after sending response', () async {
- var impl = SimpleServerImpl();
- var proxy = impl.newAsyncProxy();
- var pinged = false;
-
- Future<Null> pingFut = proxy.ping().then((_) {
- pinged = true;
- });
- var closedFut = proxy.ctrl.whenClosed.then((_) {
- expect(pinged, equals(true));
- });
- await Future.wait([pingFut, closedFut]);
- });
});
group('unbound', () {
@@ -91,25 +74,3 @@
});
});
}
-
-// This implementation uses the callback-based bindings, since the future-based
-// bindings don't cleanly allow SimpleServerImpl.ping() to respond and then
-// close the bound channel.
-class SimpleServerImpl extends fidlgen.SimpleServer {
- SimpleServerProxy newAsyncProxy() {
- var proxy = SimpleServerProxy();
- binding.bind(
- this,
- InterfaceRequest<fidlgen.SimpleServer>(
- proxy.ctrl.request().passChannel()));
- return proxy;
- }
-
- @override
- void ping(void callback()) {
- callback();
- binding.close();
- }
-
- fidlgen.SimpleServerBinding binding = fidlgen.SimpleServerBinding();
-}
diff --git a/bin/ui/benchmarks/image_grid_flutter/BUILD.gn b/bin/ui/benchmarks/image_grid_flutter/BUILD.gn
index 05d4465..ffef0ff 100644
--- a/bin/ui/benchmarks/image_grid_flutter/BUILD.gn
+++ b/bin/ui/benchmarks/image_grid_flutter/BUILD.gn
@@ -24,6 +24,6 @@
deps = [
"//third_party/dart-pkg/git/flutter/packages/flutter",
"//topaz/public/dart/widgets:lib.widgets",
- "//topaz/public/lib/app/dart",
+ "//topaz/public/dart/fuchsia_logger",
]
}
diff --git a/bin/ui/benchmarks/image_grid_flutter/lib/image_grid_model.dart b/bin/ui/benchmarks/image_grid_flutter/lib/image_grid_model.dart
index 909fa80..1f74da7 100644
--- a/bin/ui/benchmarks/image_grid_flutter/lib/image_grid_model.dart
+++ b/bin/ui/benchmarks/image_grid_flutter/lib/image_grid_model.dart
@@ -8,10 +8,11 @@
import 'dart:ui' as ui;
import 'package:flutter/widgets.dart';
-import 'package:lib.app.dart/logging.dart';
import 'package:lib.widgets/model.dart';
+import 'package:lib.widgets/utils.dart';
import 'package:lib.widgets/widgets.dart';
+
const RK4SpringDescription _kSimulationDesc =
RK4SpringDescription(tension: 10.0, friction: 50.0);
const double _kMinScrollOffset = 0.0;
diff --git a/bin/ui/benchmarks/image_grid_flutter/lib/main.dart b/bin/ui/benchmarks/image_grid_flutter/lib/main.dart
index d1b2bdb..1debbdf 100644
--- a/bin/ui/benchmarks/image_grid_flutter/lib/main.dart
+++ b/bin/ui/benchmarks/image_grid_flutter/lib/main.dart
@@ -3,7 +3,7 @@
// found in the LICENSE file.
import 'package:flutter/material.dart';
-import 'package:lib.app.dart/logging.dart';
+import 'package:fuchsia_logger/logger.dart';
import 'package:lib.widgets/model.dart' show ScopedModel, ScopedModelDescendant;
import 'image_grid.dart';
diff --git a/bin/userpicker_base_shell/lib/user_picker_base_shell_model.dart b/bin/userpicker_base_shell/lib/user_picker_base_shell_model.dart
index 3fe0d69..decbdb0 100644
--- a/bin/userpicker_base_shell/lib/user_picker_base_shell_model.dart
+++ b/bin/userpicker_base_shell/lib/user_picker_base_shell_model.dart
@@ -13,10 +13,10 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
-import 'package:lib.app.dart/logging.dart';
import 'package:lib.base_shell/base_model.dart';
import 'package:lib.widgets/model.dart';
import 'package:zircon/zircon.dart';
+import 'package:fuchsia_logger/logger.dart';
export 'package:lib.widgets/model.dart'
show ScopedModel, ScopedModelDescendant, ModelFinder;
diff --git a/examples/fidl/BUILD.gn b/examples/fidl/BUILD.gn
index 07fb3cb..46e7ecf 100644
--- a/examples/fidl/BUILD.gn
+++ b/examples/fidl/BUILD.gn
@@ -16,7 +16,6 @@
"//garnet/examples/fidl/services:echo",
"//sdk/fidl/fuchsia.sys",
"//topaz/public/dart/fidl",
- "//topaz/public/lib/app/dart",
]
},
{
@@ -28,7 +27,6 @@
deps = [
"//garnet/examples/fidl/services:echo",
"//topaz/public/dart/fidl",
- "//topaz/public/lib/app/dart",
]
},
]
diff --git a/examples/fidl/echo_client_dart/analysis_options.yaml b/examples/fidl/echo_client_dart/analysis_options.yaml
deleted file mode 100644
index e36fcd5..0000000
--- a/examples/fidl/echo_client_dart/analysis_options.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2019 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.
-
-include: ../../../tools/analysis_options.yaml
diff --git a/examples/fidl/echo_client_dart/lib/main.dart b/examples/fidl/echo_client_dart/lib/main.dart
deleted file mode 100644
index 996d979..0000000
--- a/examples/fidl/echo_client_dart/lib/main.dart
+++ /dev/null
@@ -1,31 +0,0 @@
-// 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_examples_echo/fidl.dart';
-import 'package:lib.app.dart/app.dart';
-import 'package:fidl_fuchsia_sys/fidl.dart';
-
-StartupContext _context;
-EchoProxy _echo;
-
-void main(List<String> args) {
- String server = 'fuchsia-pkg://fuchsia.com/echo_dart#meta/echo_server_dart.cmx';
- if (args.length >= 2 && args[0] == '--server') {
- server = args[1];
- }
-
- _context = StartupContext.fromStartupInfo();
-
- final Services services = Services();
- final LaunchInfo launchInfo =
- LaunchInfo(url: server, directoryRequest: services.request());
- _context.launcher.createComponent(launchInfo, null);
-
- _echo = EchoProxy();
- _echo.ctrl.bind(services.connectToServiceByName<Echo>(Echo.$serviceName));
-
- _echo.echoString('hello', (String response) {
- print('***** Response: $response');
- });
-}
diff --git a/examples/fidl/echo_client_dart/meta/echo_client_dart.cmx b/examples/fidl/echo_client_dart/meta/echo_client_dart.cmx
deleted file mode 100644
index 698a385..0000000
--- a/examples/fidl/echo_client_dart/meta/echo_client_dart.cmx
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "program": {
- "data": "data/echo_client_dart"
- },
- "sandbox": {
- "services": [ "fuchsia.sys.Environment" ]
- }
-}
diff --git a/examples/fidl/echo_client_dart/pubspec.yaml b/examples/fidl/echo_client_dart/pubspec.yaml
deleted file mode 100644
index 64e8f21..0000000
--- a/examples/fidl/echo_client_dart/pubspec.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-# Copyright 2019 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.
diff --git a/examples/fidl/echo_server_dart/analysis_options.yaml b/examples/fidl/echo_server_dart/analysis_options.yaml
deleted file mode 100644
index e36fcd5..0000000
--- a/examples/fidl/echo_server_dart/analysis_options.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2019 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.
-
-include: ../../../tools/analysis_options.yaml
diff --git a/examples/fidl/echo_server_dart/lib/main.dart b/examples/fidl/echo_server_dart/lib/main.dart
deleted file mode 100644
index f920fee..0000000
--- a/examples/fidl/echo_server_dart/lib/main.dart
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2016 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 'package:fidl_fidl_examples_echo/fidl.dart';
-import 'package:lib.app.dart/app.dart';
-
-bool quiet = false;
-
-class _EchoImpl extends Echo {
- final EchoBinding _binding = EchoBinding();
-
- void bind(InterfaceRequest<Echo> request) {
- _binding.bind(this, request);
- }
-
- @override
- void echoString(String value, void callback(String response)) {
- if (!quiet) {
- print('EchoString: $value');
- }
- callback(value);
- }
-}
-
-StartupContext _context;
-_EchoImpl _echo;
-
-void main(List<String> args) {
- quiet = args.contains('-q');
- _context = StartupContext.fromStartupInfo();
- _echo = _EchoImpl();
- _context.outgoingServices
- .addServiceForName<Echo>(_echo.bind, Echo.$serviceName);
-}
diff --git a/examples/fidl/echo_server_dart/meta/echo_server_dart.cmx b/examples/fidl/echo_server_dart/meta/echo_server_dart.cmx
deleted file mode 100644
index 363b04a..0000000
--- a/examples/fidl/echo_server_dart/meta/echo_server_dart.cmx
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "program": {
- "data": "data/echo_server_dart"
- },
- "sandbox": {
- "services": [ "fuchsia.sys.Environment" ]
- }
-}
diff --git a/examples/fidl/echo_server_dart/pubspec.yaml b/examples/fidl/echo_server_dart/pubspec.yaml
deleted file mode 100644
index 64e8f21..0000000
--- a/examples/fidl/echo_server_dart/pubspec.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-# Copyright 2019 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.
diff --git a/examples/fidl/fidl_bindings_performance/BUILD.gn b/examples/fidl/fidl_bindings_performance/BUILD.gn
deleted file mode 100644
index 1c232c5..0000000
--- a/examples/fidl/fidl_bindings_performance/BUILD.gn
+++ /dev/null
@@ -1,26 +0,0 @@
-# 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("//topaz/runtime/dart_runner/dart_app.gni")
-
-dart_app("fidl_bindings_performance") {
-
- main_dart = "lib/main.dart"
-
- meta = [
- {
- path = rebase_path("meta/fidl_bindings_performance.cmx")
- dest = "fidl_bindings_performance.cmx"
- },
- ]
-
- sources = []
- deps = [
- "//garnet/examples/fidl/services:echo",
- "//sdk/fidl/fuchsia.sys",
- "//third_party/dart-pkg/pub/args",
- "//topaz/public/dart/fidl",
- "//topaz/public/lib/app/dart",
- ]
-}
diff --git a/examples/fidl/fidl_bindings_performance/analysis_options.yaml b/examples/fidl/fidl_bindings_performance/analysis_options.yaml
deleted file mode 100644
index f0cea8a..0000000
--- a/examples/fidl/fidl_bindings_performance/analysis_options.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-# 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.
-
-include: ../../../tools/analysis_options.yaml
diff --git a/examples/fidl/fidl_bindings_performance/lib/main.dart b/examples/fidl/fidl_bindings_performance/lib/main.dart
deleted file mode 100644
index ac6bbb9..0000000
--- a/examples/fidl/fidl_bindings_performance/lib/main.dart
+++ /dev/null
@@ -1,168 +0,0 @@
-// 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 'dart:async';
-import 'package:args/args.dart';
-import 'package:fidl_fidl_examples_echo/fidl.dart';
-import 'package:lib.app.dart/app.dart';
-import 'package:fidl_fuchsia_sys/fidl.dart';
-import 'package:fuchsia/fuchsia.dart';
-
-typedef PerfTest = Future<int> Function(String server, int number);
-
-StartupContext _context;
-
-const List<String> kDefaultServers = [
- 'fuchsia-pkg://fuchsia.com/echo_server_cpp#meta/echo_server_cpp.cmx',
- 'fuchsia-pkg://fuchsia.com/echo_server_rust#meta/echo_server_rust.cmx',
- 'fuchsia-pkg://fuchsia.com/echo_server_go#meta/echo_server_go.cmx',
- 'fuchsia-pkg://fuchsia.com/echo_dart#meta/echo_server_dart.cmx',
- 'fuchsia-pkg://fuchsia.com/echo_server_async_dart#meta/echo_server_async_dart.cmx'
-];
-const List<int> kDefaultCalls = [1000, 10000];
-const String kMessage = 'hello';
-
-Future<int> runTest(String server, void ready(Echo echo, void complete())) {
- final EchoProxy echo = EchoProxy();
- final ComponentControllerProxy controller = ComponentControllerProxy();
- final Services services = Services();
- final LaunchInfo launchInfo = LaunchInfo(
- url: server,
- arguments: <String>['-q'],
- directoryRequest: services.request());
- _context.launcher.createComponent(launchInfo, controller.ctrl.request());
- echo.ctrl.bind(services.connectToServiceByName<Echo>(Echo.$serviceName));
-
- final Completer<int> completer = Completer<int>();
-
- // Notice if the echo server or its controller goes away.
- echo.ctrl.onConnectionError = () {
- final message = '$server unexpectedly closed the connection';
- print(message);
- completer.completeError(message);
- };
- controller.ctrl.onConnectionError = () { // ignore: cascade_invocations
- final message = '$server controller connection unexpectedly closed';
- print(message);
- completer.completeError(message);
- };
-
- // Wait until the echo server is up and replying to messages.
- echo.echoString(kMessage, (String response) {
- final Stopwatch stopwatch = Stopwatch()..start();
- void done() {
- stopwatch.stop();
- void complete() {
- if (!completer.isCompleted) {
- completer.complete(stopwatch.elapsedMicroseconds);
- }
- }
-
- // Stop the echo server.
- echo.ctrl.onConnectionError = null;
- echo.ctrl.close();
- controller
- ..ctrl.onConnectionError = complete
- ..ctrl.onClose = complete
- ..kill()
- ..onTerminated = (unusedReturnCode, unusedTerminationReason) {
- // Now we're done...
- complete();
- controller.ctrl.close();
- };
- }
-
- try {
- ready(echo, done);
- // ignore: avoid_catches_without_on_clauses
- } catch (ex, stack) {
- print('Exception testing $server: $ex');
- print(stack);
- completer.completeError(ex);
- }
- });
-
- return completer.future;
-}
-
-Future<int> testSerialPerf(String server, int number) async {
- return runTest(server, (Echo echo, void complete()) {
- int remaining = number;
- void callServer() {
- echo.echoString(kMessage, (String _) {
- remaining--;
- if (remaining == 0) {
- complete();
- } else {
- callServer();
- }
- });
- }
-
- callServer();
- });
-}
-
-Future<int> testParallelPerf(String server, int number) async {
- return runTest(server, (Echo echo, void complete()) {
- int remaining = number;
- for (int i = 0; i < number; i++) {
- echo.echoString(kMessage, (String _) {
- remaining--;
- if (remaining == 0) {
- complete();
- }
- });
- }
- });
-}
-
-void main(List<String> argv) async {
- final parser = ArgParser()
- ..addMultiOption('server', abbr: 's', defaultsTo: kDefaultServers)
- ..addMultiOption('num-calls',
- abbr: 'n', defaultsTo: kDefaultCalls.map((i) => i.toString()))
- ..addFlag('parallel', abbr: 'p');
- final ArgResults args = parser.parse(argv);
- final List<String> servers = args['server'];
- final List<int> numCalls = [];
- for (final String str in args['num-calls']) {
- numCalls.add(int.parse(str));
- }
- final PerfTest perfTest =
- args['parallel'] ? testParallelPerf : testSerialPerf;
-
- _context = StartupContext.fromStartupInfo();
-
- // Map of server to map of count to total microseconds.
- final Map<String, Map<int, int>> results = {};
-
- try {
- for (final int count in numCalls) {
- for (final String server in servers) {
- if (!results.containsKey(server)) {
- results[server] = {};
- }
- print('Making $count calls to $server...');
- final microseconds = await perfTest(server, count);
- results[server][count] = microseconds;
- }
- }
- // ignore: avoid_catches_without_on_clauses
- } catch (ex, stack) {
- print('Exception running tests: $ex');
- print(stack);
- }
-
- print('server,${numCalls.join(',')}');
- for (final String server in results.keys) {
- StringBuffer line = StringBuffer(server);
- for (final int count in numCalls) {
- final int microseconds = results[server][count] ?? 0;
- line.write(',${(microseconds / count)}');
- }
- print(line);
- }
- exit(0);
-}
diff --git a/examples/fidl/fidl_bindings_performance/meta/fidl_bindings_performance.cmx b/examples/fidl/fidl_bindings_performance/meta/fidl_bindings_performance.cmx
deleted file mode 100644
index 948ae42..0000000
--- a/examples/fidl/fidl_bindings_performance/meta/fidl_bindings_performance.cmx
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "program": {
- "data": "data/fidl_bindings_performance"
- },
- "sandbox": {
- "services": [
- "fuchsia.cobalt.LoggerFactory",
- "fuchsia.fonts.Provider",
- "fuchsia.logger.LogSink",
- "fuchsia.modular.Clipboard",
- "fuchsia.modular.ContextWriter",
- "fuchsia.modular.ModuleContext",
- "fuchsia.netstack.Netstack",
- "fuchsia.sys.Environment",
- "fuchsia.ui.input.ImeService",
- "fuchsia.ui.policy.Presenter",
- "fuchsia.ui.scenic.Scenic",
- "fuchsia.wlan.service.Wlan"
- ]
- }
-}
diff --git a/examples/fidl/fidl_bindings_performance/pubspec.yaml b/examples/fidl/fidl_bindings_performance/pubspec.yaml
deleted file mode 100644
index de784fc..0000000
--- a/examples/fidl/fidl_bindings_performance/pubspec.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-# 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.
diff --git a/lib/story_shell/examples/mondrian_test/BUILD.gn b/lib/story_shell/examples/mondrian_test/BUILD.gn
index b8c7881..a78c4d6 100644
--- a/lib/story_shell/examples/mondrian_test/BUILD.gn
+++ b/lib/story_shell/examples/mondrian_test/BUILD.gn
@@ -19,6 +19,6 @@
sources = []
deps = [
"//third_party/dart-pkg/git/flutter/packages/flutter",
- "//topaz/public/lib/app/dart",
+ "//topaz/public/dart/fuchsia_logger",
]
}
diff --git a/lib/story_shell/examples/mondrian_test/lib/main.dart b/lib/story_shell/examples/mondrian_test/lib/main.dart
index f42480d..0a6e3a3 100644
--- a/lib/story_shell/examples/mondrian_test/lib/main.dart
+++ b/lib/story_shell/examples/mondrian_test/lib/main.dart
@@ -5,7 +5,7 @@
import 'dart:math' as math;
import 'package:flutter/material.dart';
-import 'package:lib.app.dart/logging.dart';
+import 'package:fuchsia_logger/logger.dart';
void main() {
setupLogger(name: 'mondrianTest');
diff --git a/packages/examples/BUILD.gn b/packages/examples/BUILD.gn
index f222ee9..9b563dc 100644
--- a/packages/examples/BUILD.gn
+++ b/packages/examples/BUILD.gn
@@ -48,9 +48,7 @@
public_deps = [
"//topaz/examples/fidl/compiler",
"//topaz/examples/fidl/echo_client_async_dart",
- "//topaz/examples/fidl:echo_dart",
"//topaz/examples/fidl/echo_server_async_dart",
- "//topaz/examples/fidl/fidl_bindings_performance",
]
}
diff --git a/packages/tests/BUILD.gn b/packages/tests/BUILD.gn
index bf0d49a..b3c7fed 100644
--- a/packages/tests/BUILD.gn
+++ b/packages/tests/BUILD.gn
@@ -30,7 +30,6 @@
"//topaz/public/dart/sledge:dart_sledge_tests($host_toolchain)",
"//topaz/public/dart/story_shell_labs:layout_unittests($host_toolchain)",
"//topaz/public/dart/widgets:dart_widget_tests($host_toolchain)",
- "//topaz/public/lib/app/dart:dart_app_tests($host_toolchain)",
"//topaz/public/lib/display/flutter:display_test($host_toolchain)",
"//topaz/shell/mondrian_story_shell:mondrian_story_shell_tests($host_toolchain)",
]
diff --git a/public/dart/fuchsia_inspect/test/integration/BUILD.gn b/public/dart/fuchsia_inspect/test/integration/BUILD.gn
index 57a90e9..eda71a2 100644
--- a/public/dart/fuchsia_inspect/test/integration/BUILD.gn
+++ b/public/dart/fuchsia_inspect/test/integration/BUILD.gn
@@ -53,7 +53,6 @@
"//topaz/public/dart/fidl",
"//topaz/public/dart/fuchsia_inspect",
"//topaz/public/dart/fuchsia_services",
- "//topaz/public/lib/app/dart",
]
},
]
diff --git a/public/dart/widgets/BUILD.gn b/public/dart/widgets/BUILD.gn
index f976d0e..4489117 100644
--- a/public/dart/widgets/BUILD.gn
+++ b/public/dart/widgets/BUILD.gn
@@ -50,7 +50,6 @@
"//topaz/public/dart/fidl",
"//topaz/public/dart/fuchsia_logger",
"//topaz/public/dart/fuchsia_scenic_flutter",
- "//topaz/public/lib/app/dart",
"//zircon/public/fidl/fuchsia-cobalt",
]
}
diff --git a/public/dart/widgets/lib/src/application/application_widget.dart b/public/dart/widgets/lib/src/application/application_widget.dart
index b6e6319..3e9d22b 100644
--- a/public/dart/widgets/lib/src/application/application_widget.dart
+++ b/public/dart/widgets/lib/src/application/application_widget.dart
@@ -10,7 +10,7 @@
import 'package:fuchsia_scenic_flutter/child_view.dart' show ChildView;
import 'package:fuchsia_scenic_flutter/child_view_connection.dart'
show ChildViewConnection;
-import 'package:lib.app.dart/app_async.dart';
+import 'package:fuchsia_services/services.dart';
import 'package:meta/meta.dart';
import 'package:zircon/zircon.dart';
@@ -88,9 +88,11 @@
void _launchApp() {
_applicationController = ComponentControllerProxy();
- Services incomingServices = Services();
+ final incomingServices = Incoming();
widget.launcher.createComponent(
- LaunchInfo(url: widget.url, directoryRequest: incomingServices.request()),
+ LaunchInfo(
+ url: widget.url,
+ directoryRequest: incomingServices.request().passChannel()),
_applicationController.ctrl.request(),
);
@@ -105,10 +107,10 @@
/// Creates a [ViewProviderProxy] from a [Services], closing it in the
/// process.
- ViewProviderProxy _consumeServices(Services services) {
+ ViewProviderProxy _consumeServices(Incoming services) {
ViewProviderProxy viewProvider = ViewProviderProxy();
services
- ..connectToService(viewProvider.ctrl)
+ ..connectToService(viewProvider)
..close();
return viewProvider;
}
diff --git a/public/lib/app/dart/BUILD.gn b/public/lib/app/dart/BUILD.gn
deleted file mode 100644
index 4f1cfcf..0000000
--- a/public/lib/app/dart/BUILD.gn
+++ /dev/null
@@ -1,88 +0,0 @@
-# Copyright 2016 The Chromium 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("//build/dart/dart_library.gni")
-import("//topaz/runtime/dart/flutter_test.gni")
-
-dart_library("dart") {
- package_name = "lib.app.dart"
-
- sdk_category = "partner"
-
- source_dir = "."
- # Unclear non-standard directory structure
- sources_required = false
-
- sources = [
- "app.dart",
- "logging.dart",
- "src/frame_rate_tracer.dart",
- "src/fuchsia_log_record.dart",
- "src/fuchsia_logger.dart",
- "src/logging.dart",
- "src/outgoing.dart",
- ]
-
- deps = [
- "//sdk/fidl/fuchsia.sys",
- "//third_party/dart-pkg/pub/logging",
- "//third_party/dart-pkg/pub/stack_trace",
- "//topaz/public/dart/fidl",
- "//topaz/public/dart/fuchsia",
- "//topaz/public/dart/fuchsia_vfs",
- "//topaz/public/dart/zircon",
- "//zircon/public/fidl/fuchsia-cobalt",
- "//zircon/public/fidl/fuchsia-io",
- "//zircon/public/fidl/fuchsia-logger",
- ]
-}
-
-dart_library("testing") {
- package_name = "lib.app.dart.testing"
-
- sdk_category = "partner"
- # Unclear non-standard directory structure
- sources_required = false
-
- source_dir = "testing"
-
- sources = [
- "app_test.dart",
- ]
-
- deps = [
- "//third_party/dart-pkg/pub/mockito",
- "//third_party/dart-pkg/pub/test",
- "//topaz/public/dart/fidl",
- "//topaz/public/lib/app/dart",
- ]
-}
-
-flutter_test("dart_app_tests") {
- sources = [
- "fuchsia_log_record_test.dart",
- "legacy_code.dart",
- "legacy_logger_test.dart",
- "log_writer_test.dart",
- "socket_test.dart",
- "socket_validate.dart",
- "socket_with_exception_test.dart",
- "socket_with_location_test.dart",
- "socket_with_stacktrace_test.dart",
- "socket_with_tags_test.dart",
- "stdout_test.dart",
- "stdout_with_exception.dart",
- "stdout_with_location.dart",
- "test_startup_context_test.dart",
- ]
-
- deps = [
- ":dart",
- "//third_party/dart-pkg/git/flutter/packages/flutter_test",
- "//third_party/dart-pkg/pub/logging",
- "//third_party/dart-pkg/pub/mockito",
- "//third_party/dart-pkg/pub/test",
- "//topaz/public/lib/app/dart",
- ]
-}
diff --git a/public/lib/app/dart/OWNERS b/public/lib/app/dart/OWNERS
deleted file mode 100644
index 371ca9c..0000000
--- a/public/lib/app/dart/OWNERS
+++ /dev/null
@@ -1,4 +0,0 @@
-jasoncampbell@google.com
-larrylandry@google.com
-
-*
diff --git a/public/lib/app/dart/analysis_options.yaml b/public/lib/app/dart/analysis_options.yaml
deleted file mode 100644
index 54917c0..0000000
--- a/public/lib/app/dart/analysis_options.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2017 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.
-
-include: ../../../analysis_options.yaml
diff --git a/public/lib/app/dart/app.dart b/public/lib/app/dart/app.dart
deleted file mode 100644
index 68f4c64..0000000
--- a/public/lib/app/dart/app.dart
+++ /dev/null
@@ -1,172 +0,0 @@
-// Copyright 2016 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: public_member_api_docs
-
-import 'package:fidl/fidl.dart';
-import 'package:fuchsia/fuchsia.dart';
-import 'package:fidl_fuchsia_sys/fidl.dart';
-import 'package:fidl_fuchsia_io/fidl.dart';
-import 'package:zircon/zircon.dart';
-import 'package:fidl_fuchsia_io/fidl_async.dart' as async_io;
-
-import 'src/outgoing.dart';
-
-export 'src/outgoing.dart';
-
-/// Deprecated! Use package:fuchsia_services/services.dart instead
-class StartupContext {
- static StartupContext _context;
-
- /// Holds the stack trace for the when the startup info is retrieved.
- /// It's useful for tracking down why the async StartupInfo is missing
- /// during the port.
- static StackTrace initialTrace;
-
- StartupContext();
-
- final EnvironmentProxy environment = EnvironmentProxy();
- final LauncherProxy launcher = LauncherProxy();
- final ServiceProviderProxy environmentServices = ServiceProviderProxy();
- final Outgoing outgoingServices = Outgoing();
-
- factory StartupContext.fromStartupInfo() {
- if (_context != null) {
- return _context;
- }
- initialTrace = StackTrace.current;
-
- final StartupContext context = StartupContext();
-
- final Handle environmentHandle = MxStartupInfo.takeEnvironment();
- if (environmentHandle != null) {
- context.environment
- ..ctrl.bind(
- InterfaceHandle<Environment>(Channel(environmentHandle)))
- ..getLauncher(context.launcher.ctrl.request())
- ..getServices(context.environmentServices.ctrl.request());
- }
-
- final Handle outgoingServicesHandle = MxStartupInfo.takeOutgoingServices();
- if (outgoingServicesHandle != null) {
- context.outgoingServices.serve(
- InterfaceRequest<async_io.Node>(Channel(outgoingServicesHandle)));
- }
-
- _context = context;
-
- return context;
- }
-
- /// Provide an alternative startup context that will then be provided on
- /// through [StartupContext.fromStartupInfo].
- ///
- /// This is primarily used to provide alternative environment services for
- /// testing purposes.
- static void provideStartupContext(StartupContext context) {
- assert(_context == null, 'StartupContext should never be overwritten.');
- _context = context;
- }
-
- void close() {
- environment.ctrl.close();
- launcher.ctrl.close();
- environmentServices.ctrl.close();
- outgoingServices.close();
- }
-}
-
-/// Deprecated! Use package:fuchsia_services/services.dart instead
-void connectToService<T>(
- ServiceProvider serviceProvider, ProxyController<T> controller) {
- final String serviceName = controller.$serviceName;
- assert(serviceName != null,
- 'controller.\$serviceName must not be null. Check the FIDL file for a missing [Discoverable]');
- serviceProvider.connectToService(
- serviceName, controller.request().passChannel());
-}
-
-/// Deprecated! Use package:fuchsia_services/services.dart instead
-InterfaceHandle<T> connectToServiceByName<T>(
- ServiceProvider serviceProvider, String serviceName) {
- final ChannelPair pair = ChannelPair();
- serviceProvider.connectToService(serviceName, pair.first);
- return InterfaceHandle<T>(pair.second);
-}
-
-typedef ServiceConnector<T> = void Function(InterfaceRequest<T> request);
-typedef DefaultServiceConnector<T> = void Function(
- String serviceName, InterfaceRequest<T> request);
-
-typedef _ServiceConnectorThunk = void Function(Channel channel);
-
-/// Deprecated! Use package:fuchsia_services/services.dart instead
-class ServiceProviderImpl extends ServiceProvider {
- final ServiceProviderBinding _binding = ServiceProviderBinding();
-
- void bind(InterfaceRequest<ServiceProvider> interfaceRequest) {
- _binding.bind(this, interfaceRequest);
- }
-
- void close() {
- _binding.close();
- }
-
- DefaultServiceConnector<dynamic> defaultConnector;
-
- final Map<String, _ServiceConnectorThunk> _connectorThunks =
- <String, _ServiceConnectorThunk>{};
-
- void addServiceForName<T>(ServiceConnector<T> connector, String serviceName) {
- _connectorThunks[serviceName] = (Channel channel) {
- connector(InterfaceRequest<T>(channel));
- };
- }
-
- @override
- void connectToService(String serviceName, Channel channel) {
- final _ServiceConnectorThunk connectorThunk = _connectorThunks[serviceName];
- if (connectorThunk != null) {
- connectorThunk(channel);
- } else if (defaultConnector != null) {
- defaultConnector(serviceName, InterfaceRequest<dynamic>(channel));
- } else {
- channel.close();
- }
- }
-}
-
-/// Deprecated! Use package:fuchsia_services/services.dart instead
-class Services {
- DirectoryProxy _proxy;
- static const int _openFlags =
- openRightReadable | openRightWritable; // connect flags for service
- static const int _openMode = 0x1ED; // 0755
-
- Services();
-
- Channel request() {
- _proxy = DirectoryProxy();
- return _proxy.ctrl.request().passChannel();
- }
-
- void connectToService<T>(ProxyController<T> controller) {
- final String serviceName = controller.$serviceName;
- assert(serviceName != null,
- 'controller.\$serviceName must not be null. Check the FIDL file for a missing [Discoverable]');
- _proxy.open(_openFlags, _openMode, serviceName,
- InterfaceRequest<Node>(controller.request().passChannel()));
- }
-
- InterfaceHandle<T> connectToServiceByName<T>(String serviceName) {
- final ChannelPair pair = ChannelPair();
- _proxy.open(
- _openFlags, _openMode, serviceName, InterfaceRequest<Node>(pair.first));
- return InterfaceHandle<T>(pair.second);
- }
-
- void close() {
- _proxy.close((_) {});
- }
-}
diff --git a/public/lib/app/dart/app_async.dart b/public/lib/app/dart/app_async.dart
deleted file mode 100644
index b48ce38..0000000
--- a/public/lib/app/dart/app_async.dart
+++ /dev/null
@@ -1,181 +0,0 @@
-// 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
-
-/// A version of app.dart built on the new async bindings.
-
-import 'dart:async';
-import 'package:fidl/fidl.dart';
-import 'package:fuchsia/fuchsia.dart';
-import 'package:fidl_fuchsia_sys/fidl_async.dart';
-import 'package:zircon/zircon.dart';
-import 'package:fidl_fuchsia_io/fidl_async.dart';
-
-import 'app.dart' as sync_app;
-import 'src/outgoing.dart';
-
-export 'src/outgoing.dart';
-
-/// Deprecated! Use package:fuchsia_services/services.dart instead
-class StartupContext {
- static StartupContext _context;
-
- StartupContext();
-
- final EnvironmentProxy environment = EnvironmentProxy();
- final LauncherProxy launcher = LauncherProxy();
- final ServiceProviderProxy environmentServices = ServiceProviderProxy();
- final Outgoing outgoingServices = Outgoing();
-
- factory StartupContext.fromStartupInfo() {
- if (_context != null) {
- return _context;
- }
-
- if (sync_app.StartupContext.initialTrace != null) {
- print(
- "WARNING: app.dart's StartupContext was created at:\n${sync_app.StartupContext.initialTrace}");
- }
-
- final StartupContext context = StartupContext();
-
- final Handle environmentHandle = MxStartupInfo.takeEnvironment();
- if (environmentHandle != null) {
- context.environment
- ..ctrl.bind(
- InterfaceHandle<Environment>(Channel(environmentHandle)))
- ..getLauncher(context.launcher.ctrl.request())
- ..getServices(context.environmentServices.ctrl.request());
- }
-
- final Handle outgoingServicesHandle = MxStartupInfo.takeOutgoingServices();
- if (outgoingServicesHandle != null) {
- context.outgoingServices
- .serve(InterfaceRequest<Node>(Channel(outgoingServicesHandle)));
- }
-
- _context = context;
-
- return context;
- }
-
- /// Provide an alternative startup context that will then be provided on
- /// through [StartupContext.fromStartupInfo].
- ///
- /// This is primarily used to provide alternative environment services for
- /// testing purposes.
- static void provideStartupContext(StartupContext context) {
- assert(_context != null, 'StartupContext should never be overwritten.');
- _context = context;
- }
-
- void close() {
- environment.ctrl.close();
- launcher.ctrl.close();
- environmentServices.ctrl.close();
- outgoingServices.close();
- }
-}
-
-/// Deprecated! Use package:fuchsia_services/services.dart instead
-Future<void> connectToService<T>(
- ServiceProvider serviceProvider, AsyncProxyController<T> controller) async {
- final String serviceName = controller.$serviceName;
- if (serviceName == null) {
- throw Exception(
- "${controller.$interfaceName}'s controller.\$serviceName"
- ' must not be null. Check the FIDL file for a missing [Discoverable]');
- }
- await serviceProvider.connectToService(
- serviceName, controller.request().passChannel());
-}
-
-/// Deprecated! Use package:fuchsia_services/services.dart instead
-InterfaceHandle<T> connectToServiceByName<T>(
- ServiceProvider serviceProvider, String serviceName) {
- final ChannelPair pair = ChannelPair();
- serviceProvider.connectToService(serviceName, pair.first);
- return InterfaceHandle<T>(pair.second);
-}
-
-typedef ServiceConnector<T> = void Function(InterfaceRequest<T> request);
-typedef DefaultServiceConnector<T> = void Function(
- String serviceName, InterfaceRequest<T> request);
-
-typedef _ServiceConnectorThunk = void Function(Channel channel);
-
-/// Deprecated! Use package:fuchsia_services/services.dart instead
-class ServiceProviderImpl extends ServiceProvider {
- final ServiceProviderBinding _binding = ServiceProviderBinding();
-
- void bind(InterfaceRequest<ServiceProvider> interfaceRequest) {
- _binding.bind(this, interfaceRequest);
- }
-
- void close() {
- _binding.close();
- }
-
- DefaultServiceConnector<dynamic> defaultConnector;
-
- final Map<String, _ServiceConnectorThunk> _connectorThunks =
- <String, _ServiceConnectorThunk>{};
-
- void addServiceForName<T>(ServiceConnector<T> connector, String serviceName) {
- _connectorThunks[serviceName] = (Channel channel) {
- connector(InterfaceRequest<T>(channel));
- };
- }
-
- @override
- Future<Null> connectToService(String serviceName, Channel channel) {
- final _ServiceConnectorThunk connectorThunk = _connectorThunks[serviceName];
- if (connectorThunk != null) {
- connectorThunk(channel);
- } else if (defaultConnector != null) {
- defaultConnector(serviceName, InterfaceRequest<dynamic>(channel));
- } else {
- channel.close();
- }
- return null;
- }
-}
-
-/// Deprecated! Use package:fuchsia_services/services.dart instead
-class Services {
- DirectoryProxy _proxy;
- static const int _openFlags =
- openRightReadable | openRightWritable; // connect flags for service
- static const int _openMode = 0x1ED; // 0755
-
- Services();
-
- Channel request() {
- _proxy = DirectoryProxy();
- return _proxy.ctrl.request().passChannel();
- }
-
- Future<void> connectToService<T>(AsyncProxyController<T> controller) async {
- final String serviceName = controller.$serviceName;
- if (serviceName == null) {
- throw Exception(
- "${controller.$interfaceName}'s controller.\$serviceName"
- ' must not be null. Check the FIDL file for a missing [Discoverable]');
- }
- await _proxy.open(_openFlags, _openMode, serviceName,
- InterfaceRequest<Node>(controller.request().passChannel()));
- }
-
- Future<InterfaceHandle<T>> connectToServiceByName<T>(
- String serviceName) async {
- final ChannelPair pair = ChannelPair();
-
- await _proxy.open(
- _openFlags, _openMode, serviceName, InterfaceRequest<Node>(pair.first));
- return InterfaceHandle<T>(pair.second);
- }
-
- Future<void> close() async {
- await _proxy.close();
- }
-}
diff --git a/public/lib/app/dart/logging.dart b/public/lib/app/dart/logging.dart
deleted file mode 100644
index b5bdde1..0000000
--- a/public/lib/app/dart/logging.dart
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright 2018 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file
-
-// NOTE: Some of the non-fuchsia flutter projects import this file, so this file
-// should only contain pure dart/flutter files. Including any fuchsia-specific,
-// FIDL related files here will break some of the host-side flutter tests we
-// have. (See: https://fuchsia.atlassian.net/browse/SO-435)
-
-export 'package:logging/logging.dart' show Level;
-
-export 'src/frame_rate_tracer.dart';
-export 'src/logging.dart';
diff --git a/public/lib/app/dart/pubspec.yaml b/public/lib/app/dart/pubspec.yaml
deleted file mode 100644
index 3a809f4..0000000
--- a/public/lib/app/dart/pubspec.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-# Copyright 2017 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.
diff --git a/public/lib/app/dart/src/frame_rate_tracer.dart b/public/lib/app/dart/src/frame_rate_tracer.dart
deleted file mode 100644
index 3217c9f..0000000
--- a/public/lib/app/dart/src/frame_rate_tracer.dart
+++ /dev/null
@@ -1,73 +0,0 @@
-// 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_fuchsia_cobalt/fidl.dart';
-import 'package:meta/meta.dart';
-
-import 'logging.dart';
-
-/// Traces the frame rate of an animation.
-@Deprecated('Use package:lib.widgets/utils.dart instead')
-class FrameRateTracer {
- /// Name of the animation for tracing purposes.
- final String name;
-
- /// Optional cobalt logger. If not null the frame rate will be logged as
- /// an observation to cobalt.
- final Logger cobaltLogger;
-
- DateTime _animationStart = DateTime.now();
- int _frames = 0;
- String _currentTargetName;
- int _currentCobaltMetricId;
-
- /// Constructor.
- FrameRateTracer({@required this.name, this.cobaltLogger});
-
- /// Starts tracking an animation.
- void start({String targetName, int cobaltMetricId}) {
- _currentTargetName = targetName;
- _currentCobaltMetricId = cobaltMetricId;
- _animationStart = DateTime.now();
- _frames = 0;
- }
-
- /// Must be called per tick of the animation.
- void tick() {
- _frames++;
- }
-
- /// Must be called when the animation is done. This emits the trace.
- void done() {
- if (_frames == 0) {
- return;
- }
- int microSeconds =
- DateTime.now().difference(_animationStart).inMicroseconds;
- double frameRate = _frames.toDouble() * 1000000.0 / microSeconds.toDouble();
- String prefix = _currentTargetName?.isEmpty ?? true
- ? '$name'
- : '$name to $_currentTargetName';
- trace(
- '$prefix: ${frameRate.toStringAsPrecision(3)} fps '
- '($_frames/${microSeconds / 1000000.0}s)',
- );
- if (cobaltLogger != null && _currentCobaltMetricId != null) {
- cobaltLogger.logFrameRate(
- _currentCobaltMetricId,
- 0,
- '',
- frameRate,
- (Status status) {
- if (status != Status.ok) {
- log.warning(
- 'Failed to observe frame rate metric '
- '$_currentCobaltMetricId: $status. ',
- );
- }
- },
- );
- }
- }
-}
diff --git a/public/lib/app/dart/src/fuchsia_log_record.dart b/public/lib/app/dart/src/fuchsia_log_record.dart
deleted file mode 100644
index f53b787..0000000
--- a/public/lib/app/dart/src/fuchsia_log_record.dart
+++ /dev/null
@@ -1,42 +0,0 @@
-// 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:logging/logging.dart' show Level;
-
-/// A log entry representation used to propagate information from
-/// FuchsiaLogger to individual handlers.
-class FuchsiaLogRecord {
- /// Time specified in system time. On a system running zircon this is
- /// defined by zx_get_time() as nanoseconds since boot. Otherwise it is
- /// defined by DateTime.now().microsecondsSinceEpoch converted to nanoseconds.
- final int systemTime;
-
- /// One additional tag specified for this log record.
- final String localTag;
-
- /// Level of severity for this log message.
- final Level level;
-
- /// Message to display.
- final String message;
-
- /// Unique sequence number greater than all log records created before it.
- final int sequenceNumber;
-
- static int _nextNumber = 1;
-
- /// Associated error (if any) when recording errors messages.
- final Object error;
-
- /// Associated stackTrace (if any) when recording errors messages.
- final StackTrace stackTrace;
-
- /// Constructor
- FuchsiaLogRecord(this.level, this.message, this.systemTime,
- {this.localTag, this.error, this.stackTrace})
- : sequenceNumber = _nextNumber++;
-
- @override
- String toString() => '[${level.name}] $message';
-}
diff --git a/public/lib/app/dart/src/fuchsia_logger.dart b/public/lib/app/dart/src/fuchsia_logger.dart
deleted file mode 100644
index b519f9d..0000000
--- a/public/lib/app/dart/src/fuchsia_logger.dart
+++ /dev/null
@@ -1,195 +0,0 @@
-// 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.
-
-// The standard dart logger cannot be extended as the only way to create one is
-// via factory methods. Those factory methods cannot return an instance of this
-// class, which they know nothing about. To remedy that, this code provides a
-// parallel implementation of Logger with extensions required to accommodate
-// the extended functionality logger in fuchsia/zircon.
-//
-// This removes support for the hierarchical logger that is enabled in the dart
-// version.
-
-import 'dart:async';
-import 'dart:io';
-
-import 'package:logging/logging.dart';
-import 'package:zircon/zircon.dart';
-
-import 'fuchsia_log_record.dart';
-
-/// Handler callback to process log entries as they are added to a [Logger].
-typedef LoggerHandler = void Function(FuchsiaLogRecord logRecord);
-
-const int _zxClockMonotonic = 0;
-
-/// Use a [FuchsiaLogger] to log debug messages. This class adds fuchsia
-/// specific extenstions for logging: time specified in zircon time and local
-/// tags in log messages.
-class FuchsiaLogger {
- /// Constructor
- FuchsiaLogger(this.level) {
- Logger.root.clearListeners();
- Logger.root.onRecord.listen((LogRecord rec) {
- log(rec.level, rec.message, /* local tag */ null, rec.error,
- rec.stackTrace);
- });
- }
-
- /// Logging [Level] used for entries generated on this logger.
- Level level;
-
- /// Controller used to notify when log entries are added to this logger.
- StreamController<FuchsiaLogRecord> _controller;
-
- /// Returns a stream of messages added to this [FuchsiaLogger].
- ///
- /// You can listen for messages using the standard stream APIs, for instance:
- ///
- /// ```dart
- /// logger.onRecord.listen((record) { ... });
- /// ```
- Stream<FuchsiaLogRecord> get onRecord => _getStream();
-
- /// Remove the Listener attached to this [FuchsiaLogger].
- void clearListener() {
- if (_controller != null) {
- _controller.close();
- _controller = null;
- }
- }
-
- /// Log message at level [Level.FINEST].
- // ignore: type_annotate_public_apis, always_specify_types
- void finest(message, [Object error, StackTrace stackTrace]) =>
- log(Level.FINEST, message, null, error, stackTrace);
-
- /// Log message at level [Level.FINER].
- // ignore: type_annotate_public_apis, always_specify_types
- void finer(message, [Object error, StackTrace stackTrace]) =>
- log(Level.FINER, message, null, error, stackTrace);
-
- /// Log message at level [Level.FINE].
- // ignore: type_annotate_public_apis, always_specify_types
- void fine(message, [Object error, StackTrace stackTrace]) =>
- log(Level.FINE, message, null, error, stackTrace);
-
- /// Log message at level [Level.CONFIG].
- // ignore: type_annotate_public_apis, always_specify_types
- void config(message, [Object error, StackTrace stackTrace]) =>
- log(Level.CONFIG, message, null, error, stackTrace);
-
- /// Log message at level [Level.INFO].
- // ignore: type_annotate_public_apis, always_specify_types
- void info(message, [Object error, StackTrace stackTrace]) =>
- log(Level.INFO, message, null, error, stackTrace);
-
- /// Log message at level [Level.WARNING].
- // ignore: type_annotate_public_apis, always_specify_types
- void warning(message, [Object error, StackTrace stackTrace]) =>
- log(Level.WARNING, message, null, error, stackTrace);
-
- /// Log message at level [Level.SEVERE].
- // ignore: type_annotate_public_apis, always_specify_types
- void severe(message, [Object error, StackTrace stackTrace]) =>
- log(Level.SEVERE, message, null, error, stackTrace);
-
- /// Log message at level [Level.SHOUT].
- // ignore: type_annotate_public_apis, always_specify_types
- void shout(message, [Object error, StackTrace stackTrace]) =>
- log(Level.SHOUT, message, null, error, stackTrace);
-
- /// Log message at level [Level.FINEST].
- // ignore: type_annotate_public_apis, always_specify_types
- void finestT(message, {String tag, Object error, StackTrace stackTrace}) =>
- log(Level.FINEST, message, tag, error, stackTrace);
-
- /// Log message at level [Level.FINER].
- // ignore: type_annotate_public_apis, always_specify_types
- void finerT(message, {String tag, Object error, StackTrace stackTrace}) =>
- log(Level.FINER, message, tag, error, stackTrace);
-
- /// Log message at level [Level.FINE].
- // ignore: type_annotate_public_apis, always_specify_types
- void fineT(message, {String tag, Object error, StackTrace stackTrace}) =>
- log(Level.FINE, message, tag, error, stackTrace);
-
- /// Log message at level [Level.CONFIG].
- // ignore: type_annotate_public_apis, always_specify_types
- void configT(message, {String tag, Object error, StackTrace stackTrace}) =>
- log(Level.CONFIG, message, tag, error, stackTrace);
-
- /// Log message at level [Level.INFO].
- // ignore: type_annotate_public_apis, always_specify_types
- void infoT(message, {String tag, Object error, StackTrace stackTrace}) =>
- log(Level.INFO, message, tag, error, stackTrace);
-
- /// Log message at level [Level.WARNING].
- // ignore: type_annotate_public_apis, always_specify_types
- void warningT(message, {String tag, Object error, StackTrace stackTrace}) =>
- log(Level.WARNING, message, tag, error, stackTrace);
-
- /// Log message at level [Level.SEVERE].
- // ignore: type_annotate_public_apis, always_specify_types
- void severeT(message, {String tag, Object error, StackTrace stackTrace}) =>
- log(Level.SEVERE, message, tag, error, stackTrace);
-
- /// Log message at level [Level.SHOUT].
- // ignore: type_annotate_public_apis, always_specify_types
- void shoutT(message, {String tag, Object error, StackTrace stackTrace}) =>
- log(Level.SHOUT, message, tag, error, stackTrace);
-
- /// Whether a message for [value]'s level is loggable in this logger.
- bool isLoggable(Level value) => value >= level;
-
- /// Adds a log record for a [message] at a particular [logLevel] if
- /// `isLoggable(logLevel)` is true.
- ///
- /// Use this method to create log entries for user-defined levels. To record a
- /// message at a predefined level (e.g. [Level.INFO], [Level.WARNING], etc)
- /// you can use their specialized methods instead (e.g. [info], [warning],
- /// etc).
- ///
- /// If [message] is a [Function], it will be lazy evaluated. Additionally, if
- /// [message] or its evaluated value is not a [String], then 'toString()' will
- /// be called on the object and the result will be logged. The log record will
- /// contain a field holding the original object.
- ///
- /// The log record will also contain a field for the zone in which this call
- /// was made. This can be advantageous if a log listener wants to handler
- /// records of different zones differently (e.g. group log records by HTTP
- /// request if each HTTP request handler runs in it's own zone).
- void log(Level logLevel, Object message, String localTag, Object error,
- StackTrace stackTrace) {
- if (!isLoggable(logLevel)) {
- return;
- }
- int systemTime = Platform.isFuchsia
- ? System.clockGet(_zxClockMonotonic)
- : DateTime.now().microsecondsSinceEpoch * 1000;
- String logMsg;
- if (message is Function) {
- logMsg = message();
- } else if (message is String) {
- logMsg = message;
- } else {
- Object object = message;
- logMsg = object.toString();
- }
- _publish(FuchsiaLogRecord(logLevel, logMsg, systemTime,
- localTag: localTag, error: error, stackTrace: stackTrace));
- }
-
- Stream<FuchsiaLogRecord> _getStream() {
- _controller ??=
- StreamController<FuchsiaLogRecord>.broadcast(sync: true);
- return _controller.stream;
- }
-
- void _publish(FuchsiaLogRecord record) {
- if (_controller != null) {
- _controller.add(record);
- }
- }
-}
diff --git a/public/lib/app/dart/src/logging.dart b/public/lib/app/dart/src/logging.dart
deleted file mode 100644
index 5466f59..0000000
--- a/public/lib/app/dart/src/logging.dart
+++ /dev/null
@@ -1,435 +0,0 @@
-// Copyright 2017 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 'dart:async';
-import 'dart:convert';
-import 'dart:developer' show Timeline;
-import 'dart:io';
-import 'dart:isolate';
-import 'dart:math';
-import 'dart:typed_data';
-
-import 'package:fidl_fuchsia_logger/fidl.dart' show LogSinkProxy;
-import 'package:fidl_fuchsia_logger/fidl_async.dart' as logger_async
- show LogSinkProxy;
-import 'package:lib.app.dart/app.dart' show connectToService, StartupContext;
-import 'package:lib.app.dart/app_async.dart' as app_async
- show connectToService, StartupContext;
-import 'package:logging/logging.dart' show Level;
-import 'package:stack_trace/stack_trace.dart';
-import 'package:zircon/zircon.dart' as zircon;
-
-import 'fuchsia_log_record.dart';
-import 'fuchsia_logger.dart';
-
-const int _maxGlobalTags = 3;
-const int _maxCombinedTags = 5;
-const int _maxTagLength = 63;
-
-const int _socketBufferLength = 2032;
-
-final Map<Level, int> _enumToFuchsiaLevelMap = <Level, int>{
- Level.FINEST: -4,
- Level.FINER: -3,
- Level.FINE: -2,
- Level.CONFIG: -1,
- Level.INFO: 0,
- Level.WARNING: 1,
- Level.SEVERE: 2,
- Level.SHOUT: 3,
-};
-const int _unexpectedLoggingLevel = 100;
-
-/// Method to write a single log message to a single output medium.
-/// Solutions are provided to write to stdout and a fuchsia Socket.
-typedef LogWriter = void Function(LogWriterMessage message);
-
-/// Interim method that sets up the logger using the new-style bindings for service resolution.
-void setupLoggerAsync({
- String name,
- Level level,
- bool forceShowCodeLocation,
- bool logToStdoutForTest,
- List<String> globalTags,
- zircon.Socket logSocket,
- LogWriter logWriter,
-}) {
- FutureOr<zircon.Socket> sock;
- if (logSocket == null) {
- final socketPair = zircon.SocketPair(zircon.Socket.DATAGRAM);
- final logSinkProxy = logger_async.LogSinkProxy();
-
- final completer = Completer<zircon.Socket>();
-
- app_async
- .connectToService(
- app_async.StartupContext.fromStartupInfo().environmentServices,
- logSinkProxy.ctrl,
- )
- .then((_) => logSinkProxy.connect(socketPair.second))
- .then((_) => completer.complete(socketPair.first))
- .catchError(completer.completeError);
-
- sock = completer.future;
- } else {
- sock = logSocket;
- }
-
- setupLogger(
- name: name,
- level: level,
- forceShowCodeLocation: forceShowCodeLocation,
- logToStdoutForTest: logToStdoutForTest,
- globalTags: globalTags,
- logSocket: sock,
- logWriter: logWriter);
-}
-
-/// Sets up the default logger for the current Dart application.
-///
-/// Every Dart application should call this [setupLogger] function in their main
-/// before calling the actual log statements.
-///
-/// The provided [name] will be used for displaying the scope, and this name
-/// will default to the last segment (i.e. basename) of the application url.
-///
-/// If [level] is provided, only the log messages of which level is greater than
-/// equal to the provided [level] will be shown. If not provided, it defaults to
-/// [Level.INFO].
-///
-/// By default, the caller code location is automatically added in checked mode
-/// and not in production mode, because it is relatively expensive to calculate
-/// the code location. If [forceShowCodeLocation] is set to true, the location
-/// will be added in production mode as well.
-///
-/// If [globalTags] is provided, these tags will be added to each message logged
-/// via this logger.
-///
-/// [logToStdoutForTest] will redirect log output to stdout. This should only be
-/// used when debugging tests that run on device to mix the log output with
-/// the messages from the test infrastructure. It has no effect for on-host
-/// tests and should not be included in production code.
-///
-/// [logWriter] and [logSocket] are intended only for testing purposes.
-void setupLogger({
- String name,
- Level level,
- bool forceShowCodeLocation,
- bool logToStdoutForTest,
- List<String> globalTags,
- FutureOr<zircon.Socket> logSocket,
- LogWriter logWriter,
-}) {
- final String scopeName = name ??
- Platform.script?.pathSegments?.lastWhere((_) => true, orElse: () => null);
- final List<String> approvedTags = _verifyGlobalTags(globalTags);
-
- log = FuchsiaLogger(level ?? Level.ALL);
-
- // This code decides how to log messages. Here's the why:
- // If not running on zircon, there is no sys_logger so must use stdout.
- // The author can force stdout via flag to assist is debugging tests.
- // logSocket and logWriter are used for internal logging tests.
- LogWriter activeLogWriter;
- if (logWriter != null) {
- activeLogWriter = logWriter;
- } else if (logToStdoutForTest != true &&
- (Platform.isFuchsia || logSocket != null)) {
- _logSocket = logSocket ?? _connectToLoggerSocket();
- activeLogWriter = writeLogToSocket;
- } else {
- activeLogWriter = writeLogToStdout;
- }
- _loggerName = scopeName;
-
- bool inCheckedMode = false;
- assert(() {
- inCheckedMode = true;
- return true;
- }());
-
- log.onRecord.listen((FuchsiaLogRecord rec) {
- String codeLocation;
- if (forceShowCodeLocation ?? inCheckedMode) {
- final Trace trace = Trace.current();
- final Frame callerFrame = _findCallerFrame(trace);
- if (callerFrame != null) {
- if (callerFrame.uri.pathSegments.isNotEmpty) {
- final String filename = callerFrame.uri.pathSegments.last;
- final String line =
- callerFrame.line != null ? '(${callerFrame.line})' : '';
- codeLocation = '$filename$line';
- }
- }
- }
-
- activeLogWriter(LogWriterMessage(
- logRecord: rec,
- scopeName: scopeName,
- codeLocation: codeLocation,
- tags: approvedTags,
- ));
- });
-}
-
-/// Create a Socket and connect it to the FIDL logger
-zircon.Socket _connectToLoggerSocket() {
- final socketPair = zircon.SocketPair(zircon.Socket.DATAGRAM);
- final logSinkProxy = LogSinkProxy();
- connectToService(
- StartupContext.fromStartupInfo().environmentServices,
- logSinkProxy.ctrl,
- );
- logSinkProxy.connect(socketPair.second);
- return socketPair.first;
-}
-
-/// All information required to construct a log message to either stdout or
-/// Zircon logging Socket.
-class LogWriterMessage {
- /// Log record created by fuchsiaLogger
- final FuchsiaLogRecord logRecord;
-
- /// Name from the logger, typically the module name
- final String scopeName;
-
- /// If specified, file name and line number where this log message originated
- final String codeLocation;
-
- /// Identifying tags to associate with this logging message
- final List<String> tags;
-
- /// Constructor
- LogWriterMessage(
- {this.logRecord, this.scopeName, this.codeLocation, this.tags});
-}
-
-/// The default logger to be used by dart applications. Each application should
-/// call [setupLogger()] in their main function to properly configure it.
-FuchsiaLogger log = FuchsiaLogger(Level.ALL)
- ..onRecord.listen((FuchsiaLogRecord rec) {
- print('WARNING: The logger is not initialized properly.');
- print('WARNING: Please call setupLogger() from your main function.');
- print('[${rec.level}] ${rec.message}');
- });
-
-/// The name of the logger.
-String _loggerName = 'uninitialized';
-
-/// Socket used to write to the universal Zircon logger.
-FutureOr<zircon.Socket> _logSocket;
-
-// Enforce limits on number of global tags and length of each tag
-List<String> _verifyGlobalTags(List<String> globalTags) {
- List<String> result = <String>[];
- if (globalTags != null) {
- if (globalTags.length > _maxGlobalTags) {
- print('WARNING: Logger initialized with > $_maxGlobalTags tags.');
- print('WARNING: Later tags will be ignored.');
- }
- for (int i = 0; i < _maxGlobalTags && i < globalTags.length; i++) {
- String s = globalTags[i];
- if (s.length > _maxTagLength) {
- print('WARNING: Logger tags limited to $_maxTagLength characters.');
- print('WARNING: Tag "$s" will be truncated.');
- s = s.substring(0, _maxTagLength);
- }
- result.add(s);
- }
- }
- return result;
-}
-
-/// LogWriter that outputs to stdout in a similar format the original fuchsia
-/// logger.
-void writeLogToStdout(LogWriterMessage message) {
- final List<dynamic> scopes = <dynamic>[
- _getLevelString(message.logRecord.level),
- ];
- if (message.scopeName != null) {
- scopes.add(message.scopeName);
- }
- if (message.codeLocation != null) {
- scopes.add(message.codeLocation);
- }
- message.tags.forEach(scopes.add);
- String scopesString = scopes.join(':');
- if (message.logRecord.error != null) {
- print(
- '[$scopesString] ${message.logRecord.message}: ${message.logRecord.error}');
- } else {
- print('[$scopesString] ${message.logRecord.message}');
- }
-
- if (message.logRecord.stackTrace != null) {
- print('${message.logRecord.stackTrace}');
- }
-}
-
-int _convertLogLevel(Level logLevel) =>
- _enumToFuchsiaLevelMap[logLevel] ?? _unexpectedLoggingLevel;
-
-/// Format log message zircon socket connected to Log Viewer
-void writeLogToSocket(LogWriterMessage message) {
- ByteData bytes = ByteData(_socketBufferLength)
- ..setUint64(0, pid, Endian.little)
- ..setUint64(8, Isolate.current.hashCode, Endian.little)
- ..setUint64(16, message.logRecord.systemTime, Endian.little)
- ..setInt32(24, _convertLogLevel(message.logRecord.level), Endian.little)
- ..setUint32(28, 0, Endian.little); // TODO droppedLogs
- int byteOffset = 32;
-
- // Write global tags
- int totalTagCount = 0;
- if (message.scopeName != null) {
- byteOffset = _setTag(bytes, byteOffset, message.scopeName);
- totalTagCount++;
- }
- if (message.codeLocation != null) {
- byteOffset = _setTag(bytes, byteOffset, message.codeLocation);
- totalTagCount++;
- }
- for (String tag in message.tags) {
- if (tag != null && totalTagCount < _maxCombinedTags) {
- byteOffset = _setTag(bytes, byteOffset, tag);
- totalTagCount++;
- }
- }
- // Local tags are currently not supported by dart.
- bytes.setUint8(byteOffset++, 0);
-
- // Write message
- byteOffset = _setString(bytes, byteOffset, message.logRecord.message,
- _socketBufferLength - byteOffset - 1);
- if (message.logRecord.error != null) {
- byteOffset = _setString(
- bytes, byteOffset, ': ', _socketBufferLength - byteOffset - 1);
- byteOffset = _setString(
- bytes,
- byteOffset,
- message.logRecord.error.toString(),
- _socketBufferLength - byteOffset - 1);
- }
- if (message.logRecord.stackTrace != null) {
- byteOffset = _setString(
- bytes, byteOffset, '\n', _socketBufferLength - byteOffset - 1);
- byteOffset = _setString(
- bytes,
- byteOffset,
- message.logRecord.stackTrace.toString(),
- _socketBufferLength - byteOffset - 1);
- }
- bytes.setUint8(byteOffset++, 0);
- assert(byteOffset <= _socketBufferLength);
-
- void writeBytes(zircon.Socket sock) {
- sock.write(ByteData.view(bytes.buffer, 0, byteOffset));
- }
-
- if (_logSocket is Future) {
- // need to wrap in a function to avoid casting errors
- _writeToSocketFuture(_logSocket, writeBytes);
- } else {
- writeBytes(_logSocket);
- }
-}
-
-void _writeToSocketFuture(Future<zircon.Socket> socketFuture,
- void Function(zircon.Socket) writer) =>
- socketFuture.then(writer);
-
-// Write a string to ByteData with a leading length byte. Return the byteOffstet
-// to use for the next value.
-int _setTag(ByteData bytes, int byteOffset, String tag) {
- if (tag == null || tag == 'null') {
- return byteOffset;
- }
- int nextOffset = _setString(bytes, byteOffset + 1, tag, _maxTagLength);
- bytes.setUint8(byteOffset, nextOffset - byteOffset - 1);
- return nextOffset;
-}
-
-// Wrie a non-terminated string to ByteData. Return the byteOffset to use for
-// the terminating byte or the next value.
-int _setString(ByteData bytes, int firstByteOffset, String value, int maxLen) {
- if (value == null || value.isEmpty) {
- return firstByteOffset;
- }
- List<int> charBytes = utf8.encode(value);
- int len = min(charBytes.length, maxLen);
- int byteOffset = firstByteOffset;
- for (int i = 0; i < len; i++) {
- bytes.setUint8(byteOffset++, charBytes[i]);
- }
- // If the string was truncated (and there is space), add an elipsis character.
- if (len < charBytes.length && len >= 3) {
- const int period = 46; // UTF8 value for '.'
- for (int i = 1; i <= 3; i++) {
- bytes.setUint8(byteOffset - i, period);
- }
- }
- return byteOffset;
-}
-
-/// A convenient function for displaying the stack trace of the caller in the
-/// console.
-void showStackTrace() {
- print(Trace.current(1).toString());
-}
-
-/// Emits an instant trace with [name] prefixed with [log]'s name
-void trace(String name) {
- Timeline.instantSync('$_loggerName $name');
-}
-
-/// From the given [Trace], finds the last [Frame] from this package
-/// (lib.app.dart) and then the next [Frame] not in this package. That frame
-/// represents whomever called the log function and is returned.
-/// If no such [Frame] is found, returns `null`.
-///
-/// SEE: https://github.com/dart-lang/logging/issues/32
-Frame _findCallerFrame(Trace trace) {
- bool foundLogging = false;
- Frame matchedFrame;
-
- for (int i = 0; i < trace.frames.length; ++i) {
- final Frame frame = trace.frames[i];
- final bool loggingPackage = frame.package == 'lib.app.dart';
- if (foundLogging && !loggingPackage) {
- matchedFrame = frame;
- }
- foundLogging = loggingPackage;
- }
-
- return matchedFrame;
-}
-
-/// Remaps the level string to the ones used in FTL.
-String _getLevelString(Level level) {
- if (level == null) {
- return null;
- }
-
- if (level == Level.FINE) {
- return 'VLOG(1)';
- }
-
- if (level == Level.FINER) {
- return 'VLOG(2)';
- }
-
- if (level == Level.FINEST) {
- return 'VLOG(3)';
- }
-
- if (level == Level.SEVERE) {
- return 'ERROR';
- }
-
- if (level == Level.SHOUT) {
- return 'FATAL';
- }
-
- return level.toString();
-}
diff --git a/public/lib/app/dart/src/outgoing.dart b/public/lib/app/dart/src/outgoing.dart
deleted file mode 100644
index c643fcb..0000000
--- a/public/lib/app/dart/src/outgoing.dart
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright 2019 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:fuchsia_vfs/vfs.dart' as vfs;
-import 'package:fidl/fidl.dart';
-import 'package:fidl_fuchsia_io/fidl_async.dart';
-
-/// Helper class to publish outgoing services and other directories for debug
-/// and control purposes
-class Outgoing {
- final vfs.PseudoDir _root = vfs.PseudoDir();
- final vfs.PseudoDir _public = vfs.PseudoDir();
- final vfs.PseudoDir _debug = vfs.PseudoDir();
- final vfs.PseudoDir _ctrl = vfs.PseudoDir();
- bool _isClosed = false;
-
- /// This will setup outgoing directory and add required
- /// directories to root of this class.
- ///
- /// This class will throw an Exception if its methods are called
- /// after it is closed. Calling close twice doesn't cause exception.
- Outgoing() {
- _root
- ..addNode('public', _public)
- ..addNode('debug', _debug)
- ..addNode('ctrl', _ctrl);
- }
-
- void _ensureNotClosed() {
- if (_isClosed) {
- throw Exception('Outgoing closed');
- }
- }
-
- /// deprecated method, until we change all reference to use [addPublicService].
- void addServiceForName<T>(vfs.Connector<T> connector, String serviceName) {
- addPublicService(connector, serviceName);
- }
-
- /// Serves root dir to request channel and serve [fuchsia.io.Directory]
- /// over it.
- void serve(InterfaceRequest<Node> request) {
- _ensureNotClosed();
- _root.serve(request);
- }
-
- /// Closes root directory
- void close() {
- if (_isClosed) {
- return;
- }
- _root.close();
- _isClosed = true;
- }
-
- /// return root directory which can be used to host other directories
- /// and extend this class.
- vfs.PseudoDir rootDir() {
- _ensureNotClosed();
- return _root;
- }
-
- /// return debug directory which can be used to publish debug info to /hub
- vfs.PseudoDir debugDir() {
- _ensureNotClosed();
- return _debug;
- }
-
- /// return public directory which usually contains all published services.
- vfs.PseudoDir publicDir() {
- _ensureNotClosed();
- return _public;
- }
-
- /// return ctrl directory which can be used to publish control information
- /// for /hub and system.
- vfs.PseudoDir ctrlDir() {
- _ensureNotClosed();
- return _ctrl;
- }
-
- /// Add and publish a public service.
- /// Will return ZX_OK if successful, else will return error status.
- int addPublicService<T>(vfs.Connector<T> connector, String serviceName) {
- _ensureNotClosed();
- var service = vfs.Service.withConnector(connector);
- int status = _public.addNode(serviceName, service);
- return status;
- }
-}
diff --git a/public/lib/app/dart/test/fuchsia_log_record_test.dart b/public/lib/app/dart/test/fuchsia_log_record_test.dart
deleted file mode 100644
index 854f27b..0000000
--- a/public/lib/app/dart/test/fuchsia_log_record_test.dart
+++ /dev/null
@@ -1,87 +0,0 @@
-// 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 'dart:io';
-
-import 'package:test/test.dart';
-import 'package:zircon/zircon.dart';
-
-import 'package:lib.app.dart/logging.dart';
-import 'package:lib.app.dart/src/fuchsia_log_record.dart';
-
-const int _lookBackTimeGap = 15 * 1000 * 1000 * 1000; // 15 sec in nanoseconds
-
-const int _zxClockMonotonic = 0;
-
-class LoggerStub {
- final List<LogWriterMessage> logMessages = <LogWriterMessage>[];
-
- void writeLogMessage(LogWriterMessage message) {
- logMessages.add(message);
- }
-}
-
-void main() {
- test('simple message', _testSimpleMessage);
- test('message with exception', _testMessageWithException);
-}
-
-void _testSimpleMessage() {
- LoggerStub logger = LoggerStub();
- setupLogger(
- logWriter: logger.writeLogMessage,
- );
- expect(logger.logMessages.isEmpty, true);
-
- log.infoT('hello', tag: 'tag');
- expect(logger.logMessages.length, equals(1));
- FuchsiaLogRecord underTest = logger.logMessages[0].logRecord;
-
- int now = Platform.isFuchsia
- ? System.clockGet(_zxClockMonotonic)
- : DateTime.now().microsecondsSinceEpoch * 1000;
-
- expect(underTest.systemTime, lessThanOrEqualTo(now));
- expect(underTest.systemTime, greaterThanOrEqualTo(now - _lookBackTimeGap));
-
- expect(underTest.localTag, equals('tag'));
- expect(underTest.level, equals(Level.INFO));
- expect(underTest.message, equals('hello'));
- expect(underTest.sequenceNumber, equals(1));
- expect(underTest.error, equals(null));
- expect(underTest.stackTrace, equals(null));
-
- log.info('world');
- expect(logger.logMessages.length, equals(2));
- underTest = logger.logMessages[1].logRecord;
- expect(underTest.sequenceNumber, equals(2));
-}
-
-void _testMessageWithException() {
- LoggerStub logger = LoggerStub();
- setupLogger(
- logWriter: logger.writeLogMessage,
- );
- expect(logger.logMessages.isEmpty, true);
-
- Exception exception = Exception('cause');
- log.infoT('hello',
- tag: 'tag', error: exception, stackTrace: StackTrace.current);
- expect(logger.logMessages.length, equals(1));
- FuchsiaLogRecord underTest = logger.logMessages[0].logRecord;
-
- int now = Platform.isFuchsia
- ? System.clockGet(_zxClockMonotonic)
- : DateTime.now().microsecondsSinceEpoch * 1000;
-
- expect(underTest.systemTime, lessThanOrEqualTo(now));
- expect(underTest.systemTime, greaterThanOrEqualTo(now - _lookBackTimeGap));
-
- expect(underTest.localTag, equals('tag'));
- expect(underTest.level, equals(Level.INFO));
- expect(underTest.message, equals('hello'));
- expect(underTest.error, equals(exception));
- expect(
- underTest.stackTrace.toString(), contains('_testMessageWithException'));
-}
diff --git a/public/lib/app/dart/test/legacy_code.dart b/public/lib/app/dart/test/legacy_code.dart
deleted file mode 100644
index 44cfaac..0000000
--- a/public/lib/app/dart/test/legacy_code.dart
+++ /dev/null
@@ -1,13 +0,0 @@
-// 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:logging/logging.dart';
-
-/// This method makes one log call using the legacy dart logger implementation.
-/// This is used as part of a test to ensure that the new zircon base logger
-/// will also log calls from legacy libraries and pass those to the zircon
-/// logger.
-void makeOneLegacyLogCall() {
- Logger.root.info('hello');
-}
diff --git a/public/lib/app/dart/test/legacy_logger_test.dart b/public/lib/app/dart/test/legacy_logger_test.dart
deleted file mode 100644
index aded451..0000000
--- a/public/lib/app/dart/test/legacy_logger_test.dart
+++ /dev/null
@@ -1,43 +0,0 @@
-// 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 'dart:convert';
-import 'dart:typed_data';
-
-import 'package:lib.app.dart/logging.dart';
-import 'package:mockito/mockito.dart';
-import 'package:test/test.dart';
-import 'package:zircon/zircon.dart';
-
-import 'legacy_code.dart';
-import 'socket_validate.dart';
-
-class MockSocket extends Mock implements Socket {}
-
-void main() {
- test('_testLegacyLogger', _testLegacyLogger);
-}
-
-void _testLegacyLogger() {
- MockSocket mockSocket = MockSocket();
- setupLogger(
- name: 'TEST',
- forceShowCodeLocation: false,
- logSocket: mockSocket,
- );
-
- makeOneLegacyLogCall();
-
- ByteData byteData = verify(mockSocket.write(captureAny)).captured.single;
- List<int> logged = byteData.buffer.asInt8List(0, byteData.lengthInBytes);
- validateFixedBlock(logged, 0);
- expect(logged[32], equals(4));
- expect(utf8.decode(logged.sublist(33, 37)), equals('TEST'));
- expect(utf8.decode(logged.sublist(38, 43)), equals('hello'));
- expect(logged[43], equals(0));
- // Length should be 33 + 5 (TEST) + 6 (foo)
- expect(logged.length, equals(44));
-
- mockSocket.close();
-}
diff --git a/public/lib/app/dart/test/log_writer_test.dart b/public/lib/app/dart/test/log_writer_test.dart
deleted file mode 100644
index 5237c7d..0000000
--- a/public/lib/app/dart/test/log_writer_test.dart
+++ /dev/null
@@ -1,231 +0,0 @@
-// 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 'dart:async';
-
-import 'package:lib.app.dart/logging.dart';
-import 'package:test/test.dart';
-
-List<String> _tagNames = <String>[
- 'TAG1',
- 'TAG2',
- 'TAG3', // Only 3 global tags are allowed
- 'TAG4',
-];
-
-List<String> _tooLongTagName = <String>[
- 'THIS NAME IS TOO LONG, IT ONLY ALLOWED TO BE 63 CHARACTERS AND NOT 70.',
- // 34567890123456789012345678901234567890123456789012345678901234567890
-];
-
-class LoggerStub {
- final List<LogWriterMessage> logMessages = <LogWriterMessage>[];
-
- void writeLogMessage(LogWriterMessage message) {
- logMessages.add(message);
- }
-}
-
-void main() {
- test('simple message', _testSimpleMessage);
- test('constructor options 1', _constructorOptions1);
- test('constructor options 2', _constructorOptions2);
- test('_testTooManyTags', _testTooManyTags);
- test('_tagTooLong', _testTagTooLong);
- test('_testInfoLevels', _testInfoLevels);
- test('_testDefaultLevels', _testDefaultLevels);
-}
-
-void _testSimpleMessage() {
- LoggerStub logger = LoggerStub();
- setupLogger(
- logWriter: logger.writeLogMessage,
- );
- expect(logger.logMessages.isEmpty, true);
-
- log.info('hello');
- expect(logger.logMessages.length, equals(1));
- expect(logger.logMessages[0].scopeName, equals('main.dart'));
- expect(logger.logMessages[0].tags.isEmpty, equals(true));
- expect(logger.logMessages[0].logRecord.message, equals('hello'));
- expect(logger.logMessages[0].logRecord.level, equals(Level.INFO));
- expect(logger.logMessages[0].logRecord.error, equals(null));
- expect(logger.logMessages[0].logRecord.stackTrace, equals(null));
-}
-
-void _constructorOptions1() {
- LoggerStub logger = LoggerStub();
- setupLogger(
- logWriter: logger.writeLogMessage,
- name: 'LOGGER_NAME',
- level: Level.ALL,
- forceShowCodeLocation: true,
- globalTags: _tagNames.sublist(1, 3),
- );
- expect(logger.logMessages.isEmpty, true);
-
- log.finest('world');
- expect(logger.logMessages.length, equals(1));
- expect(logger.logMessages[0].scopeName, equals('LOGGER_NAME'));
- expect(
- logger.logMessages[0].codeLocation, startsWith('log_writer_test.dart'));
- expect(logger.logMessages[0].tags.length, equals(2));
- expect(logger.logMessages[0].tags[0], equals(_tagNames[1]));
- expect(logger.logMessages[0].tags[1], equals(_tagNames[2]));
- expect(logger.logMessages[0].logRecord.message, equals('world'));
- expect(logger.logMessages[0].logRecord.level, equals(Level.FINEST));
- expect(logger.logMessages[0].logRecord.error, equals(null));
- expect(logger.logMessages[0].logRecord.stackTrace, equals(null));
-}
-
-void _constructorOptions2() {
- LoggerStub logger = LoggerStub();
- setupLogger(
- logWriter: logger.writeLogMessage,
- level: Level.WARNING,
- forceShowCodeLocation: false,
- globalTags: _tagNames.sublist(0, 3),
- );
- expect(logger.logMessages.isEmpty, true);
-
- log.warning('cruel');
- expect(logger.logMessages.length, equals(1));
- expect(logger.logMessages[0].codeLocation, equals(null));
- expect(logger.logMessages[0].tags.length, equals(3));
- expect(logger.logMessages[0].tags[0], equals(_tagNames[0]));
- expect(logger.logMessages[0].tags[1], equals(_tagNames[1]));
- expect(logger.logMessages[0].tags[2], equals(_tagNames[2]));
- expect(logger.logMessages[0].logRecord.message, equals('cruel'));
- expect(logger.logMessages[0].logRecord.level, equals(Level.WARNING));
-
- log.info('info should be blocked because we are at warning level');
- expect(logger.logMessages.length, equals(1));
-
- log.severe('but sending the higher level severe should get logged');
- expect(logger.logMessages.length, equals(2));
-}
-
-void _testTooManyTags() {
- final List<String> stdoutLines = <String>[];
- runZoned<void>(
- () {
- LoggerStub logger = LoggerStub();
- setupLogger(
- logWriter: logger.writeLogMessage,
- level: Level.WARNING,
- forceShowCodeLocation: false,
- globalTags: _tagNames,
- );
- expect(logger.logMessages.isEmpty, true);
-
- log.warning('cruel');
- expect(logger.logMessages.length, equals(1));
- expect(logger.logMessages[0].codeLocation, equals(null));
- expect(logger.logMessages[0].tags.length, equals(3));
- expect(logger.logMessages[0].tags[0], equals(_tagNames[0]));
- expect(logger.logMessages[0].tags[1], equals(_tagNames[1]));
- expect(logger.logMessages[0].tags[2], equals(_tagNames[2]));
- expect(logger.logMessages[0].logRecord.message, equals('cruel'));
- expect(logger.logMessages[0].logRecord.level, equals(Level.WARNING));
-
- expect(stdoutLines.length, equals(2));
- expect(
- stdoutLines[0], equals('WARNING: Logger initialized with > 3 tags.'));
- expect(stdoutLines[1], equals('WARNING: Later tags will be ignored.'));
- },
- zoneSpecification: ZoneSpecification(
- print: (Zone self, ZoneDelegate parent, Zone zone, String line) {
- stdoutLines.add(line);
- },
- ),
- );
-}
-
-void _testTagTooLong() {
- final List<String> stdoutLines = <String>[];
- runZoned<void>(
- () {
- LoggerStub logger = LoggerStub();
- setupLogger(
- logWriter: logger.writeLogMessage,
- level: Level.WARNING,
- forceShowCodeLocation: false,
- globalTags: _tooLongTagName,
- );
- expect(logger.logMessages.isEmpty, true);
-
- log.warning('cruel');
- expect(logger.logMessages.length, equals(1));
- expect(logger.logMessages[0].codeLocation, equals(null));
- expect(logger.logMessages[0].tags.length, equals(1));
- expect(logger.logMessages[0].tags[0],
- equals(_tooLongTagName[0].substring(0, 63)));
- expect(logger.logMessages[0].logRecord.message, equals('cruel'));
- expect(logger.logMessages[0].logRecord.level, equals(Level.WARNING));
-
- expect(stdoutLines.length, equals(2));
- expect(stdoutLines[0],
- equals('WARNING: Logger tags limited to 63 characters.'));
- expect(stdoutLines[1], startsWith('WARNING: Tag "'));
- },
- zoneSpecification: ZoneSpecification(
- print: (Zone self, ZoneDelegate parent, Zone zone, String line) {
- stdoutLines.add(line);
- },
- ),
- );
-}
-
-void _testInfoLevels() {
- LoggerStub logger = LoggerStub();
- setupLogger(
- logWriter: logger.writeLogMessage,
- level: Level.INFO,
- );
- expect(logger.logMessages.isEmpty, true);
-
- log
- ..shout('shout')
- ..severe('severe')
- ..warning('warning')
- ..info('info')
- ..config('config')
- ..fine('fine')
- ..finer('finer')
- ..finest('finest');
-
- expect(logger.logMessages.length, equals(4));
- expect(logger.logMessages[0].logRecord.message, equals('shout'));
- expect(logger.logMessages[1].logRecord.message, equals('severe'));
- expect(logger.logMessages[2].logRecord.message, equals('warning'));
- expect(logger.logMessages[3].logRecord.message, equals('info'));
-}
-
-void _testDefaultLevels() {
- LoggerStub logger = LoggerStub();
- setupLogger(
- logWriter: logger.writeLogMessage,
- );
- expect(logger.logMessages.isEmpty, true);
-
- log
- ..shout('shout')
- ..severe('severe')
- ..warning('warning')
- ..info('info')
- ..config('config')
- ..fine('fine')
- ..finer('finer')
- ..finest('finest');
-
- expect(logger.logMessages.length, equals(8));
- expect(logger.logMessages[0].logRecord.message, equals('shout'));
- expect(logger.logMessages[1].logRecord.message, equals('severe'));
- expect(logger.logMessages[2].logRecord.message, equals('warning'));
- expect(logger.logMessages[3].logRecord.message, equals('info'));
- expect(logger.logMessages[4].logRecord.message, equals('config'));
- expect(logger.logMessages[5].logRecord.message, equals('fine'));
- expect(logger.logMessages[6].logRecord.message, equals('finer'));
- expect(logger.logMessages[7].logRecord.message, equals('finest'));
-}
diff --git a/public/lib/app/dart/test/socket_redirect_to_stdout_test.dart b/public/lib/app/dart/test/socket_redirect_to_stdout_test.dart
deleted file mode 100644
index 9c56b69..0000000
--- a/public/lib/app/dart/test/socket_redirect_to_stdout_test.dart
+++ /dev/null
@@ -1,36 +0,0 @@
-// 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.
-
-// This test should run on device to enable sys_logger
-
-import 'dart:async';
-
-import 'package:lib.app.dart/logging.dart';
-import 'package:test/test.dart';
-
-void main() {
- test('_testlogToStdout', _testlogToStdout);
-}
-
-void _testlogToStdout() {
- final List<String> logOutput = <String>[];
- runZoned<void>(
- () {
- setupLogger(
- name: 'TEST',
- forceShowCodeLocation: false,
- logToStdoutForTest: true,
- );
- log.info('foo');
-
- expect(logOutput.length, equals(1));
- expect(logOutput[0], equals('[INFO:TEST] foo'));
- },
- zoneSpecification: ZoneSpecification(
- print: (Zone self, ZoneDelegate parent, Zone zone, String line) {
- logOutput.add(line);
- },
- ),
- );
-}
diff --git a/public/lib/app/dart/test/socket_test.dart b/public/lib/app/dart/test/socket_test.dart
deleted file mode 100644
index e44b1a6..0000000
--- a/public/lib/app/dart/test/socket_test.dart
+++ /dev/null
@@ -1,41 +0,0 @@
-// 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 'dart:convert';
-import 'dart:typed_data';
-
-import 'package:lib.app.dart/logging.dart';
-import 'package:mockito/mockito.dart';
-import 'package:test/test.dart';
-import 'package:zircon/zircon.dart';
-
-import 'socket_validate.dart';
-
-class MockSocket extends Mock implements Socket {}
-
-void main() {
- test('_testlogToSocket', _testlogToSocket);
-}
-
-void _testlogToSocket() {
- MockSocket mockSocket = MockSocket();
- setupLogger(
- name: 'TEST',
- forceShowCodeLocation: false,
- logSocket: mockSocket,
- );
- log.info('foo');
-
- ByteData byteData = verify(mockSocket.write(captureAny)).captured.single;
- List<int> logged = byteData.buffer.asInt8List(0, byteData.lengthInBytes);
- validateFixedBlock(logged, 0);
- expect(logged[32], equals(4));
- expect(utf8.decode(logged.sublist(33, 37)), equals('TEST'));
- expect(utf8.decode(logged.sublist(38, 41)), equals('foo'));
- expect(logged[41], equals(0));
- // Length should be 33 + 5 (TEST) + 4 (foo)
- expect(logged.length, equals(42));
-
- mockSocket.close();
-}
diff --git a/public/lib/app/dart/test/socket_validate.dart b/public/lib/app/dart/test/socket_validate.dart
deleted file mode 100644
index 42016cf..0000000
--- a/public/lib/app/dart/test/socket_validate.dart
+++ /dev/null
@@ -1,51 +0,0 @@
-// 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 'dart:io';
-import 'dart:isolate';
-import 'dart:typed_data';
-
-import 'package:test/test.dart';
-import 'package:zircon/zircon.dart';
-
-const int _lookBackTimeGap = 15 * 1000 * 1000 * 1000; // 15 sec in nanoseconds
-
-const int _zxClockMonotonic = 0;
-
-/// Convert from little endian format bytes to an unsiged 32 bit int.
-int bytesToInt32(List<int> bytes) {
- ByteData byteData = ByteData(4);
- for (int i = 0; i < 4; i++) {
- byteData.setInt8(i, bytes[i]);
- }
- return byteData.getInt32(0, Endian.little);
-}
-
-/// Convert from little endian format bytes to an unsiged 64 bit int.
-int bytesToUint64(List<int> bytes) {
- ByteData byteData = ByteData(8);
- for (int i = 0; i < 8; i++) {
- byteData.setInt8(i, bytes[i]);
- }
- return byteData.getUint64(0, Endian.little);
-}
-
-/// Validate the primary contents of the fixed location portion of a log
-/// record on the logging Socket.
-void validateFixedBlock(List<int> data, int level) {
- // Process ID
- expect(bytesToUint64(data), equals(pid));
- // Thread ID
- expect(bytesToUint64(data.sublist(8, 16)), equals(Isolate.current.hashCode));
-
- // Log time should be within the last 30 seconds
- int nowNanos = Platform.isFuchsia
- ? System.clockGet(_zxClockMonotonic)
- : DateTime.now().microsecondsSinceEpoch * 1000;
- int logNanos = bytesToUint64(data.sublist(16, 24));
- expect(logNanos, lessThanOrEqualTo(nowNanos));
- expect(logNanos + _lookBackTimeGap, greaterThan(nowNanos));
-
- expect(bytesToInt32(data.sublist(24, 28)), equals(level));
-}
diff --git a/public/lib/app/dart/test/socket_with_exception_test.dart b/public/lib/app/dart/test/socket_with_exception_test.dart
deleted file mode 100644
index f71fb3c..0000000
--- a/public/lib/app/dart/test/socket_with_exception_test.dart
+++ /dev/null
@@ -1,49 +0,0 @@
-// 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 'dart:convert';
-import 'dart:typed_data';
-
-import 'package:lib.app.dart/logging.dart';
-import 'package:mockito/mockito.dart';
-import 'package:test/test.dart';
-import 'package:zircon/zircon.dart';
-
-import 'socket_validate.dart';
-
-class MockSocket extends Mock implements Socket {}
-
-void main() {
- test('_testLogToSocketWithException', _testLogToSocketWithException);
-}
-
-void _testLogToSocketWithException() {
- MockSocket mockSocket = MockSocket();
- setupLogger(
- name: 'TEST',
- forceShowCodeLocation: false,
- logSocket: mockSocket,
- );
- log.shout('error', Exception('cause'));
-
- ByteData byteData = verify(mockSocket.write(captureAny)).captured.single;
- List<int> logged = byteData.buffer.asInt8List(0, byteData.lengthInBytes);
- validateFixedBlock(logged, 3);
-
- expect(logged[32], equals(4));
- expect(utf8.decode(logged.sublist(33, 37)), equals('TEST'));
- int end = 37;
-
- // dividing 0 byte
- expect(logged[end++], equals(0));
-
- int start = end;
- expect(
- utf8.decode(logged.sublist(start)), matches('error: Exception: cause'));
- end = start + 23;
- expect(logged[end++], equals(0));
- expect(logged.length, equals(end));
-
- mockSocket.close();
-}
diff --git a/public/lib/app/dart/test/socket_with_location_test.dart b/public/lib/app/dart/test/socket_with_location_test.dart
deleted file mode 100644
index 8800af8..0000000
--- a/public/lib/app/dart/test/socket_with_location_test.dart
+++ /dev/null
@@ -1,56 +0,0 @@
-// 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 'dart:convert';
-import 'dart:typed_data';
-
-import 'package:lib.app.dart/logging.dart';
-import 'package:mockito/mockito.dart';
-import 'package:test/test.dart';
-import 'package:zircon/zircon.dart';
-
-import 'socket_validate.dart';
-
-const String _fileName = 'socket_with_location_test.dart';
-
-class MockSocket extends Mock implements Socket {}
-
-void main() {
- test('_testLogToSocketWithLocation', _testLogToSocketWithLocation);
-}
-
-void _testLogToSocketWithLocation() {
- MockSocket mockSocket = MockSocket();
- setupLogger(
- name: 'TEST',
- level: Level.ALL,
- forceShowCodeLocation: true,
- logSocket: mockSocket,
- );
- log.finest('bar');
-
- ByteData byteData = verify(mockSocket.write(captureAny)).captured.single;
- List<int> logged = byteData.buffer.asInt8List(0, byteData.lengthInBytes);
- validateFixedBlock(logged, -4);
-
- expect(logged[32], equals(4));
- expect(utf8.decode(logged.sublist(33, 37)), equals('TEST'));
- int start = 37;
- expect(logged[start], greaterThan(_fileName.length));
- int end = start + logged[start] + 1;
- start++;
- expect(
- utf8.decode(logged.sublist(start, end)), matches('$_fileName\\(\\d+\\)'));
-
- // dividing 0 byte
- expect(logged[end++], equals(0));
-
- start = end;
- expect(utf8.decode(logged.sublist(start, start + 3)), equals('bar'));
- end = start + 3;
- expect(logged[end++], equals(0));
- expect(logged.length, equals(end));
-
- mockSocket.close();
-}
diff --git a/public/lib/app/dart/test/socket_with_stacktrace_test.dart b/public/lib/app/dart/test/socket_with_stacktrace_test.dart
deleted file mode 100644
index 9f9f826..0000000
--- a/public/lib/app/dart/test/socket_with_stacktrace_test.dart
+++ /dev/null
@@ -1,56 +0,0 @@
-// 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 'dart:convert';
-import 'dart:typed_data';
-
-import 'package:lib.app.dart/logging.dart';
-import 'package:mockito/mockito.dart';
-import 'package:test/test.dart';
-import 'package:zircon/zircon.dart';
-
-import 'socket_validate.dart';
-
-class MockSocket extends Mock implements Socket {}
-
-void main() {
- test('_testLogToSocketWithStacktrace', _testLogToSocketWithStacktrace);
-}
-
-const int _socketBufferLength = 2032;
-const String _errorMsg = 'this error message plus the stacktrace need to be '
- 'long enough to hit the max block size to validate that truncation of long '
- 'messages works properly';
-
-void _testLogToSocketWithStacktrace() {
- MockSocket mockSocket = MockSocket();
- setupLogger(
- name: 'TEST',
- forceShowCodeLocation: false,
- logSocket: mockSocket,
- );
- log.severe(_errorMsg, Exception('because'), StackTrace.current);
-
- ByteData byteData = verify(mockSocket.write(captureAny)).captured.single;
- List<int> logged = byteData.buffer.asInt8List(0, byteData.lengthInBytes);
- validateFixedBlock(logged, 2);
-
- expect(logged[32], equals(4));
- expect(utf8.decode(logged.sublist(33, 37)), equals('TEST'));
- int end = 37;
-
- // dividing 0 byte
- expect(logged[end++], equals(0));
-
- String msg = utf8.decode(logged.sublist(end));
- expect(msg, startsWith('$_errorMsg: Exception: because\n'));
- expect(msg, matches(r'.*_testLogToSocketWithStacktrace'));
- expect(logged.length, equals(_socketBufferLength));
- expect(
- utf8.decode(
- logged.sublist(_socketBufferLength - 4, _socketBufferLength - 1)),
- equals('...'));
-
- mockSocket.close();
-}
diff --git a/public/lib/app/dart/test/socket_with_tags_test.dart b/public/lib/app/dart/test/socket_with_tags_test.dart
deleted file mode 100644
index 7adab2a..0000000
--- a/public/lib/app/dart/test/socket_with_tags_test.dart
+++ /dev/null
@@ -1,76 +0,0 @@
-// 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 'dart:convert';
-import 'dart:typed_data';
-
-import 'package:lib.app.dart/logging.dart';
-import 'package:mockito/mockito.dart';
-import 'package:test/test.dart';
-import 'package:zircon/zircon.dart';
-
-import 'socket_validate.dart';
-
-List<String> _tagNames = <String>[
- 'TAG1',
- 'TAG2',
-];
-
-const String _fileName = 'socket_with_tags_test.dart';
-
-class MockSocket extends Mock implements Socket {}
-
-void main() {
- test('_testlogToSocketWithTags', _testlogToSocketWithTags);
-}
-
-void _testlogToSocketWithTags() {
- MockSocket mockSocket = MockSocket();
- setupLogger(
- name: 'TEST',
- level: Level.ALL,
- forceShowCodeLocation: true,
- globalTags: _tagNames.sublist(0, 2),
- logSocket: mockSocket,
- );
- log.fine('bar');
-
- ByteData byteData = verify(mockSocket.write(captureAny)).captured.single;
- List<int> logged = byteData.buffer.asInt8List(0, byteData.lengthInBytes);
- validateFixedBlock(logged, -2);
-
- expect(logged[32], equals(4));
- expect(utf8.decode(logged.sublist(33, 37)), equals('TEST'));
- int start = 37;
- expect(logged[start], greaterThan(_fileName.length));
- int end = start + logged[start] + 1;
- start++;
- expect(
- utf8.decode(logged.sublist(start, end)), matches('$_fileName\\(\\d+\\)'));
-
- // verify the first tag
- start = end;
- expect(logged[start], equals(_tagNames[0].length));
- end = start + logged[start] + 1;
- start++;
- expect(utf8.decode(logged.sublist(start, end)), equals(_tagNames[0]));
-
- // verify the second tag
- start = end;
- expect(logged[start], equals(_tagNames[1].length));
- end = start + logged[start] + 1;
- start++;
- expect(utf8.decode(logged.sublist(start, end)), equals(_tagNames[1]));
-
- // dividing 0 byte
- expect(logged[end++], equals(0));
-
- start = end;
- expect(utf8.decode(logged.sublist(start, start + 3)), equals('bar'));
- end = start + 3;
- expect(logged[end++], equals(0));
- expect(logged.length, equals(end));
-
- mockSocket.close();
-}
diff --git a/public/lib/app/dart/test/stdout_test.dart b/public/lib/app/dart/test/stdout_test.dart
deleted file mode 100644
index b8d1599..0000000
--- a/public/lib/app/dart/test/stdout_test.dart
+++ /dev/null
@@ -1,36 +0,0 @@
-// 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 'dart:async';
-
-import 'package:lib.app.dart/logging.dart';
-import 'package:test/test.dart';
-
-void main() {
- test('_testlogToStdout', _testlogToStdout);
-}
-
-void _testlogToStdout() async {
- final List<String> logOutput = <String>[];
- runZoned<void>(
- () {
- setupLogger(
- name: 'TEST',
- forceShowCodeLocation: false,
- );
- log
- ..info('foo')
- ..warning('bar');
-
- expect(logOutput.length, equals(2));
- expect(logOutput[0], equals('[INFO:TEST] foo'));
- expect(logOutput[1], equals('[WARNING:TEST] bar'));
- },
- zoneSpecification: ZoneSpecification(
- print: (Zone self, ZoneDelegate parent, Zone zone, String line) {
- logOutput.add(line);
- },
- ),
- );
-}
diff --git a/public/lib/app/dart/test/stdout_with_exception.dart b/public/lib/app/dart/test/stdout_with_exception.dart
deleted file mode 100644
index 248c4a0..0000000
--- a/public/lib/app/dart/test/stdout_with_exception.dart
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2017 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 'dart:async';
-
-import 'package:lib.app.dart/logging.dart';
-import 'package:test/test.dart';
-
-void main() {
- test('_testLogToStdoutWithException', _testLogToStdoutWithException);
-}
-
-void _testLogToStdoutWithException() async {
- final List<String> logOutput = <String>[];
- runZoned<void>(
- () {
- setupLogger(
- name: 'TEST',
- level: Level.ALL,
- forceShowCodeLocation: false,
- );
- log.shout('foo', Exception('cause'));
-
- expect(logOutput.length, equals(1));
- expect(logOutput[0], equals('[FATAL:TEST] foo: Exception: cause'));
-
- log.severe('bar', Exception('because'), StackTrace.current);
-
- expect(logOutput.length, equals(3));
- expect(logOutput[1], equals('[ERROR:TEST] bar: Exception: because'));
- expect(logOutput[2], matches(r'.*_testLogToStdoutWithError.*'));
- },
- zoneSpecification: ZoneSpecification(
- print: (Zone self, ZoneDelegate parent, Zone zone, String line) {
- logOutput.add(line);
- },
- ),
- );
-}
diff --git a/public/lib/app/dart/test/stdout_with_location.dart b/public/lib/app/dart/test/stdout_with_location.dart
deleted file mode 100644
index 751b495..0000000
--- a/public/lib/app/dart/test/stdout_with_location.dart
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2017 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 'dart:async';
-
-import 'package:lib.app.dart/logging.dart';
-import 'package:test/test.dart';
-
-const String _fileName = 'stdout_with_location_test.dart';
-
-void main() {
- test('_testLogToStdoutWithLocation', _testLogToStdoutWithLocation);
-}
-
-void _testLogToStdoutWithLocation() async {
- final List<String> logOutput = <String>[];
- runZoned<void>(
- () {
- setupLogger(
- name: 'TEST',
- forceShowCodeLocation: true,
- );
- log.info('foo');
-
- expect(logOutput.length, equals(1));
- expect(logOutput[0], matches('\\[INFO:TEST:$_fileName\\(\\d+\\)\\] foo'));
- },
- zoneSpecification: ZoneSpecification(
- print: (Zone self, ZoneDelegate parent, Zone zone, String line) {
- logOutput.add(line);
- },
- ),
- );
-}
diff --git a/public/lib/app/dart/test/test_startup_context_test.dart b/public/lib/app/dart/test/test_startup_context_test.dart
deleted file mode 100644
index 4b01ee4..0000000
--- a/public/lib/app/dart/test/test_startup_context_test.dart
+++ /dev/null
@@ -1,41 +0,0 @@
-// 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:lib.app.dart/testing/test_startup_context.dart';
-import 'package:lib.app.dart/app.dart';
-import 'package:test/test.dart';
-import 'package:zircon/zircon.dart';
-
-void main() {
- TestStartupContext testContext = TestStartupContext();
- StartupContext.provideStartupContext(testContext);
-
- group('Fake context', () {
- test('can be obtained through fromStartupInfo', () {
- expect(StartupContext.fromStartupInfo(), testContext);
- });
- test('should not crash with normal calls', () {
- final context = StartupContext.fromStartupInfo();
-
- context.outgoingServices.addServiceForName((req) {}, 'service');
- context.environmentServices.ctrl.close();
- context.close();
- });
- test('should connect a service when connected', () {
- final context = StartupContext.fromStartupInfo();
- var wasConnected = false;
-
- testContext.withTestService((req) {
- wasConnected = true;
- }, 'connectedService');
-
- context.environmentServices.connectToService(
- 'connectedService', Channel(Handle.invalid()));
-
- expect(wasConnected, true);
- }, skip: 'TODO(tvolkert): re-enable this test');
- });
-
- // TODO(ejia): add tests with full fidl service
-}
diff --git a/public/lib/app/dart/testing/test_startup_context.dart b/public/lib/app/dart/testing/test_startup_context.dart
deleted file mode 100644
index 2fdfedb..0000000
--- a/public/lib/app/dart/testing/test_startup_context.dart
+++ /dev/null
@@ -1,79 +0,0 @@
-import 'package:fidl/fidl.dart';
-import 'package:fidl_fuchsia_sys/fidl.dart';
-import 'package:lib.app.dart/app.dart';
-import 'package:mockito/mockito.dart';
-import 'package:zircon/zircon.dart';
-
-/// Fake startup context that can be used to provide services for host testing
-/// as well as outgoing services.
-///
-/// To use:
-///
-/// Before first call to get StartupContext, call
-/// final startupContext = TestStartupContext();
-/// provideStartupContext(startupContext);
-class TestStartupContext implements StartupContext {
- @override
- MockEnvironmentProxy environment = MockEnvironmentProxy();
-
- @override
- TestServiceProvider environmentServices = TestServiceProvider();
-
- @override
- final MockLauncherProxy launcher = MockLauncherProxy();
-
- @override
- final MockOutgoing outgoingServices = MockOutgoing();
-
- @override
- void close() {
- // No-op.
- }
-
- void withTestService<T>(ServiceConnector<T> connector, String serviceName) =>
- environmentServices._withTestService(connector, serviceName);
-}
-
-class TestServiceProvider implements ServiceProviderProxy {
- final ServiceProviderImpl _testServices = ServiceProviderImpl();
- final Set<String> _serviceNames = <String>{};
-
- void _withTestService<T>(ServiceConnector<T> connector, String serviceName) {
- if (_serviceNames.contains(serviceName)) {
- throw TestEnvironmentException('Duplicate $serviceName provided');
- }
- _serviceNames.add(serviceName);
- _testServices.addServiceForName(connector, serviceName);
- }
-
- @override
- MockProxyController<ServiceProvider> ctrl =
- MockProxyController<ServiceProvider>();
-
- @override
- void connectToService(String serviceName, Channel channel) {
- if (!_serviceNames.contains(serviceName)) {
- throw TestEnvironmentException(
- 'No service provider for $serviceName in test environment.');
- }
-
- _testServices.connectToService(serviceName, channel);
- }
-}
-
-class MockEnvironmentProxy extends Mock implements EnvironmentProxy {}
-
-class MockLauncherProxy extends Mock implements LauncherProxy {}
-
-class MockProxyController<T> extends Mock implements ProxyController<T> {}
-
-class MockOutgoing extends Mock implements Outgoing {}
-
-class TestEnvironmentException implements Exception {
- final String message;
-
- TestEnvironmentException([this.message]);
-
- @override
- String toString() => 'TestEnvironmentException: $message';
-}
diff --git a/public/lib/device/dart/BUILD.gn b/public/lib/device/dart/BUILD.gn
index d7ee2c5..06d3066 100644
--- a/public/lib/device/dart/BUILD.gn
+++ b/public/lib/device/dart/BUILD.gn
@@ -18,6 +18,5 @@
"//sdk/fidl/fuchsia.auth",
"//sdk/fidl/fuchsia.modular",
"//topaz/public/dart/fidl",
- "//topaz/public/lib/app/dart",
]
}
diff --git a/public/lib/media/dart/BUILD.gn b/public/lib/media/dart/BUILD.gn
index 605a809..a156745 100644
--- a/public/lib/media/dart/BUILD.gn
+++ b/public/lib/media/dart/BUILD.gn
@@ -18,7 +18,6 @@
"//topaz/public/dart/fidl",
"//topaz/public/dart/fuchsia_logger",
"//topaz/public/dart/fuchsia_services",
- "//topaz/public/lib/app/dart",
"//topaz/public/lib/settings:settings_protos",
]
}
diff --git a/public/lib/mediaplayer/flutter/BUILD.gn b/public/lib/mediaplayer/flutter/BUILD.gn
index 819fe3d..5135bd8 100644
--- a/public/lib/mediaplayer/flutter/BUILD.gn
+++ b/public/lib/mediaplayer/flutter/BUILD.gn
@@ -23,7 +23,6 @@
"//third_party/dart-pkg/git/flutter/packages/flutter",
"//topaz/public/dart/fuchsia_scenic",
"//topaz/public/dart/fuchsia_scenic_flutter",
- "//topaz/public/lib/app/dart",
"//topaz/public/lib/mediaplayer/dart",
]
}
diff --git a/runtime/dart_runner/embedder/script_runner_snapshot.dart b/runtime/dart_runner/embedder/script_runner_snapshot.dart
index 9a2ff32..95553ae 100644
--- a/runtime/dart_runner/embedder/script_runner_snapshot.dart
+++ b/runtime/dart_runner/embedder/script_runner_snapshot.dart
@@ -24,8 +24,7 @@
import 'package:zircon/zircon.dart';
// FIDL bindings and application libraries.
-import 'package:lib.app.dart/app.dart';
import 'package:fidl/fidl.dart';
// From //sdk/fidl/fuchsia.modular
-import 'package:fidl_fuchsia_modular/fidl.dart';
+import 'package:fidl_fuchsia_modular/fidl_async.dart';