Compare commits
No commits in common. "main" and "master" have entirely different histories.
|
@ -1,34 +0,0 @@
|
|||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pong/main.dart';
|
||||
import 'package:mockito/mockito.dart'
|
||||
|
||||
|
||||
class MockGameScreen extends Mock implements GameScreen {}
|
||||
|
||||
void main() {
|
||||
// Test for the 'moveRacket' function
|
||||
test('moveRacket', () {});
|
||||
|
||||
// Test for the 'moveBall' function, checking ball position updates and collision handling
|
||||
test('moveBall updates ball position and handles collisions', () {
|
||||
final gameScreenState = GameScreenState();
|
||||
|
||||
// Set the ball to an initial position
|
||||
gameScreenState.ballPositionX = 50;
|
||||
gameScreenState.ballPositionY = 50;
|
||||
|
||||
// Move the ball to the right and check the position
|
||||
gameScreenState.moveBall(1.0);
|
||||
expect(gameScreenState.ballPositionX, greaterThan(50));
|
||||
|
||||
// Move the ball down and check the position
|
||||
gameScreenState.moveBall(1.0);
|
||||
expect(gameScreenState.ballPositionY, greaterThan(50));
|
||||
|
||||
// Test collision with the walls
|
||||
gameScreenState.ballPositionX = 0;
|
||||
gameScreenState.ballSpeedX = -1.0;
|
||||
gameScreenState.moveBall(1.0);
|
||||
expect(gameScreenState.ballSpeedX, greaterThan(0));
|
||||
});
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:pong/main.dart';
|
||||
|
||||
void main() {
|
||||
// Widget test for the "Berühren um zu beginnen!" message
|
||||
testWidgets('Tests "Berühren um zu beginnen!"', (WidgetTester tester) async {
|
||||
final tapToStart = find.text("Berühren um zu beginnen!");
|
||||
|
||||
// Build the widget tree with StartScreen and pump the widget tree
|
||||
await tester.pumpWidget(const MaterialApp(home: StartScreen()));
|
||||
|
||||
// Verify that the "Berühren um zu beginnen!" text is displayed
|
||||
expect(tapToStart, findsOneWidget);
|
||||
});
|
||||
|
||||
// Widget test for the "Punkte:" message in GameScreen
|
||||
testWidgets('Tests "Punkte:"', (WidgetTester tester) async {
|
||||
final points = find.text("Punkte: 0");
|
||||
|
||||
// Build the widget tree with GameScreen and pump the widget tree
|
||||
await tester.pumpWidget(const MaterialApp(home: GameScreen()));
|
||||
|
||||
// Verify that the "Punkte: 0" text is displayed
|
||||
expect(points, findsOneWidget);
|
||||
});
|
||||
|
||||
// Widget test for the UI of StartScreen
|
||||
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 is displayed.
|
||||
expect(find.text('Berühren um zu beginnen!'), findsOneWidget);
|
||||
|
||||
// Tap on the GestureDetector to navigate to GameScreen.
|
||||
await tester.tap(find.byType(GestureDetector));
|
||||
await tester.pump();
|
||||
|
||||
// Verify that the transition to GameScreen has occurred.
|
||||
expect(find.byType(GameScreen), findsOneWidget);
|
||||
});
|
||||
}
|
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 544 B |
Before Width: | Height: | Size: 442 B After Width: | Height: | Size: 442 B |
Before Width: | Height: | Size: 721 B After Width: | Height: | Size: 721 B |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 295 B After Width: | Height: | Size: 295 B |
Before Width: | Height: | Size: 406 B After Width: | Height: | Size: 406 B |
Before Width: | Height: | Size: 450 B After Width: | Height: | Size: 450 B |
Before Width: | Height: | Size: 282 B After Width: | Height: | Size: 282 B |
Before Width: | Height: | Size: 462 B After Width: | Height: | Size: 462 B |
Before Width: | Height: | Size: 704 B After Width: | Height: | Size: 704 B |
Before Width: | Height: | Size: 406 B After Width: | Height: | Size: 406 B |
Before Width: | Height: | Size: 586 B After Width: | Height: | Size: 586 B |
Before Width: | Height: | Size: 862 B After Width: | Height: | Size: 862 B |
Before Width: | Height: | Size: 862 B After Width: | Height: | Size: 862 B |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 762 B After Width: | Height: | Size: 762 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 68 B After Width: | Height: | Size: 68 B |
Before Width: | Height: | Size: 68 B After Width: | Height: | Size: 68 B |
Before Width: | Height: | Size: 68 B After Width: | Height: | Size: 68 B |
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 101 KiB |
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 520 B After Width: | Height: | Size: 520 B |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |