public static IEnumerator SimulateMouseMove(EditorWindow window, Vector2 positionFrom, Vector2 positionTo, MouseButton button = MouseButton.LeftMouse, EventModifiers modifiers = EventModifiers.None) { const int dragSamples = 10; const int moveFramesDelay = 1; var dragDistance = Vector2.Distance(positionFrom, positionTo); var dragSpeed = Mathf.Max(1f, dragDistance / dragSamples); var normalizedDirection = (positionTo - positionFrom).normalized; var currentMousePosition = positionFrom; do { currentMousePosition += dragSpeed * normalizedDirection; var moveEvt = new Event { type = EventType.MouseMove, mousePosition = currentMousePosition, delta = normalizedDirection, button = (int)button, modifiers = modifiers }; window.rootVisualElement.SendEvent(UIETestEvents.MakeEvent(moveEvt)); yield return(UIETestHelpers.Pause(moveFramesDelay)); } while (Vector2.Distance(currentMousePosition, positionTo) > 1f); }
public static EventBase MakeMouseMoveEvent(Vector2 deltaMove, MouseButton button = MouseButton.LeftMouse, EventModifiers modifiers = EventModifiers.None, int clickCount = 1) { var evt = new Event { type = EventType.MouseMove, delta = deltaMove, button = (int)button, modifiers = modifiers, clickCount = clickCount }; return(UIETestEvents.MakeEvent(evt)); }
public static EventBase MakeEvent(EventType type, Vector2 position, MouseButton button = MouseButton.LeftMouse, EventModifiers modifiers = EventModifiers.None, int clickCount = 1) { var evt = new Event { type = type, mousePosition = position, button = (int)button, modifiers = modifiers, clickCount = clickCount }; return(UIETestEvents.MakeEvent(evt)); }
public static EventBase MakeEvent(EventType type, char character, EventModifiers modifiers = EventModifiers.None) { var evt = new Event { type = type, keyCode = KeyCode.None, character = character, modifiers = modifiers }; return(UIETestEvents.MakeEvent(evt)); }
public static EventBase SimulateScroll(Vector2 delta, Vector2 position) { var evt = new Event { type = EventType.ScrollWheel, delta = delta, mousePosition = position }; return(UIETestEvents.MakeEvent(evt)); }
public static IEnumerator SimulateScroll(Vector2 delta, Vector2 position) { var evt = new Event { type = EventType.ScrollWheel, delta = delta, mousePosition = position }; UIETestEvents.MakeEvent(evt); yield return(UIETestHelpers.Pause()); }
public static IEnumerator SimulateScroll(VisualElement target, Vector2 delta, Vector2 position) { Assert.That(target.panel, Is.Not.Null); var root = UIETestHelpers.GetRoot(target); var evt = new Event { type = EventType.ScrollWheel, delta = delta, mousePosition = position }; var scrollEvent = UIETestEvents.MakeEvent(evt); root.SendEvent(scrollEvent); yield return(UIETestHelpers.Pause()); }