public IEnumerator PressRight() { var rightKey = _keyboard.dKey; _inputSystem.Press(rightKey); yield return(new WaitForEndOfFrame()); }
public InputPress(InputTestFixture input, params ButtonControl[] controls) { this.input = input; this.controls = controls; foreach (var control in controls) { input.Press(control); } InputSystem.Update(); }
public IEnumerator TestAvatarInput([ValueSource(nameof(MOVEMENT_DIRECTIONS))] Move move) { AsyncOperation operation = SceneManager.LoadSceneAsync(SCENE_NAME); yield return(new WaitUntil(() => operation.isDone)); var avatar = FindAvatars().First(); var target = move.direction; avatar.transform.position = Vector3.zero; yield return(new WaitForFixedUpdate()); Assert.AreEqual(Vector3.zero, avatar.transform.position, $"Must not move avatar when no input is happening."); Array.ForEach(move.keys, key => input.Press(key)); InputSystem.Update(); yield return(new WaitForFixedUpdate()); var actual = avatar.transform.position; Assert.AreEqual(Math.Sign(target.x), Math.Sign(actual.x), $"With input {move}, avatar's x should've moved towards {target.x}"); Assert.AreEqual(Math.Sign(target.y), Math.Sign(actual.y), $"With input {move}, avatar's y should've moved towards {target.y}"); Assert.AreEqual(Math.Sign(target.z), Math.Sign(actual.z), $"With input {move}, avatar's z should've moved towards {target.z}"); yield return(new WaitForFixedUpdate()); Assert.AreNotEqual(actual, avatar.transform.position, $"Avatar must keep moving in direction {target}"); actual = avatar.transform.position; Array.ForEach(move.keys, key => input.Release(key)); InputSystem.Update(); yield return(new WaitForFixedUpdate()); Assert.AreEqual(actual, avatar.transform.position, $"Avatar should've stopped at position {actual}"); }