2023-11-21 15:53:43 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2024-01-10 22:59:41 +01:00
|
|
|
import 'package:flutter/scheduler.dart';
|
2023-11-21 15:53:43 +01:00
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
|
|
|
|
import 'package:pong/main.dart';
|
|
|
|
|
|
|
|
void main() {
|
2023-11-21 23:41:52 +01:00
|
|
|
testWidgets('Tests "Berühren um zu beginnen!"', (WidgetTester tester) async {
|
2024-01-10 22:59:41 +01:00
|
|
|
final tapToStart = find.text("Berühren um zu beginnen!");
|
2023-11-21 15:53:43 +01:00
|
|
|
|
2023-11-21 23:41:52 +01:00
|
|
|
await tester.pumpWidget(const MaterialApp(home: StartScreen()));
|
2024-01-10 22:59:41 +01:00
|
|
|
|
|
|
|
expect(tapToStart, findsOneWidget);
|
|
|
|
});
|
|
|
|
|
|
|
|
testWidgets('Tests "Punkte:"', (WidgetTester tester) async {
|
|
|
|
final points = find.text("Punkte: 0");
|
|
|
|
|
|
|
|
await tester.pumpWidget(const MaterialApp(home: GameScreen()));
|
|
|
|
|
|
|
|
expect(points, findsOneWidget);
|
|
|
|
});
|
|
|
|
|
|
|
|
testWidgets('StartScreen UI Test', (WidgetTester tester) async {
|
|
|
|
// Build our app and trigger a frame.
|
|
|
|
await tester.pumpWidget(const MaterialApp(
|
|
|
|
home: StartScreen(),
|
|
|
|
));
|
|
|
|
|
|
|
|
// Verify that the "Berühren um zu beginnen!" Text angezeigt wird.
|
|
|
|
expect(find.text('Berühren um zu beginnen!'), findsOneWidget);
|
|
|
|
|
|
|
|
// Tap auf das GestureDetector, um zur GameScreen zu wechseln.
|
|
|
|
await tester.tap(find.byType(GestureDetector));
|
2023-11-21 15:53:43 +01:00
|
|
|
await tester.pump();
|
|
|
|
|
2024-01-10 22:59:41 +01:00
|
|
|
// Verify, dass der Übergang zur GameScreen erfolgt ist.
|
|
|
|
expect(find.byType(GameScreen), findsOneWidget);
|
2023-11-21 15:53:43 +01:00
|
|
|
});
|
|
|
|
}
|