Files
fanuzu/app/test/home_i18n_layout_test.dart
T

87 lines
3.2 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:fancake/core/i18n/app_locale.dart';
import 'package:fancake/core/theme/app_theme.dart';
import 'package:fancake/features/home/home_data.dart';
import 'package:fancake/features/home/widgets/home_hero.dart';
import 'package:fancake/features/home/widgets/home_weekly.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
/// 긴 언어(es · ja)에서 HOME 이 깨지지 않는다 — 10/8 r11 실기기(Flip3) 관찰.
void main() {
tearDown(() => appL10n = koL10n);
Future<void> pump(WidgetTester tester, Locale locale, Widget child,
{double width = 360}) async {
tester.view.physicalSize = Size(width * 3, 2400);
tester.view.devicePixelRatio = 3;
addTearDown(tester.view.reset);
await tester.pumpWidget(MaterialApp(
theme: buildAppTheme(),
locale: locale,
supportedLocales: appLocales,
localizationsDelegates: const [
RemoteL10nDelegate({}),
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
home: Scaffold(body: child),
));
await tester.pumpAndSettle();
}
const growth = PlanetGrowth(
fandomName: '오로라',
contributorName: 'Kinos',
stage: 2,
contributedPop: 0,
growthPercent: 1,
currentPop: 189,
requiredPop: 16575,
);
testWidgets('es 주간 카드 「Mis POP」 라벨이 한 글자씩 줄바꿈되지 않는다', (tester) async {
final weekly = HomeWeekly.from(
fandomId: 'f',
snapshots: const [],
fandom: const {},
myWeekPop: 250,
wallet: const {'activityBalance': 12130, 'supportBalance': 330},
);
await pump(tester, const Locale('es'), HomeWeeklyCard(weekly: weekly));
expect(tester.takeException(), isNull);
// 한 줄 = 글자 13 × 행간 18/13.
expect(tester.getSize(find.text('Mis POP')).height, 18);
});
testWidgets('es 인사 줄은 「De Kinos」 — 「aporta:」 오역이 아니다', (tester) async {
await pump(tester, const Locale('es'), const HomeHero(growth: growth));
expect(find.text('De '), findsOneWidget);
expect(find.text('Kinos'), findsOneWidget);
expect(find.textContaining('aporta'), findsNothing);
});
testWidgets('es 성장 말풍선이 성장률 글자를 가리지 않는다', (tester) async {
await pump(tester, const Locale('es'), const HomeHero(growth: growth),
width: 540);
final rate = tester.getRect(find.text('Crecimiento del planeta 1%'));
final bubble = tester.getRect(find.text('Ver condiciones'));
expect(bubble.left, greaterThanOrEqualTo(rate.right));
});
testWidgets('ja 제목이 미니맵 아래로 들어가지 않는다', (tester) async {
await pump(
tester,
const Locale('ja'),
const HomeHero(
growth: growth,
miniMap: SizedBox(width: HomeHero.miniMapSize, height: 90),
),
);
expect(tester.takeException(), isNull);
final title = tester.getRect(find.text('みんなで育てるファンダム惑星'));
expect(title.right, lessThanOrEqualTo(360 - HomeHero.miniMapSize));
});
}