[cleanup] remove public/lib/fuchsia_driver
Change-Id: I76ed3c6311487e81924f6bbd6c4c6ae18e7a5859
diff --git a/README.md b/README.md
index 73a089b..4a37757 100644
--- a/README.md
+++ b/README.md
@@ -38,3 +38,4 @@
* topaz/public/lib/context: f489f45e6883df6e3be578342b4e739928adcf77
* topaz/public/lib/mod: 75067a620790d76515c3824321eca335a6aa6bab
* topaz/public/lib/app_driver: 0196bf704f
+* topaz/public/lib/fuchsia_driver: b34f97387
diff --git a/public/lib/fuchsia_driver/BUILD.gn b/public/lib/fuchsia_driver/BUILD.gn
deleted file mode 100644
index 04ead89..0000000
--- a/public/lib/fuchsia_driver/BUILD.gn
+++ /dev/null
@@ -1,20 +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("//build/dart/dart_library.gni")
-
-dart_library("fuchsia_driver") {
- package_name = "fuchsia_driver"
-
- sources = [
- "fuchsia_driver.dart",
- ]
-
- deps = [
- "//third_party/dart-pkg/git/flutter/packages/flutter",
- "//third_party/dart-pkg/git/flutter/packages/flutter_driver",
- "//third_party/dart-pkg/git/flutter/packages/fuchsia_remote_debug_protocol",
- "//topaz/public/lib/app/dart",
- ]
-}
diff --git a/public/lib/fuchsia_driver/README.md b/public/lib/fuchsia_driver/README.md
deleted file mode 100644
index d3b9e88..0000000
--- a/public/lib/fuchsia_driver/README.md
+++ /dev/null
@@ -1,101 +0,0 @@
-# The Fuchsia Driver Library
-
-This library is a wrapper for the `flutter_driver` library that allows for
-`flutter_driver` tests and scripts to run either as a target application
-(running on a Fuchsia device), or as a remote-to-target test (a test that will
-connect to the Fuchsia device to run a `flutter_driver` script).
-
-## Using this library
-
-*Note:* the mod you are trying to drive _must already be running_ in order for
-you to be able to connect to it. Doing this automatically is outside of the
-scope of this library. Please instead refer to
-`//topaz/tests/modular_integration_tests` for how to run mods along with driver
-tests simultaneously.
-
-First, make sure you've got a cursory familiarity with the `flutter_driver`
-library
-[api available here](https://docs.flutter.io/flutter/flutter_driver/flutter_driver-library.html),
-and [some examples here](https://flutter.io/testing/). This is a very powerful
-way to drive integration tests.
-
-Include `//topaz/public/lib/fuchsia_driver` in your `BUILD.gn` file's deps.
-
-Then make sure to include the following:
-
-```dart
-import 'package:fuchsia_driver/fuchsia_driver.dart';
-import 'package:flutter_driver/flutter_driver.dart';
-```
-
-You can then connect to the Isolate running your mod using the following code:
-
-```dart
-final FuchsiaRemoteConnection connection = FuchsiaDriver.connect();
-final List<IsolateRef> refs =
- await connection.getMainIsolatesByPattern(yourModulePackageName);
-// If this doesn't return null, you can assume there is only one isolate.
-final IsolateRef ref = refs.first;
-final FlutterDriver driver = await FlutterDriver.connect(
- dartVmServiceUrl: ref.dartVm.uri.toString(),
- isolateNumber: ref.number);
-```
-
-Now that you have an instance of the driver, you can drive your mod using the
-`FlutterDriver` API.
-
-## Running tests
-
-If you use the Fuchsia Driver for testing, you can either declare your test file
-as a `dart_fuchsia_test` target, which will then build your test to run on the
-Fuchsia device, or you can make a `dart_remote_test` target in your BUILD.gn
-file, which will allow you to run the `flutter_driver` connection from your host
-machine to the Fuchsia device through an SSH tunnel.
-
-### Running a `dart_fuchsia_test`
-
-A `dart_fuchsia_test` is a test that runs on the Fuchsia device.
-
-To build one of these tests, first make sure that your test file is under a
-`test` folder inside your mod's root directory, and that it ends in
-`_test.dart`.
-
-Then, make a `dart_fuchsia_test` target in your BUILD.gn file(imported from
-`//topaz/runtime/dart/dart_fuchsia_test.gni`).
-
-You should then point to the target as a package (an example would be
-`//topaz/packages/examples/tests` for something that points to a
-`dart_fuchsia_test` as one of its package targets.
-
-Then, once you've included this in your build via the `--packages` flag for `fx
-set` and installed the package onto your device, you can run it with:
-
-```
-$ run your_test_target_name
-```
-
-### Running a `dart_remote_test`
-
-A `dart_remote_test` is a test that runs on your host machine that has its env
-information (`FUCHSIA_SSH_CONFIG` and `FUCHSIA_DEVICE_URL`) set so that an SSH
-tunnel to the Fuchsia device can be created. An example of this would be the
-execution of the call
-[`FuchsiaRemoteConnection.connect`](https://github.com/flutter/flutter/blob/master/packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart#L188),
-which uses these environment variables.
-
-Making one of these tests requires that you import
-`//build/dart/dart_remote_test.gni` into your BUILD.gn file.
-
-Declaring a `dart_remote_test` target is different from `dart_fuchsia_test` as
-you need to specify the source files.
-
-You can then run it using the `fx dart-remote-test` command with a target of
-your `GN` target, like
-`//topaz/examples/test/driver_example_mod:driver_mod_integration_tests`, for
-example.
-
-## Examples
-
-Example code that uses the `flutter_driver`, `fuchsia_driver`,
-`dart_fuchsia_test`, and `dart_remote_test` can be found in
-`//topaz/examples/test/driver_example_mod`.
diff --git a/public/lib/fuchsia_driver/analysis_options.yaml b/public/lib/fuchsia_driver/analysis_options.yaml
deleted file mode 100644
index f0cea8a..0000000
--- a/public/lib/fuchsia_driver/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/public/lib/fuchsia_driver/lib/fuchsia_driver.dart b/public/lib/fuchsia_driver/lib/fuchsia_driver.dart
deleted file mode 100644
index d9ceff0..0000000
--- a/public/lib/fuchsia_driver/lib/fuchsia_driver.dart
+++ /dev/null
@@ -1,151 +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.
-
-/// Convenience methods for location-agnostic Flutter application driving. Can
-/// be run on either a host machine (making a remote connection to a Fuchsia
-/// device), or on the target Fuchsia machine.
-library fuchsia_driver;
-
-import 'dart:async';
-import 'dart:core';
-import 'dart:io';
-
-import 'package:lib.app.dart/logging.dart';
-import 'package:flutter_driver/flutter_driver.dart';
-import 'package:fuchsia_remote_debug_protocol/fuchsia_remote_debug_protocol.dart';
-
-/// Convenience method for driving an `Isolate` by pattern.
-///
-/// Accepts a [FuchsiaRemoteConnection] that will be used to search for the
-/// [Pattern] passed. If the pattern cannot be found an exception will be
-/// raised. Once the `Isolate` is found, the [driverFunction] will be executed,
-/// passing the [FlutterDriver] connection to the function to execute the series
-/// of driver commands.
-///
-/// example:
-///
-/// ```dart
-/// FuchsiaRemoteConnection connection = await FuchsiaDriver.connect();
-///
-/// Future<Null> tapWidget(FlutterDriver driver) {
-/// await driver.tap(find.text('foo'));
-/// }
-///
-/// drive(
-/// isolatePattern: 'bar',
-/// driverFunction: tapWidget,
-/// connection: connection,
-/// );
-/// ```
-Future<Null> drive({
- FuchsiaRemoteConnection connection,
- Future<Null> driverFunction(FlutterDriver driver),
- Pattern isolatePattern,
-}) async {
- final List<IsolateRef> isolateRefs =
- await connection.getMainIsolatesByPattern(isolatePattern);
- final IsolateRef ref = isolateRefs.first;
- final FlutterDriver driver = await FlutterDriver.connect(
- dartVmServiceUrl: ref.dartVm.uri.toString(),
- isolateNumber: ref.number,
- printCommunication: true,
- logCommunicationToFile: false,
- );
- await driverFunction(driver);
- await driver.close();
-}
-
-class _DummyPortForwarder implements PortForwarder {
- _DummyPortForwarder(this._port, this._remotePort);
-
- final int _port;
- final int _remotePort;
-
- @override
- int get port => _port;
-
- @override
- int get remotePort => _remotePort;
-
- @override
- Future<Null> stop() async {}
-}
-
-class _DummySshCommandRunner implements SshCommandRunner {
- _DummySshCommandRunner();
-
- @override
- String get sshConfigPath => null;
-
- @override
- String get address => InternetAddress.loopbackIPv4.address;
-
- @override
- String get interface => null;
-
- @override
- Future<List<String>> run(String command) async {
- if (command.contains('"') || command.contains("'")) {
- log.warning("The command runner does not support quotes: '$command'");
- return <String>[];
- }
- try {
- final List<String> splitCommand = command.split(' ');
- final String exe = splitCommand[0];
- final List<String> args = splitCommand.skip(1).toList();
- final ProcessResult r = await Process.run(exe, args);
- return r.stdout.split('\n');
- } on ProcessException catch (e) {
- log.warning("Error running '$command': $e");
- }
- return <String>[];
- }
-}
-
-Future<PortForwarder> _dummyPortForwardingFunction(
- String address,
- int remotePort, [
- String interface = '',
- String configFile,
-]) async {
- return _DummyPortForwarder(remotePort, remotePort);
-}
-
-/// Utility class for creating connections to the Fuchsia Device.
-///
-/// If executed on a host (non-Fuchsia device), behaves the same as running
-/// [FuchsiaRemoteConnection.connect] whereby the `FUCHSIA_REMOTE_URL` and
-/// `FUCHSIA_SSH_CONFIG` variables must be set. If run on a Fuchsia device, will
-/// connect locally without need for environment variables.
-class FuchsiaDriver {
- static Future<Null> _init() async {
- fuchsiaPortForwardingFunction = _dummyPortForwardingFunction;
- }
-
- /// Restores state to normal if running on a Fuchsia device.
- ///
- /// Noop if running on the host machine.
- static Future<Null> cleanup() async {
- restoreFuchsiaPortForwardingFunction();
- }
-
- /// Creates a connection to the Fuchsia device's Dart VM's.
- ///
- /// See [FuchsiaRemoteConnection.connect] for more details.
- /// [FuchsiaDriver.cleanup] must be called when the connection is no longer in
- /// use. It is the caller's responsibility to call
- /// [FuchsiaRemoteConnection.stop].
- static Future<FuchsiaRemoteConnection> connect() async {
- if (Platform.isFuchsia) {
- // TODO(FL-74): This is a workaround for flutter driver code that
- // writes directly to `stderr`, which causes an error in Fuchsia.
- flutterDriverLog.listen(log.info);
- await FuchsiaDriver._init();
- return FuchsiaRemoteConnection
- // ignore: invalid_use_of_visible_for_testing_member
- .connectWithSshCommandRunner(_DummySshCommandRunner());
- }
- return FuchsiaRemoteConnection.connect();
- }
-}
diff --git a/public/lib/fuchsia_driver/pubspec.yaml b/public/lib/fuchsia_driver/pubspec.yaml
deleted file mode 100644
index 21c3cde..0000000
--- a/public/lib/fuchsia_driver/pubspec.yaml
+++ /dev/null
@@ -1,11 +0,0 @@
-name: fuchsia_driver
-description: Flutter Driver convenience functions for Fuchsia
-author: Flutter Authors <flutter-dev@googlegroups.com>
-
-dependencies:
- flutter_test:
- sdk: flutter
- flutter_driver:
- sdk: flutter
- fuchsia_remote_debug_protocol:
- sdk: flutter