From 4b05a67d755239265355837782509ed62a143d05 Mon Sep 17 00:00:00 2001 From: "Ricardo Bossan (BEYONDSOFT CONSULTING INC) (from Dev Box)" Date: Mon, 30 Dec 2024 21:36:48 -0300 Subject: [PATCH] Re-enabled tests previously skipped with message 'Crash with AbandonedMutexException' --- .../Forms/Application.ParkingWindowTests.cs | 10 +++------- .../System/Windows/Forms/ApplicationTests.cs | 6 +++--- .../System/Windows/Forms/CommonDialogTests.cs | 6 +++--- .../Forms/DataGridViewHeaderCellTests.cs | 18 +++++++++--------- .../Forms/ListViewInsertionMarkTests.cs | 10 +++++----- .../System/Windows/Forms/TabPageTests.cs | 4 ++-- 6 files changed, 25 insertions(+), 29 deletions(-) diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/Application.ParkingWindowTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/Application.ParkingWindowTests.cs index 80c6ca2b2d1..9187afc3951 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/Application.ParkingWindowTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/Application.ParkingWindowTests.cs @@ -1,17 +1,16 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Microsoft.DotNet.RemoteExecutor; using static System.Windows.Forms.Application; namespace System.Windows.Forms.Tests; public class ParkingWindowTests { - [WinFormsFact(Skip = "Crash with AbandonedMutexException. See: https://github.com/dotnet/arcade/issues/5325")] + [WinFormsFact] public void ParkingWindow_DoesNotThrowOnGarbageCollecting() { - using RemoteInvokeHandle invokerHandle = RemoteExecutor.Invoke(() => + Task.Run(() => { Control.CheckForIllegalCrossThreadCalls = true; @@ -28,10 +27,7 @@ public void ParkingWindow_DoesNotThrowOnGarbageCollecting() { Assert.True(ex is null, $"Expected no exception, but got: {ex.Message}"); // Actually need to check whether GC.Collect() does not throw exception. } - }); - - // verify the remote process succeeded - Assert.Equal(RemoteExecutor.SuccessExitCode, invokerHandle.ExitCode); + }).Wait(); } private static Form InitFormWithControlToGarbageCollect() diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ApplicationTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ApplicationTests.cs index 9a832be2150..165c81664a4 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ApplicationTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ApplicationTests.cs @@ -72,7 +72,7 @@ public void Application_CurrentCulture_SetNull_ThrowsArgumentNullException() Assert.Throws("value", () => Application.CurrentCulture = null); } - [WinFormsFact(Skip = "Crash with AbandonedMutexException. See: https://github.com/dotnet/arcade/issues/5325")] + [WinFormsFact] public void Application_EnableVisualStyles_InvokeBeforeGettingRenderWithVisualStyles_Success() { RemoteExecutor.Invoke(() => @@ -83,7 +83,7 @@ public void Application_EnableVisualStyles_InvokeBeforeGettingRenderWithVisualSt }).Dispose(); } - [WinFormsFact(Skip = "Crash with AbandonedMutexException. See: https://github.com/dotnet/arcade/issues/5325")] + [WinFormsFact] public void Application_EnableVisualStyles_InvokeAfterGettingRenderWithVisualStyles_Success() { // This is not a recommended scenario per @@ -115,7 +115,7 @@ public void Application_VisualStyleState_Get_ReturnsExpected() Assert.Equal(state, Application.VisualStyleState); } - [WinFormsTheory(Skip = "Crash with AbandonedMutexException. See: https://github.com/dotnet/arcade/issues/5325")] + [WinFormsTheory] [EnumData] [InvalidEnumData] public void Application_VisualStyleState_Set_ReturnsExpected(VisualStyleState valueParam) diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/CommonDialogTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/CommonDialogTests.cs index d1af4adeccb..f89034ad302 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/CommonDialogTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/CommonDialogTests.cs @@ -116,7 +116,7 @@ public void ShowDialog_NonControlOwner_ReturnsExpected(bool runDialogResult, Dia Assert.Equal(expectedDialogResult, dialog.ShowDialog(owner.Object)); } - [WinFormsTheory(Skip = "Crash with AbandonedMutexException. See: https://github.com/dotnet/arcade/issues/5325")] + [WinFormsTheory] [InlineData(true, DialogResult.OK)] [InlineData(false, DialogResult.Cancel)] public void ShowDialog_NonControlOwnerWithVisualStyles_ReturnsExpected(bool runDialogResultParam, DialogResult expectedDialogResultParam) @@ -154,7 +154,7 @@ public void ShowDialog_ControlOwner_ReturnsExpected(bool runDialogResult, Dialog Assert.Equal(expectedDialogResult, dialog.ShowDialog(owner)); } - [WinFormsTheory(Skip = "Crash with AbandonedMutexException. See: https://github.com/dotnet/arcade/issues/5325")] + [WinFormsTheory] [InlineData(true, DialogResult.OK)] [InlineData(false, DialogResult.Cancel)] public void ShowDialog_ControlOwnerWithVisualStyles_ReturnsExpected(bool runDialogResultParam, DialogResult expectedDialogResultParam) @@ -190,7 +190,7 @@ public void ShowDialog_ControlOwnerWithHandle_ReturnsExpected(bool runDialogResu Assert.Equal(expectedDialogResult, dialog.ShowDialog(owner)); } - [WinFormsTheory(Skip = "Crash with AbandonedMutexException. See: https://github.com/dotnet/arcade/issues/5325")] + [WinFormsTheory] [InlineData(true, DialogResult.OK)] [InlineData(false, DialogResult.Cancel)] public void ShowDialog_ControlOwnerWithHandleWithVisualStyles_ReturnsExpected(bool runDialogResultParam, DialogResult expectedDialogResultParam) diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/DataGridViewHeaderCellTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/DataGridViewHeaderCellTests.cs index 60e988686f9..b2f2d929b58 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/DataGridViewHeaderCellTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/DataGridViewHeaderCellTests.cs @@ -3859,7 +3859,7 @@ public static IEnumerable MouseDownUnsharesRow_WithDataGridView_TestDa } } - [WinFormsFact(Skip = "Crash with AbandonedMutexException. See: https://github.com/dotnet/arcade/issues/5325")] + [WinFormsFact] public void DataGridViewHeaderCell_MouseDownUnsharesRow_InvokeWithDataGridView_ReturnsExpected() { // Run this from another thread as we call Application.EnableVisualStyles. @@ -4009,7 +4009,7 @@ public static IEnumerable MouseLeaveUnsharesRow_WithDataGridViewMouseD yield return new object[] { false, 1, ButtonState.Normal }; } - [WinFormsTheory(Skip = "Crash with AbandonedMutexException. See: https://github.com/dotnet/arcade/issues/5325")] + [WinFormsTheory] [MemberData(nameof(MouseLeaveUnsharesRow_WithDataGridViewMouseDown_TestData))] public void DataGridViewHeaderCell_MouseLeaveUnsharesRow_InvokeWithDataGridViewMouseDown_ReturnsExpected(bool enableHeadersVisualStylesParam, int rowIndexParam, ButtonState expectedButtonStateParam) { @@ -4049,7 +4049,7 @@ public void DataGridViewHeaderCell_MouseUpUnsharesRow_Invoke_ReturnsFalse(DataGr Assert.Equal(ButtonState.Normal, cell.ButtonState); } - [WinFormsFact(Skip = "Crash with AbandonedMutexException. See: https://github.com/dotnet/arcade/issues/5325")] + [WinFormsFact] public void DataGridViewHeaderCell_MouseUpUnsharesRow_InvokeWithDataGridView_ReturnsExpected() { // Run this from another thread as we call Application.EnableVisualStyles. @@ -4156,7 +4156,7 @@ public static IEnumerable OnMouseDown_WithDataGridView_TestData() yield return new object[] { false, new DataGridViewCellMouseEventArgs(0, 1, 0, 0, new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0)), ButtonState.Normal }; } - [WinFormsFact(Skip = "Crash with AbandonedMutexException. See: https://github.com/dotnet/arcade/issues/5325")] + [WinFormsFact] public void DataGridViewHeaderCell_OnMouseDown_InvokeWithDataGridView_Nop() { // Run this from another thread as we call Application.EnableVisualStyles. @@ -4188,7 +4188,7 @@ public void DataGridViewHeaderCell_OnMouseDown_InvokeWithDataGridView_Nop() }).Dispose(); } - [WinFormsFact(Skip = "Crash with AbandonedMutexException. See: https://github.com/dotnet/arcade/issues/5325")] + [WinFormsFact] public void DataGridViewHeaderCell_OnMouseDown_InvalidRowIndexVisualStyles_ThrowsArgumentOutOfRangeException() { // Run this from another thread as we call Application.EnableVisualStyles. @@ -4364,7 +4364,7 @@ public void DataGridViewHeaderCell_OnMouseLeave_VisualStyles_on_ThrowsArgumentOu Assert.Throws(() => cell.OnMouseLeave(rowIndex)); } - [WinFormsTheory(Skip = "Crash with AbandonedMutexException. See: https://github.com/dotnet/arcade/issues/5325")] + [WinFormsTheory] [InlineData(true, -1)] [InlineData(true, 0)] [InlineData(false, -2)] @@ -4399,7 +4399,7 @@ public void DataGridViewHeaderCell_OnMouseLeave_InvokeWithDataGridViewMouseDown_ }, enableHeadersVisualStylesParam.ToString(), rowIndexParam.ToString()).Dispose(); } - [WinFormsTheory(Skip = "Crash with AbandonedMutexException. See: https://github.com/dotnet/arcade/issues/5325")] + [WinFormsTheory] [InlineData(-2)] [InlineData(1)] public void DataGridViewHeaderCell_OnMouseLeave_InvalidRowIndexVisualStyles_ThrowsArgumentOutOfRangeException(int rowIndexParam) @@ -4538,7 +4538,7 @@ public static IEnumerable OnMouseUp_WithDataGridViewMouseDown_TestData yield return new object[] { false, new DataGridViewCellMouseEventArgs(0, 1, 0, 0, new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0)), ButtonState.Normal }; } - [WinFormsFact(Skip = "Crash with AbandonedMutexException. See: https://github.com/dotnet/arcade/issues/5325")] + [WinFormsFact] public void DataGridViewHeaderCell_OnMouseUp_InvokeWithDataGridViewMouseDown_ReturnsExpected() { // Run this from another thread as we call Application.EnableVisualStyles. @@ -4571,7 +4571,7 @@ public void DataGridViewHeaderCell_OnMouseUp_InvokeWithDataGridViewMouseDown_Ret }).Dispose(); } - [WinFormsFact(Skip = "Crash with AbandonedMutexException. See: https://github.com/dotnet/arcade/issues/5325")] + [WinFormsFact] public void DataGridViewHeaderCell_OnMouseUp_InvalidRowIndexVisualStyles_ThrowsArgumentOutOfRangeException() { // Run this from another thread as we call Application.EnableVisualStyles. diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewInsertionMarkTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewInsertionMarkTests.cs index 7071fa662ff..3bc40361c64 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewInsertionMarkTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewInsertionMarkTests.cs @@ -78,7 +78,7 @@ public void ListViewInsertionMark_AppearsAfterItem_SetWithHandle_GetReturnsExpec Assert.Equal(0, createdCallCount); } - [WinFormsFact(Skip = "Crash with AbandonedMutexException. See: https://github.com/dotnet/arcade/issues/5325")] + [WinFormsFact] public unsafe void ListViewInsertionMark_AppearsAfterItem_GetInsertMark_Success() { // Run this from another thread as we call Application.EnableVisualStyles. @@ -128,7 +128,7 @@ public unsafe void ListViewInsertionMark_AppearsAfterItem_GetInsertMark_Success( }).Dispose(); } - [WinFormsFact(Skip = "Crash with AbandonedMutexException. See: https://github.com/dotnet/arcade/issues/5325")] + [WinFormsFact] public unsafe void ListViewInsertionMark_AppearsAfterItem_GetInsertMarkWithColor_Success() { // Run this from another thread as we call Application.EnableVisualStyles. @@ -354,7 +354,7 @@ public void ListViewInsertionMark_Color_SetWithHandle_ReturnsExpected(Color valu Assert.Equal(0, createdCallCount); } - [WinFormsFact(Skip = "Crash with AbandonedMutexException. See: https://github.com/dotnet/arcade/issues/5325")] + [WinFormsFact] public unsafe void ListViewInsertionMark_Color_GetInsertMarkColor_Success() { // Run this from another thread as we call Application.EnableVisualStyles. @@ -448,7 +448,7 @@ public void ListViewInsertionMark_Index_SetWithHandle_GetReturnsExpected(int val Assert.Equal(value, insertionMark.Index); } - [WinFormsTheory(Skip = "Crash with AbandonedMutexException. See: https://github.com/dotnet/arcade/issues/5325")] + [WinFormsTheory] [InlineData(-2)] [InlineData(1)] public unsafe void ListViewInsertionMark_Index_GetInsertMark_Success(int indexParam) @@ -502,7 +502,7 @@ public unsafe void ListViewInsertionMark_Index_GetInsertMark_Success(int indexPa }, indexParam.ToString()).Dispose(); } - [WinFormsTheory(Skip = "Crash with AbandonedMutexException. See: https://github.com/dotnet/arcade/issues/5325")] + [WinFormsTheory] [InlineData(-2)] [InlineData(1)] public unsafe void ListViewInsertionMark_Index_GetInsertMarkWithColor_Success(int indexParam) diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/TabPageTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/TabPageTests.cs index 014c5e082e7..2b2f715be39 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/TabPageTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/TabPageTests.cs @@ -534,7 +534,7 @@ public static void TabPage_BackColor_Get_ReturnsExpected(bool useVisualStyleBack Assert.Equal(Control.DefaultBackColor, control.BackColor); } - [WinFormsTheory(Skip = "Crash with AbandonedMutexException. See: https://github.com/dotnet/arcade/issues/5325")] + [WinFormsTheory] [BoolData] public static void TabPage_BackColor_GetVisualStyles_ReturnsExpected(bool useVisualStyleBackColorParam) { @@ -614,7 +614,7 @@ public static IEnumerable BackColor_GetVisualStylesWithParent_TestData yield return new object[] { false, TabAppearance.Normal, Control.DefaultBackColor }; } - [WinFormsTheory(Skip = "Crash with AbandonedMutexException. See: https://github.com/dotnet/arcade/issues/5325")] + [WinFormsTheory] [MemberData(nameof(BackColor_GetVisualStylesWithParent_TestData))] public static void TabPage_BackColor_GetVisualStylesWithParent_ReturnsExpected(bool useVisualStyleBackColorParam, TabAppearance parentAppearanceParam, Color expectedParam) {