flutter_immediately_exit_test.dart 1.22 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
// Copyright 2014 The Flutter 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 '../src/common.dart';
import 'test_data/project_with_immediate_exit.dart';
import 'test_driver.dart';
import 'test_utils.dart';

void main() {
  Directory tempDir;
  final ProjectWithImmediateExit _project = ProjectWithImmediateExit();
  FlutterRunTestDriver _flutter;

  setUp(() async {
    tempDir = createResolvedTempDirectorySync('run_test.');
    await _project.setUpIn(tempDir);
    _flutter = FlutterRunTestDriver(tempDir);
  });

  tearDown(() async {
    tryToDelete(tempDir);
  });


  testWithoutContext('flutter_tools gracefully handles quick app shutdown', () async {
    try {
      await _flutter.run();
    } on Exception {
      expect(_flutter.lastErrorInfo, contains('Error connecting to the service protocol:'));
      expect(
        _flutter.lastErrorInfo.contains(
          // Looks for stack trace entry of the form:
          //   test/integration.shard/test_driver.dart 379:18  FlutterTestDriver._waitFor.<fn>
37
          RegExp(r'^(.+)\/([^\/]+)\.dart \d*:\d*\s*.*\$')
38 39 40 41 42 43
        ),
        isFalse
      );
    }
  });
}