-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow multiple inputs of the same type (#3134)
* allow multiple inputs of the same type * fix error * use addInput * add InputFrontEnd tests
- Loading branch information
Showing
4 changed files
with
150 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
tests/unit/src/flixel/system/frontEnds/InputFrontEndTest.hx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package flixel.system.frontEnds; | ||
|
||
import flixel.system.frontEnds.InputFrontEnd; | ||
import flixel.FlxG; | ||
import flixel.input.IFlxInputManager; | ||
import massive.munit.Assert; | ||
|
||
class InputFrontEndTest | ||
{ | ||
var inputs:InputFrontEnd; | ||
|
||
@Before | ||
function before():Void | ||
{ | ||
@:privateAccess | ||
inputs = new InputFrontEnd(); | ||
} | ||
|
||
@Test | ||
@:haxe.warning("-WDeprecated") | ||
function testAdd() | ||
{ | ||
final input1 = new CustomInputManager(); | ||
inputs.add(input1); | ||
FlxAssert.arrayContains(inputs.list, input1); | ||
|
||
final input2 = new CustomInputManager(); | ||
inputs.add(input2); | ||
FlxAssert.arrayNotContains(inputs.list, input2); | ||
} | ||
|
||
@Test | ||
function testAddUniqueType() | ||
{ | ||
final input1 = new CustomInputManager(); | ||
inputs.addUniqueType(input1); | ||
FlxAssert.arrayContains(inputs.list, input1); | ||
|
||
final input2 = new CustomInputManager(); | ||
inputs.addUniqueType(input2); | ||
FlxAssert.arrayNotContains(inputs.list, input2); | ||
} | ||
|
||
@Test | ||
function testAddInput() | ||
{ | ||
final input1 = new CustomInputManager(); | ||
inputs.addInput(input1); | ||
FlxAssert.arrayContains(inputs.list, input1); | ||
|
||
final oldLength = inputs.list.length; | ||
// add again | ||
inputs.addInput(input1); | ||
Assert.areEqual(inputs.list.length, oldLength); | ||
|
||
final input2 = new CustomInputManager(); | ||
inputs.addInput(input2); | ||
FlxAssert.arrayContains(inputs.list, input2); | ||
} | ||
} | ||
|
||
class CustomInputManager implements IFlxInputManager | ||
{ | ||
public function new () {} | ||
public function destroy() {} | ||
public function reset():Void {} | ||
function update():Void {} | ||
function onFocus():Void {} | ||
function onFocusLost():Void {} | ||
} |