41 lines
1.2 KiB
Dart
41 lines
1.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/scheduler.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'package:pong/main.dart';
|
|
|
|
void main() {
|
|
testWidgets('Tests "Berühren um zu beginnen!"', (WidgetTester tester) async {
|
|
final tapToStart = find.text("Berühren um zu beginnen!");
|
|
|
|
await tester.pumpWidget(const MaterialApp(home: StartScreen()));
|
|
|
|
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));
|
|
await tester.pump();
|
|
|
|
// Verify, dass der Übergang zur GameScreen erfolgt ist.
|
|
expect(find.byType(GameScreen), findsOneWidget);
|
|
});
|
|
}
|