2
2
// Use of this source code is governed by a BSD-style license that can be
3
3
// found in the LICENSE file.
4
4
5
- // @dart = 2.8
6
-
7
5
import 'dart:async' ;
8
6
9
7
import 'package:flutter_tools/src/android/android_workflow.dart' ;
@@ -36,6 +34,7 @@ import 'package:flutter_tools/src/reporting/crash_reporting.dart';
36
34
import 'package:flutter_tools/src/reporting/reporting.dart' ;
37
35
import 'package:flutter_tools/src/version.dart' ;
38
36
import 'package:meta/meta.dart' ;
37
+ import 'package:test/fake.dart' ;
39
38
40
39
import 'common.dart' ;
41
40
import 'fake_http_client.dart' ;
@@ -48,18 +47,18 @@ export 'package:flutter_tools/src/base/context.dart' show Generator;
48
47
export 'fake_process_manager.dart' show ProcessManager, FakeProcessManager, FakeCommand;
49
48
50
49
/// Return the test logger. This assumes that the current Logger is a BufferLogger.
51
- BufferLogger get testLogger => context.get <Logger >() as BufferLogger ;
50
+ BufferLogger get testLogger => context.get <Logger >()! as BufferLogger ;
52
51
53
- FakeDeviceManager get testDeviceManager => context.get <DeviceManager >() as FakeDeviceManager ;
52
+ FakeDeviceManager get testDeviceManager => context.get <DeviceManager >()! as FakeDeviceManager ;
54
53
55
54
@isTest
56
55
void testUsingContext (
57
56
String description,
58
57
dynamic Function () testMethod, {
59
58
Map <Type , Generator > overrides = const < Type , Generator > {},
60
59
bool initializeFlutterRoot = true ,
61
- String testOn,
62
- bool skip, // should default to `false`, but https://github.com/dart-lang/test/issues/545 doesn't allow this
60
+ String ? testOn,
61
+ bool ? skip, // should default to `false`, but https://github.com/dart-lang/test/issues/545 doesn't allow this
63
62
}) {
64
63
if (overrides[FileSystem ] != null && overrides[ProcessManager ] == null ) {
65
64
throw StateError (
@@ -74,10 +73,10 @@ void testUsingContext(
74
73
75
74
// Ensure we don't rely on the default [Config] constructor which will
76
75
// leak a sticky $HOME/.flutter_settings behind!
77
- Directory configDir;
76
+ Directory ? configDir;
78
77
tearDown (() {
79
78
if (configDir != null ) {
80
- tryToDelete (configDir);
79
+ tryToDelete (configDir! );
81
80
configDir = null ;
82
81
}
83
82
});
@@ -92,7 +91,7 @@ void testUsingContext(
92
91
PersistentToolState buildPersistentToolState (FileSystem fs) {
93
92
configDir ?? = globals.fs.systemTempDirectory.createTempSync ('flutter_config_dir_test.' );
94
93
return PersistentToolState .test (
95
- directory: configDir,
94
+ directory: configDir! ,
96
95
logger: globals.logger,
97
96
);
98
97
}
@@ -172,7 +171,7 @@ void testUsingContext(
172
171
173
172
void _printBufferedErrors (AppContext testContext) {
174
173
if (testContext.get <Logger >() is BufferLogger ) {
175
- final BufferLogger bufferLogger = testContext.get <Logger >() as BufferLogger ;
174
+ final BufferLogger bufferLogger = testContext.get <Logger >()! as BufferLogger ;
176
175
if (bufferLogger.errorText.isNotEmpty) {
177
176
// This is where the logger outputting errors is implemented, so it has
178
177
// to use `print`.
@@ -185,18 +184,18 @@ void _printBufferedErrors(AppContext testContext) {
185
184
class FakeDeviceManager implements DeviceManager {
186
185
List <Device > devices = < Device > [];
187
186
188
- String _specifiedDeviceId;
187
+ String ? _specifiedDeviceId;
189
188
190
189
@override
191
- String get specifiedDeviceId {
190
+ String ? get specifiedDeviceId {
192
191
if (_specifiedDeviceId == null || _specifiedDeviceId == 'all' ) {
193
192
return null ;
194
193
}
195
194
return _specifiedDeviceId;
196
195
}
197
196
198
197
@override
199
- set specifiedDeviceId (String id) {
198
+ set specifiedDeviceId (String ? id) {
200
199
_specifiedDeviceId = id;
201
200
}
202
201
@@ -212,7 +211,7 @@ class FakeDeviceManager implements DeviceManager {
212
211
Future <List <Device >> getAllConnectedDevices () async => devices;
213
212
214
213
@override
215
- Future <List <Device >> refreshAllConnectedDevices ({ Duration timeout }) async => devices;
214
+ Future <List <Device >> refreshAllConnectedDevices ({ Duration ? timeout }) async => devices;
216
215
217
216
@override
218
217
Future <List <Device >> getDevicesById (String deviceId) async {
@@ -222,7 +221,7 @@ class FakeDeviceManager implements DeviceManager {
222
221
@override
223
222
Future <List <Device >> getDevices () {
224
223
return hasSpecifiedDeviceId
225
- ? getDevicesById (specifiedDeviceId)
224
+ ? getDevicesById (specifiedDeviceId! )
226
225
: getAllConnectedDevices ();
227
226
}
228
227
@@ -238,17 +237,17 @@ class FakeDeviceManager implements DeviceManager {
238
237
List <DeviceDiscovery > get deviceDiscoverers => < DeviceDiscovery > [];
239
238
240
239
@override
241
- bool isDeviceSupportedForProject (Device device, FlutterProject flutterProject) {
242
- return device.isSupportedForProject (flutterProject);
240
+ bool isDeviceSupportedForProject (Device device, FlutterProject ? flutterProject) {
241
+ return device.isSupportedForProject (flutterProject! );
243
242
}
244
243
245
244
@override
246
- Future <List <Device >> findTargetDevices (FlutterProject flutterProject, { Duration timeout }) async {
245
+ Future <List <Device >> findTargetDevices (FlutterProject ? flutterProject, { Duration ? timeout }) async {
247
246
return devices;
248
247
}
249
248
}
250
249
251
- class FakeAndroidLicenseValidator extends AndroidLicenseValidator {
250
+ class FakeAndroidLicenseValidator extends Fake implements AndroidLicenseValidator {
252
251
@override
253
252
Future <LicensesAccepted > get licensesAccepted async => LicensesAccepted .all;
254
253
}
@@ -302,7 +301,7 @@ class FakeXcodeProjectInterpreter implements XcodeProjectInterpreter {
302
301
@override
303
302
Future <Map <String , String >> getBuildSettings (
304
303
String projectPath, {
305
- XcodeProjectBuildContext buildContext,
304
+ XcodeProjectBuildContext ? buildContext,
306
305
Duration timeout = const Duration (minutes: 1 ),
307
306
}) async {
308
307
return < String , String > {};
@@ -313,14 +312,14 @@ class FakeXcodeProjectInterpreter implements XcodeProjectInterpreter {
313
312
Directory podXcodeProject, {
314
313
Duration timeout = const Duration (minutes: 1 ),
315
314
}) async {
316
- return null ;
315
+ return '' ;
317
316
}
318
317
319
318
@override
320
319
Future <void > cleanWorkspace (String workspacePath, String scheme, { bool verbose = false }) async { }
321
320
322
321
@override
323
- Future <XcodeProjectInfo > getInfo (String projectPath, {String projectFilename}) async {
322
+ Future <XcodeProjectInfo > getInfo (String projectPath, {String ? projectFilename}) async {
324
323
return XcodeProjectInfo (
325
324
< String > ['Runner' ],
326
325
< String > ['Debug' , 'Release' ],
@@ -358,7 +357,7 @@ class LocalFileSystemBlockingSetCurrentDirectory extends LocalFileSystem {
358
357
class FakeSignals implements Signals {
359
358
@override
360
359
Object addHandler (ProcessSignal signal, SignalHandler handler) {
361
- return null ;
360
+ return Object () ;
362
361
}
363
362
364
363
@override
0 commit comments