12using System.Collections;
18 public class InteractionButtonTests : InteractionEngineTestBase {
20 public enum ButtonEventType {
25 public enum ButtonActionType {
31 public IEnumerator TestButtonActionsDuringEvents(
32 [Values(ButtonEventType.OnPress,
33 ButtonEventType.OnUnpress)] ButtonEventType buttonEventType,
34 [Values(ButtonActionType.DisableIt,
35 ButtonActionType.DestroyIt)] ButtonActionType buttonActionType
38 yield
return wait(beginningTestWait);
40 InitTest(PRESS_BUTTON_RIG, DEFAULT_STAGE);
44 yield
return wait(aWhile);
50 System.Action buttonAction;
51 switch (buttonActionType) {
52 case ButtonActionType.DestroyIt:
53 buttonAction = () => { GameObject.Destroy(button); };
break;
54 case ButtonActionType.DisableIt:
55 buttonAction = () => { button.gameObject.SetActive(
false); };
break;
57 throw new System.NotImplementedException(
"This action is not implemented.");
61 bool eventFired =
false;
62 System.Action doOnEvent = () => {
67 switch (buttonEventType) {
68 case ButtonEventType.OnPress:
69 button.OnPress += doOnEvent;
break;
70 case ButtonEventType.OnUnpress:
71 button.OnUnpress += doOnEvent;
break;
73 throw new System.NotImplementedException(
"This button event is not implemented.");
78 while (!eventFired && framesWaited < WAIT_FOR_INTERACTION_FRAME_LIMIT) {
82 Assert.That(framesWaited != WAIT_FOR_INTERACTION_FRAME_LIMIT,
83 "Test recording failed to press the button (fire the event).");
87 if (buttonActionType == ButtonActionType.DestroyIt
88 || buttonActionType == ButtonActionType.DisableIt) {
90 Assert.That(rightHand.primaryHoverLocked ==
false,
91 "Primary hover lock was active even after the button was disabled "
95 yield
return wait(endingTestWait);