|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
// ignore_for_file: prefer_const_constructors
|
|
|
|
|
|
|
|
|
|
import 'dart:ui';
|
|
|
|
|
|
|
|
|
|
import 'package:bloc_test/bloc_test.dart';
|
|
|
|
|
import 'package:flame/game.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
@ -291,5 +293,43 @@ void main() {
|
|
|
|
|
findsNothing,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWidgets('keep focus on game when mouse hovers over it', (tester) async {
|
|
|
|
|
final startGameState = StartGameState.initial().copyWith(
|
|
|
|
|
status: StartGameStatus.play,
|
|
|
|
|
);
|
|
|
|
|
final gameState = GameState.initial().copyWith(
|
|
|
|
|
status: GameStatus.gameOver,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
whenListen(
|
|
|
|
|
startGameBloc,
|
|
|
|
|
Stream.value(startGameState),
|
|
|
|
|
initialState: startGameState,
|
|
|
|
|
);
|
|
|
|
|
whenListen(
|
|
|
|
|
gameBloc,
|
|
|
|
|
Stream.value(gameState),
|
|
|
|
|
initialState: gameState,
|
|
|
|
|
);
|
|
|
|
|
await tester.pumpApp(
|
|
|
|
|
PinballGameView(game: game),
|
|
|
|
|
gameBloc: gameBloc,
|
|
|
|
|
startGameBloc: startGameBloc,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
game.focusNode.unfocus();
|
|
|
|
|
await tester.pump();
|
|
|
|
|
|
|
|
|
|
expect(game.focusNode.hasFocus, isFalse);
|
|
|
|
|
|
|
|
|
|
final gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
|
|
|
|
|
await gesture.addPointer(location: Offset.zero);
|
|
|
|
|
addTearDown(gesture.removePointer);
|
|
|
|
|
await gesture.moveTo((game.size / 2).toOffset());
|
|
|
|
|
await tester.pump();
|
|
|
|
|
|
|
|
|
|
expect(game.focusNode.hasFocus, isTrue);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|