2019-11-27 23:04:02 +00:00
|
|
|
// Copyright 2014 The Flutter Authors. All rights reserved.
|
2018-07-25 16:29:35 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-01-27 23:17:53 +00:00
|
|
|
// @dart = 2.8
|
|
|
|
|
2018-07-25 16:29:35 +00:00
|
|
|
import 'package:file/file.dart';
|
|
|
|
|
2018-08-15 03:33:58 +00:00
|
|
|
import '../src/common.dart';
|
2018-07-25 16:29:35 +00:00
|
|
|
import 'test_data/basic_project.dart';
|
|
|
|
import 'test_driver.dart';
|
2018-10-19 11:51:31 +00:00
|
|
|
import 'test_utils.dart';
|
2018-07-25 16:29:35 +00:00
|
|
|
|
|
|
|
/// This duration is arbitrary but is ideally:
|
2020-08-06 23:18:52 +00:00
|
|
|
/// a) Long enough to ensure that if the app is crashing at startup, we notice.
|
|
|
|
/// b) As short as possible, to avoid inflating build times.
|
2018-08-02 10:02:32 +00:00
|
|
|
const Duration requiredLifespan = Duration(seconds: 5);
|
2018-07-25 16:29:35 +00:00
|
|
|
|
|
|
|
void main() {
|
2019-10-18 23:35:39 +00:00
|
|
|
final BasicProject _project = BasicProject();
|
|
|
|
FlutterRunTestDriver _flutter;
|
|
|
|
Directory tempDir;
|
|
|
|
|
|
|
|
setUp(() async {
|
|
|
|
tempDir = createResolvedTempDirectorySync('lifetime_test.');
|
|
|
|
await _project.setUpIn(tempDir);
|
|
|
|
_flutter = FlutterRunTestDriver(tempDir);
|
|
|
|
});
|
|
|
|
|
|
|
|
tearDown(() async {
|
|
|
|
await _flutter.stop();
|
|
|
|
tryToDelete(tempDir);
|
|
|
|
});
|
|
|
|
|
2020-09-08 22:56:00 +00:00
|
|
|
testWithoutContext('flutter run does not terminate when a debugger is attached', () async {
|
2019-10-18 23:35:39 +00:00
|
|
|
await _flutter.run(withDebugger: true);
|
|
|
|
await Future<void>.delayed(requiredLifespan);
|
|
|
|
expect(_flutter.hasExited, equals(false));
|
|
|
|
});
|
|
|
|
|
2020-09-08 22:56:00 +00:00
|
|
|
testWithoutContext('fluter run does not terminate when a debugger is attached and pause-on-exceptions', () async {
|
2019-10-18 23:35:39 +00:00
|
|
|
await _flutter.run(withDebugger: true, pauseOnExceptions: true);
|
|
|
|
await Future<void>.delayed(requiredLifespan);
|
|
|
|
expect(_flutter.hasExited, equals(false));
|
|
|
|
});
|
2018-07-25 16:29:35 +00:00
|
|
|
}
|