import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:friendly_map/modules/app/app.dart'; import 'package:friendly_map/modules/transport/transport.dart'; import 'package:friendly_map/modules/ui/ui.dart'; import 'support/app_device.dart'; /// 키·저장소를 어떻게 여는지는 화면이 모른다. 시험에서는 메모리 기기로 대신한다. class FakeBootstrap implements Bootstrap { FakeBootstrap({this.keys = false, this.app}); bool keys; final FriendlyApp? app; @override Future hasKeys() async => keys; @override Future createKeys() async { keys = true; return 'one two three four five six seven eight nine ten eleven twelve'; } @override Future restoreKeys(String phrase) async => false; @override Future> splitRecovery(int n, int k) async => [for (var i = 1; i <= n; i++) 'fmr1.$k.0000.$i:00']; @override Future openApp() async => app!; @override Future recoveryPhrase() async => null; } void main() { testWidgets('키가 없으면 처음 화면이 보인다', (tester) async { await tester.pumpWidget(FriendlyMapApp(bootstrap: FakeBootstrap())); await tester.pumpAndSettle(); expect(find.text('새로 시작하기'), findsOneWidget); }); testWidgets('내 정보가 있으면 홈과 아래 메뉴가 보이고 칸을 옮길 수 있다', (tester) async { final device = await tester.runAsync(() => AppDevice.create(MemoryHub(), '010-1111-2222', '+821011112222', '이미영', start: false)); await tester.pumpWidget(FriendlyMapApp(bootstrap: FakeBootstrap(keys: true, app: device!.app))); await tester.pumpAndSettle(); expect(find.byType(NavigationBar), findsOneWidget); await tester.tap(find.descendant(of: find.byType(NavigationBar), matching: find.text('명함'))); await tester.pumpAndSettle(); expect(find.text('내 명함'), findsWidgets); }); }