screen-locker/stronglift_replacement/workout_app/test/ui/theme_test.dart
Krzysztof kuhy Rudnicki 5f2925a550 Move workout_app to Flutter 3.50 material_ui
Flutter 3.50 deprecates package:flutter/material.dart, which made
flutter-analyze report 27 deprecated_member_use infos and blocked the
gate. workout_app now imports material_ui 1.11.0, with crdt_sync_dart
0.14.1 and sync_settings_ui 0.8.2 (both on material_ui).

material_ui's MaterialApp ships its own MaterialLocalizations, so a
package that still calls the framework showDialog threw a null check.
WorkoutApp now adds the framework delegate, and a widget test opens a
material_ui and a framework dialog through the real app root.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWWfb63jncj9Lca2jeX
2026-11-16 08:54:33 +01:00

58 lines
2.0 KiB
Dart

import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:workout_app/ui/theme.dart';
void main() {
group('buildAppTheme', () {
test('uses the shared palette and 16px body floor', () {
final theme = buildAppTheme();
expect(theme.colorScheme.brightness, Brightness.dark);
expect(theme.colorScheme.primary, const Color(0xFFB8862E));
expect(theme.colorScheme.onPrimary, const Color(0xFF211D1B));
expect(theme.textTheme.bodyLarge!.fontSize, AppTextSize.body);
expect(theme.textTheme.bodyMedium!.fontSize, AppTextSize.body);
});
test('registers AppStatusColors', () {
final theme = buildAppTheme();
expect(theme.extension<AppStatusColors>(), AppStatusColors.dark);
});
});
group('AppStatusColors', () {
const colors = AppStatusColors.dark;
test('copyWith overrides only the given fields', () {
final overridden = colors.copyWith(success: Colors.red);
expect(overridden.success, Colors.red);
expect(overridden.warning, colors.warning);
});
test('copyWith with no args returns equivalent values', () {
final same = colors.copyWith();
expect(same.success, colors.success);
expect(same.warning, colors.warning);
});
test('lerp at t=0 returns this', () {
const other = AppStatusColors(success: Colors.red, warning: Colors.blue);
final result = colors.lerp(other, 0);
expect(result.success, colors.success);
expect(result.warning, colors.warning);
});
test('lerp at t=1 matches Color.lerp at t=1', () {
const other = AppStatusColors(success: Colors.red, warning: Colors.blue);
final result = colors.lerp(other, 1);
expect(result.success, Color.lerp(colors.success, other.success, 1));
expect(result.warning, Color.lerp(colors.warning, other.warning, 1));
});
test('lerp with a non-AppStatusColors other returns this unchanged', () {
final result = colors.lerp(null, 0.5);
expect(result, same(colors));
});
});
}