@ -1,9 +1,12 @@
import ' package:flame/components.dart ' ;
import ' package:flame_forge2d/contact_callbacks.dart ' ;
import ' package:flutter_test/flutter_test.dart ' ;
import ' package:mocktail/mocktail.dart ' ;
import ' package:pinball_ components/pinball_components .dart' ;
import ' package:pinball_ flame/pinball_flame .dart' ;
import ' ../../helpers/helpers.dart ' ;
import ' ../helpers/helpers.dart ' ;
class TestContactCallback extends ContactCallback < dynamic , dynamic > { }
class MyBlueprint extends Blueprint {
@ override
@ -51,19 +54,19 @@ void main() {
} ) ;
test ( ' components can be added to it ' , ( ) {
final blueprint = MyBlueprint ( ) . . build ( Mock Game( ) ) ;
final blueprint = MyBlueprint ( ) . . build ( Mock Forge2D Game( ) ) ;
expect ( blueprint . components . length , equals ( 3 ) ) ;
} ) ;
test ( ' blueprints can be added to it ' , ( ) {
final blueprint = MyComposedBlueprint ( ) . . build ( Mock Game( ) ) ;
final blueprint = MyComposedBlueprint ( ) . . build ( Mock Forge2D Game( ) ) ;
expect ( blueprint . blueprints . length , equals ( 3 ) ) ;
} ) ;
test ( ' adds the components to a game on attach ' , ( ) {
final mockGame = Mock Game( ) ;
final mockGame = Mock Forge2D Game( ) ;
when ( ( ) = > mockGame . addAll ( any ( ) ) ) . thenAnswer ( ( _ ) async { } ) ;
MyBlueprint ( ) . attach ( mockGame ) ;
@ -71,7 +74,7 @@ void main() {
} ) ;
test ( ' adds components from a child Blueprint the to a game on attach ' , ( ) {
final mockGame = Mock Game( ) ;
final mockGame = Mock Forge2D Game( ) ;
when ( ( ) = > mockGame . addAll ( any ( ) ) ) . thenAnswer ( ( _ ) async { } ) ;
MyComposedBlueprint ( ) . attach ( mockGame ) ;
@ -81,7 +84,7 @@ void main() {
test (
' throws assertion error when adding to an already attached blueprint ' ,
( ) async {
final mockGame = Mock Game( ) ;
final mockGame = Mock Forge2D Game( ) ;
when ( ( ) = > mockGame . addAll ( any ( ) ) ) . thenAnswer ( ( _ ) async { } ) ;
final blueprint = MyBlueprint ( ) ;
await blueprint . attach ( mockGame ) ;
@ -94,17 +97,17 @@ void main() {
group ( ' Forge2DBlueprint ' , ( ) {
setUpAll ( ( ) {
registerFallbackValue ( SpaceshipHoleBall ContactCallback( ) ) ;
registerFallbackValue ( Test ContactCallback( ) ) ;
} ) ;
test ( ' callbacks can be added to it ' , ( ) {
final blueprint = MyForge2dBlueprint ( ) . . build ( Mock Game( ) ) ;
final blueprint = MyForge2dBlueprint ( ) . . build ( Mock Forge2D Game( ) ) ;
expect ( blueprint . callbacks . length , equals ( 3 ) ) ;
} ) ;
test ( ' adds the callbacks to a game on attach ' , ( ) async {
final mockGame = Mock Game( ) ;
final mockGame = Mock Forge2D Game( ) ;
when ( ( ) = > mockGame . addAll ( any ( ) ) ) . thenAnswer ( ( _ ) async { } ) ;
when ( ( ) = > mockGame . addContactCallback ( any ( ) ) ) . thenAnswer ( ( _ ) async { } ) ;
await MyForge2dBlueprint ( ) . attach ( mockGame ) ;
@ -115,7 +118,7 @@ void main() {
test (
' throws assertion error when adding to an already attached blueprint ' ,
( ) async {
final mockGame = Mock Game( ) ;
final mockGame = Mock Forge2D Game( ) ;
when ( ( ) = > mockGame . addAll ( any ( ) ) ) . thenAnswer ( ( _ ) async { } ) ;
when ( ( ) = > mockGame . addContactCallback ( any ( ) ) ) . thenAnswer ( ( _ ) async { } ) ;
final blueprint = MyForge2dBlueprint ( ) ;