[flutter_tools] rewrite Usage.test to capture objects instead of print logs (#74829)

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 c2ab75b..b8f886b 100644
--- a/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart
+++ b/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart
@@ -34,7 +34,7 @@
   CocoaPods cocoaPodsUnderTest;
   InvokeProcess resultOfPodVersion;
   BufferLogger logger;
-  Usage usage;
+  TestUsage usage;
 
   void pretendPodVersionFails() {
     resultOfPodVersion = () async => exitsWithError();
@@ -71,7 +71,7 @@
     projectUnderTest = FlutterProject.fromDirectory(fileSystem.directory('project'));
     projectUnderTest.ios.xcodeProject.createSync(recursive: true);
     projectUnderTest.macos.xcodeProject.createSync(recursive: true);
-    usage = Usage.test();
+    usage = TestUsage();
     cocoaPodsUnderTest = CocoaPods(
       fileSystem: fileSystem,
       processManager: mockProcessManager,
@@ -486,21 +486,18 @@
             'LoadError - dlsym(0x7fbbeb6837d0, Init_ffi_c): symbol not found - /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/lib/ffi_c.bundle',
           ));
 
-      // Capture Usage.test() events.
-      final StringBuffer buffer =
-          await capturedConsolePrint(() => expectToolExitLater(
-                cocoaPodsUnderTest.processPods(
-                  xcodeProject: projectUnderTest.ios,
-                  buildMode: BuildMode.debug,
-                ),
-                equals('Error running pod install'),
-              ));
+      await expectToolExitLater(
+        cocoaPodsUnderTest.processPods(
+          xcodeProject: projectUnderTest.ios,
+          buildMode: BuildMode.debug,
+        ),
+        equals('Error running pod install'),
+      );
       expect(
         logger.errorText,
         contains('set up CocoaPods for ARM macOS'),
       );
-      expect(buffer.toString(),
-          contains('event {category: pod-install-failure, action: arm-ffi'));
+      expect(usage.events, contains(const TestUsageEvent('pod-install-failure', 'arm-ffi')));
     });
 
     testWithoutContext('ffi failure on x86 macOS does not prompt gem install', () async {