Convert CocoaPods tests to testWithoutContext (#53291)

diff --git a/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart b/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart
index fbba453..a690f51 100644
--- a/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart
+++ b/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart
@@ -6,6 +6,7 @@
 
 import 'package:file/file.dart';
 import 'package:file/memory.dart';
+import 'package:flutter_tools/src/base/logger.dart';
 import 'package:platform/platform.dart';
 import 'package:mockito/mockito.dart';
 import 'package:process/process.dart';
@@ -31,6 +32,7 @@
   FlutterProject projectUnderTest;
   CocoaPods cocoaPodsUnderTest;
   InvokeProcess resultOfPodVersion;
+  BufferLogger logger;
 
   void pretendPodVersionFails() {
     resultOfPodVersion = () async => exitsWithError();
@@ -64,10 +66,18 @@
     Cache.flutterRoot = 'flutter';
     fs = MemoryFileSystem();
     mockProcessManager = MockProcessManager();
+    logger = BufferLogger.test();
     mockXcodeProjectInterpreter = MockXcodeProjectInterpreter();
     projectUnderTest = FlutterProject.fromDirectory(fs.directory('project'));
     projectUnderTest.ios.xcodeProject.createSync(recursive: true);
-    cocoaPodsUnderTest = CocoaPods();
+    cocoaPodsUnderTest = CocoaPods(
+      fileSystem: fs,
+      processManager: mockProcessManager,
+      logger: logger,
+      platform: FakePlatform(),
+      xcodeProjectInterpreter: mockXcodeProjectInterpreter,
+      timeoutConfiguration: const TimeoutConfiguration(),
+    );
     pretendPodVersionIs('1.8.0');
     fs.file(fs.path.join(
       Cache.flutterRoot, 'packages', 'flutter_tools', 'templates', 'cocoapods', 'Podfile-ios-objc',
@@ -139,92 +149,74 @@
       when(mockProcessManager.canRun(any)).thenReturn(true);
     });
 
-    testUsingContext('detects not installed, if pod exec does not exist', () async {
+    testWithoutContext('detects not installed, if pod exec does not exist', () async {
       pretendPodIsNotInstalled();
       expect(await cocoaPodsUnderTest.evaluateCocoaPodsInstallation, CocoaPodsStatus.notInstalled);
-    }, overrides: <Type, Generator>{
-      ProcessManager: () => mockProcessManager,
     });
 
-    testUsingContext('detects not installed, if pod is installed but version fails', () async {
+    testWithoutContext('detects not installed, if pod is installed but version fails', () async {
       pretendPodIsInstalled();
       pretendPodVersionFails();
       expect(await cocoaPodsUnderTest.evaluateCocoaPodsInstallation, CocoaPodsStatus.brokenInstall);
-    }, overrides: <Type, Generator>{
-      ProcessManager: () => mockProcessManager,
     });
 
-    testUsingContext('detects installed', () async {
+    testWithoutContext('detects installed', () async {
       pretendPodIsInstalled();
       pretendPodVersionIs('0.0.1');
       expect(await cocoaPodsUnderTest.evaluateCocoaPodsInstallation, isNot(CocoaPodsStatus.notInstalled));
-    }, overrides: <Type, Generator>{
-      ProcessManager: () => mockProcessManager,
     });
 
-    testUsingContext('detects unknown version', () async {
+    testWithoutContext('detects unknown version', () async {
       pretendPodIsInstalled();
       pretendPodVersionIs('Plugin loaded.\n1.5.3');
       expect(await cocoaPodsUnderTest.evaluateCocoaPodsInstallation, CocoaPodsStatus.unknownVersion);
-    }, overrides: <Type, Generator>{
-      ProcessManager: () => mockProcessManager,
     });
 
-    testUsingContext('detects below minimum version', () async {
+    testWithoutContext('detects below minimum version', () async {
       pretendPodIsInstalled();
       pretendPodVersionIs('1.5.0');
       expect(await cocoaPodsUnderTest.evaluateCocoaPodsInstallation, CocoaPodsStatus.belowMinimumVersion);
-    }, overrides: <Type, Generator>{
-      ProcessManager: () => mockProcessManager,
     });
 
-    testUsingContext('detects below recommended version', () async {
+    testWithoutContext('detects below recommended version', () async {
       pretendPodIsInstalled();
       pretendPodVersionIs('1.6.0');
       expect(await cocoaPodsUnderTest.evaluateCocoaPodsInstallation, CocoaPodsStatus.belowRecommendedVersion);
-    }, overrides: <Type, Generator>{
-      ProcessManager: () => mockProcessManager,
     });
 
-    testUsingContext('detects at recommended version', () async {
+    testWithoutContext('detects at recommended version', () async {
       pretendPodIsInstalled();
       pretendPodVersionIs('1.8.0');
       expect(await cocoaPodsUnderTest.evaluateCocoaPodsInstallation, CocoaPodsStatus.recommended);
-    }, overrides: <Type, Generator>{
-      ProcessManager: () => mockProcessManager,
     });
 
-    testUsingContext('detects above recommended version', () async {
+    testWithoutContext('detects above recommended version', () async {
       pretendPodIsInstalled();
       pretendPodVersionIs('1.8.1');
       expect(await cocoaPodsUnderTest.evaluateCocoaPodsInstallation, CocoaPodsStatus.recommended);
-    }, overrides: <Type, Generator>{
-      ProcessManager: () => mockProcessManager,
     });
 
-    testUsingContext('detects initialized over 1.8.0', () async {
+    testWithoutContext('detects initialized over 1.8.0', () async {
       pretendPodIsInstalled();
       pretendPodVersionIs('1.8.0');
       expect(await cocoaPodsUnderTest.isCocoaPodsInitialized, isTrue);
-    }, overrides: <Type, Generator>{
-      Platform: () => FakePlatform(),
-      FileSystem: () => fs,
-      ProcessManager: () => mockProcessManager,
     });
   });
 
   group('Setup Podfile', () {
-    testUsingContext('creates objective-c Podfile when not present', () async {
+    setUp(() {
+      when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
+    });
+
+    testWithoutContext('creates objective-c Podfile when not present', () async {
+      when(mockXcodeProjectInterpreter.getBuildSettings(any, any))
+        .thenAnswer((_) async => <String, String>{});
       await cocoaPodsUnderTest.setupPodfile(projectUnderTest.ios);
 
       expect(projectUnderTest.ios.podfile.readAsStringSync(), 'Objective-C iOS podfile template');
-    }, overrides: <Type, Generator>{
-      FileSystem: () => fs,
-      ProcessManager: () => FakeProcessManager.any(),
     });
 
     testUsingContext('creates swift Podfile if swift', () async {
-      when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
       when(mockXcodeProjectInterpreter.getBuildSettings(any, any))
         .thenAnswer((_) async => <String, String>{
           'SWIFT_VERSION': '5.0',
@@ -240,14 +232,11 @@
       XcodeProjectInterpreter: () => mockXcodeProjectInterpreter,
     });
 
-    testUsingContext('creates macOS Podfile when not present', () async {
+    testWithoutContext('creates macOS Podfile when not present', () async {
       projectUnderTest.macos.xcodeProject.createSync(recursive: true);
       await cocoaPodsUnderTest.setupPodfile(projectUnderTest.macos);
 
       expect(projectUnderTest.macos.podfile.readAsStringSync(), 'macOS podfile template');
-    }, overrides: <Type, Generator>{
-      FileSystem: () => fs,
-      ProcessManager: () => FakeProcessManager.any(),
     });
 
     testUsingContext('does not recreate Podfile when already present', () async {
@@ -337,7 +326,7 @@
       when(mockProcessManager.canRun(any)).thenReturn(true);
     });
 
-    testUsingContext('throwsToolExit if CocoaPods is not installed', () async {
+    testWithoutContext('throwsToolExit if CocoaPods is not installed', () async {
       pretendPodIsNotInstalled();
       projectUnderTest.ios.podfile.createSync();
       final Function invokeProcessPods = () async => await cocoaPodsUnderTest.processPods(
@@ -350,12 +339,9 @@
         workingDirectory: anyNamed('workingDirectory'),
         environment: anyNamed('environment'),
       ));
-    }, overrides: <Type, Generator>{
-      FileSystem: () => fs,
-      ProcessManager: () => mockProcessManager,
     });
 
-    testUsingContext('throwsToolExit if CocoaPods install is broken', () async {
+    testWithoutContext('throwsToolExit if CocoaPods install is broken', () async {
       pretendPodIsBroken();
       projectUnderTest.ios.podfile.createSync();
       final Function invokeProcessPods = () async => await cocoaPodsUnderTest.processPods(
@@ -368,12 +354,9 @@
         workingDirectory: anyNamed('workingDirectory'),
         environment: anyNamed('environment'),
       ));
-    }, overrides: <Type, Generator>{
-      FileSystem: () => fs,
-      ProcessManager: () => mockProcessManager,
     });
 
-    testUsingContext('prints warning, if Podfile is out of date', () async {
+    testWithoutContext('prints warning, if Podfile is out of date', () async {
       pretendPodIsInstalled();
 
       fs.file(fs.path.join('project', 'ios', 'Podfile'))
@@ -388,13 +371,10 @@
         xcodeProject: projectUnderTest.ios,
         engineDir: 'engine/path',
       );
-      expect(testLogger.errorText, contains('Warning: Podfile is out of date'));
-    }, overrides: <Type, Generator>{
-      FileSystem: () => fs,
-      ProcessManager: () => mockProcessManager,
+      expect(logger.errorText, contains('Warning: Podfile is out of date'));
     });
 
-    testUsingContext('throws, if Podfile is missing.', () async {
+    testWithoutContext('throws, if Podfile is missing.', () async {
       pretendPodIsInstalled();
       try {
         await cocoaPodsUnderTest.processPods(
@@ -410,12 +390,9 @@
           environment: anyNamed('environment'),
         ));
       }
-    }, overrides: <Type, Generator>{
-      FileSystem: () => fs,
-      ProcessManager: () => mockProcessManager,
     });
 
-    testUsingContext('throws, if specs repo is outdated.', () async {
+    testWithoutContext('throws, if specs repo is outdated.', () async {
       pretendPodIsInstalled();
       fs.file(fs.path.join('project', 'ios', 'Podfile'))
         ..createSync()
@@ -454,16 +431,13 @@
       } on Exception catch (e) {
         expect(e, isA<ToolExit>());
         expect(
-          testLogger.errorText,
+          logger.errorText,
           contains("CocoaPods's specs repository is too out-of-date to satisfy dependencies"),
         );
       }
-    }, overrides: <Type, Generator>{
-      FileSystem: () => fs,
-      ProcessManager: () => mockProcessManager,
     });
 
-    testUsingContext('run pod install, if Podfile.lock is missing', () async {
+    testWithoutContext('run pod install, if Podfile.lock is missing', () async {
       pretendPodIsInstalled();
       projectUnderTest.ios.podfile
         ..createSync()
@@ -482,12 +456,9 @@
         workingDirectory: 'project/ios',
         environment: <String, String>{'FLUTTER_FRAMEWORK_DIR': 'engine/path', 'COCOAPODS_DISABLE_STATS': 'true', 'LANG': 'en_US.UTF-8'},
       ));
-    }, overrides: <Type, Generator>{
-      FileSystem: () => fs,
-      ProcessManager: () => mockProcessManager,
     });
 
-    testUsingContext('runs pod install, if Manifest.lock is missing', () async {
+    testWithoutContext('runs pod install, if Manifest.lock is missing', () async {
       pretendPodIsInstalled();
       projectUnderTest.ios.podfile
         ..createSync()
@@ -510,12 +481,9 @@
           'LANG': 'en_US.UTF-8',
         },
       ));
-    }, overrides: <Type, Generator>{
-      FileSystem: () => fs,
-      ProcessManager: () => mockProcessManager,
     });
 
-    testUsingContext('runs pod install, if Manifest.lock different from Podspec.lock', () async {
+    testWithoutContext('runs pod install, if Manifest.lock different from Podspec.lock', () async {
       pretendPodIsInstalled();
       projectUnderTest.ios.podfile
         ..createSync()
@@ -541,12 +509,9 @@
           'LANG': 'en_US.UTF-8',
         },
       ));
-    }, overrides: <Type, Generator>{
-      FileSystem: () => fs,
-      ProcessManager: () => mockProcessManager,
     });
 
-    testUsingContext('runs pod install, if flutter framework changed', () async {
+    testWithoutContext('runs pod install, if flutter framework changed', () async {
       pretendPodIsInstalled();
       projectUnderTest.ios.podfile
         ..createSync()
@@ -572,12 +537,9 @@
           'LANG': 'en_US.UTF-8',
         },
       ));
-    }, overrides: <Type, Generator>{
-      FileSystem: () => fs,
-      ProcessManager: () => mockProcessManager,
     });
 
-    testUsingContext('runs pod install, if Podfile.lock is older than Podfile', () async {
+    testWithoutContext('runs pod install, if Podfile.lock is older than Podfile', () async {
       pretendPodIsInstalled();
       projectUnderTest.ios.podfile
         ..createSync()
@@ -605,12 +567,9 @@
           'LANG': 'en_US.UTF-8',
         },
       ));
-    }, overrides: <Type, Generator>{
-      FileSystem: () => fs,
-      ProcessManager: () => mockProcessManager,
     });
 
-    testUsingContext('skips pod install, if nothing changed', () async {
+    testWithoutContext('skips pod install, if nothing changed', () async {
       pretendPodIsInstalled();
       projectUnderTest.ios.podfile
         ..createSync()
@@ -632,12 +591,9 @@
         workingDirectory: anyNamed('workingDirectory'),
         environment: anyNamed('environment'),
       ));
-    }, overrides: <Type, Generator>{
-      FileSystem: () => fs,
-      ProcessManager: () => mockProcessManager,
     });
 
-    testUsingContext('a failed pod install deletes Pods/Manifest.lock', () async {
+    testWithoutContext('a failed pod install deletes Pods/Manifest.lock', () async {
       pretendPodIsInstalled();
       projectUnderTest.ios.podfile
         ..createSync()
@@ -671,9 +627,6 @@
       } on ToolExit {
         expect(projectUnderTest.ios.podManifestLock.existsSync(), isFalse);
       }
-    }, overrides: <Type, Generator>{
-      FileSystem: () => fs,
-      ProcessManager: () => mockProcessManager,
     });
   });
 
@@ -692,7 +645,7 @@
       };
     });
 
-    testUsingContext('succeeds, if specs repo is in CP_REPOS_DIR.', () async {
+    testWithoutContext('succeeds, if specs repo is in CP_REPOS_DIR.', () async {
       pretendPodIsInstalled();
       fs.file(fs.path.join('project', 'ios', 'Podfile'))
         ..createSync()
@@ -707,10 +660,6 @@
         engineDir: 'engine/path',
       );
       expect(success, true);
-    }, overrides: <Type, Generator>{
-      FileSystem: () => fs,
-      ProcessManager: () => mockProcessManager,
-      Platform: () => FakePlatform(environment: environment),
     });
   });
 }