mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-02 11:43:19 +08:00
39 lines
1.0 KiB
Dart
39 lines
1.0 KiB
Dart
import 'package:flame/game.dart';
|
|
import 'package:flame_console/src/commands/pause_command.dart';
|
|
import 'package:flame_test/flame_test.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
group('Pause Command', () {
|
|
testWithGame(
|
|
'pauses the game',
|
|
FlameGame.new,
|
|
(game) async {
|
|
expect(game.paused, isFalse);
|
|
final command = PauseConsoleCommand();
|
|
command.execute(game, command.parser.parse([]));
|
|
expect(game.paused, isTrue);
|
|
},
|
|
);
|
|
|
|
group('when the game is already paused', () {
|
|
testWithGame(
|
|
'returns error',
|
|
FlameGame.new,
|
|
(game) async {
|
|
game.pauseEngine();
|
|
expect(game.paused, isTrue);
|
|
final command = PauseConsoleCommand();
|
|
final result = command.execute(game, command.parser.parse([]));
|
|
expect(game.paused, isTrue);
|
|
|
|
expect(
|
|
result.$1,
|
|
'Game is already paused, use the resume command start it again',
|
|
);
|
|
},
|
|
);
|
|
});
|
|
});
|
|
}
|