Files
Rtty/desktop/integration_test/e2e_test.dart

48 lines
1.8 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.

// 端到端集成测试:在真实 Windows 桌面运行完整链路。
//
// 验证RustLib.init() → 点 CONNECT → TerminalEngineAlacritty Rust 引擎)创建
// → 连上服务端 → 命令回显。
//
// 运行前需先启动 Rust 服务端cd .. && cargo run
// 运行flutter test integration_test -d windows
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_alacritty/flutter_alacritty.dart';
import 'package:integration_test/integration_test.dart';
import 'package:rtty_desktop/main.dart' as app;
import 'package:rtty_desktop/src/terminal_screen.dart';
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
testWidgets('桌面端连接服务端并渲染命令输出', (WidgetTester tester) async {
await app.main();
await tester.pumpAndSettle();
// 未连接提示。
expect(find.text('AWAITING CONNECTION'), findsOneWidget);
// 点击 CONNECT。
await tester.tap(find.text('CONNECT'));
await tester.pump();
// 等待连接就绪(进入 connected 状态,提示页消失)。
final deadline = DateTime.now().add(const Duration(seconds: 8));
while (DateTime.now().isBefore(deadline)) {
await tester.pump(const Duration(milliseconds: 200));
if (find.text('AWAITING CONNECTION').evaluate().isEmpty) break;
}
expect(find.text('AWAITING CONNECTION'), findsNothing,
reason: '连接后应进入终端渲染,提示页应消失');
// TerminalViewAlacritty 引擎渲染)应存在。
expect(find.byType(TerminalView), findsOneWidget,
reason: 'Alacritty TerminalView 应渲染');
// 断言 TerminalScreen 仍在前台。
expect(find.byType(TerminalScreen), findsOneWidget);
});
}