69 lines
3.1 KiB
Dart
69 lines
3.1 KiB
Dart
import 'package:fancake/core/theme/app_theme.dart';
|
|
import 'package:fancake/core/theme/tokens.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
/// 테마를 주지 않은 컴포넌트는 Material 3 가 기본 시드(보라)에서 색을 만들어 낸다.
|
|
///
|
|
/// 코스믹 다크 서피스 위에 그 색이 뜨면 시안과 어긋나는데, 화면을 눈으로 보기
|
|
/// 전까지 드러나지 않는다. 실제로 INSIDE·STATION 정렬 칩이 보라색으로 나간 적이
|
|
/// 있어(09-02) 그 회귀를 여기서 잡는다.
|
|
void main() {
|
|
final theme = buildAppTheme();
|
|
|
|
/// 코스믹 팔레트에 속한 색인가. 토큰 밖의 색이면 Material 이 만들어 낸 것이다.
|
|
bool isCosmic(Color? c) {
|
|
if (c == null) return false;
|
|
final palette = <Color>{
|
|
AppColors.cosmicVoid,
|
|
AppColors.cosmicSurface,
|
|
AppColors.cosmicSurfaceContainer,
|
|
AppColors.cosmicSurfaceRaised,
|
|
AppColors.cosmicOutline,
|
|
AppColors.cosmicAccent,
|
|
AppColors.onCosmic,
|
|
AppColors.onCosmicVariant,
|
|
AppColors.onCosmicAccent,
|
|
AppColors.neonCyan,
|
|
AppColors.neonViolet,
|
|
AppColors.error,
|
|
};
|
|
return palette.contains(c) || c == Colors.transparent;
|
|
}
|
|
|
|
group('테마가 컴포넌트를 비워 두지 않는다', () {
|
|
test('Material 기본값으로 떨어지던 12종에 테마가 있다', () {
|
|
expect(theme.chipTheme.backgroundColor, isNotNull, reason: 'ChipTheme');
|
|
expect(theme.cardTheme.color, isNotNull, reason: 'CardTheme');
|
|
expect(theme.floatingActionButtonTheme.backgroundColor, isNotNull, reason: 'FAB');
|
|
expect(theme.inputDecorationTheme.focusedBorder, isNotNull, reason: 'Input');
|
|
expect(theme.progressIndicatorTheme.color, isNotNull, reason: 'Progress');
|
|
expect(theme.bottomSheetTheme.backgroundColor, isNotNull, reason: 'BottomSheet');
|
|
expect(theme.dialogTheme.backgroundColor, isNotNull, reason: 'Dialog');
|
|
expect(theme.snackBarTheme.backgroundColor, isNotNull, reason: 'SnackBar');
|
|
expect(theme.listTileTheme.titleTextStyle, isNotNull, reason: 'ListTile');
|
|
expect(theme.textButtonTheme.style, isNotNull, reason: 'TextButton');
|
|
expect(theme.outlinedButtonTheme.style, isNotNull, reason: 'OutlinedButton');
|
|
expect(theme.iconTheme.color, isNotNull, reason: 'IconTheme');
|
|
});
|
|
|
|
test('칩 색이 코스믹 팔레트 안에 있다', () {
|
|
// 보라색 칩이 다시 나오면 여기서 잡힌다.
|
|
expect(isCosmic(theme.chipTheme.backgroundColor), isTrue);
|
|
expect(isCosmic(theme.chipTheme.selectedColor), isTrue);
|
|
});
|
|
|
|
test('ColorScheme 의 컨테이너 슬롯이 채워져 있다', () {
|
|
// 비워 두면 Material 이 시드에서 만들어 내고, 그 값이 칩·배지로 샌다.
|
|
final s = theme.colorScheme;
|
|
for (final (name, c) in [
|
|
('primaryContainer', s.primaryContainer),
|
|
('secondaryContainer', s.secondaryContainer),
|
|
('tertiaryContainer', s.tertiaryContainer),
|
|
]) {
|
|
expect(isCosmic(c), isTrue, reason: '$name 이 팔레트 밖이다: $c');
|
|
}
|
|
});
|
|
});
|
|
}
|