flutter_attach_test.dart 1.52 KB
Newer Older
1 2 3 4 5 6
// 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.

import 'package:file/file.dart';
import 'package:flutter_tools/src/base/file_system.dart';
7
import 'package:flutter_tools/src/base/platform.dart';
8

9
import '../src/common.dart';
10 11 12 13 14
import '../src/context.dart';
import 'test_data/basic_project.dart';
import 'test_driver.dart';

void main() {
15 16 17
  FlutterTestDriver _flutterRun, _flutterAttach;
  final BasicProject _project = new BasicProject();
  Directory tempDir;
18 19

  setUp(() async {
20
    tempDir = fs.systemTempDirectory.createTempSync('flutter_attach_test.');
21 22 23 24 25 26
    await _project.setUpIn(tempDir);
    _flutterRun = new FlutterTestDriver(tempDir);
    _flutterAttach = new FlutterTestDriver(tempDir);
  });

  tearDown(() async {
27 28 29
    // We can't call stop() on both of these because they'll both try to stop the
    // same app. Just quit the attach process and then send a stop to the original
    // process.
30
    await _flutterRun.stop();
31
    await _flutterAttach.quit();
32
    tryToDelete(tempDir);
33 34 35 36 37 38 39 40
  });

  group('attached process', () {
    testUsingContext('can hot reload', () async {
      await _flutterRun.run(withDebugger: true);
      await _flutterAttach.attach(_flutterRun.vmServicePort);
      await _flutterAttach.hotReload();
    });
41 42
    // TODO(dantup): Unskip after flutter-tester is fixed on Windows:
    // https://github.com/flutter/flutter/issues/17833.
43
  }, timeout: const Timeout.factor(6), skip: platform.isWindows);
44
}