Unverified Commit 0a600e1d authored by Dan Field's avatar Dan Field Committed by GitHub

Fix tool test order (#48735)

parent 8b6b3b62
...@@ -25,7 +25,6 @@ import '../../src/mocks.dart'; ...@@ -25,7 +25,6 @@ import '../../src/mocks.dart';
void main() { void main() {
group('drive', () { group('drive', () {
DriveCommand command; DriveCommand command;
Device mockDevice;
Device mockUnsupportedDevice; Device mockUnsupportedDevice;
MemoryFileSystem fs; MemoryFileSystem fs;
Directory tempDir; Directory tempDir;
...@@ -249,7 +248,7 @@ void main() { ...@@ -249,7 +248,7 @@ void main() {
group('findTargetDevice', () { group('findTargetDevice', () {
testUsingContext('uses specified device', () async { testUsingContext('uses specified device', () async {
testDeviceManager.specifiedDeviceId = '123'; testDeviceManager.specifiedDeviceId = '123';
mockDevice = MockDevice(); final Device mockDevice = MockDevice();
testDeviceManager.addDevice(mockDevice); testDeviceManager.addDevice(mockDevice);
when(mockDevice.name).thenReturn('specified-device'); when(mockDevice.name).thenReturn('specified-device');
when(mockDevice.id).thenReturn('123'); when(mockDevice.id).thenReturn('123');
...@@ -274,7 +273,7 @@ void main() { ...@@ -274,7 +273,7 @@ void main() {
}); });
testUsingContext('uses existing Android device', () async { testUsingContext('uses existing Android device', () async {
mockDevice = MockAndroidDevice(); final Device mockDevice = MockAndroidDevice();
when(mockDevice.name).thenReturn('mock-android-device'); when(mockDevice.name).thenReturn('mock-android-device');
testDeviceManager.addDevice(mockDevice); testDeviceManager.addDevice(mockDevice);
...@@ -287,7 +286,7 @@ void main() { ...@@ -287,7 +286,7 @@ void main() {
}); });
testUsingContext('skips unsupported device', () async { testUsingContext('skips unsupported device', () async {
mockDevice = MockAndroidDevice(); final Device mockDevice = MockAndroidDevice();
mockUnsupportedDevice = MockDevice(); mockUnsupportedDevice = MockDevice();
when(mockUnsupportedDevice.isSupportedForProject(any)) when(mockUnsupportedDevice.isSupportedForProject(any))
.thenReturn(false); .thenReturn(false);
...@@ -333,6 +332,7 @@ void main() { ...@@ -333,6 +332,7 @@ void main() {
Platform macOsPlatform() => FakePlatform(operatingSystem: 'macos'); Platform macOsPlatform() => FakePlatform(operatingSystem: 'macos');
testUsingContext('uses existing simulator', () async { testUsingContext('uses existing simulator', () async {
final Device mockDevice = MockDevice();
testDeviceManager.addDevice(mockDevice); testDeviceManager.addDevice(mockDevice);
when(mockDevice.name).thenReturn('mock-simulator'); when(mockDevice.name).thenReturn('mock-simulator');
when(mockDevice.isLocalEmulator) when(mockDevice.isLocalEmulator)
...@@ -354,8 +354,8 @@ void main() { ...@@ -354,8 +354,8 @@ void main() {
restoreAppStarter(); restoreAppStarter();
}); });
Future<void> appStarterSetup() async { Future<Device> appStarterSetup() async {
mockDevice = MockDevice(); final Device mockDevice = MockDevice();
testDeviceManager.addDevice(mockDevice); testDeviceManager.addDevice(mockDevice);
final MockDeviceLogReader mockDeviceLogReader = MockDeviceLogReader(); final MockDeviceLogReader mockDeviceLogReader = MockDeviceLogReader();
...@@ -388,10 +388,11 @@ void main() { ...@@ -388,10 +388,11 @@ void main() {
final MemoryFileSystem memFs = fs; final MemoryFileSystem memFs = fs;
await memFs.file(testApp).writeAsString('main() {}'); await memFs.file(testApp).writeAsString('main() {}');
await memFs.file(testFile).writeAsString('main() {}'); await memFs.file(testFile).writeAsString('main() {}');
return mockDevice;
} }
testUsingContext('does not use pre-built app if no build arg provided', () async { testUsingContext('does not use pre-built app if no build arg provided', () async {
await appStarterSetup(); final Device mockDevice = await appStarterSetup();
final List<String> args = <String>[ final List<String> args = <String>[
'drive', 'drive',
...@@ -418,7 +419,7 @@ void main() { ...@@ -418,7 +419,7 @@ void main() {
}); });
testUsingContext('does not use pre-built app if --build arg provided', () async { testUsingContext('does not use pre-built app if --build arg provided', () async {
await appStarterSetup(); final Device mockDevice = await appStarterSetup();
final List<String> args = <String>[ final List<String> args = <String>[
'drive', 'drive',
...@@ -446,7 +447,7 @@ void main() { ...@@ -446,7 +447,7 @@ void main() {
}); });
testUsingContext('uses prebuilt app if --no-build arg provided', () async { testUsingContext('uses prebuilt app if --no-build arg provided', () async {
await appStarterSetup(); final Device mockDevice = await appStarterSetup();
final List<String> args = <String>[ final List<String> args = <String>[
'drive', 'drive',
...@@ -483,8 +484,8 @@ void main() { ...@@ -483,8 +484,8 @@ void main() {
restoreAppStarter(); restoreAppStarter();
}); });
Future<void> appStarterSetup() async { Future<Device> appStarterSetup() async {
mockDevice = MockDevice(); final Device mockDevice = MockDevice();
testDeviceManager.addDevice(mockDevice); testDeviceManager.addDevice(mockDevice);
final MockDeviceLogReader mockDeviceLogReader = MockDeviceLogReader(); final MockDeviceLogReader mockDeviceLogReader = MockDeviceLogReader();
...@@ -521,6 +522,7 @@ void main() { ...@@ -521,6 +522,7 @@ void main() {
final MemoryFileSystem memFs = fs; final MemoryFileSystem memFs = fs;
await memFs.file(testApp).writeAsString('main() {}'); await memFs.file(testApp).writeAsString('main() {}');
await memFs.file(testFile).writeAsString('main() {}'); await memFs.file(testFile).writeAsString('main() {}');
return mockDevice;
} }
void _testOptionThatDefaultsToFalse( void _testOptionThatDefaultsToFalse(
...@@ -529,7 +531,7 @@ void main() { ...@@ -529,7 +531,7 @@ void main() {
bool optionValue(), bool optionValue(),
) { ) {
testUsingContext('$optionName ${setToTrue ? 'works' : 'defaults to false'}', () async { testUsingContext('$optionName ${setToTrue ? 'works' : 'defaults to false'}', () async {
await appStarterSetup(); final Device mockDevice = await appStarterSetup();
final List<String> args = <String>[ final List<String> args = <String>[
'drive', 'drive',
......
...@@ -35,6 +35,7 @@ void main() { ...@@ -35,6 +35,7 @@ void main() {
setUpAll(() { setUpAll(() {
Cache.disableLocking(); Cache.disableLocking();
Cache.flutterRoot = FlutterCommandRunner.defaultFlutterRoot;
}); });
setUp(() { setUp(() {
......
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