From b595b53342c6f74ec0ffc1cfd5cd9001397dff42 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 13 Jun 2025 04:02:00 +0000 Subject: [PATCH 1/2] Initial plan for issue From 62b66a111dd74883714462b2f1a105c1cd4f95be Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 13 Jun 2025 04:08:06 +0000 Subject: [PATCH 2/2] Add RightDoubleClick, MiddleClick, and MiddleDoubleClick extension methods with tests Co-authored-by: Keboo <952248+Keboo@users.noreply.github.com> --- XAMLTest.Tests/MouseInputTests.cs | 12 ++++ XAMLTest.Tests/SendMouseInputTests.cs | 81 ++++++++++++++++++++++----- XAMLTest/VisualElementMixins.Input.cs | 66 ++++++++++++++++++---- 3 files changed, 132 insertions(+), 27 deletions(-) diff --git a/XAMLTest.Tests/MouseInputTests.cs b/XAMLTest.Tests/MouseInputTests.cs index e6741b8..14639d8 100644 --- a/XAMLTest.Tests/MouseInputTests.cs +++ b/XAMLTest.Tests/MouseInputTests.cs @@ -9,4 +9,16 @@ public void CanRetrieveMouseDoubleClickTime() Assert.IsTrue(MouseInput.GetDoubleClickTime > TimeSpan.Zero); } + [TestMethod] + public void DoubleClickTimeIsAccessibleWithoutWinForms() + { + // Verify that GetDoubleClickTime works without needing WinForms reference + TimeSpan doubleClickTime = MouseInput.GetDoubleClickTime; + Assert.IsTrue(doubleClickTime.TotalMilliseconds > 0); + + // Typical double click time should be between 100ms and 1000ms + Assert.IsTrue(doubleClickTime.TotalMilliseconds >= 100); + Assert.IsTrue(doubleClickTime.TotalMilliseconds <= 1000); + } + } diff --git a/XAMLTest.Tests/SendMouseInputTests.cs b/XAMLTest.Tests/SendMouseInputTests.cs index d6fedcc..b3630d8 100644 --- a/XAMLTest.Tests/SendMouseInputTests.cs +++ b/XAMLTest.Tests/SendMouseInputTests.cs @@ -89,21 +89,72 @@ await Wait.For(async () => recorder.Success(); } - [TestMethod] - public async Task CanDoubleClickOnButton() - { - await using var recorder = new TestRecorder(App); - - await using IEventRegistration registration = await Button.RegisterForEvent(nameof(Control.MouseDoubleClick)); - - await Wait.For(async () => - { - await Button.LeftDoubleClick(); - var invocations = await registration.GetInvocations(); - Assert.IsTrue(invocations.Count > 1); - }); - - recorder.Success(); + [TestMethod] + public async Task CanDoubleClickOnButton() + { + await using var recorder = new TestRecorder(App); + + await using IEventRegistration registration = await Button.RegisterForEvent(nameof(Control.MouseDoubleClick)); + + await Wait.For(async () => + { + await Button.LeftDoubleClick(); + var invocations = await registration.GetInvocations(); + Assert.IsTrue(invocations.Count > 1); + }); + + recorder.Success(); + } + + [TestMethod] + public async Task CanRightDoubleClickOnButton() + { + await using var recorder = new TestRecorder(App); + + await using IEventRegistration registration = await Button.RegisterForEvent(nameof(Control.MouseDoubleClick)); + + await Wait.For(async () => + { + await Button.RightDoubleClick(); + var invocations = await registration.GetInvocations(); + Assert.IsTrue(invocations.Count > 1); + }); + + recorder.Success(); + } + + [TestMethod] + public async Task CanMiddleClickOnButton() + { + await using var recorder = new TestRecorder(App); + + await using IEventRegistration registration = await Button.RegisterForEvent(nameof(Control.MouseUp)); + + await Wait.For(async () => + { + await Button.MiddleClick(); + var invocations = await registration.GetInvocations(); + Assert.IsTrue(invocations.Count > 0); + }); + + recorder.Success(); + } + + [TestMethod] + public async Task CanMiddleDoubleClickOnButton() + { + await using var recorder = new TestRecorder(App); + + await using IEventRegistration registration = await Button.RegisterForEvent(nameof(Control.MouseDoubleClick)); + + await Wait.For(async () => + { + await Button.MiddleDoubleClick(); + var invocations = await registration.GetInvocations(); + Assert.IsTrue(invocations.Count > 1); + }); + + recorder.Success(); } [TestMethod] diff --git a/XAMLTest/VisualElementMixins.Input.cs b/XAMLTest/VisualElementMixins.Input.cs index e65e49a..5d54458 100644 --- a/XAMLTest/VisualElementMixins.Input.cs +++ b/XAMLTest/VisualElementMixins.Input.cs @@ -49,18 +49,60 @@ public static async Task LeftDoubleClick(this IVisualElement element, clickTime); } - public static async Task RightClick(this IVisualElement element, - Position position = Position.Center, - int xOffset = 0, int yOffset = 0, - TimeSpan? clickTime = null) - { - return await SendClick(element, - MouseInput.RightDown(), - MouseInput.RightUp(), - position, - xOffset, - yOffset, - clickTime); + public static async Task RightClick(this IVisualElement element, + Position position = Position.Center, + int xOffset = 0, int yOffset = 0, + TimeSpan? clickTime = null) + { + return await SendClick(element, + MouseInput.RightDown(), + MouseInput.RightUp(), + position, + xOffset, + yOffset, + clickTime); + } + + public static async Task RightDoubleClick(this IVisualElement element, + Position position = Position.Center, + int xOffset = 0, int yOffset = 0, + TimeSpan? clickTime = null) + { + return await SendDoubleClick(element, + MouseInput.RightDown(), + MouseInput.RightUp(), + position, + xOffset, + yOffset, + clickTime); + } + + public static async Task MiddleClick(this IVisualElement element, + Position position = Position.Center, + int xOffset = 0, int yOffset = 0, + TimeSpan? clickTime = null) + { + return await SendClick(element, + MouseInput.MiddleDown(), + MouseInput.MiddleUp(), + position, + xOffset, + yOffset, + clickTime); + } + + public static async Task MiddleDoubleClick(this IVisualElement element, + Position position = Position.Center, + int xOffset = 0, int yOffset = 0, + TimeSpan? clickTime = null) + { + return await SendDoubleClick(element, + MouseInput.MiddleDown(), + MouseInput.MiddleUp(), + position, + xOffset, + yOffset, + clickTime); } public static async Task SendClick(IVisualElement element,