-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Removes dependency on RemoteExecutor in tests #14538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ricardobossan
wants to merge
4
commits into
dotnet:main
Choose a base branch
from
ricardobossan:Issue_4500_Remove_RemoteExecutor
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
src/test/integration/UIIntegrationTests/Application.ParkingWindowTests.cs
This file contains hidden or 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,53 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace System.Windows.Forms.UITests; | ||
|
|
||
| // Migrated from unit tests; see issue #4500. | ||
| public class ParkingWindowTests : ControlTestBase | ||
| { | ||
| public ParkingWindowTests(ITestOutputHelper testOutputHelper) | ||
| : base(testOutputHelper) | ||
| { | ||
| } | ||
|
|
||
| [WinFormsFact] | ||
| public void ParkingWindow_DoesNotThrowOnGarbageCollecting() | ||
| { | ||
| bool original = Control.CheckForIllegalCrossThreadCalls; | ||
| Control.CheckForIllegalCrossThreadCalls = true; | ||
|
|
||
| try | ||
| { | ||
| using Form form = InitFormWithControlToGarbageCollect(); | ||
|
|
||
| // Access ComboBox from the GC thread; test passes if this does not throw. | ||
| GC.Collect(); | ||
| GC.WaitForPendingFinalizers(); | ||
| } | ||
| finally | ||
| { | ||
| Control.CheckForIllegalCrossThreadCalls = original; | ||
| } | ||
| } | ||
|
|
||
| private static Form InitFormWithControlToGarbageCollect() | ||
| { | ||
| Form form = new(); | ||
| ComboBox comboBox = new() | ||
| { | ||
| DropDownStyle = ComboBoxStyle.DropDown | ||
| }; | ||
|
|
||
| form.Controls.Add(comboBox); | ||
| form.Show(); | ||
|
|
||
| // Park ComboBox handle in ParkingWindow. | ||
| comboBox.Parent = null; | ||
|
|
||
| // Recreate ComboBox handle to set parent to ParkingWindow. | ||
| comboBox.DropDownStyle = ComboBoxStyle.DropDownList; | ||
|
|
||
| return form; | ||
| } | ||
| } | ||
113 changes: 113 additions & 0 deletions
113
src/test/integration/UIIntegrationTests/Application.StaticStateTests.cs
This file contains hidden or 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,113 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Globalization; | ||
| using System.Windows.Forms.VisualStyles; | ||
|
|
||
| namespace System.Windows.Forms.UITests; | ||
|
|
||
| // Migrated from unit tests; see issue #4500. | ||
| public class ApplicationStaticStateTests : ControlTestBase | ||
| { | ||
| public ApplicationStaticStateTests(ITestOutputHelper testOutputHelper) | ||
| : base(testOutputHelper) | ||
| { | ||
| } | ||
|
|
||
| public static IEnumerable<object[]> CurrentCulture_Set_TestData() | ||
| { | ||
| yield return new object[] { CultureInfo.InvariantCulture }; | ||
| yield return new object[] { new CultureInfo("en") }; | ||
| yield return new object[] { new CultureInfo("fr-FR") }; | ||
| yield return new object[] { new CultureInfo("en-DK") }; | ||
| yield return new object[] { new CultureInfo("haw") }; | ||
| yield return new object[] { new CultureInfo("en-US") }; | ||
| yield return new object[] { new CultureInfo("de-DE_phoneb") }; | ||
| yield return new object[] { new CustomLCIDCultureInfo(10) }; | ||
| yield return new object[] { new CustomLCIDCultureInfo(0) }; | ||
| yield return new object[] { new CustomLCIDCultureInfo(-1) }; | ||
| } | ||
|
|
||
| [WinFormsFact] | ||
| public void Application_CurrentCulture_Set_GetReturnsExpected() | ||
| { | ||
| // GetThreadLocale round-trip assertion dropped: [UseDefaultXunitCulture] restores the | ||
| // thread locale per test, and SetThreadLocale silently no-ops for LCID 0x7F on STA hosts. | ||
| // Managed CurrentCulture surface is still verified below. | ||
| CultureInfo originalApplicationCulture = Application.CurrentCulture; | ||
| CultureInfo originalThreadCulture = Thread.CurrentThread.CurrentCulture; | ||
|
|
||
| try | ||
| { | ||
| foreach (object[] testData in CurrentCulture_Set_TestData()) | ||
| { | ||
| CultureInfo value = (CultureInfo)testData[0]; | ||
|
|
||
| CultureInfo oldValue = Application.CurrentCulture; | ||
| try | ||
| { | ||
|
ricardobossan marked this conversation as resolved.
|
||
| Application.CurrentCulture = value; | ||
| Assert.Same(value, Application.CurrentCulture); | ||
| Assert.Same(value, Thread.CurrentThread.CurrentCulture); | ||
| Assert.Same(value, CultureInfo.CurrentCulture); | ||
|
|
||
| // Set same. | ||
| Application.CurrentCulture = value; | ||
| Assert.Same(value, Application.CurrentCulture); | ||
| Assert.Same(value, Thread.CurrentThread.CurrentCulture); | ||
| Assert.Same(value, CultureInfo.CurrentCulture); | ||
| } | ||
| finally | ||
| { | ||
| Application.CurrentCulture = oldValue; | ||
| } | ||
| } | ||
| } | ||
| finally | ||
| { | ||
| Application.CurrentCulture = originalApplicationCulture; | ||
| Thread.CurrentThread.CurrentCulture = originalThreadCulture; | ||
| } | ||
| } | ||
|
|
||
| [WinFormsFact] | ||
| public void Application_EnableVisualStyles_InvokeBeforeGettingRenderWithVisualStyles_Success() | ||
| { | ||
| Application.EnableVisualStyles(); | ||
| Assert.True(Application.UseVisualStyles); | ||
| Assert.True(Application.RenderWithVisualStyles); | ||
| } | ||
|
|
||
| // InvokeAfterGettingRenderWithVisualStyles_Success dropped: precondition UseVisualStyles==false | ||
| // is unsatisfiable here (EnableVisualStyles is a one-way switch and the host already enabled it). | ||
|
|
||
| [WinFormsTheory] | ||
| [EnumData<VisualStyleState>] | ||
| [InvalidEnumData<VisualStyleState>] | ||
| public void Application_VisualStyleState_Set_ReturnsExpected(VisualStyleState value) | ||
| { | ||
| // Serial execution in UIIntegrationTests prevents WM_THEMECHANGED cross-test interference. | ||
| VisualStyleState state = Application.VisualStyleState; | ||
| try | ||
| { | ||
| Application.VisualStyleState = value; | ||
| Assert.Equal(value, Application.VisualStyleState); | ||
| } | ||
| finally | ||
| { | ||
| Application.VisualStyleState = state; | ||
| } | ||
| } | ||
|
|
||
| private class CustomLCIDCultureInfo : CultureInfo | ||
| { | ||
| private readonly int _lcid; | ||
|
|
||
| public CustomLCIDCultureInfo(int lcid) : base("en-US") | ||
| { | ||
| _lcid = lcid; | ||
| } | ||
|
|
||
| public override int LCID => _lcid; | ||
| } | ||
| } | ||
69 changes: 69 additions & 0 deletions
69
src/test/integration/UIIntegrationTests/CommonDialogTests.cs
This file contains hidden or 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,69 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using Moq; | ||
|
|
||
| namespace System.Windows.Forms.UITests; | ||
|
|
||
| // Migrated from unit tests; see issue #4500. | ||
| public class CommonDialogTests : ControlTestBase | ||
| { | ||
| public CommonDialogTests(ITestOutputHelper testOutputHelper) | ||
| : base(testOutputHelper) | ||
| { | ||
| } | ||
|
|
||
| [WinFormsTheory] | ||
| [InlineData(true, DialogResult.OK)] | ||
| [InlineData(false, DialogResult.Cancel)] | ||
| public void ShowDialog_NonControlOwnerWithVisualStyles_ReturnsExpected(bool runDialogResult, DialogResult expectedDialogResult) | ||
| { | ||
| using SubCommonDialog dialog = new() | ||
| { | ||
| RunDialogResult = runDialogResult | ||
| }; | ||
| var owner = new Mock<IWin32Window>(MockBehavior.Strict); | ||
| owner | ||
| .Setup(o => o.Handle) | ||
| .Returns(IntPtr.Zero); | ||
| Assert.Equal(expectedDialogResult, dialog.ShowDialog(owner.Object)); | ||
| } | ||
|
|
||
| [WinFormsTheory] | ||
| [InlineData(true, DialogResult.OK)] | ||
| [InlineData(false, DialogResult.Cancel)] | ||
| public void ShowDialog_ControlOwnerWithVisualStyles_ReturnsExpected(bool runDialogResult, DialogResult expectedDialogResult) | ||
| { | ||
| using SubCommonDialog dialog = new() | ||
| { | ||
| RunDialogResult = runDialogResult | ||
| }; | ||
| using Control owner = new(); | ||
| Assert.Equal(expectedDialogResult, dialog.ShowDialog(owner)); | ||
| } | ||
|
|
||
| [WinFormsTheory] | ||
| [InlineData(true, DialogResult.OK)] | ||
| [InlineData(false, DialogResult.Cancel)] | ||
| public void ShowDialog_ControlOwnerWithHandleWithVisualStyles_ReturnsExpected(bool runDialogResult, DialogResult expectedDialogResult) | ||
| { | ||
| using SubCommonDialog dialog = new() | ||
| { | ||
| RunDialogResult = runDialogResult | ||
| }; | ||
| using Control owner = new(); | ||
| Assert.NotEqual(IntPtr.Zero, owner.Handle); | ||
| Assert.Equal(expectedDialogResult, dialog.ShowDialog(owner)); | ||
| } | ||
|
|
||
| private class SubCommonDialog : CommonDialog | ||
| { | ||
| public override void Reset() | ||
| { | ||
| } | ||
|
|
||
| public bool RunDialogResult { get; set; } | ||
|
|
||
| protected override bool RunDialog(IntPtr hwndOwner) => RunDialogResult; | ||
| } | ||
| } |
98 changes: 98 additions & 0 deletions
98
src/test/integration/UIIntegrationTests/DataGridViewHeaderCellTests.cs
This file contains hidden or 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,98 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Windows.Forms.VisualStyles; | ||
|
|
||
| namespace System.Windows.Forms.UITests; | ||
|
|
||
| // Migrated from unit tests; see issue #4500. Remaining skipped tests in this file deferred to a follow-up PR. | ||
| public class DataGridViewHeaderCellTests : ControlTestBase | ||
| { | ||
| public DataGridViewHeaderCellTests(ITestOutputHelper testOutputHelper) | ||
| : base(testOutputHelper) | ||
| { | ||
| } | ||
|
|
||
| public static IEnumerable<object[]> MouseLeaveUnsharesRow_WithDataGridViewMouseDown_TestData() | ||
| { | ||
| ButtonState expected = VisualStyleRenderer.IsSupported ? ButtonState.Pushed : ButtonState.Normal; | ||
| yield return new object[] { true, -2, expected }; | ||
| yield return new object[] { true, -1, expected }; | ||
| yield return new object[] { true, 0, expected }; | ||
| yield return new object[] { true, 1, expected }; | ||
| yield return new object[] { false, -2, ButtonState.Normal }; | ||
| yield return new object[] { false, -1, ButtonState.Normal }; | ||
| yield return new object[] { false, 0, ButtonState.Normal }; | ||
| yield return new object[] { false, 1, ButtonState.Normal }; | ||
| } | ||
|
|
||
| [WinFormsTheory] | ||
| [MemberData(nameof(MouseLeaveUnsharesRow_WithDataGridViewMouseDown_TestData))] | ||
| public void DataGridViewHeaderCell_MouseLeaveUnsharesRow_InvokeWithDataGridViewMouseDown_ReturnsExpected(bool enableHeadersVisualStyles, int rowIndex, ButtonState expectedButtonState) | ||
| { | ||
| using SubDataGridViewHeaderCell cellTemplate = new(); | ||
| using DataGridViewColumn column = new() | ||
| { | ||
| CellTemplate = cellTemplate | ||
| }; | ||
| using DataGridView control = new() | ||
| { | ||
| EnableHeadersVisualStyles = enableHeadersVisualStyles | ||
| }; | ||
| control.Columns.Add(column); | ||
| SubDataGridViewHeaderCell cell = (SubDataGridViewHeaderCell)control.Rows[0].Cells[0]; | ||
| cell.OnMouseDown(new DataGridViewCellMouseEventArgs(-1, -1, 0, 0, new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0))); | ||
| Assert.Equal(enableHeadersVisualStyles && VisualStyleRenderer.IsSupported, cell.MouseLeaveUnsharesRow(rowIndex)); | ||
| Assert.Equal(expectedButtonState, cell.ButtonState); | ||
| Assert.False(control.IsHandleCreated); | ||
| } | ||
|
|
||
| [WinFormsFact] | ||
| public void DataGridViewHeaderCell_OnMouseDown_InvalidRowIndexVisualStyles_ThrowsArgumentOutOfRangeException() | ||
| { | ||
| using SubDataGridViewHeaderCell cellTemplate = new(); | ||
| using DataGridViewColumn column = new() | ||
| { | ||
| CellTemplate = cellTemplate | ||
| }; | ||
| using DataGridView control = new() | ||
| { | ||
| EnableHeadersVisualStyles = true | ||
| }; | ||
| control.Columns.Add(column); | ||
| SubDataGridViewHeaderCell cell = (SubDataGridViewHeaderCell)control.Rows[0].Cells[0]; | ||
| DataGridViewCellMouseEventArgs e = new(0, 1, 0, 0, new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0)); | ||
| Assert.Throws<ArgumentOutOfRangeException>("rowIndex", () => cell.OnMouseDown(e)); | ||
| Assert.Equal(VisualStyleRenderer.IsSupported ? ButtonState.Pushed : ButtonState.Normal, cell.ButtonState); | ||
| } | ||
|
|
||
| [WinFormsFact] | ||
| public void DataGridViewHeaderCell_OnMouseUp_InvalidRowIndexVisualStyles_ThrowsArgumentOutOfRangeException() | ||
| { | ||
| using SubDataGridViewHeaderCell cellTemplate = new(); | ||
| using DataGridViewColumn column = new() | ||
| { | ||
| CellTemplate = cellTemplate | ||
| }; | ||
| using DataGridView control = new() | ||
| { | ||
| EnableHeadersVisualStyles = true | ||
| }; | ||
| control.Columns.Add(column); | ||
| SubDataGridViewHeaderCell cell = (SubDataGridViewHeaderCell)control.Rows[0].Cells[0]; | ||
| DataGridViewCellMouseEventArgs e = new(0, 1, 0, 0, new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0)); | ||
| Assert.Throws<ArgumentOutOfRangeException>("rowIndex", () => cell.OnMouseUp(e)); | ||
| Assert.Equal(ButtonState.Normal, cell.ButtonState); | ||
| } | ||
|
|
||
| public class SubDataGridViewHeaderCell : DataGridViewHeaderCell | ||
| { | ||
| public new ButtonState ButtonState => base.ButtonState; | ||
|
|
||
| public new bool MouseLeaveUnsharesRow(int rowIndex) => base.MouseLeaveUnsharesRow(rowIndex); | ||
|
|
||
| public new void OnMouseDown(DataGridViewCellMouseEventArgs e) => base.OnMouseDown(e); | ||
|
|
||
| public new void OnMouseUp(DataGridViewCellMouseEventArgs e) => base.OnMouseUp(e); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.