From 466c1ce2a248f4a68e5425e226c9df0437ebf395 Mon Sep 17 00:00:00 2001 From: alestiago Date: Wed, 30 Mar 2022 20:23:47 +0100 Subject: [PATCH] feat: included Controls tests --- test/flame/component_controller_test.dart | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/flame/component_controller_test.dart b/test/flame/component_controller_test.dart index ab9bddd0..cef304b3 100644 --- a/test/flame/component_controller_test.dart +++ b/test/flame/component_controller_test.dart @@ -10,6 +10,14 @@ class TestComponentController extends ComponentController { TestComponentController(Component component) : super(component); } +class ControlledComponent extends Component + with Controls { + ControlledComponent() : super(); + + @override + TestComponentController controllerBuilder() => TestComponentController(this); +} + void main() { TestWidgetsFlutterBinding.ensureInitialized(); final flameTester = FlameTester(FlameGame.new); @@ -38,4 +46,22 @@ void main() { }, ); }); + + group('Controls', () { + flameTester.test( + 'can be instantiated', + (game) async { + expect(ControlledComponent(), isA()); + }, + ); + + flameTester.test('adds controller', (game) async { + final component = ControlledComponent(); + + await game.add(component); + await game.ready(); + + expect(component.contains(component.controller), isTrue); + }); + }); }