Skip to content

Commit c18ed25

Browse files
committed
test(theme): cover registerFontLicenses to restore the patch gate
codecov/patch failed at 66.66% because registerFontLicenses() was never executed by a test — the licence-loading stream was covered but the one-line glue that hands it to the LicenseRegistry was not. Drain the registry itself after resetting Flutter's own collectors, so the wiring is verified end to end rather than the function merely being called. The drain runs inside tester.runAsync: testWidgets' fake-async zone never advances the real asset read the collector awaits, which is why an earlier attempt hung to the 10-minute test timeout instead of failing.
1 parent 4874f9b commit c18ed25

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

test/app_theme_test.dart

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,32 @@ void main() {
192192
);
193193
});
194194

195+
testWidgets('feeds the entries into the LicenseRegistry', (
196+
WidgetTester tester,
197+
) async {
198+
// Drop Flutter's own collectors so the registry yields only ours.
199+
LicenseRegistry.reset();
200+
addTearDown(LicenseRegistry.reset);
201+
202+
registerFontLicenses();
203+
204+
// runAsync escapes testWidgets' fake-async zone. The collector awaits a
205+
// real asset read, which never completes on the fake clock — draining it
206+
// directly hangs until the 10-minute test timeout.
207+
final List<LicenseEntry>? entries = await tester.runAsync(
208+
() => LicenseRegistry.licenses.toList(),
209+
);
210+
211+
expect(
212+
entries!.expand((LicenseEntry entry) => entry.packages),
213+
containsAll(fontLicenseAssets.keys),
214+
);
215+
});
216+
195217
testWidgets('yields one licence entry per family, carrying its text', (
196218
WidgetTester tester,
197219
) async {
198-
// Drains the collector directly rather than LicenseRegistry.licenses,
199-
// which never completes under flutter_test.
220+
// Drains the collector directly, bypassing the global registry.
200221
final List<LicenseEntry>? entries = await tester.runAsync(
201222
() => loadFontLicenses().toList(),
202223
);

0 commit comments

Comments
 (0)