Files
pipelines/app/test/ui/theme/app_font_theme_test.dart
alan 9adee6cc60 Remove Cupertino UI branches
Keep the public Cupertino-compatible parameters while retaining only the Material implementations and tests. The app is Material-only, so deleting unreachable Cupertino branches reduces dead code without changing the active path.
2026-11-11 02:41:26 +00:00

64 lines
2.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/application/app.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/ui/theme/app_font.dart';
import 'package:pipelines_app/ui/theme/app_font_controller.dart';
import 'package:pipelines_app/ui/theme/app_font_store.dart';
import 'package:pipelines_app/ui/theme/app_theme.dart';
void main() {
test('Material themes take the family and keep sizes and weights', () {
for (final build in <ThemeData Function({String? fontFamily})>[
appLightTheme,
appDarkTheme,
]) {
final system = build().textTheme;
final inter = build(fontFamily: 'Inter').textTheme;
expect(build().textTheme.bodyMedium?.fontFamily, isNot('Inter'));
for (final (a, b) in <(TextStyle?, TextStyle?)>[
(system.bodyMedium, inter.bodyMedium),
(system.titleMedium, inter.titleMedium),
(system.labelLarge, inter.labelLarge),
(system.headlineSmall, inter.headlineSmall),
]) {
expect(b?.fontFamily, 'Inter');
expect(b?.fontSize, a?.fontSize);
expect(b?.fontWeight, a?.fontWeight);
}
}
});
testWidgets('the Material host switches font live, without a restart', (
tester,
) async {
final fonts = AppFontController(
store: MemoryAppFontStore(),
loader: (family, assets) async {},
);
String? family;
await tester.pumpWidget(
MyApp(
fonts: fonts,
destination: AppDestination.settings,
destinationBodies: <AppDestination, WidgetBuilder>{
AppDestination.settings: (context) => Builder(
builder: (context) {
family = DefaultTextStyle.of(context).style.fontFamily;
return const Text('body');
},
),
},
),
);
final before = family;
expect(before, isNot('IBM Plex Sans'));
await fonts.select(AppFont.ibmPlexSans);
await tester.pumpAndSettle();
expect(family, 'IBM Plex Sans');
await fonts.select(AppFont.system);
await tester.pumpAndSettle();
expect(family, before);
});
}