update
parent
e850a61cda
commit
8306c01d1d
|
@ -23,6 +23,5 @@ linter:
|
|||
rules:
|
||||
# avoid_print: false # Uncomment to disable the `avoid_print` rule
|
||||
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
|
||||
|
||||
# Additional information about this file can be found at
|
||||
# https://dart.dev/guides/language/analysis-options
|
||||
|
|
|
@ -8,7 +8,7 @@ import 'package:flutter/scheduler.dart';
|
|||
import 'package:pong/pong_menu.dart';
|
||||
|
||||
void main() {
|
||||
// Run the PongGame
|
||||
// Run the PongGame app
|
||||
runApp(const PongGame());
|
||||
}
|
||||
|
||||
|
|
|
@ -66,10 +66,10 @@ packages:
|
|||
dependency: "direct dev"
|
||||
description:
|
||||
name: flutter_lints
|
||||
sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04
|
||||
sha256: e2a421b7e59244faef694ba7b30562e489c2b489866e505074eb005cd7060db7
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.3"
|
||||
version: "3.0.1"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
|
@ -79,10 +79,10 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: lints
|
||||
sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
|
||||
sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
version: "3.0.0"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -44,7 +44,7 @@ dev_dependencies:
|
|||
# activated in the `analysis_options.yaml` file located at the root of your
|
||||
# package. See that file for information about deactivating specific lint
|
||||
# rules and activating additional ones.
|
||||
flutter_lints: ^2.0.0
|
||||
flutter_lints: ^3.0.1
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
|
|
@ -1,7 +1,35 @@
|
|||
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('moveRacket', () {});
|
||||
|
||||
test('moveBall updates ball position and handles collisions', () {
|
||||
final gameScreenState = GameScreenState();
|
||||
|
||||
// Setze den Ball in eine Ausgangsposition
|
||||
gameScreenState.ballPositionX = 50;
|
||||
gameScreenState.ballPositionY = 50;
|
||||
|
||||
// Bewege den Ball nach rechts und überprüfe die Position
|
||||
gameScreenState.moveBall(1.0);
|
||||
expect(gameScreenState.ballPositionX, greaterThan(50));
|
||||
|
||||
// Bewege den Ball nach unten und überprüfe die Position
|
||||
gameScreenState.moveBall(1.0);
|
||||
expect(gameScreenState.ballPositionY, greaterThan(50));
|
||||
|
||||
// Teste die Kollision mit den Wänden
|
||||
gameScreenState.ballPositionX = 0;
|
||||
gameScreenState.ballSpeedX = -1.0;
|
||||
gameScreenState.moveBall(1.0);
|
||||
expect(gameScreenState.ballSpeedX,
|
||||
greaterThan(0)); // Die Richtung des Balls sollte sich ändern
|
||||
|
||||
// Füge weitere Tests für Kollisionen hinzu
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,16 +1,40 @@
|
|||
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.byKey(const ValueKey("tapToStart"));
|
||||
final tapToStart = find.text("Berühren um zu beginnen!");
|
||||
|
||||
await tester.pumpWidget(const MaterialApp(home: StartScreen()));
|
||||
await tester.tap(tapToStart);
|
||||
|
||||
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();
|
||||
|
||||
expect(find.text("Berühren um zu beginnen!"), findsOneWidget);
|
||||
// Verify, dass der Übergang zur GameScreen erfolgt ist.
|
||||
expect(find.byType(GameScreen), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue