Unverified Commit 3e5f620a authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Convert some general.shard base tests to null safety (#79985)

parent 71e99d29
...@@ -33,4 +33,4 @@ class ToolExit implements Exception { ...@@ -33,4 +33,4 @@ class ToolExit implements Exception {
/// the flutter_tools package. However, there are times where one or more /// the flutter_tools package. However, there are times where one or more
/// futures are intentionally not awaited. This function may be used to ignore a /// futures are intentionally not awaited. This function may be used to ignore a
/// particular future. It silences the unawaited_futures lint. /// particular future. It silences the unawaited_futures lint.
void unawaited(Future<void> future) { } void unawaited(Future<void>? future) { }
...@@ -118,7 +118,7 @@ class AppContext { ...@@ -118,7 +118,7 @@ class AppContext {
if (value == null && _parent != null) { if (value == null && _parent != null) {
value = _parent!.get<T>(); value = _parent!.get<T>();
} }
return _unboxNull(value ?? _generateIfNecessary(T, _fallbacks)) as T; return _unboxNull(value ?? _generateIfNecessary(T, _fallbacks)) as T?;
} }
/// Runs [body] in a child context and returns the value returned by [body]. /// Runs [body] in a child context and returns the value returned by [body].
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:async'; import 'dart:async';
...@@ -32,7 +31,7 @@ Future<void> syncAndAsyncError() { ...@@ -32,7 +31,7 @@ Future<void> syncAndAsyncError() {
Future<void> delayedThrow(FakeAsync time) { Future<void> delayedThrow(FakeAsync time) {
final Future<void> result = final Future<void> result =
Future<void>.delayed(const Duration(milliseconds: 10)) Future<void>.delayed(const Duration(milliseconds: 10))
.then((_) { .then((_) async {
throw 'Delayed Doom'; throw 'Delayed Doom';
}); });
time.elapse(const Duration(seconds: 1)); time.elapse(const Duration(seconds: 1));
...@@ -41,10 +40,10 @@ Future<void> delayedThrow(FakeAsync time) { ...@@ -41,10 +40,10 @@ Future<void> delayedThrow(FakeAsync time) {
} }
void main() { void main() {
Completer<void> caughtInZone; late Completer<void> caughtInZone;
bool caughtByZone = false; bool caughtByZone = false;
bool caughtByHandler = false; bool caughtByHandler = false;
Zone zone; late Zone zone;
setUp(() { setUp(() {
caughtInZone = Completer<void>(); caughtInZone = Completer<void>();
...@@ -270,7 +269,7 @@ void main() { ...@@ -270,7 +269,7 @@ void main() {
unawaited(runZonedGuarded(() async { unawaited(runZonedGuarded(() async {
final Future<void> f = asyncGuard<void>( final Future<void> f = asyncGuard<void>(
() => delayedThrow(time), () => delayedThrow(time),
onError: (Object e, [StackTrace s]) { onError: (Object e, [StackTrace? s]) {
caughtByOnError = true; caughtByOnError = true;
nonNullStackTrace = s != null; nonNullStackTrace = s != null;
}, },
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/context.dart'; import 'package:flutter_tools/src/base/context.dart';
......
...@@ -2,19 +2,16 @@ ...@@ -2,19 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/deferred_component.dart'; import 'package:flutter_tools/src/base/deferred_component.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
import '../../src/common.dart'; import '../../src/common.dart';
import '../../src/context.dart';
void main() { void main() {
group('DeferredComponent basics', () { group('DeferredComponent basics', () {
test('constructor sets values', () { testWithoutContext('constructor sets values', () {
final DeferredComponent component = DeferredComponent( final DeferredComponent component = DeferredComponent(
name: 'bestcomponent', name: 'bestcomponent',
libraries: <String>['lib1', 'lib2'], libraries: <String>['lib1', 'lib2'],
...@@ -25,7 +22,7 @@ void main() { ...@@ -25,7 +22,7 @@ void main() {
expect(component.assets, <Uri>[Uri.file('asset1'), Uri.file('asset2')]); expect(component.assets, <Uri>[Uri.file('asset1'), Uri.file('asset2')]);
}); });
test('assignLoadingUnits selects the needed loading units and sets assigned', () { testWithoutContext('assignLoadingUnits selects the needed loading units and sets assigned', () {
final DeferredComponent component = DeferredComponent( final DeferredComponent component = DeferredComponent(
name: 'bestcomponent', name: 'bestcomponent',
libraries: <String>['lib1', 'lib2'], libraries: <String>['lib1', 'lib2'],
...@@ -56,10 +53,10 @@ void main() { ...@@ -56,10 +53,10 @@ void main() {
component.assignLoadingUnits(loadingUnits1); component.assignLoadingUnits(loadingUnits1);
expect(component.assigned, true); expect(component.assigned, true);
expect(component.loadingUnits.length, 2); expect(component.loadingUnits, hasLength(2));
expect(component.loadingUnits.contains(loadingUnits1[0]), true); expect(component.loadingUnits, contains(loadingUnits1[0]));
expect(component.loadingUnits.contains(loadingUnits1[1]), true); expect(component.loadingUnits, contains(loadingUnits1[1]));
expect(component.loadingUnits.contains(loadingUnits1[2]), false); expect(component.loadingUnits, isNot(contains(loadingUnits1[2])));
final List<LoadingUnit> loadingUnits2 = <LoadingUnit>[ final List<LoadingUnit> loadingUnits2 = <LoadingUnit>[
LoadingUnit( LoadingUnit(
...@@ -82,18 +79,18 @@ void main() { ...@@ -82,18 +79,18 @@ void main() {
component.assignLoadingUnits(loadingUnits2); component.assignLoadingUnits(loadingUnits2);
expect(component.assigned, true); expect(component.assigned, true);
expect(component.loadingUnits.length, 1); expect(component.loadingUnits, hasLength(1));
expect(component.loadingUnits.contains(loadingUnits2[0]), true); expect(component.loadingUnits, contains(loadingUnits2[0]));
expect(component.loadingUnits.contains(loadingUnits2[1]), false); expect(component.loadingUnits, isNot(contains(loadingUnits2[1])));
expect(component.loadingUnits.contains(loadingUnits2[2]), false); expect(component.loadingUnits, isNot(contains(loadingUnits2[2])));
component.assignLoadingUnits(<LoadingUnit>[]); component.assignLoadingUnits(<LoadingUnit>[]);
expect(component.assigned, true); expect(component.assigned, true);
expect(component.loadingUnits.length, 0); expect(component.loadingUnits, hasLength(0));
}); });
test('toString produces correct string for unassigned component', () { testWithoutContext('toString produces correct string for unassigned component', () {
final DeferredComponent component = DeferredComponent( final DeferredComponent component = DeferredComponent(
name: 'bestcomponent', name: 'bestcomponent',
libraries: <String>['lib1', 'lib2'], libraries: <String>['lib1', 'lib2'],
...@@ -102,7 +99,7 @@ void main() { ...@@ -102,7 +99,7 @@ void main() {
expect(component.toString(), '\nDeferredComponent: bestcomponent\n Libraries:\n - lib1\n - lib2\n Assets:\n - asset1\n - asset2'); expect(component.toString(), '\nDeferredComponent: bestcomponent\n Libraries:\n - lib1\n - lib2\n Assets:\n - asset1\n - asset2');
}); });
test('toString produces correct string for assigned component', () { testWithoutContext('toString produces correct string for assigned component', () {
final DeferredComponent component = DeferredComponent( final DeferredComponent component = DeferredComponent(
name: 'bestcomponent', name: 'bestcomponent',
libraries: <String>['lib1', 'lib2'], libraries: <String>['lib1', 'lib2'],
...@@ -114,7 +111,7 @@ void main() { ...@@ -114,7 +111,7 @@ void main() {
}); });
group('LoadingUnit basics', () { group('LoadingUnit basics', () {
test('constructor sets values', () { testWithoutContext('constructor sets values', () {
final LoadingUnit unit = LoadingUnit( final LoadingUnit unit = LoadingUnit(
id: 2, id: 2,
path: 'path/to/so.so', path: 'path/to/so.so',
...@@ -125,7 +122,7 @@ void main() { ...@@ -125,7 +122,7 @@ void main() {
expect(unit.libraries, <String>['lib1', 'lib4']); expect(unit.libraries, <String>['lib1', 'lib4']);
}); });
test('toString produces correct string', () { testWithoutContext('toString produces correct string', () {
final LoadingUnit unit = LoadingUnit( final LoadingUnit unit = LoadingUnit(
id: 2, id: 2,
path: 'path/to/so.so', path: 'path/to/so.so',
...@@ -134,7 +131,7 @@ void main() { ...@@ -134,7 +131,7 @@ void main() {
expect(unit.toString(),'\nLoadingUnit 2\n Libraries:\n - lib1\n - lib4'); expect(unit.toString(),'\nLoadingUnit 2\n Libraries:\n - lib1\n - lib4');
}); });
test('equalsIgnoringPath works for various input', () { testWithoutContext('equalsIgnoringPath works for various input', () {
final LoadingUnit unit1 = LoadingUnit( final LoadingUnit unit1 = LoadingUnit(
id: 2, id: 2,
path: 'path/to/so.so', path: 'path/to/so.so',
...@@ -172,7 +169,7 @@ void main() { ...@@ -172,7 +169,7 @@ void main() {
expect(unit5.equalsIgnoringPath(unit6), false); expect(unit5.equalsIgnoringPath(unit6), false);
}); });
test('parseLoadingUnitManifest parses single manifest file', () { testWithoutContext('parseLoadingUnitManifest parses single manifest file', () {
final FileSystem fileSystem = MemoryFileSystem.test(); final FileSystem fileSystem = MemoryFileSystem.test();
final File manifest = fileSystem.file('/manifest.json'); final File manifest = fileSystem.file('/manifest.json');
manifest.createSync(recursive: true); manifest.createSync(recursive: true);
...@@ -202,7 +199,7 @@ void main() { ...@@ -202,7 +199,7 @@ void main() {
expect(loadingUnits[1].libraries[1], 'lib4'); expect(loadingUnits[1].libraries[1], 'lib4');
}); });
testUsingContext('parseLoadingUnitManifest returns empty when manifest is invalid JSON', () { testWithoutContext('parseLoadingUnitManifest returns empty when manifest is invalid JSON', () {
final FileSystem fileSystem = MemoryFileSystem.test(); final FileSystem fileSystem = MemoryFileSystem.test();
final File manifest = fileSystem.file('/manifest.json'); final File manifest = fileSystem.file('/manifest.json');
manifest.createSync(recursive: true); manifest.createSync(recursive: true);
...@@ -225,7 +222,7 @@ void main() { ...@@ -225,7 +222,7 @@ void main() {
expect(loadingUnits.isEmpty, true); expect(loadingUnits.isEmpty, true);
}); });
testUsingContext('parseLoadingUnitManifest does not exist', () { testWithoutContext('parseLoadingUnitManifest does not exist', () {
final FileSystem fileSystem = MemoryFileSystem.test(); final FileSystem fileSystem = MemoryFileSystem.test();
final File manifest = fileSystem.file('/manifest.json'); final File manifest = fileSystem.file('/manifest.json');
if (manifest.existsSync()) { if (manifest.existsSync()) {
...@@ -236,7 +233,7 @@ void main() { ...@@ -236,7 +233,7 @@ void main() {
expect(loadingUnits.isEmpty, true); expect(loadingUnits.isEmpty, true);
}); });
test('parseGeneratedLoadingUnits parses all abis if no abis provided', () { testWithoutContext('parseGeneratedLoadingUnits parses all abis if no abis provided', () {
final FileSystem fileSystem = MemoryFileSystem.test(); final FileSystem fileSystem = MemoryFileSystem.test();
final File manifest1 = fileSystem.file('/test-abi1/manifest.json'); final File manifest1 = fileSystem.file('/test-abi1/manifest.json');
manifest1.createSync(recursive: true); manifest1.createSync(recursive: true);
...@@ -293,7 +290,7 @@ void main() { ...@@ -293,7 +290,7 @@ void main() {
expect(loadingUnits[3].libraries[1], 'lib4'); expect(loadingUnits[3].libraries[1], 'lib4');
}); });
test('parseGeneratedLoadingUnits only parses provided abis', () { testWithoutContext('parseGeneratedLoadingUnits only parses provided abis', () {
final FileSystem fileSystem = MemoryFileSystem.test(); final FileSystem fileSystem = MemoryFileSystem.test();
final File manifest1 = fileSystem.file('/test-abi1/manifest.json'); final File manifest1 = fileSystem.file('/test-abi1/manifest.json');
manifest1.createSync(recursive: true); manifest1.createSync(recursive: true);
...@@ -340,7 +337,7 @@ void main() { ...@@ -340,7 +337,7 @@ void main() {
expect(loadingUnits[1].libraries[1], 'lib4'); expect(loadingUnits[1].libraries[1], 'lib4');
}); });
test('parseGeneratedLoadingUnits returns empty when no manifest files exist', () { testWithoutContext('parseGeneratedLoadingUnits returns empty when no manifest files exist', () {
final FileSystem fileSystem = MemoryFileSystem.test(); final FileSystem fileSystem = MemoryFileSystem.test();
final List<LoadingUnit> loadingUnits = final List<LoadingUnit> loadingUnits =
LoadingUnit.parseGeneratedLoadingUnits(fileSystem.directory('/'), BufferLogger.test()); LoadingUnit.parseGeneratedLoadingUnits(fileSystem.directory('/'), BufferLogger.test());
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:async'; import 'dart:async';
import 'dart:io' as io; import 'dart:io' as io;
...@@ -15,12 +13,11 @@ import 'package:flutter_tools/src/base/signals.dart'; ...@@ -15,12 +13,11 @@ import 'package:flutter_tools/src/base/signals.dart';
import 'package:test/fake.dart'; import 'package:test/fake.dart';
import '../../src/common.dart'; import '../../src/common.dart';
import '../../src/context.dart';
void main() { void main() {
group('fsUtils', () { group('fsUtils', () {
MemoryFileSystem fs; late MemoryFileSystem fs;
FileSystemUtils fsUtils; late FileSystemUtils fsUtils;
setUp(() { setUp(() {
fs = MemoryFileSystem.test(); fs = MemoryFileSystem.test();
...@@ -129,15 +126,15 @@ void main() { ...@@ -129,15 +126,15 @@ void main() {
}); });
group('LocalFileSystem', () { group('LocalFileSystem', () {
FakeProcessSignal fakeSignal; late FakeProcessSignal fakeSignal;
ProcessSignal signalUnderTest; late ProcessSignal signalUnderTest;
setUp(() { setUp(() {
fakeSignal = FakeProcessSignal(); fakeSignal = FakeProcessSignal();
signalUnderTest = ProcessSignal(fakeSignal); signalUnderTest = ProcessSignal(fakeSignal);
}); });
testUsingContext('deletes system temp entry on a fatal signal', () async { testWithoutContext('deletes system temp entry on a fatal signal', () async {
final Completer<void> completer = Completer<void>(); final Completer<void> completer = Completer<void>();
final Signals signals = Signals.test(); final Signals signals = Signals.test();
final LocalFileSystem localFileSystem = LocalFileSystem.test( final LocalFileSystem localFileSystem = LocalFileSystem.test(
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:convert' show json; import 'dart:convert' show json;
import 'package:file/memory.dart'; import 'package:file/memory.dart';
...@@ -12,9 +10,10 @@ import 'package:flutter_tools/src/base/logger.dart'; ...@@ -12,9 +10,10 @@ import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/utils.dart'; import 'package:flutter_tools/src/base/utils.dart';
import '../../src/common.dart'; import '../../src/common.dart';
void main() { void main() {
group('Fingerprinter', () { group('Fingerprinter', () {
MemoryFileSystem fileSystem; late MemoryFileSystem fileSystem;
setUp(() { setUp(() {
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
...@@ -85,7 +84,7 @@ void main() { ...@@ -85,7 +84,7 @@ void main() {
group('Fingerprint', () { group('Fingerprint', () {
group('fromBuildInputs', () { group('fromBuildInputs', () {
MemoryFileSystem fileSystem; late MemoryFileSystem fileSystem;
setUp(() { setUp(() {
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
...@@ -104,8 +103,8 @@ void main() { ...@@ -104,8 +103,8 @@ void main() {
fileSystem.file('b.dart').writeAsStringSync('This is b'); fileSystem.file('b.dart').writeAsStringSync('This is b');
final Fingerprint fingerprint = Fingerprint.fromBuildInputs(const <String>['a.dart', 'b.dart'], fileSystem); final Fingerprint fingerprint = Fingerprint.fromBuildInputs(const <String>['a.dart', 'b.dart'], fileSystem);
final Map<String, dynamic> jsonObject = castStringKeyedMap(json.decode(fingerprint.toJson())); final Map<String, dynamic>? jsonObject = castStringKeyedMap(json.decode(fingerprint.toJson()));
expect(jsonObject['files'], hasLength(2)); expect(jsonObject!['files'], hasLength(2));
expect(jsonObject['files']['a.dart'], '8a21a15fad560b799f6731d436c1b698'); expect(jsonObject['files']['a.dart'], '8a21a15fad560b799f6731d436c1b698');
expect(jsonObject['files']['b.dart'], '6f144e08b58cd0925328610fad7ac07c'); expect(jsonObject['files']['b.dart'], '6f144e08b58cd0925328610fad7ac07c');
}); });
...@@ -124,9 +123,9 @@ void main() { ...@@ -124,9 +123,9 @@ void main() {
}, },
}); });
final Fingerprint fingerprint = Fingerprint.fromJson(jsonString); final Fingerprint fingerprint = Fingerprint.fromJson(jsonString);
final Map<String, dynamic> content = castStringKeyedMap(json.decode(fingerprint.toJson())); final Map<String, dynamic>? content = castStringKeyedMap(json.decode(fingerprint.toJson()));
expect(content, hasLength(1)); expect(content, hasLength(1));
expect(content['files'], hasLength(2)); expect(content!['files'], hasLength(2));
expect(content['files']['a.dart'], '8a21a15fad560b799f6731d436c1b698'); expect(content['files']['a.dart'], '8a21a15fad560b799f6731d436c1b698');
expect(content['files']['b.dart'], '6f144e08b58cd0925328610fad7ac07c'); expect(content['files']['b.dart'], '6f144e08b58cd0925328610fad7ac07c');
}); });
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:async'; import 'dart:async';
import 'dart:io' as io; import 'dart:io' as io;
...@@ -13,11 +11,10 @@ import 'package:flutter_tools/src/base/platform.dart'; ...@@ -13,11 +11,10 @@ import 'package:flutter_tools/src/base/platform.dart';
import 'package:test/fake.dart'; import 'package:test/fake.dart';
import '../../src/common.dart'; import '../../src/common.dart';
import '../../src/context.dart';
import '../../src/io.dart'; import '../../src/io.dart';
void main() { void main() {
test('IOOverrides can inject a memory file system', () async { testWithoutContext('IOOverrides can inject a memory file system', () async {
final MemoryFileSystem memoryFileSystem = MemoryFileSystem.test(); final MemoryFileSystem memoryFileSystem = MemoryFileSystem.test();
final FlutterIOOverrides flutterIOOverrides = FlutterIOOverrides(fileSystem: memoryFileSystem); final FlutterIOOverrides flutterIOOverrides = FlutterIOOverrides(fileSystem: memoryFileSystem);
await io.IOOverrides.runWithIOOverrides(() async { await io.IOOverrides.runWithIOOverrides(() async {
...@@ -57,7 +54,8 @@ void main() { ...@@ -57,7 +54,8 @@ void main() {
expect(memoryFileSystem.link('ggg').resolveSymbolicLinksSync(), linkB.resolveSymbolicLinksSync()); expect(memoryFileSystem.link('ggg').resolveSymbolicLinksSync(), linkB.resolveSymbolicLinksSync());
}, flutterIOOverrides); }, flutterIOOverrides);
}); });
testUsingContext('ProcessSignal signals are properly delegated', () async {
testWithoutContext('ProcessSignal signals are properly delegated', () async {
final FakeProcessSignal signal = FakeProcessSignal(); final FakeProcessSignal signal = FakeProcessSignal();
final ProcessSignal signalUnderTest = ProcessSignal(signal); final ProcessSignal signalUnderTest = ProcessSignal(signal);
...@@ -66,15 +64,15 @@ void main() { ...@@ -66,15 +64,15 @@ void main() {
expect(signalUnderTest, await signalUnderTest.watch().first); expect(signalUnderTest, await signalUnderTest.watch().first);
}); });
testUsingContext('ProcessSignal toString() works', () async { testWithoutContext('ProcessSignal toString() works', () async {
expect(io.ProcessSignal.sigint.toString(), ProcessSignal.sigint.toString()); expect(io.ProcessSignal.sigint.toString(), ProcessSignal.sigint.toString());
}); });
test('exit throws a StateError if called without being overriden', () { testWithoutContext('exit throws a StateError if called without being overriden', () {
expect(() => exit(0), throwsAssertionError); expect(() => exit(0), throwsAssertionError);
}); });
test('exit does not throw a StateError if overriden', () { testWithoutContext('exit does not throw a StateError if overriden', () {
try { try {
setExitFunctionForTests((int value) {}); setExitFunctionForTests((int value) {});
...@@ -84,16 +82,16 @@ void main() { ...@@ -84,16 +82,16 @@ void main() {
} }
}); });
test('test_api defines the Declarer in a known place', () { testWithoutContext('test_api defines the Declarer in a known place', () {
expect(Zone.current[#test.declarer], isNotNull); expect(Zone.current[#test.declarer], isNotNull);
}); });
test('listNetworkInterfaces() uses overrides', () async { testWithoutContext('listNetworkInterfaces() uses overrides', () async {
setNetworkInterfaceLister( setNetworkInterfaceLister(
({ ({
bool includeLoopback, bool? includeLoopback,
bool includeLinkLocal, bool? includeLinkLocal,
InternetAddressType type, InternetAddressType? type,
}) async => <NetworkInterface>[], }) async => <NetworkInterface>[],
); );
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:convert'; import 'dart:convert';
import 'package:file/file.dart'; import 'package:file/file.dart';
...@@ -20,7 +18,7 @@ import '../../src/common.dart'; ...@@ -20,7 +18,7 @@ import '../../src/common.dart';
import '../../src/fake_http_client.dart'; import '../../src/fake_http_client.dart';
void main() { void main() {
BufferLogger testLogger; late BufferLogger testLogger;
setUp(() { setUp(() {
testLogger = BufferLogger.test(); testLogger = BufferLogger.test();
...@@ -36,7 +34,7 @@ void main() { ...@@ -36,7 +34,7 @@ void main() {
group('successful fetch', () { group('successful fetch', () {
const String responseString = 'response string'; const String responseString = 'response string';
List<int> responseData; late List<int> responseData;
setUp(() { setUp(() {
responseData = utf8.encode(responseString); responseData = utf8.encode(responseString);
...@@ -51,7 +49,7 @@ void main() { ...@@ -51,7 +49,7 @@ void main() {
]) ])
); );
final List<int> data = await net.fetchUrl(Uri.parse('http://example.invalid/')); final List<int>? data = await net.fetchUrl(Uri.parse('http://example.invalid/'));
expect(data, equals(responseData)); expect(data, equals(responseData));
}); });
...@@ -65,7 +63,7 @@ void main() { ...@@ -65,7 +63,7 @@ void main() {
); );
final MemoryFileSystem fileSystem = MemoryFileSystem.test(); final MemoryFileSystem fileSystem = MemoryFileSystem.test();
final File destFile = fileSystem.file('dest_file')..createSync(); final File destFile = fileSystem.file('dest_file')..createSync();
final List<int> data = await net.fetchUrl( final List<int>? data = await net.fetchUrl(
Uri.parse('http://example.invalid/'), Uri.parse('http://example.invalid/'),
destFile: destFile, destFile: destFile,
); );
...@@ -127,9 +125,9 @@ void main() { ...@@ -127,9 +125,9 @@ void main() {
FakeRequest(invalid, responseError: const io.SocketException('')), FakeRequest(invalid, responseError: const io.SocketException('')),
]) ])
); );
String error; String? error;
FakeAsync().run((FakeAsync time) { FakeAsync().run((FakeAsync time) {
net.fetchUrl(invalid).then((List<int> value) { net.fetchUrl(invalid).then((List<int>? value) async {
error = 'test completed unexpectedly'; error = 'test completed unexpectedly';
}, onError: (dynamic exception) { }, onError: (dynamic exception) {
error = 'test failed unexpectedly: $exception'; error = 'test failed unexpectedly: $exception';
...@@ -158,9 +156,9 @@ void main() { ...@@ -158,9 +156,9 @@ void main() {
FakeRequest(invalid, responseError: const io.HandshakeException('')), FakeRequest(invalid, responseError: const io.HandshakeException('')),
]) ])
); );
String error; String? error;
FakeAsync().run((FakeAsync time) { FakeAsync().run((FakeAsync time) {
net.fetchUrl(invalid).then((List<int> value) { net.fetchUrl(invalid).then((List<int>? value) async {
error = 'test completed unexpectedly'; error = 'test completed unexpectedly';
}, onError: (dynamic exception) { }, onError: (dynamic exception) {
error = 'test failed: $exception'; error = 'test failed: $exception';
...@@ -188,9 +186,9 @@ void main() { ...@@ -188,9 +186,9 @@ void main() {
}, },
), ),
); );
String error; String? error;
FakeAsync().run((FakeAsync time) { FakeAsync().run((FakeAsync time) {
net.fetchUrl(Uri.parse('example.invalid/')).then((List<int> value) { net.fetchUrl(Uri.parse('example.invalid/')).then((List<int>? value) async {
error = 'test completed unexpectedly'; error = 'test completed unexpectedly';
}, onError: (dynamic exception) { }, onError: (dynamic exception) {
error = 'test failed: $exception'; error = 'test failed: $exception';
...@@ -214,9 +212,9 @@ void main() { ...@@ -214,9 +212,9 @@ void main() {
FakeRequest(invalid, responseError: const io.HttpException('')), FakeRequest(invalid, responseError: const io.HttpException('')),
]) ])
); );
String error; String? error;
FakeAsync().run((FakeAsync time) { FakeAsync().run((FakeAsync time) {
net.fetchUrl(invalid).then((List<int> value) { net.fetchUrl(invalid).then((List<int>? value) async {
error = 'test completed unexpectedly'; error = 'test completed unexpectedly';
}, onError: (dynamic exception) { }, onError: (dynamic exception) {
error = 'test failed unexpectedly: $exception'; error = 'test failed unexpectedly: $exception';
...@@ -245,9 +243,9 @@ void main() { ...@@ -245,9 +243,9 @@ void main() {
FakeRequest(invalid, responseError: const io.HttpException('')), FakeRequest(invalid, responseError: const io.HttpException('')),
]) ])
); );
String error; String? error;
FakeAsync().run((FakeAsync time) { FakeAsync().run((FakeAsync time) {
net.fetchUrl(invalid).then((List<int> value) { net.fetchUrl(invalid).then((List<int>? value) async {
error = 'test completed unexpectedly'; error = 'test completed unexpectedly';
}, onError: (dynamic exception) { }, onError: (dynamic exception) {
error = 'test failed unexpectedly: $exception'; error = 'test failed unexpectedly: $exception';
...@@ -281,10 +279,10 @@ void main() { ...@@ -281,10 +279,10 @@ void main() {
)), )),
]) ])
); );
String error; String? error;
List<int> actualResult; List<int>? actualResult;
FakeAsync().run((FakeAsync time) { FakeAsync().run((FakeAsync time) {
net.fetchUrl(invalid, maxAttempts: 3).then((List<int> value) { net.fetchUrl(invalid, maxAttempts: 3).then((List<int>? value) async {
actualResult = value; actualResult = value;
}, onError: (dynamic exception) { }, onError: (dynamic exception) {
error = 'test failed unexpectedly: $exception'; error = 'test failed unexpectedly: $exception';
......
...@@ -13,7 +13,7 @@ import 'package:flutter_tools/src/base/os.dart'; ...@@ -13,7 +13,7 @@ import 'package:flutter_tools/src/base/os.dart';
import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/platform.dart';
import '../../src/common.dart'; import '../../src/common.dart';
import '../../src/context.dart'; import '../../src/fake_process_manager.dart';
const String kExecutable = 'foo'; const String kExecutable = 'foo';
const String kPath1 = '/bar/bin/$kExecutable'; const String kPath1 = '/bar/bin/$kExecutable';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/os.dart'; import 'package:flutter_tools/src/base/os.dart';
...@@ -15,8 +13,8 @@ import '../../src/common.dart'; ...@@ -15,8 +13,8 @@ import '../../src/common.dart';
void main() { void main() {
group('OperatingSystemUtils', () { group('OperatingSystemUtils', () {
Directory tempDir; late Directory tempDir;
FileSystem fileSystem; late FileSystem fileSystem;
setUp(() { setUp(() {
fileSystem = LocalFileSystem.test(signals: Signals.test()); fileSystem = LocalFileSystem.test(signals: Signals.test());
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/platform.dart';
import '../../src/common.dart'; import '../../src/common.dart';
...@@ -26,8 +24,8 @@ void _expectPlatformsEqual(Platform actual, Platform expected) { ...@@ -26,8 +24,8 @@ void _expectPlatformsEqual(Platform actual, Platform expected) {
void main() { void main() {
group('FakePlatform.fromPlatform', () { group('FakePlatform.fromPlatform', () {
FakePlatform fake; late FakePlatform fake;
LocalPlatform local; late LocalPlatform local;
setUp(() { setUp(() {
local = const LocalPlatform(); local = const LocalPlatform();
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:async'; import 'dart:async';
import 'dart:io' as io; import 'dart:io' as io;
...@@ -15,9 +13,9 @@ import '../../src/common.dart'; ...@@ -15,9 +13,9 @@ import '../../src/common.dart';
void main() { void main() {
group('Signals', () { group('Signals', () {
Signals signals; late Signals signals;
FakeProcessSignal fakeSignal; late FakeProcessSignal fakeSignal;
ProcessSignal signalUnderTest; late ProcessSignal signalUnderTest;
setUp(() { setUp(() {
signals = Signals.test(); signals = Signals.test();
...@@ -58,7 +56,7 @@ void main() { ...@@ -58,7 +56,7 @@ void main() {
testWithoutContext('signal handlers do not cause concurrent modification errors when removing handlers in a signal callback', () async { testWithoutContext('signal handlers do not cause concurrent modification errors when removing handlers in a signal callback', () async {
final Completer<void> completer = Completer<void>(); final Completer<void> completer = Completer<void>();
Object token; late Object token;
Future<void> handle(ProcessSignal s) async { Future<void> handle(ProcessSignal s) async {
expect(s, signalUnderTest); expect(s, signalUnderTest);
expect(await signals.removeHandler(signalUnderTest, token), true); expect(await signals.removeHandler(signalUnderTest, token), true);
...@@ -73,7 +71,7 @@ void main() { ...@@ -73,7 +71,7 @@ void main() {
testWithoutContext('signal handler error goes on error stream', () async { testWithoutContext('signal handler error goes on error stream', () async {
final Exception exn = Exception('Error'); final Exception exn = Exception('Error');
signals.addHandler(signalUnderTest, (ProcessSignal s) { signals.addHandler(signalUnderTest, (ProcessSignal s) async {
throw exn; throw exn;
}); });
...@@ -95,7 +93,7 @@ void main() { ...@@ -95,7 +93,7 @@ void main() {
testWithoutContext('removed signal handler does not run', () async { testWithoutContext('removed signal handler does not run', () async {
final Object token = signals.addHandler( final Object token = signals.addHandler(
signalUnderTest, signalUnderTest,
(ProcessSignal s) { (ProcessSignal s) async {
fail('Signal handler should have been removed.'); fail('Signal handler should have been removed.');
}, },
); );
...@@ -124,7 +122,7 @@ void main() { ...@@ -124,7 +122,7 @@ void main() {
final Object token = signals.addHandler( final Object token = signals.addHandler(
signalUnderTest, signalUnderTest,
(ProcessSignal s) { (ProcessSignal s) async {
fail('Signal handler should have been removed.'); fail('Signal handler should have been removed.');
}, },
); );
...@@ -153,7 +151,7 @@ void main() { ...@@ -153,7 +151,7 @@ void main() {
completer.complete(); completer.complete();
}); });
signals.addHandler(otherSignal, (ProcessSignal s) { signals.addHandler(otherSignal, (ProcessSignal s) async {
fail('Wrong signal!.'); fail('Wrong signal!.');
}); });
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/platform.dart';
...@@ -37,7 +35,7 @@ void main() { ...@@ -37,7 +35,7 @@ void main() {
}); });
group('ANSI coloring and bold', () { group('ANSI coloring and bold', () {
AnsiTerminal terminal; late AnsiTerminal terminal;
setUp(() { setUp(() {
terminal = AnsiTerminal( terminal = AnsiTerminal(
...@@ -108,7 +106,7 @@ void main() { ...@@ -108,7 +106,7 @@ void main() {
}); });
group('character input prompt', () { group('character input prompt', () {
AnsiTerminal terminalUnderTest; late AnsiTerminal terminalUnderTest;
setUp(() { setUp(() {
terminalUnderTest = TestTerminal(stdio: FakeStdio()); terminalUnderTest = TestTerminal(stdio: FakeStdio());
...@@ -118,7 +116,7 @@ void main() { ...@@ -118,7 +116,7 @@ void main() {
expect(terminalUnderTest.promptForCharInput( expect(terminalUnderTest.promptForCharInput(
<String>['a', 'b', 'c'], <String>['a', 'b', 'c'],
prompt: 'Please choose something', prompt: 'Please choose something',
logger: null, logger: BufferLogger.test(),
), throwsStateError); ), throwsStateError);
}); });
...@@ -183,13 +181,13 @@ void main() { ...@@ -183,13 +181,13 @@ void main() {
}); });
} }
Stream<String> mockStdInStream; late Stream<String> mockStdInStream;
class TestTerminal extends AnsiTerminal { class TestTerminal extends AnsiTerminal {
TestTerminal({ TestTerminal({
Stdio stdio, Stdio? stdio,
Platform platform = const LocalPlatform(), Platform platform = const LocalPlatform(),
}) : super(stdio: stdio, platform: platform); }) : super(stdio: stdio ?? Stdio(), platform: platform);
@override @override
Stream<String> get keystrokes { Stream<String> get keystrokes {
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/user_messages.dart'; import 'package:flutter_tools/src/base/user_messages.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:convert'; import 'dart:convert';
import 'dart:typed_data'; import 'dart:typed_data';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment