forked from dotnet/winforms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass SendKeys state by ref (dotnet#6711)
Regression introduced in 90f7c1d. Fixes dotnet#6666 Co-authored-by: Jeremy Kuhne <jkuhne@microsoft.com>
- Loading branch information
1 parent
f7295a4
commit e9e5c8c
Showing
2 changed files
with
46 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/SendKeysTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using Xunit; | ||
|
||
namespace System.Windows.Forms.Tests | ||
{ | ||
public class SendKeysTests | ||
{ | ||
[WinFormsFact(Skip = "This test depends on focus and should be run manually.")] | ||
public void SendKeysGrouping() | ||
{ | ||
// Regression https://github.com/dotnet/winforms/issues/6666 | ||
|
||
using var form = new CaptureForm(); | ||
form.Show(); | ||
form.Focus(); | ||
SendKeys.SendWait("^(a)^(c)"); | ||
|
||
Assert.Equal(4, form.KeyEvents.Count); | ||
Assert.Equal(Keys.ControlKey, form.KeyEvents[0].KeyCode); | ||
Assert.Equal(Keys.A, form.KeyEvents[1].KeyCode); | ||
Assert.Equal(Keys.Control, form.KeyEvents[1].Modifiers); | ||
Assert.Equal(Keys.ControlKey, form.KeyEvents[2].KeyCode); | ||
Assert.Equal(Keys.C, form.KeyEvents[3].KeyCode); | ||
Assert.Equal(Keys.Control, form.KeyEvents[3].Modifiers); | ||
} | ||
|
||
private class CaptureForm : Form | ||
{ | ||
public List<KeyEventArgs> KeyEvents { get; } = new(); | ||
|
||
protected override void OnKeyDown(KeyEventArgs e) | ||
{ | ||
KeyEvents.Add(e); | ||
base.OnKeyDown(e); | ||
} | ||
} | ||
} | ||
} |