[pigeon] Create a message call free InstanceManager when running unit tests (#9395)
To support hot restart, PigeonInstanceManager.instance makes a call to clear the native InstanceManager when it is instantiated.
This was the source of unit test race condition flakes like https://github.com/flutter/flutter/issues/164132.
The current workaround is to try/catch the async PlatformException at the top of every test file or pass a test InstanceManager to every ProxyApi class:
```dart
final MyNativeClass object = MyNativeClass(
pigeon_instanceManager: PigeonInstanceManager(
onWeakReferenceRemoved: (_) {}
),
);
```
This PR changes it to [detect a test ran as Flutter unit test](https://api.flutter.dev/flutter/flutter_test/TestWidgetsFlutterBinding/ensureInitialized.html) and sets the default InstanceManager with one that doesn't make any message calls.
## Pre-Review Checklist
[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
[pigeon] Create a message call free InstanceManager when running unit tests (#9395)
To support hot restart, PigeonInstanceManager.instance makes a call to clear the native InstanceManager when it is instantiated.
This was the source of unit test race condition flakes like https://github.com/flutter/flutter/issues/164132.
The current workaround is to try/catch the async PlatformException at the top of every test file or pass a test InstanceManager to every ProxyApi class:
```dart
final MyNativeClass object = MyNativeClass(
pigeon_instanceManager: PigeonInstanceManager(
onWeakReferenceRemoved: (_) {}
),
);
```
This PR changes it to [detect a test ran as Flutter unit test](https://api.flutter.dev/flutter/flutter_test/TestWidgetsFlutterBinding/ensureInitialized.html) and sets the default InstanceManager with one that doesn't make any message calls.
## Pre-Review Checklist
[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.