private void UpdateStateMachine() { // Stop editing the textBox EditorGUIUtility.editingTextField = false; // Update state machine RexISM.Update(); // Only reenable editing if the state is NOT intelliselect if (RexISM.State != RexInputState.IntelliSelect) { EditorGUIUtility.editingTextField = true; } else { _inputField.MoveLineEnd(); } if (RexISM.ShouldReplaceCode) { RexISM.Code = RexISM.ReplacementCode; //EditorGUI.FocusTextInControl(NameOfInputField); RexISM.ShouldReplaceCode = false; // This doesnt seem to work in with EditorGUI TextField GUI.FocusControl(NAME_OF_INPUT_FIELD); if (_inputField != null) { _inputField.text = RexISM.Code; _inputField.MoveLineEnd(); } } }
public void IntellisenseSelectionTest() { RexISM.Enter_Typing(); RexISM.Code = "Math.P"; RexISM.Update(); Assert.AreEqual(RexInputState.Typing, RexISM.State); Assert.IsTrue(RexISM.DisplayHelp); Assert.IsNotEmpty(RexISM.IntelliSenceHelp); Assert.AreEqual(RexISM.SelectedHelp, -1); PressKey(KeyCode.DownArrow); Assert.AreEqual(RexInputState.IntelliSelect, RexISM.State); Assert.AreEqual(RexISM.SelectedHelp, 0); RexISM.Enter_Typing(); Assert.AreEqual(RexInputState.Typing, RexISM.State); Assert.AreEqual(RexISM.SelectedHelp, -1); RexISM.Code = "x = Math."; RexISM.Update(); PressKey(KeyCode.DownArrow); Assert.AreEqual(RexInputState.IntelliSelect, RexISM.State); Assert.AreEqual(RexISM.SelectedHelp, 0); PressKey(KeyCode.DownArrow); Assert.AreEqual(RexInputState.IntelliSelect, RexISM.State); Assert.AreEqual(RexISM.SelectedHelp, 1); PressKey(KeyCode.Return); Assert.IsTrue(RexISM.Code.Contains("x = Math.")); }
void TestIntelliSelect(string code, IEnumerable <string> selections, bool withMethodOverloads = true) { RexISM.Enter_Typing(); RexISM.Code = code; RexISM.Update(); Assert.AreEqual(RexInputState.Typing, RexISM.State); Assert.IsTrue(RexISM.DisplayHelp); var help = RexISM.IntelliSenceHelp.Where(i => !i.IsMethodOverload); var meth = RexISM.IntelliSenceHelp.Where(i => i.IsMethodOverload); Assert.IsNotEmpty(help); if (withMethodOverloads) { Assert.IsNotEmpty(meth); } else { Assert.IsEmpty(meth); } Assert.AreEqual(-1, RexISM.SelectedHelp); var count = 0; foreach (var select in selections) { PressKey(KeyCode.DownArrow); Assert.AreEqual(select, RexISM.ReplacementString(), "At i = " + count); Assert.AreEqual(count++, RexISM.SelectedHelp); } }
public static void PressKey(KeyCode key, int repeat = 1) { for (int i = 0; i < repeat; i++) { RexISM.PressKey(key); RexISM.Update(); } }
public void IntellisenseTest() { RexISM.Enter_Typing(); RexISM.Code = "Math.P"; RexISM.Update(); Assert.AreEqual(RexInputState.Typing, RexISM.State); Assert.IsTrue(RexISM.DisplayHelp); Assert.IsNotEmpty(RexISM.IntelliSenceHelp); }
public void UpdateTest() { Assert.AreEqual(RexInputState.NoInput, RexISM.State); RexISM.Update(); Assert.AreEqual(RexInputState.NoInput, RexISM.State); RexISM.Enter_Typing(); Assert.AreEqual(RexInputState.Typing, RexISM.State); Assert.IsTrue(RexISM.DisplayHelp); RexISM.Update(); Assert.AreEqual(RexInputState.Typing, RexISM.State); Assert.IsTrue(RexISM.DisplayHelp); PressKey(KeyCode.Escape); RexISM.Update(); Assert.AreEqual(RexInputState.Typing, RexISM.State); Assert.IsFalse(RexISM.DisplayHelp); Assert.IsEmpty(RexISM.IntelliSenceHelp); }