diff --git a/packages/flutter_tools/test/ios/cocoapods_test.dart b/packages/flutter_tools/test/ios/cocoapods_test.dart index 825bbe4bef..5b376754c3 100644 --- a/packages/flutter_tools/test/ios/cocoapods_test.dart +++ b/packages/flutter_tools/test/ios/cocoapods_test.dart @@ -47,7 +47,7 @@ void main() { ['pod', 'install', '--verbose'], workingDirectory: 'project/ios', environment: {'FLUTTER_FRAMEWORK_DIR': 'engine/path', 'COCOAPODS_DISABLE_STATS': 'true'}, - )).thenReturn(exitsHappy); + )).thenAnswer((_) => new Future.value(exitsHappy)); }); group('Setup Podfile', () { @@ -177,7 +177,7 @@ void main() { 'FLUTTER_FRAMEWORK_DIR': 'engine/path', 'COCOAPODS_DISABLE_STATS': 'true', }, - )).thenReturn(new ProcessResult( + )).thenAnswer((_) => new Future.value(new ProcessResult( 1, 1, ''' @@ -195,7 +195,7 @@ You have either: Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default.''', '', - )); + ))); try { await cocoaPodsUnderTest.processPods( appIosDirectory: projectUnderTest, @@ -360,7 +360,11 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by 'FLUTTER_FRAMEWORK_DIR': 'engine/path', 'COCOAPODS_DISABLE_STATS': 'true', }, - )).thenReturn(new ProcessResult(1, 1, 'fails for some reason', '')); + )).thenAnswer( + (_) => new Future.value( + new ProcessResult(1, 1, 'fails for some reason', '') + ) + ); try { await cocoaPodsUnderTest.processPods( diff --git a/packages/flutter_tools/test/ios/code_signing_test.dart b/packages/flutter_tools/test/ios/code_signing_test.dart index 015eb1d1b8..5137b30a38 100644 --- a/packages/flutter_tools/test/ios/code_signing_test.dart +++ b/packages/flutter_tools/test/ios/code_signing_test.dart @@ -189,7 +189,7 @@ void main() { )) )); when(mockOpenSslProcess.stderr).thenAnswer((Invocation invocation) => mockOpenSslStdErr); - when(mockOpenSslProcess.exitCode).thenReturn(0); + when(mockOpenSslProcess.exitCode).thenAnswer((_) => new Future.value(0)); final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam(iosApp: app); @@ -259,7 +259,7 @@ void main() { )), )); when(mockOpenSslProcess.stderr).thenAnswer((Invocation invocation) => mockOpenSslStdErr); - when(mockOpenSslProcess.exitCode).thenReturn(0); + when(mockOpenSslProcess.exitCode).thenAnswer((_) => new Future.value(0)); final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam(iosApp: app, usesTerminalUi: false); @@ -321,7 +321,7 @@ void main() { )) )); when(mockOpenSslProcess.stderr).thenAnswer((Invocation invocation) => mockOpenSslStdErr); - when(mockOpenSslProcess.exitCode).thenReturn(0); + when(mockOpenSslProcess.exitCode).thenAnswer((_) => new Future.value(0)); when(mockConfig.getValue('ios-signing-cert')).thenReturn('iPhone Developer: Profile 3 (3333CCCC33)'); final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam(iosApp: app); @@ -390,7 +390,7 @@ void main() { )) )); when(mockOpenSslProcess.stderr).thenAnswer((Invocation invocation) => mockOpenSslStdErr); - when(mockOpenSslProcess.exitCode).thenReturn(0); + when(mockOpenSslProcess.exitCode).thenAnswer((_) => new Future.value(0)); when(mockConfig.getValue('ios-signing-cert')).thenReturn('iPhone Developer: Invalid Profile'); final String developmentTeam = await getCodeSigningIdentityDevelopmentTeam(iosApp: app); diff --git a/packages/flutter_tools/test/ios/devices_test.dart b/packages/flutter_tools/test/ios/devices_test.dart index 099e7afdea..8d3c06e6d4 100644 --- a/packages/flutter_tools/test/ios/devices_test.dart +++ b/packages/flutter_tools/test/ios/devices_test.dart @@ -59,10 +59,14 @@ void main() { 98206e7a4afd4aedaff06e687594e089dede3c44 f577a7903cc54959be2e34bc4f7f80b7009efcf4 ''')); - when(iMobileDevice.getInfoForDevice('98206e7a4afd4aedaff06e687594e089dede3c44', 'DeviceName')).thenReturn('La tele me regarde'); - when(iMobileDevice.getInfoForDevice('98206e7a4afd4aedaff06e687594e089dede3c44', 'ProductVersion')).thenReturn('10.3.2'); - when(iMobileDevice.getInfoForDevice('f577a7903cc54959be2e34bc4f7f80b7009efcf4', 'DeviceName')).thenReturn('Puits sans fond'); - when(iMobileDevice.getInfoForDevice('f577a7903cc54959be2e34bc4f7f80b7009efcf4', 'ProductVersion')).thenReturn('11.0'); + when(iMobileDevice.getInfoForDevice('98206e7a4afd4aedaff06e687594e089dede3c44', 'DeviceName')) + .thenAnswer((_) => new Future.value('La tele me regarde')); + when(iMobileDevice.getInfoForDevice('98206e7a4afd4aedaff06e687594e089dede3c44', 'ProductVersion')) + .thenAnswer((_) => new Future.value('10.3.2')); + when(iMobileDevice.getInfoForDevice('f577a7903cc54959be2e34bc4f7f80b7009efcf4', 'DeviceName')) + .thenAnswer((_) => new Future.value('Puits sans fond')); + when(iMobileDevice.getInfoForDevice('f577a7903cc54959be2e34bc4f7f80b7009efcf4', 'ProductVersion')) + .thenAnswer((_) => new Future.value('11.0')); final List devices = await IOSDevice.getAttachedDevices(); expect(devices, hasLength(2)); expect(devices[0].id, '98206e7a4afd4aedaff06e687594e089dede3c44'); diff --git a/packages/flutter_tools/test/ios/ios_workflow_test.dart b/packages/flutter_tools/test/ios/ios_workflow_test.dart index 29c1ad69de..62d7e0fdf7 100644 --- a/packages/flutter_tools/test/ios/ios_workflow_test.dart +++ b/packages/flutter_tools/test/ios/ios_workflow_test.dart @@ -33,8 +33,10 @@ void main() { cocoaPods = new MockCocoaPods(); fs = new MemoryFileSystem(); - when(cocoaPods.isCocoaPodsInstalledAndMeetsVersionCheck).thenReturn(true); - when(cocoaPods.isCocoaPodsInitialized).thenReturn(true); + when(cocoaPods.isCocoaPodsInstalledAndMeetsVersionCheck) + .thenAnswer((_) => new Future.value(true)); + when(cocoaPods.isCocoaPodsInitialized) + .thenAnswer((_) => new Future.value(true)); }); testUsingContext('Emit missing status when nothing is installed', () async { @@ -227,8 +229,9 @@ void main() { .thenReturn('Xcode 8.2.1\nBuild version 8C1002\n'); when(xcode.isInstalledAndMeetsVersionCheck).thenReturn(true); when(xcode.eulaSigned).thenReturn(true); - when(cocoaPods.isCocoaPodsInstalledAndMeetsVersionCheck).thenReturn(false); - when(cocoaPods.hasCocoaPods).thenReturn(false); + when(cocoaPods.isCocoaPodsInstalledAndMeetsVersionCheck) + .thenAnswer((_) => new Future.value(false)); + when(cocoaPods.hasCocoaPods).thenAnswer((_) => new Future.value(false)); when(xcode.isSimctlInstalled).thenReturn(true); final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget(); final ValidationResult result = await workflow.validate(); @@ -245,9 +248,11 @@ void main() { .thenReturn('Xcode 8.2.1\nBuild version 8C1002\n'); when(xcode.isInstalledAndMeetsVersionCheck).thenReturn(true); when(xcode.eulaSigned).thenReturn(true); - when(cocoaPods.isCocoaPodsInstalledAndMeetsVersionCheck).thenReturn(false); - when(cocoaPods.hasCocoaPods).thenReturn(true); - when(cocoaPods.cocoaPodsVersionText).thenReturn('0.39.0'); + when(cocoaPods.isCocoaPodsInstalledAndMeetsVersionCheck) + .thenAnswer((_) => new Future.value(false)); + when(cocoaPods.hasCocoaPods).thenAnswer((_) => new Future.value(true)); + when(cocoaPods.cocoaPodsVersionText) + .thenAnswer((_) => new Future.value('0.39.0')); when(xcode.isSimctlInstalled).thenReturn(true); final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget(); final ValidationResult result = await workflow.validate(); diff --git a/packages/flutter_tools/test/ios/mac_test.dart b/packages/flutter_tools/test/ios/mac_test.dart index fc7b5a54bc..3772ab2a5d 100644 --- a/packages/flutter_tools/test/ios/mac_test.dart +++ b/packages/flutter_tools/test/ios/mac_test.dart @@ -41,7 +41,7 @@ void main() { testUsingContext('getAvailableDeviceIDs throws ToolExit when idevice_id returns non-zero', () async { when(mockProcessManager.run(['idevice_id', '-l'])) - .thenReturn(new ProcessResult(1, 1, '', 'Sad today')); + .thenAnswer((_) => new Future.value(new ProcessResult(1, 1, '', 'Sad today'))); expect(() async => await iMobileDevice.getAvailableDeviceIDs(), throwsToolExit()); }, overrides: { ProcessManager: () => mockProcessManager, @@ -49,7 +49,7 @@ void main() { testUsingContext('getAvailableDeviceIDs returns idevice_id output when installed', () async { when(mockProcessManager.run(['idevice_id', '-l'])) - .thenReturn(new ProcessResult(1, 0, 'foo', '')); + .thenAnswer((_) => new Future.value(new ProcessResult(1, 0, 'foo', ''))); expect(await iMobileDevice.getAvailableDeviceIDs(), 'foo'); }, overrides: { ProcessManager: () => mockProcessManager, @@ -72,7 +72,7 @@ void main() { when(mockProcessManager.run(['idevicescreenshot', outputPath], environment: null, workingDirectory: null - )).thenReturn(new ProcessResult(4, 1, '', '')); + )).thenAnswer((_) => new Future.value(new ProcessResult(4, 1, '', ''))); expect(() async => await iMobileDevice.takeScreenshot(mockOutputFile), throwsA(anything)); }, overrides: {