Allow FlutterTester to be provided with the working directory for execution (#21119)

* Allow FlutterTester to be provided with the working directory for execution

Previously this test set fs.currentDirectory which prevents running tests concurrently. This allows setting the working directory for a FlutterTester in the cosntructor (optionally) and passes it through from the test (without setting fs.currentDirectory).

* Remove trailing whitespace
diff --git a/packages/flutter_tools/lib/src/tester/flutter_tester.dart b/packages/flutter_tools/lib/src/tester/flutter_tester.dart
index adf2905..ca56fa3 100644
--- a/packages/flutter_tools/lib/src/tester/flutter_tester.dart
+++ b/packages/flutter_tools/lib/src/tester/flutter_tester.dart
@@ -41,8 +41,9 @@
 
 // TODO(scheglov): This device does not currently work with full restarts.
 class FlutterTesterDevice extends Device {
-  FlutterTesterDevice(String deviceId) : super(deviceId);
+  FlutterTesterDevice(String deviceId, { this.workingDirectory }) : super(deviceId);
 
+  final String workingDirectory;
   Process _process;
   final DevicePortForwarder _portForwarder = new _NoopPortForwarder();
 
@@ -151,6 +152,7 @@
         environment: <String, String>{
           'FLUTTER_TEST': 'true',
         },
+        workingDirectory: workingDirectory,
       );
       // Setting a bool can't fail in the callback.
       _process.exitCode.then((_) => _isRunning = false); // ignore: unawaited_futures
diff --git a/packages/flutter_tools/test/integration/flutter_tester_test.dart b/packages/flutter_tools/test/integration/flutter_tester_test.dart
index 6b98e19..a758280 100644
--- a/packages/flutter_tools/test/integration/flutter_tester_test.dart
+++ b/packages/flutter_tools/test/integration/flutter_tester_test.dart
@@ -15,25 +15,18 @@
 import 'test_utils.dart';
 
 void main() {
-  Directory tempDir;
-  Directory oldCurrentDir;
-
-  setUp(() async {
-    tempDir = fs.systemTempDirectory.createTempSync('flutter_tester_device_test.');
-    oldCurrentDir = fs.currentDirectory;
-    fs.currentDirectory = tempDir;
-  });
-
-  tearDown(() {
-    fs.currentDirectory = oldCurrentDir;
-    tryToDelete(tempDir);
-  });
 
   group('FlutterTesterDevice', () {
+    Directory tempDir;
     FlutterTesterDevice device;
 
-    setUp(() {
-      device = new FlutterTesterDevice('flutter-tester');
+    setUp(() async {
+      tempDir = fs.systemTempDirectory.createTempSync('flutter_tester_device_test.');
+      device = new FlutterTesterDevice('flutter-tester', workingDirectory: tempDir.path);
+    });
+
+    tearDown(() {
+      tryToDelete(tempDir);
     });
 
     Future<LaunchResult> start(String mainPath) async {
@@ -50,7 +43,7 @@
       writePubspec(tempDir.path);
       writePackages(tempDir.path);
 
-      final String mainPath = fs.path.join('lib', 'main.dart');
+      final String mainPath = fs.path.join(tempDir.path, 'lib', 'main.dart');
       writeFile(mainPath, r'''
 import 'dart:async';
 void main() {