feat(mobile): UI-01 theme system, shared components and navigation
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
/// ErrorState widget 测试(UI-01 Task 3)。
|
||||
///
|
||||
/// 覆盖:错误图标 + 说明 + 重试按钮(主强调,与 EmptyState 区分);
|
||||
/// 重试回调触发。
|
||||
library;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:photo_live/app/theme.dart';
|
||||
import 'package:photo_live/l10n/app_localizations.dart';
|
||||
import 'package:photo_live/ui/components/error_state.dart';
|
||||
import 'package:photo_live/ui/tokens.dart';
|
||||
|
||||
void main() {
|
||||
Future<void> pumpState(WidgetTester tester, VoidCallback onRetry) {
|
||||
return tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: AppTheme.light,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: Scaffold(
|
||||
body: ErrorState(
|
||||
message: 'Network error. Please retry',
|
||||
onRetry: onRetry,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('渲染错误图标 + 说明 + 重试按钮,回调触发', (tester) async {
|
||||
var retries = 0;
|
||||
await pumpState(tester, () => retries++);
|
||||
|
||||
expect(find.byIcon(Icons.cloud_off), findsOneWidget, reason: '错误语义图标');
|
||||
expect(find.text('Network error. Please retry'), findsOneWidget);
|
||||
final retryButton = find.widgetWithText(FilledButton, 'Retry');
|
||||
expect(retryButton, findsOneWidget, reason: '重试为主强调按钮');
|
||||
expect(find.byIcon(Icons.refresh), findsOneWidget);
|
||||
|
||||
await tester.tap(retryButton);
|
||||
expect(retries, 1, reason: '重试回调触发');
|
||||
});
|
||||
|
||||
testWidgets('深色主题错误图标用提亮变体', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: AppTheme.dark,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: const Scaffold(
|
||||
body: ErrorState(message: 'boom', onRetry: _noop),
|
||||
),
|
||||
),
|
||||
);
|
||||
final icon = tester.widget<Icon>(find.byIcon(Icons.cloud_off));
|
||||
expect(icon.color, kColorErrorDark);
|
||||
});
|
||||
}
|
||||
|
||||
void _noop() {}
|
||||
Reference in New Issue
Block a user