1// Copyright 2018 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5// Integration tests which invoke flutter instead of unit testing the code 6// will not produce meaningful coverage information - we can measure coverage 7// from the isolate running the test, but not from the isolate started via 8// the command line process. 9@Tags(<String>['no_coverage']) 10import 'dart:async'; 11 12import 'package:file/file.dart'; 13import 'package:flutter_tools/src/base/file_system.dart'; 14 15import '../src/common.dart'; 16import 'test_data/basic_project.dart'; 17import 'test_driver.dart'; 18import 'test_utils.dart'; 19 20/// This duration is arbitrary but is ideally: 21/// a) long enough to ensure that if the app is crashing at startup, we notice 22/// b) as short as possible, to avoid inflating build times 23const Duration requiredLifespan = Duration(seconds: 5); 24 25void main() { 26 group('flutter run', () { 27 final BasicProject _project = BasicProject(); 28 FlutterRunTestDriver _flutter; 29 Directory tempDir; 30 31 setUp(() async { 32 tempDir = createResolvedTempDirectorySync('lifetime_test.'); 33 await _project.setUpIn(tempDir); 34 _flutter = FlutterRunTestDriver(tempDir); 35 }); 36 37 tearDown(() async { 38 await _flutter.stop(); 39 tryToDelete(tempDir); 40 }); 41 42 test('does not terminate when a debugger is attached', () async { 43 await _flutter.run(withDebugger: true); 44 await Future<void>.delayed(requiredLifespan); 45 expect(_flutter.hasExited, equals(false)); 46 }); 47 48 test('does not terminate when a debugger is attached and pause-on-exceptions', () async { 49 await _flutter.run(withDebugger: true, pauseOnExceptions: true); 50 await Future<void>.delayed(requiredLifespan); 51 expect(_flutter.hasExited, equals(false)); 52 }); 53 }, timeout: const Timeout.factor(10), tags: <String>['integration']); // The DevFS sync takes a really long time, so these tests can be slow. 54} 55