installFakeVooWatch function
Installs a FakeVooWatchTransport as the VooWatch singleton's
transport, so widget tests and unit tests can exercise watch-bound
code without a real method channel.
Returns the installed FakeVooWatchTransport so callers can inspect
sentPayloads or feed events back through it.
Default: resets VooWatch and VooWatchUi before installing the
fake. Pass reset: false if you want to layer a fresh transport on
top of an existing test context (rare).
Pair with resetVooWatch in tearDown, or use withFakeVooWatch to
scope the install/teardown to a single async block.
Implementation
@visibleForTesting
Future<FakeVooWatchTransport> installFakeVooWatch({bool reset = true}) async {
if (reset) {
await VooWatch.debugReset();
await VooWatchUi.debugReset();
}
final fake = FakeVooWatchTransport();
VooWatch.debugInstall(fake);
// Force singleton creation so the closure-callback bridge is wired
// before any WatchView factory runs in the test body. Without this,
// closure-form events would throw "VooWatchUi not initialized".
// ignore: unnecessary_statements
VooWatchUi.instance;
return fake;
}