Merge branch 'main' into feat/spaceship-drop-assets

pull/110/head
RuiAlonso 4 years ago
commit 0ab616cdad

@ -23,6 +23,11 @@ abstract class ComponentController<T extends Component> extends Component {
);
await super.addToParent(parent);
}
@override
Future<void> add(Component component) {
throw Exception('ComponentController cannot add other components.');
}
}
/// Mixin that attaches a single [ComponentController] to a [Component].

@ -31,6 +31,7 @@ void main() {
);
},
);
flameTester.test(
'throws AssertionError when not attached to controlled component',
(game) async {
@ -44,6 +45,35 @@ void main() {
);
},
);
flameTester.test(
'throws Exception when adding a component',
(game) async {
final component = ControlledComponent();
final controller = TestComponentController(component);
await expectLater(
() async => controller.add(Component()),
throwsException,
);
},
);
flameTester.test(
'throws Exception when adding multiple components',
(game) async {
final component = ControlledComponent();
final controller = TestComponentController(component);
await expectLater(
() async => controller.addAll([
Component(),
Component(),
]),
throwsException,
);
},
);
});
group('Controls', () {

Loading…
Cancel
Save