feat: add Flutter mobile app
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:imagefind_mobile/src/models.dart';
|
||||
import 'package:imagefind_mobile/src/screens/core_screens.dart';
|
||||
import 'package:imagefind_mobile/src/screens/shell.dart';
|
||||
import 'package:imagefind_mobile/src/theme.dart';
|
||||
|
||||
void main() {
|
||||
test('formats media duration', () {
|
||||
expect(formatDuration(1845000), '30:45');
|
||||
expect(formatDuration(3723000), '1:02:03');
|
||||
});
|
||||
|
||||
testWidgets('selected navigation has no bubble', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: buildTheme(Brightness.light, TargetPlatform.android),
|
||||
home: Scaffold(
|
||||
bottomNavigationBar: NavigationBar(
|
||||
selectedIndex: 0,
|
||||
destinations: const [
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.home_outlined),
|
||||
label: '首页',
|
||||
),
|
||||
NavigationDestination(icon: Icon(Icons.search), label: '搜索'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
final theme = NavigationBarTheme.of(
|
||||
tester.element(find.byType(NavigationBar)),
|
||||
);
|
||||
expect(theme.indicatorColor, Colors.transparent);
|
||||
});
|
||||
|
||||
testWidgets('phone shell and search fit a 390dp viewport', (tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
|
||||
await tester.pumpWidget(
|
||||
ProviderScope(
|
||||
child: MaterialApp(
|
||||
theme: buildTheme(Brightness.light, TargetPlatform.android),
|
||||
home: const AppShell(index: 1, child: SearchScreen()),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(find.byType(NavigationBar), findsOneWidget);
|
||||
final field = tester.getRect(find.byType(TextField));
|
||||
expect(field.left, greaterThanOrEqualTo(6));
|
||||
expect(field.right, lessThan(340));
|
||||
final navigation = tester.getRect(find.byType(NavigationBar));
|
||||
expect(navigation.left, 0);
|
||||
expect(navigation.right, 390);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user