Exercise an independent mouse release at the Windows desktop receiver

This commit is contained in:
creatixchu committed 2026-11-20 18:35:29 +08:00
1 parent cb0f0ffa9a
commit ad535742cb
2 files changed
+16 -6

No files matched your search

@@ -105,13 +105,12 @@ internal static class Program
{
private static void Write(object value) { Console.WriteLine(JsonSerializer.Serialize(value)); Console.Out.Flush(); }
private static void ReleaseButtons()
private static void SendMouse(params uint[] flags)
{
var inputs = new[] { 0x0004u, 0x0010u, 0x0040u }
.Select(flags => new Input { Type = 0, Data = new MouseInput { Flags = flags } }).ToArray();
var inputs = flags.Select(flag => new Input { Type = 0, Data = new MouseInput { Flags = flag } }).ToArray();
if (SendInput((uint)inputs.Length, inputs, Marshal.SizeOf<Input>()) != inputs.Length)
{
Console.Error.WriteLine("Fixture could not release every mouse button");
Console.Error.WriteLine("Fixture could not dispatch all requested mouse events");
Environment.ExitCode = 1;
}
}
@@ -148,7 +147,8 @@ internal static class Program
case "pointer-outside": form.PointOutside(); Write(form.Inspect()); break;
case "cover": form.Cover(sibling); Write(new { form = form.Inspect(), sibling = sibling.Inspect() }); break;
case "uncover": form.Uncover(sibling); Write(form.Inspect()); break;
case "release-input": ReleaseButtons(); Write(form.Inspect()); break;
case "left-up": SendMouse(0x0004); Write(form.Inspect()); break;
case "release-input": SendMouse(0x0004, 0x0010, 0x0040); Write(form.Inspect()); break;
case "minimize": form.WindowState = FormWindowState.Minimized; Write(form.Inspect()); break;
case "hide": form.Hide(); Write(form.Inspect()); break;
case "resize": form.Width += 50; Write(form.Inspect()); break;
@@ -170,9 +170,19 @@ it.skipIf(process.platform !== 'win32' || !helperPath || !fixturePath)(
await expect.poll(async () => (await inspect()).inputEvents.slice(offset)).toEqual(
['ShiftKey:down', 'Left:down', 'W:down', 'W:up', 'Left:up', 'ShiftKey:up'])
const beforeExternal = await inspect()
await toggle('left', 'down')
await observed({ downs: { left: beforeExternal.downs.left + 1 } })
await fixture.command('left-up', FixtureState)
await observed({ ups: { left: beforeExternal.ups.left + 1 } })
expect(released.parse(await holds()).map(input => input.button)).toEqual(['left'])
const afterExternal = await native.requestCleanup('releaseHeldInputs', { taskId })
expect(released.parse(afterExternal).map(input => input.button)).toEqual(['left'])
expect(await holds()).toEqual([])
const beforeSwitch = (await inspect()).inputEvents.length
await key('w', 'down')
await expect.poll(async () => (await inspect()).inputEvents.slice(beforeSwitch)).toEqual(['W:down'])
await expect.poll(async () => (await inspect()).inputEvents.slice(beforeSwitch)).toContain('W:down')
const switched = await fixture.command('sibling', FixtureState)
expect(switched.foreground).toBe(switched.window)
await native.dispose()