From 1fa62555d02ce3dceb932cdd87853959b459734c Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Thu, 9 Mar 2023 11:38:49 -0800 Subject: [PATCH 01/26] Disable parallel mode for test collections. --- .../tests/UnitTests/xunit.runner.json | 4 ++++ .../Microsoft.VisualBasic.IntegrationTests.csproj | 6 ++++++ .../xunit.runner.json | 4 ++++ .../VisualBasicRuntimeTest/VisualBasicRuntimeTest.csproj | 5 +++++ .../VisualBasicRuntimeTest/xunit.runner.json | 4 ++++ .../tests/UnitTests/Microsoft.VisualBasic.Tests.csproj | 6 ++++++ src/Microsoft.VisualBasic/tests/UnitTests/xunit.runner.json | 4 ++++ .../UnitTests/System.Windows.Forms.Design.Tests.csproj | 5 +++++ .../tests/UnitTests/xunit.runner.json | 4 ++++ ...stem.Windows.Forms.Primitives.TestUtilities.Tests.csproj | 6 ++++++ .../tests/TestUtilities.Tests/xunit.runner.json | 4 ++++ .../UnitTests/System.Windows.Forms.Primitives.Tests.csproj | 6 ++++++ .../tests/UnitTests/xunit.runner.json | 4 ++++ ...ystem.Windows.Forms.PrivateSourceGenerators.Tests.csproj | 5 +++++ .../tests/UnitTests/xunit.runner.json | 4 ++++ .../System.Windows.Forms.IntegrationTests.csproj | 5 +++++ .../System.Windows.Forms.IntegrationTests/xunit.runner.json | 4 ++++ .../InteropTests/System.Windows.Forms.Interop.Tests.csproj | 6 ++++++ .../tests/InteropTests/xunit.runner.json | 4 ++++ .../tests/UnitTests/System.Windows.Forms.Tests.csproj | 5 +++++ src/System.Windows.Forms/tests/UnitTests/xunit.runner.json | 4 ++++ 21 files changed, 99 insertions(+) create mode 100644 src/Microsoft.VisualBasic.Forms/tests/UnitTests/xunit.runner.json create mode 100644 src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/xunit.runner.json create mode 100644 src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/xunit.runner.json create mode 100644 src/Microsoft.VisualBasic/tests/UnitTests/xunit.runner.json create mode 100644 src/System.Windows.Forms.Design/tests/UnitTests/xunit.runner.json create mode 100644 src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/xunit.runner.json create mode 100644 src/System.Windows.Forms.Primitives/tests/UnitTests/xunit.runner.json create mode 100644 src/System.Windows.Forms.PrivateSourceGenerators/tests/UnitTests/xunit.runner.json create mode 100644 src/System.Windows.Forms/tests/IntegrationTests/System.Windows.Forms.IntegrationTests/xunit.runner.json create mode 100644 src/System.Windows.Forms/tests/InteropTests/xunit.runner.json create mode 100644 src/System.Windows.Forms/tests/UnitTests/xunit.runner.json diff --git a/src/Microsoft.VisualBasic.Forms/tests/UnitTests/xunit.runner.json b/src/Microsoft.VisualBasic.Forms/tests/UnitTests/xunit.runner.json new file mode 100644 index 00000000000..0cc608666f8 --- /dev/null +++ b/src/Microsoft.VisualBasic.Forms/tests/UnitTests/xunit.runner.json @@ -0,0 +1,4 @@ +{ + "maxParallelThreads": 1, + "parallelizeTestCollections": true +} diff --git a/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/Microsoft.VisualBasic.IntegrationTests.csproj b/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/Microsoft.VisualBasic.IntegrationTests.csproj index ca9ed1d3242..65d042b7e3a 100644 --- a/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/Microsoft.VisualBasic.IntegrationTests.csproj +++ b/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/Microsoft.VisualBasic.IntegrationTests.csproj @@ -6,4 +6,10 @@ + + + PreserveNewest + + + diff --git a/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/xunit.runner.json b/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/xunit.runner.json new file mode 100644 index 00000000000..0cc608666f8 --- /dev/null +++ b/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/xunit.runner.json @@ -0,0 +1,4 @@ +{ + "maxParallelThreads": 1, + "parallelizeTestCollections": true +} diff --git a/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/VisualBasicRuntimeTest.csproj b/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/VisualBasicRuntimeTest.csproj index 8f3ddde355d..3c400f9a2e3 100644 --- a/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/VisualBasicRuntimeTest.csproj +++ b/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/VisualBasicRuntimeTest.csproj @@ -8,4 +8,9 @@ + + + PreserveNewest + + diff --git a/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/xunit.runner.json b/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/xunit.runner.json new file mode 100644 index 00000000000..0cc608666f8 --- /dev/null +++ b/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/xunit.runner.json @@ -0,0 +1,4 @@ +{ + "maxParallelThreads": 1, + "parallelizeTestCollections": true +} diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft.VisualBasic.Tests.csproj b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft.VisualBasic.Tests.csproj index 4a1ed48e401..e794ab939f6 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft.VisualBasic.Tests.csproj +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft.VisualBasic.Tests.csproj @@ -16,4 +16,10 @@ + + + PreserveNewest + + + diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/xunit.runner.json b/src/Microsoft.VisualBasic/tests/UnitTests/xunit.runner.json new file mode 100644 index 00000000000..0cc608666f8 --- /dev/null +++ b/src/Microsoft.VisualBasic/tests/UnitTests/xunit.runner.json @@ -0,0 +1,4 @@ +{ + "maxParallelThreads": 1, + "parallelizeTestCollections": true +} diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System.Windows.Forms.Design.Tests.csproj b/src/System.Windows.Forms.Design/tests/UnitTests/System.Windows.Forms.Design.Tests.csproj index 4d47ac7bfe8..cfff7485408 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System.Windows.Forms.Design.Tests.csproj +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System.Windows.Forms.Design.Tests.csproj @@ -60,4 +60,9 @@ + + + PreserveNewest + + diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/xunit.runner.json b/src/System.Windows.Forms.Design/tests/UnitTests/xunit.runner.json new file mode 100644 index 00000000000..0cc608666f8 --- /dev/null +++ b/src/System.Windows.Forms.Design/tests/UnitTests/xunit.runner.json @@ -0,0 +1,4 @@ +{ + "maxParallelThreads": 1, + "parallelizeTestCollections": true +} diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/System.Windows.Forms.Primitives.TestUtilities.Tests.csproj b/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/System.Windows.Forms.Primitives.TestUtilities.Tests.csproj index a29b3da0eab..e91081a2269 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/System.Windows.Forms.Primitives.TestUtilities.Tests.csproj +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/System.Windows.Forms.Primitives.TestUtilities.Tests.csproj @@ -18,4 +18,10 @@ + + + PreserveNewest + + + diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/xunit.runner.json b/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/xunit.runner.json new file mode 100644 index 00000000000..0cc608666f8 --- /dev/null +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/xunit.runner.json @@ -0,0 +1,4 @@ +{ + "maxParallelThreads": 1, + "parallelizeTestCollections": true +} diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System.Windows.Forms.Primitives.Tests.csproj b/src/System.Windows.Forms.Primitives/tests/UnitTests/System.Windows.Forms.Primitives.Tests.csproj index 7a647055cae..e12c21d2884 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System.Windows.Forms.Primitives.Tests.csproj +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System.Windows.Forms.Primitives.Tests.csproj @@ -17,4 +17,10 @@ + + + PreserveNewest + + + diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/xunit.runner.json b/src/System.Windows.Forms.Primitives/tests/UnitTests/xunit.runner.json new file mode 100644 index 00000000000..0cc608666f8 --- /dev/null +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/xunit.runner.json @@ -0,0 +1,4 @@ +{ + "maxParallelThreads": 1, + "parallelizeTestCollections": true +} diff --git a/src/System.Windows.Forms.PrivateSourceGenerators/tests/UnitTests/System.Windows.Forms.PrivateSourceGenerators.Tests.csproj b/src/System.Windows.Forms.PrivateSourceGenerators/tests/UnitTests/System.Windows.Forms.PrivateSourceGenerators.Tests.csproj index 208a5519844..4b608155c38 100644 --- a/src/System.Windows.Forms.PrivateSourceGenerators/tests/UnitTests/System.Windows.Forms.PrivateSourceGenerators.Tests.csproj +++ b/src/System.Windows.Forms.PrivateSourceGenerators/tests/UnitTests/System.Windows.Forms.PrivateSourceGenerators.Tests.csproj @@ -16,4 +16,9 @@ + + + PreserveNewest + + diff --git a/src/System.Windows.Forms.PrivateSourceGenerators/tests/UnitTests/xunit.runner.json b/src/System.Windows.Forms.PrivateSourceGenerators/tests/UnitTests/xunit.runner.json new file mode 100644 index 00000000000..0cc608666f8 --- /dev/null +++ b/src/System.Windows.Forms.PrivateSourceGenerators/tests/UnitTests/xunit.runner.json @@ -0,0 +1,4 @@ +{ + "maxParallelThreads": 1, + "parallelizeTestCollections": true +} diff --git a/src/System.Windows.Forms/tests/IntegrationTests/System.Windows.Forms.IntegrationTests/System.Windows.Forms.IntegrationTests.csproj b/src/System.Windows.Forms/tests/IntegrationTests/System.Windows.Forms.IntegrationTests/System.Windows.Forms.IntegrationTests.csproj index bab99c8eff6..1708c485c95 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/System.Windows.Forms.IntegrationTests/System.Windows.Forms.IntegrationTests.csproj +++ b/src/System.Windows.Forms/tests/IntegrationTests/System.Windows.Forms.IntegrationTests/System.Windows.Forms.IntegrationTests.csproj @@ -9,4 +9,9 @@ + + + PreserveNewest + + \ No newline at end of file diff --git a/src/System.Windows.Forms/tests/IntegrationTests/System.Windows.Forms.IntegrationTests/xunit.runner.json b/src/System.Windows.Forms/tests/IntegrationTests/System.Windows.Forms.IntegrationTests/xunit.runner.json new file mode 100644 index 00000000000..0cc608666f8 --- /dev/null +++ b/src/System.Windows.Forms/tests/IntegrationTests/System.Windows.Forms.IntegrationTests/xunit.runner.json @@ -0,0 +1,4 @@ +{ + "maxParallelThreads": 1, + "parallelizeTestCollections": true +} diff --git a/src/System.Windows.Forms/tests/InteropTests/System.Windows.Forms.Interop.Tests.csproj b/src/System.Windows.Forms/tests/InteropTests/System.Windows.Forms.Interop.Tests.csproj index da36d96df85..8a725810394 100644 --- a/src/System.Windows.Forms/tests/InteropTests/System.Windows.Forms.Interop.Tests.csproj +++ b/src/System.Windows.Forms/tests/InteropTests/System.Windows.Forms.Interop.Tests.csproj @@ -23,6 +23,12 @@ + + + PreserveNewest + + + diff --git a/src/System.Windows.Forms/tests/InteropTests/xunit.runner.json b/src/System.Windows.Forms/tests/InteropTests/xunit.runner.json new file mode 100644 index 00000000000..0cc608666f8 --- /dev/null +++ b/src/System.Windows.Forms/tests/InteropTests/xunit.runner.json @@ -0,0 +1,4 @@ +{ + "maxParallelThreads": 1, + "parallelizeTestCollections": true +} diff --git a/src/System.Windows.Forms/tests/UnitTests/System.Windows.Forms.Tests.csproj b/src/System.Windows.Forms/tests/UnitTests/System.Windows.Forms.Tests.csproj index 8f1c4a98dae..d6737e2edda 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System.Windows.Forms.Tests.csproj +++ b/src/System.Windows.Forms/tests/UnitTests/System.Windows.Forms.Tests.csproj @@ -79,4 +79,9 @@ + + + PreserveNewest + + diff --git a/src/System.Windows.Forms/tests/UnitTests/xunit.runner.json b/src/System.Windows.Forms/tests/UnitTests/xunit.runner.json new file mode 100644 index 00000000000..0cc608666f8 --- /dev/null +++ b/src/System.Windows.Forms/tests/UnitTests/xunit.runner.json @@ -0,0 +1,4 @@ +{ + "maxParallelThreads": 1, + "parallelizeTestCollections": true +} From f299cdf1b3a79751c42dea1f2e4aab42596c6cf5 Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Thu, 9 Mar 2023 11:44:02 -0800 Subject: [PATCH 02/26] Disable. --- .../tests/UnitTests/xunit.runner.json | 2 +- .../Microsoft.VisualBasic.IntegrationTests/xunit.runner.json | 2 +- .../IntegrationTests/VisualBasicRuntimeTest/xunit.runner.json | 2 +- src/Microsoft.VisualBasic/tests/UnitTests/xunit.runner.json | 2 +- .../tests/UnitTests/xunit.runner.json | 2 +- .../tests/TestUtilities.Tests/xunit.runner.json | 2 +- .../tests/UnitTests/xunit.runner.json | 2 +- .../tests/UnitTests/xunit.runner.json | 2 +- src/System.Windows.Forms/tests/InteropTests/xunit.runner.json | 2 +- src/System.Windows.Forms/tests/UnitTests/xunit.runner.json | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Microsoft.VisualBasic.Forms/tests/UnitTests/xunit.runner.json b/src/Microsoft.VisualBasic.Forms/tests/UnitTests/xunit.runner.json index 0cc608666f8..fdeefaa4563 100644 --- a/src/Microsoft.VisualBasic.Forms/tests/UnitTests/xunit.runner.json +++ b/src/Microsoft.VisualBasic.Forms/tests/UnitTests/xunit.runner.json @@ -1,4 +1,4 @@ { "maxParallelThreads": 1, - "parallelizeTestCollections": true + "parallelizeTestCollections": false } diff --git a/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/xunit.runner.json b/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/xunit.runner.json index 0cc608666f8..fdeefaa4563 100644 --- a/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/xunit.runner.json +++ b/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/xunit.runner.json @@ -1,4 +1,4 @@ { "maxParallelThreads": 1, - "parallelizeTestCollections": true + "parallelizeTestCollections": false } diff --git a/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/xunit.runner.json b/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/xunit.runner.json index 0cc608666f8..fdeefaa4563 100644 --- a/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/xunit.runner.json +++ b/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/xunit.runner.json @@ -1,4 +1,4 @@ { "maxParallelThreads": 1, - "parallelizeTestCollections": true + "parallelizeTestCollections": false } diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/xunit.runner.json b/src/Microsoft.VisualBasic/tests/UnitTests/xunit.runner.json index 0cc608666f8..fdeefaa4563 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/xunit.runner.json +++ b/src/Microsoft.VisualBasic/tests/UnitTests/xunit.runner.json @@ -1,4 +1,4 @@ { "maxParallelThreads": 1, - "parallelizeTestCollections": true + "parallelizeTestCollections": false } diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/xunit.runner.json b/src/System.Windows.Forms.Design/tests/UnitTests/xunit.runner.json index 0cc608666f8..fdeefaa4563 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/xunit.runner.json +++ b/src/System.Windows.Forms.Design/tests/UnitTests/xunit.runner.json @@ -1,4 +1,4 @@ { "maxParallelThreads": 1, - "parallelizeTestCollections": true + "parallelizeTestCollections": false } diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/xunit.runner.json b/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/xunit.runner.json index 0cc608666f8..fdeefaa4563 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/xunit.runner.json +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/xunit.runner.json @@ -1,4 +1,4 @@ { "maxParallelThreads": 1, - "parallelizeTestCollections": true + "parallelizeTestCollections": false } diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/xunit.runner.json b/src/System.Windows.Forms.Primitives/tests/UnitTests/xunit.runner.json index 0cc608666f8..fdeefaa4563 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/xunit.runner.json +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/xunit.runner.json @@ -1,4 +1,4 @@ { "maxParallelThreads": 1, - "parallelizeTestCollections": true + "parallelizeTestCollections": false } diff --git a/src/System.Windows.Forms.PrivateSourceGenerators/tests/UnitTests/xunit.runner.json b/src/System.Windows.Forms.PrivateSourceGenerators/tests/UnitTests/xunit.runner.json index 0cc608666f8..fdeefaa4563 100644 --- a/src/System.Windows.Forms.PrivateSourceGenerators/tests/UnitTests/xunit.runner.json +++ b/src/System.Windows.Forms.PrivateSourceGenerators/tests/UnitTests/xunit.runner.json @@ -1,4 +1,4 @@ { "maxParallelThreads": 1, - "parallelizeTestCollections": true + "parallelizeTestCollections": false } diff --git a/src/System.Windows.Forms/tests/InteropTests/xunit.runner.json b/src/System.Windows.Forms/tests/InteropTests/xunit.runner.json index 0cc608666f8..fdeefaa4563 100644 --- a/src/System.Windows.Forms/tests/InteropTests/xunit.runner.json +++ b/src/System.Windows.Forms/tests/InteropTests/xunit.runner.json @@ -1,4 +1,4 @@ { "maxParallelThreads": 1, - "parallelizeTestCollections": true + "parallelizeTestCollections": false } diff --git a/src/System.Windows.Forms/tests/UnitTests/xunit.runner.json b/src/System.Windows.Forms/tests/UnitTests/xunit.runner.json index 0cc608666f8..fdeefaa4563 100644 --- a/src/System.Windows.Forms/tests/UnitTests/xunit.runner.json +++ b/src/System.Windows.Forms/tests/UnitTests/xunit.runner.json @@ -1,4 +1,4 @@ { "maxParallelThreads": 1, - "parallelizeTestCollections": true + "parallelizeTestCollections": false } From 794fe5e7d50620213740a75a81a4db1b6a00b2d5 Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Fri, 10 Mar 2023 15:12:34 -0800 Subject: [PATCH 03/26] Fix Cursor dispose Remove explicit collection definition that doe snothingbut disable parallelization --- .../Microsoft.VisualBasic.Forms.Tests.vbproj | 5 +++ .../Microsoft.VisualBasic.Tests.csproj | 1 - ...orms.Primitives.TestUtilities.Tests.csproj | 1 - .../UnitTests/Interop/Mocks/MockCursor.cs | 8 ++--- ...stem.Windows.Forms.Primitives.Tests.csproj | 1 - .../Forms/LocalAppContextSwitchesTest.cs | 1 - .../Windows/Forms/SynchronousCollection.cs | 13 ------- .../src/System/Windows/Forms/Cursor.cs | 8 ++--- .../System/Windows/Forms/CursorTests.cs | 36 +++++++++---------- 9 files changed, 27 insertions(+), 47 deletions(-) delete mode 100644 src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/SynchronousCollection.cs diff --git a/src/Microsoft.VisualBasic.Forms/tests/UnitTests/Microsoft.VisualBasic.Forms.Tests.vbproj b/src/Microsoft.VisualBasic.Forms/tests/UnitTests/Microsoft.VisualBasic.Forms.Tests.vbproj index 0c92c20c66a..1b0283feea2 100644 --- a/src/Microsoft.VisualBasic.Forms/tests/UnitTests/Microsoft.VisualBasic.Forms.Tests.vbproj +++ b/src/Microsoft.VisualBasic.Forms/tests/UnitTests/Microsoft.VisualBasic.Forms.Tests.vbproj @@ -23,4 +23,9 @@ + + + PreserveNewest + + diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft.VisualBasic.Tests.csproj b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft.VisualBasic.Tests.csproj index e794ab939f6..a7cc3276f72 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft.VisualBasic.Tests.csproj +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft.VisualBasic.Tests.csproj @@ -21,5 +21,4 @@ PreserveNewest - diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/System.Windows.Forms.Primitives.TestUtilities.Tests.csproj b/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/System.Windows.Forms.Primitives.TestUtilities.Tests.csproj index e91081a2269..9491ff2c16e 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/System.Windows.Forms.Primitives.TestUtilities.Tests.csproj +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/System.Windows.Forms.Primitives.TestUtilities.Tests.csproj @@ -23,5 +23,4 @@ PreserveNewest - diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Mocks/MockCursor.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Mocks/MockCursor.cs index 2e2e9dd50f1..dd5602b7663 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Mocks/MockCursor.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/Interop/Mocks/MockCursor.cs @@ -22,13 +22,9 @@ internal MockCursor(PCWSTR nResourceId) public void Dispose() { - if (!_handle.IsNull) + if (!_handle.IsNull && _ownHandle) { - if (_ownHandle) - { - PInvoke.DestroyCursor(_handle); - } - + PInvoke.DestroyCursor(_handle); _handle = HCURSOR.Null; } } diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System.Windows.Forms.Primitives.Tests.csproj b/src/System.Windows.Forms.Primitives/tests/UnitTests/System.Windows.Forms.Primitives.Tests.csproj index e12c21d2884..dd4c2167d25 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System.Windows.Forms.Primitives.Tests.csproj +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System.Windows.Forms.Primitives.Tests.csproj @@ -22,5 +22,4 @@ PreserveNewest - diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/LocalAppContextSwitchesTest.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/LocalAppContextSwitchesTest.cs index 2560db741b9..e1b7c48f54e 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/LocalAppContextSwitchesTest.cs +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/LocalAppContextSwitchesTest.cs @@ -7,7 +7,6 @@ namespace System.Windows.Forms.Tests { - [Collection(nameof(SynchronousCollection))] public class LocalAppContextSwitchesTest { private void ResetLocalSwitches(dynamic testAccessor) diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/SynchronousCollection.cs b/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/SynchronousCollection.cs deleted file mode 100644 index d327637e7f4..00000000000 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System/Windows/Forms/SynchronousCollection.cs +++ /dev/null @@ -1,13 +0,0 @@ -// 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. - -namespace System.Windows.Forms.Tests -{ - [CollectionDefinition(nameof(SynchronousCollection), DisableParallelization = true)] - public class SynchronousCollection - { - // This class has no code, and is never created. Its purpose is simply - // to be the place to apply [CollectionDefinition] - } -} diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs index 4cd0b7a81bf..b9df0affa6f 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs @@ -222,13 +222,9 @@ public void Dispose() private void Dispose(bool disposing) { - if (!_handle.IsNull) + if (!_handle.IsNull && _ownHandle) { - if (_ownHandle) - { - PInvoke.DestroyCursor(_handle); - } - + PInvoke.DestroyCursor(_handle); _handle = HCURSOR.Null; } } diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/CursorTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/CursorTests.cs index 5ba916e973b..97f6cc361c4 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/CursorTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/CursorTests.cs @@ -74,26 +74,26 @@ public void Cursor_Ctor_Stream(string fileName, Point expectedHotSpot) Assert.Null(cursor.Tag); } - [Fact] - public void Cursor_Ctor_Stream_NonStartPosition() - { - using var stream = new MemoryStream(File.ReadAllBytes(Path.Combine("bitmaps", "cursor.cur"))); - stream.Position = 5; - using var cursor = new Cursor(stream); - Assert.NotNull(cursor); - } + [Fact] + public void Cursor_Ctor_Stream_NonStartPosition() + { + using var stream = new MemoryStream(File.ReadAllBytes(Path.Combine("bitmaps", "cursor.cur"))); + stream.Position = 5; + using var cursor = new Cursor(stream); + Assert.NotNull(cursor); + } - [Fact] - public void Cursor_Ctor_EmptyStream_ThrowsArgumentException() - { - Assert.Throws("stream", () => new Cursor(new MemoryStream())); - } + [Fact] + public void Cursor_Ctor_EmptyStream_ThrowsArgumentException() + { + Assert.Throws("stream", () => new Cursor(new MemoryStream())); + } - [Fact] - public void Cursor_Ctor_NullStream_ThrowsArgumentNullException() - { - Assert.Throws("stream", () => new Cursor((Stream)null)); - } + [Fact] + public void Cursor_Ctor_NullStream_ThrowsArgumentNullException() + { + Assert.Throws("stream", () => new Cursor((Stream)null)); + } public static IEnumerable Ctor_InvalidFile_TestData() { From de3a08dfea3fd7618878384e85c2eeffd78dd42a Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Fri, 10 Mar 2023 16:17:59 -0800 Subject: [PATCH 04/26] Fix Cursor test. --- .../tests/UnitTests/System/Windows/Forms/CursorTests.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/CursorTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/CursorTests.cs index 97f6cc361c4..f34b0c2e582 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/CursorTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/CursorTests.cs @@ -357,12 +357,9 @@ public void Cursor_Dispose_InvokeNotOwned_Success() { var cursor = new Cursor(2); cursor.Dispose(); - Assert.Throws(() => cursor.Handle); - Assert.Throws(() => cursor.HotSpot); - cursor.Dispose(); - Assert.Throws(() => cursor.Handle); - Assert.Throws(() => cursor.HotSpot); + // Cursors not owned should not be disposed. + Assert.NotEqual(IntPtr.Zero, cursor.Handle); } public static IEnumerable Draw_TestData() From 7ed3b66b2cbee5561c4ab330c7bc8876641b477c Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Fri, 10 Mar 2023 18:05:03 -0800 Subject: [PATCH 05/26] Add delay to InputSimulator action. --- .../UIIntegrationTests/ButtonTests.cs | 18 +-- .../UIIntegrationTests/DataGridViewTests.cs | 4 +- .../DesignBehaviorsTests.cs | 8 +- .../UIIntegrationTests/DragDropTests.cs | 121 +++++++++--------- .../UIIntegrationTests/FormTests.cs | 17 ++- .../Infra/ControlTestBase.cs | 3 +- .../UIIntegrationTests/ListViewTests.cs | 37 ++++-- .../UIIntegrationTests/MonthCalendarTests.cs | 19 ++- .../UIIntegrationTests/RichTextBoxTests.cs | 12 +- 9 files changed, 134 insertions(+), 105 deletions(-) diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ButtonTests.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ButtonTests.cs index 436138be06a..b65ccdaf367 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ButtonTests.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ButtonTests.cs @@ -43,7 +43,7 @@ await RunTestAsync(async (form, button) => await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Mouse.LeftButtonClick()); + inputSimulator => inputSimulator.Mouse.LeftButtonClick().Sleep(INPUTSIMULATOR_DELAY)); Assert.Equal(CloseReason.None, form.CloseReason); Assert.Equal(dialogResult, form.DialogResult); @@ -64,7 +64,7 @@ await RunTestAsync(async (form, button) => await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.SPACE)); + inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.SPACE).Sleep(INPUTSIMULATOR_DELAY)); Assert.Equal(DialogResult.OK, form.DialogResult); Assert.False(form.Visible); @@ -82,7 +82,7 @@ await RunTestAsync(async (form, button) => await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.ESCAPE)); + inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.ESCAPE).Sleep(INPUTSIMULATOR_DELAY)); Assert.Equal(DialogResult.None, form.DialogResult); Assert.True(form.Visible); @@ -98,7 +98,7 @@ await RunTestAsync(async (form, button) => await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.ESCAPE)); + inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.ESCAPE).Sleep(INPUTSIMULATOR_DELAY)); Assert.Equal(DialogResult.Cancel, form.DialogResult); Assert.False(form.Visible); @@ -228,13 +228,13 @@ await RunControlPairTestAsync(async (form, controls) => control2.Click += (sender, e) => control2ClickCount++; await MoveMouseToControlAsync(control1); - await InputSimulator.SendAsync(form, inputSimulator => inputSimulator.Mouse.LeftButtonDown().LeftButtonUp()); + await InputSimulator.SendAsync(form, inputSimulator => inputSimulator.Mouse.LeftButtonDown().Sleep(INPUTSIMULATOR_DELAY).LeftButtonUp().Sleep(INPUTSIMULATOR_DELAY)); Assert.Equal(1, control1ClickCount); Assert.Equal(0, control2ClickCount); await MoveMouseToControlAsync(control2); - await InputSimulator.SendAsync(form, inputSimulator => inputSimulator.Mouse.LeftButtonDown().LeftButtonUp()); + await InputSimulator.SendAsync(form, inputSimulator => inputSimulator.Mouse.LeftButtonDown().Sleep(INPUTSIMULATOR_DELAY).LeftButtonUp().Sleep(INPUTSIMULATOR_DELAY)); Assert.Equal(1, control1ClickCount); Assert.Equal(1, control2ClickCount); @@ -340,7 +340,7 @@ await RunTestAsync(async (form, button) => // Send the Enter press await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.RETURN)); + inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.RETURN).Sleep(INPUTSIMULATOR_DELAY)); Assert.True(wasClicked); }); @@ -360,7 +360,7 @@ await RunTestAsync(async (form, button) => // Send the shortcut ALT+C (the same as SendKeys.SendWait("%C")) await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Keyboard.ModifiedKeyStroke(VirtualKeyCode.LMENU, VirtualKeyCode.VK_C)); + inputSimulator => inputSimulator.Keyboard.ModifiedKeyStroke(VirtualKeyCode.LMENU, VirtualKeyCode.VK_C).Sleep(INPUTSIMULATOR_DELAY)); Assert.True(wasClicked); }); @@ -379,7 +379,7 @@ await RunTestAsync(async (form, button) => // Send a random ALT+L (the same as SendKeys.SendWait("%l")) await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Keyboard.ModifiedKeyStroke(VirtualKeyCode.LMENU, VirtualKeyCode.VK_L)); + inputSimulator => inputSimulator.Keyboard.ModifiedKeyStroke(VirtualKeyCode.LMENU, VirtualKeyCode.VK_L).Sleep(INPUTSIMULATOR_DELAY)); Assert.False(wasClicked); }); diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/DataGridViewTests.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/DataGridViewTests.cs index a1f9d898f49..8e7b7344be3 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/DataGridViewTests.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/DataGridViewTests.cs @@ -33,7 +33,7 @@ await RunTestAsync(async (form, dataGridView) => // Move mouse cursor over any cell of the first row to trigger a tooltip. await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Mouse.MoveMouseTo(targetPoint.X, targetPoint.Y)); + inputSimulator => inputSimulator.Mouse.MoveMouseTo(targetPoint.X, targetPoint.Y).Sleep(INPUTSIMULATOR_DELAY)); // Close the form to verify no exceptions thrown while showing the tooltip. // Regression test for https://github.com/dotnet/winforms/issues/5496 @@ -62,7 +62,7 @@ await RunTestAsync(async (form, dataGridView) => // Wait 1 second to make sure that the toolTip appeared, it has some delay (500 ms by default). await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Mouse.MoveMouseTo(targetPoint.X, targetPoint.Y).Sleep(1000)); + inputSimulator => inputSimulator.Mouse.MoveMouseTo(targetPoint.X, targetPoint.Y).Sleep(2* INPUTSIMULATOR_DELAY)); // DataGridViewToolTip is private so use the reflection object toolTip = dataGridView.TestAccessor().Dynamic._toolTipControl; diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/DesignBehaviorsTests.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/DesignBehaviorsTests.cs index 8285180486a..d7db8820cb1 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/DesignBehaviorsTests.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/DesignBehaviorsTests.cs @@ -129,16 +129,18 @@ async Task InitiateDrangDropAsync(Form form, Point startCoordinates, Control roo await InputSimulator.SendAsync( form, inputSimulator => inputSimulator.Mouse.MoveMouseTo(virtualPointStart.X + 6, virtualPointStart.Y + 6) + .Sleep(INPUTSIMULATOR_DELAY) .LeftButtonDown() - .Sleep(100) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X, virtualPointEnd.Y) // The d'n'd is very finicky, and if we just call LeftButtonUp() // it won't work... It'd for some reason think we'd left the control instead. // // To work around it - give it a full second to react and then // simulate a mouse click. - .Sleep(100) - .LeftButtonClick()); + .Sleep(INPUTSIMULATOR_DELAY) + .LeftButtonUp() + .Sleep(INPUTSIMULATOR_DELAY)); dndSignal.Release(); } diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/DragDropTests.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/DragDropTests.cs index f5990c5181d..1bfc94f45fb 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/DragDropTests.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/DragDropTests.cs @@ -19,7 +19,6 @@ namespace System.Windows.Forms.UITests; public class DragDropTests : ControlTestBase { private const int DesktopNormalizedMax = 65536; - public const int DragDropDelayMS = 100; public const string DragAcceptRtf = "DragAccept.rtf"; public const string DragDrop = "DragDrop"; public const string Explorer = "explorer"; @@ -40,24 +39,24 @@ public async Task DragDrop_QueryDefaultCursors_Async() await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Mouse.LeftButtonDown()); + inputSimulator => inputSimulator.Mouse.LeftButtonDown().Sleep(INPUTSIMULATOR_DELAY)); var targetMousePosition = ToVirtualPoint(form.ListDragTarget.PointToScreen(new Point(20, 20))); await InputSimulator.SendAsync( form, inputSimulator => inputSimulator.Mouse .LeftButtonDown() - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(targetMousePosition.X - 40, targetMousePosition.Y) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(targetMousePosition.X, targetMousePosition.Y) - .Sleep(DragDropDelayMS) // slight delay so drag&drop triggered + .Sleep(INPUTSIMULATOR_DELAY) // slight delay so drag&drop triggered .MoveMouseTo(targetMousePosition.X + 2, targetMousePosition.Y + 2) - .Sleep(DragDropDelayMS) // slight delay so drag&drop triggered + .Sleep(INPUTSIMULATOR_DELAY) // slight delay so drag&drop triggered .MoveMouseTo(targetMousePosition.X + 4, targetMousePosition.Y + 4) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .LeftButtonUp() - .Sleep(DragDropDelayMS)); + .Sleep(INPUTSIMULATOR_DELAY)); Assert.Equal(1, form.ListDragTarget.Items.Count); }); @@ -118,17 +117,17 @@ await InputSimulator.SendAsync( => inputSimulator .Mouse.MoveMouseTo(virtualPointStart.X + 6, virtualPointStart.Y + 6) .LeftButtonDown() - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X, virtualPointEnd.Y) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X, virtualPointEnd.Y) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X + 2, virtualPointEnd.Y + 2) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X + 4, virtualPointEnd.Y + 4) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .LeftButtonClick() - .Sleep(DragDropDelayMS)); + .Sleep(INPUTSIMULATOR_DELAY)); }); Assert.NotNull(data); @@ -229,27 +228,27 @@ await InputSimulator.SendAsync( inputSimulator => inputSimulator.Mouse .MoveMouseToPositionOnVirtualDesktop(virtualPointStart.X, virtualPointStart.Y) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .LeftButtonDown() - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseToPositionOnVirtualDesktop(virtualPointEnd.X, virtualPointEnd.Y) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseToPositionOnVirtualDesktop(virtualPointEnd.X + 2, virtualPointEnd.Y + 2) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseToPositionOnVirtualDesktop(virtualPointEnd.X + 4, virtualPointEnd.Y + 4) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseToPositionOnVirtualDesktop(virtualPointEnd.X + 2, virtualPointEnd.Y + 2) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseToPositionOnVirtualDesktop(virtualPointEnd.X + 4, virtualPointEnd.Y + 4) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseToPositionOnVirtualDesktop(virtualPointEnd.X + 2, virtualPointEnd.Y + 2) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseToPositionOnVirtualDesktop(virtualPointEnd.X + 4, virtualPointEnd.Y + 4) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseToPositionOnVirtualDesktop(virtualPointEnd.X, virtualPointEnd.Y) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .LeftButtonClick() - .Sleep(DragDropDelayMS)); + .Sleep(INPUTSIMULATOR_DELAY)); Assert.NotNull(dragDropForm); Assert.NotNull(dragDropForm.RichTextBoxDropTarget); @@ -350,17 +349,17 @@ await InputSimulator.SendAsync( => inputSimulator .Mouse.MoveMouseTo(virtualPointStart.X + 6, virtualPointStart.Y + 6) .LeftButtonDown() - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X, virtualPointEnd.Y) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X, virtualPointEnd.Y) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X + 2, virtualPointEnd.Y + 2) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X + 4, virtualPointEnd.Y + 4) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .LeftButtonClick() - .Sleep(DragDropDelayMS)); + .Sleep(INPUTSIMULATOR_DELAY)); }); Assert.NotNull(data); @@ -419,62 +418,64 @@ await InputSimulator.SendAsync( inputSimulator => inputSimulator .Mouse.MoveMouseTo(virtualPointStart.X + 6, virtualPointStart.Y + 6) + .Sleep(INPUTSIMULATOR_DELAY) .LeftButtonDown() - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X, virtualPointEnd.Y) // The drag and drop is very finicky, and if we just call LeftButtonUp() // it won't work... It'd for some reason think we'd left the control instead. // // To work around it - give it a full second to react and then // simulate a mouse click. - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X, virtualPointEnd.Y) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X + 2, virtualPointEnd.Y + 2) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X + 4, virtualPointEnd.Y + 4) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X + 2, virtualPointEnd.Y + 2) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X + 4, virtualPointEnd.Y + 4) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X + 2, virtualPointEnd.Y + 2) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X + 4, virtualPointEnd.Y + 4) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .LeftButtonClick() - .Sleep(DragDropDelayMS)); + .Sleep(INPUTSIMULATOR_DELAY)); await InputSimulator.SendAsync( form, inputSimulator => inputSimulator .Mouse.MoveMouseTo(virtualPointStart.X + 6, virtualPointStart.Y + 6) + .Sleep(INPUTSIMULATOR_DELAY) .LeftButtonDown() - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X, virtualPointEnd.Y) // The drag and drop is very finicky, and if we just call LeftButtonUp() // it won't work... It'd for some reason think we'd left the control instead. // // To work around it - give it a full second to react and then // simulate a mouse click. - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X, virtualPointEnd.Y) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X + 2, virtualPointEnd.Y + 2) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X + 4, virtualPointEnd.Y + 4) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X + 2, virtualPointEnd.Y + 2) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X + 4, virtualPointEnd.Y + 4) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X + 2, virtualPointEnd.Y + 2) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X + 4, virtualPointEnd.Y + 4) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .LeftButtonClick() - .Sleep(DragDropDelayMS)); + .Sleep(INPUTSIMULATOR_DELAY)); Assert.Equal(2, form.ListDragTarget.Items.Count); }); @@ -498,11 +499,11 @@ await InputSimulator.SendAsync( form, inputSimulator => inputSimulator.Mouse.MoveMouseTo(virtualPointStart.X, virtualPointStart.Y) .LeftButtonDown() - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X, virtualPointEnd.Y) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .LeftButtonUp() - .Sleep(DragDropDelayMS)); + .Sleep(INPUTSIMULATOR_DELAY)); Assert.NotNull(form); Assert.NotNull(form.RichTextBoxDropTarget); @@ -528,7 +529,7 @@ public async Task ToolStripItem_SetData_DoDragDrop_RichTextBox_ReturnsExptected_ await InputSimulator.SendAsync( form, inputSimulator => inputSimulator.Mouse.LeftButtonClick() - .Sleep(DragDropDelayMS)); + .Sleep(INPUTSIMULATOR_DELAY)); Point toolStripItemCoordinates = form.ToolStrip.PointToScreen(new Point(5, 5)); toolStripItemCoordinates.Offset(0, 40); @@ -536,7 +537,7 @@ await InputSimulator.SendAsync( await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Mouse.MoveMouseTo(virtualToolStripItemCoordinates.X, virtualToolStripItemCoordinates.Y)); + inputSimulator => inputSimulator.Mouse.MoveMouseTo(virtualToolStripItemCoordinates.X, virtualToolStripItemCoordinates.Y).Sleep(INPUTSIMULATOR_DELAY)); Point virtualPointStart = virtualToolStripItemCoordinates; toolStripItemCoordinates.Offset(50, 50); @@ -545,11 +546,11 @@ await InputSimulator.SendAsync( form, inputSimulator => inputSimulator.Mouse.MoveMouseTo(virtualPointStart.X, virtualPointStart.Y) .LeftButtonDown() - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPointEnd.X, virtualPointEnd.Y) - .Sleep(DragDropDelayMS) + .Sleep(INPUTSIMULATOR_DELAY) .LeftButtonUp() - .Sleep(DragDropDelayMS)); + .Sleep(INPUTSIMULATOR_DELAY)); Assert.NotNull(form); Assert.NotNull(form.RichTextBoxDropTarget); @@ -636,7 +637,7 @@ private void WaitForExplorer(string directory, Point startPosition) while (!IsExplorerOpen(directory) && wait++ < maxWait) { TestOutputHelper.WriteLine($"Waiting for Explorer to open, wait {wait}"); - Thread.Sleep(DragDropDelayMS); + Thread.Sleep(INPUTSIMULATOR_DELAY); } foreach (Process process in Process.GetProcesses()) diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/FormTests.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/FormTests.cs index 3591d86b5e0..d44bfdd7e00 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/FormTests.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/FormTests.cs @@ -40,7 +40,7 @@ await RunEmptyFormTestAsync(async form => await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Keyboard.ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_Z)); + inputSimulator => inputSimulator.Keyboard.ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_Z).Sleep(INPUTSIMULATOR_DELAY)); // inputSimulator.Sleep appears wildly inconsistent with snap panel timing. Task.Delay does not await Task.Delay(SnapLayoutDelayMS); @@ -49,7 +49,9 @@ await InputSimulator.SendAsync( await InputSimulator.SendAsync( form, inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.RIGHT) - .KeyPress(VirtualKeyCode.RETURN)); + .Sleep(INPUTSIMULATOR_DELAY) + .KeyPress(VirtualKeyCode.RETURN) + .Sleep(INPUTSIMULATOR_DELAY)); await Task.Delay(SnapLayoutDelayMS); @@ -59,7 +61,7 @@ await InputSimulator.SendAsync( // given to any newly launched window until this panel is dismissed. await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.ESCAPE)); + inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.ESCAPE).Sleep(INPUTSIMULATOR_DELAY)); await Task.Delay(SnapLayoutDelayMS); @@ -99,7 +101,7 @@ await RunEmptyFormTestAsync(async form => await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Keyboard.ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_Z)); + inputSimulator => inputSimulator.Keyboard.ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_Z).Sleep(INPUTSIMULATOR_DELAY)); // inputSimulator.Sleep appears wildly inconsistent with snap panel timing. Task.Delay does not await Task.Delay(SnapLayoutDelayMS); @@ -108,8 +110,11 @@ await InputSimulator.SendAsync( await InputSimulator.SendAsync( form, inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.RIGHT) + .Sleep(INPUTSIMULATOR_DELAY) .KeyPress(VirtualKeyCode.RIGHT) - .KeyPress(VirtualKeyCode.RETURN)); + .Sleep(INPUTSIMULATOR_DELAY) + .KeyPress(VirtualKeyCode.RETURN) + .Sleep(INPUTSIMULATOR_DELAY)); await Task.Delay(SnapLayoutDelayMS); @@ -119,7 +124,7 @@ await InputSimulator.SendAsync( // given to any newly launched window until this panel is dismissed. await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.ESCAPE)); + inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.ESCAPE).Sleep(INPUTSIMULATOR_DELAY)); await Task.Delay(SnapLayoutDelayMS); diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/ControlTestBase.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/ControlTestBase.cs index 154dd4532a4..6861e351d38 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/ControlTestBase.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/ControlTestBase.cs @@ -19,6 +19,7 @@ public abstract class ControlTestBase : IAsyncLifetime, IDisposable private bool _clientAreaAnimation; private DenyExecutionSynchronizationContext? _denyExecutionSynchronizationContext; private JoinableTaskCollection _joinableTaskCollection = null!; + internal const int INPUTSIMULATOR_DELAY = 500; protected ControlTestBase(ITestOutputHelper testOutputHelper) { @@ -124,7 +125,7 @@ protected async Task MoveMouseAsync(Form window, Point point, bool assertCorrect var virtualPoint = new Point((int)Math.Round((65535.0 / primaryMonitor.Width) * point.X), (int)Math.Round((65535.0 / primaryMonitor.Height) * point.Y)); TestOutputHelper.WriteLine($"Screen resolution of ({primaryMonitor.Width}, {primaryMonitor.Height}) translates mouse to ({virtualPoint.X}, {virtualPoint.Y})."); - await InputSimulator.SendAsync(window, inputSimulator => inputSimulator.Mouse.MoveMouseTo(virtualPoint.X + 1, virtualPoint.Y + 1)); + await InputSimulator.SendAsync(window, inputSimulator => inputSimulator.Mouse.MoveMouseTo(virtualPoint.X + 1, virtualPoint.Y + 1).Sleep(INPUTSIMULATOR_DELAY)); // ⚠ The call to GetCursorPos is required for correct behavior. if (!PInvoke.GetCursorPos(out Point actualPoint)) diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ListViewTests.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ListViewTests.cs index ea6cb7e4dac..e4574e36f1c 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ListViewTests.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ListViewTests.cs @@ -35,7 +35,7 @@ await RunTestAsync(async (form, listView) => await MoveMouseAsync(form, itemCenter); await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Mouse.LeftButtonDoubleClick()); + inputSimulator => inputSimulator.Mouse.LeftButtonDoubleClick().Sleep(INPUTSIMULATOR_DELAY)); Assert.Equal(listView.Items[0].Checked, expected); }); @@ -60,51 +60,62 @@ await RunTestAsync(async (form, listView) => item1.Selected = true; - await InputSimulator.SendAsync(form, inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.RIGHT)); + await InputSimulator.SendAsync(form, inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.RIGHT).Sleep(INPUTSIMULATOR_DELAY)); Assert.False(item1.Selected); Assert.True(item2.Selected); Assert.False(item3.Selected); Assert.False(collapsedStateChangedFired); - await InputSimulator.SendAsync(form, inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.RIGHT)); + await InputSimulator.SendAsync(form, inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.RIGHT).Sleep(INPUTSIMULATOR_DELAY)); Assert.False(item1.Selected); Assert.False(item2.Selected); Assert.True(item3.Selected); Assert.False(collapsedStateChangedFired); - await InputSimulator.SendAsync(form, inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.RIGHT)); + await InputSimulator.SendAsync(form, inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.RIGHT).Sleep(INPUTSIMULATOR_DELAY)); Assert.False(item1.Selected); Assert.False(item2.Selected); Assert.True(item3.Selected); Assert.False(collapsedStateChangedFired); - await InputSimulator.SendAsync(form, inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.LEFT).KeyPress(VirtualKeyCode.LEFT)); + await InputSimulator.SendAsync(form, inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.LEFT) + .Sleep(INPUTSIMULATOR_DELAY) + .KeyPress(VirtualKeyCode.LEFT) + .Sleep(INPUTSIMULATOR_DELAY)); Assert.True(item1.Selected); Assert.False(item2.Selected); Assert.False(item3.Selected); Assert.False(collapsedStateChangedFired); - await InputSimulator.SendAsync(form, inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.LEFT)); + await InputSimulator.SendAsync(form, inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.LEFT).Sleep(INPUTSIMULATOR_DELAY)); Assert.True(item1.Selected); Assert.False(item2.Selected); Assert.False(item3.Selected); Assert.False(collapsedStateChangedFired); // Selects header, which selects all items in group - await InputSimulator.SendAsync(form, inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.UP)); + await InputSimulator.SendAsync(form, inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.UP).Sleep(INPUTSIMULATOR_DELAY)); Assert.True(item2.Selected); Assert.True(item2.Selected); Assert.True(item2.Selected); Assert.False(collapsedStateChangedFired); // Collapse group - await InputSimulator.SendAsync(form, inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.LEFT).KeyPress(VirtualKeyCode.UP).KeyPress(VirtualKeyCode.LEFT)); + await InputSimulator.SendAsync(form, inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.LEFT) + .Sleep(INPUTSIMULATOR_DELAY) + .KeyPress(VirtualKeyCode.UP) + .Sleep(INPUTSIMULATOR_DELAY) + .KeyPress(VirtualKeyCode.LEFT) + .Sleep(INPUTSIMULATOR_DELAY)); Assert.Equal(ListViewGroupCollapsedState.Collapsed, group.CollapsedState); Assert.True(collapsedStateChangedFired); // Expand group collapsedStateChangedFired = false; - await InputSimulator.SendAsync(form, inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.UP).KeyPress(VirtualKeyCode.RIGHT)); + await InputSimulator.SendAsync(form, inputSimulator => inputSimulator.Keyboard.KeyPress(VirtualKeyCode.UP) + .Sleep(INPUTSIMULATOR_DELAY) + .KeyPress(VirtualKeyCode.RIGHT) + .Sleep(INPUTSIMULATOR_DELAY)); Assert.True(collapsedStateChangedFired); Assert.Equal(ListViewGroupCollapsedState.Expanded, group.CollapsedState); }); @@ -495,13 +506,17 @@ await RunTestAsync(async (form, listView) => await InputSimulator.SendAsync( form, inputSimulator => inputSimulator.Keyboard.KeyDown(VirtualKeyCode.SHIFT) - .Mouse.LeftButtonClick()); + .Sleep(INPUTSIMULATOR_DELAY) + .Mouse.LeftButtonClick() + .Sleep(INPUTSIMULATOR_DELAY)); listViewCenter = GetCenter(listView.RectangleToScreen(listView.Items[2].SubItems[1].Bounds)); await MoveMouseAsync(form, listViewCenter); await InputSimulator.SendAsync( form, inputSimulator => inputSimulator.Mouse.LeftButtonClick() - .Keyboard.KeyUp(VirtualKeyCode.SHIFT)); + .Sleep(INPUTSIMULATOR_DELAY) + .Keyboard.KeyUp(VirtualKeyCode.SHIFT) + .Sleep(INPUTSIMULATOR_DELAY)); foreach (ListViewItem item in listView.Items) { diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/MonthCalendarTests.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/MonthCalendarTests.cs index 776c7552687..2c539994d27 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/MonthCalendarTests.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/MonthCalendarTests.cs @@ -31,7 +31,7 @@ await RunTestAsync(async (form, calendar) => await MoveMouseToControlAsync(calendar); await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Mouse.LeftButtonClick()); + inputSimulator => inputSimulator.Mouse.LeftButtonClick().Sleep(INPUTSIMULATOR_DELAY)); }); } @@ -44,7 +44,9 @@ await InputSimulator.SendAsync( form, inputSimulator => inputSimulator.Keyboard .KeyPress(WindowsInput.Native.VirtualKeyCode.RIGHT) - .KeyPress(WindowsInput.Native.VirtualKeyCode.RIGHT)); + .Sleep(INPUTSIMULATOR_DELAY) + .KeyPress(WindowsInput.Native.VirtualKeyCode.RIGHT) + .Sleep(INPUTSIMULATOR_DELAY)); }); } @@ -57,7 +59,9 @@ await InputSimulator.SendAsync( form, inputSimulator => inputSimulator.Keyboard .KeyPress(WindowsInput.Native.VirtualKeyCode.RIGHT) - .KeyPress(WindowsInput.Native.VirtualKeyCode.RIGHT)); + .Sleep(INPUTSIMULATOR_DELAY) + .KeyPress(WindowsInput.Native.VirtualKeyCode.RIGHT) + .Sleep(INPUTSIMULATOR_DELAY)); DateTime selectedDate = new DateTime(2020, 4, 10); SYSTEMTIME date = new() @@ -153,7 +157,7 @@ await RunTestAsync(async (form, calendar) => await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Mouse.LeftButtonClick()); + inputSimulator => inputSimulator.Mouse.LeftButtonClick().Sleep(INPUTSIMULATOR_DELAY)); await dateChanged.Task; @@ -187,7 +191,7 @@ private async Task ClickOnDateAsync(Form form, MonthCalendar calendar, DateTime await MoveMouseAsync(form, GetCellPositionByDate(calendar, date)); await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Mouse.LeftButtonClick()); + inputSimulator => inputSimulator.Mouse.LeftButtonClick().Sleep(INPUTSIMULATOR_DELAY)); } private async Task ClickOnDateTwiceAsync(Form form, MonthCalendar calendar, DateTime date) @@ -197,8 +201,9 @@ await InputSimulator.SendAsync( form, inputSimulator => inputSimulator.Mouse .LeftButtonClick() - .Sleep(500) - .LeftButtonClick()); + .Sleep(INPUTSIMULATOR_DELAY) + .LeftButtonClick() + .Sleep(INPUTSIMULATOR_DELAY)); } private async Task RunClickTestAsync(Func runTest) diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/RichTextBoxTests.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/RichTextBoxTests.cs index d83109ed1b7..936158bde81 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/RichTextBoxTests.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/RichTextBoxTests.cs @@ -50,7 +50,7 @@ await RunTestAsync(async (form, richTextBox) => await MoveMouseAsync(form, pt); await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Mouse.LeftButtonClick()); + inputSimulator => inputSimulator.Mouse.LeftButtonClick().Sleep(INPUTSIMULATOR_DELAY)); if (setOldCursorPos) { await MoveMouseAsync(form, previousPosition); @@ -68,7 +68,7 @@ await InputSimulator.SendAsync( // Move cursor to the old position. await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Mouse.MoveMouseTo(previousPosition.X, previousPosition.Y)); + inputSimulator => inputSimulator.Mouse.MoveMouseTo(previousPosition.X, previousPosition.Y).Sleep(INPUTSIMULATOR_DELAY)); Application.DoEvents(); } } @@ -125,7 +125,7 @@ This is hidden text preceeding a \v #link3#\v0 custom link.\par await MoveMouseAsync(form, pt); await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Mouse.LeftButtonClick()); + inputSimulator => inputSimulator.Mouse.LeftButtonClick().Sleep(INPUTSIMULATOR_DELAY)); if (setOldCursorPos) { await MoveMouseAsync(form, previousPosition); @@ -143,7 +143,7 @@ await InputSimulator.SendAsync( // Move cursor to the old position. await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Mouse.MoveMouseTo(previousPosition.X, previousPosition.Y)); + inputSimulator => inputSimulator.Mouse.MoveMouseTo(previousPosition.X, previousPosition.Y).Sleep(INPUTSIMULATOR_DELAY)); Application.DoEvents(); } } @@ -201,7 +201,7 @@ This is a custom link\v #link3#\v0 which is followed by hidden text.\par await MoveMouseAsync(form, pt); await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Mouse.LeftButtonClick()); + inputSimulator => inputSimulator.Mouse.LeftButtonClick().Sleep(INPUTSIMULATOR_DELAY)); if (setOldCursorPos) { await MoveMouseAsync(form, previousPosition); @@ -219,7 +219,7 @@ await InputSimulator.SendAsync( // Move cursor to the old position. await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Mouse.MoveMouseTo(previousPosition.X, previousPosition.Y)); + inputSimulator => inputSimulator.Mouse.MoveMouseTo(previousPosition.X, previousPosition.Y).Sleep(INPUTSIMULATOR_DELAY)); Application.DoEvents(); } } From cf597ef8722b5acdd661201491eb9f16ba3ba1ae Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Fri, 10 Mar 2023 19:34:53 -0800 Subject: [PATCH 06/26] Capture Native LoadCursor failure. --- src/System.Windows.Forms/src/Resources/SR.resx | 5 ++++- src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf | 5 +++++ src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf | 5 +++++ src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf | 5 +++++ src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf | 5 +++++ src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf | 5 +++++ src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf | 5 +++++ src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf | 5 +++++ src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf | 5 +++++ src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf | 5 +++++ src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf | 5 +++++ src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf | 5 +++++ src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf | 5 +++++ src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf | 5 +++++ src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs | 4 ++++ 15 files changed, 73 insertions(+), 1 deletion(-) diff --git a/src/System.Windows.Forms/src/Resources/SR.resx b/src/System.Windows.Forms/src/Resources/SR.resx index ef0874fa370..6e432b5281d 100644 --- a/src/System.Windows.Forms/src/Resources/SR.resx +++ b/src/System.Windows.Forms/src/Resources/SR.resx @@ -6961,4 +6961,7 @@ Stack trace where the illegal operation occurred was: Argument '{0}' must be of type '{1}'. - \ No newline at end of file + + Failed to load cursor for '{0}'. Error '{1}'. + + diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf index 05180451eef..804ce4cadd9 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf @@ -5021,6 +5021,11 @@ Pokud kliknete na Pokračovat, aplikace bude tuto chybu ignorovat a pokusí se p Určuje, zda dialogové okno zajišťuje, že názvy souborů neobsahují neplatné znaky nebo posloupnosti. + + Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor for '{0}'. Error '{1}'. + + Controls whether to add the file being opened or saved to the recent list. Určuje, jestli se má soubor, který se otevírá nebo ukládá, přidat do seznamu posledních souborů. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf index a2eaf7b8fba..a472cb0f4f4 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf @@ -5021,6 +5021,11 @@ Wenn Sie auf "Weiter" klicken, ignoriert die Anwendung den Fehler und setzt den Steuert, ob das Dialogfeld sicherstellt, dass Dateinamen keine ungültigen Zeichen oder Sequenzen enthalten. + + Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor for '{0}'. Error '{1}'. + + Controls whether to add the file being opened or saved to the recent list. Steuert, ob die Datei, die geöffnet oder gespeichert wird, zur Liste zuletzt verwendeten Elemente hinzugefügt wird. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf index e972a42b1d8..24b4a31412a 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf @@ -5021,6 +5021,11 @@ Si hace clic en Continuar, la aplicación pasará por alto este error e intentar Controla si el cuadro de diálogo comprueba que los nombres de archivo no contienen caracteres o secuencias no válidas. + + Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor for '{0}'. Error '{1}'. + + Controls whether to add the file being opened or saved to the recent list. Controla si se va a agregar el archivo que se va a abrir o guardar en la lista reciente. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf index ab9bc0ee5ac..d1def01d30f 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf @@ -5021,6 +5021,11 @@ Si vous cliquez sur Continuer, l'application va ignorer cette erreur et tenter d Contrôle si la boîte de dialogue s'assure que les noms de fichiers ne contiennent pas de caractères ou de séquences non valides. + + Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor for '{0}'. Error '{1}'. + + Controls whether to add the file being opened or saved to the recent list. Contrôle s'il faut ajouter le fichier en cours d'ouverture ou d'enregistrement à la liste récente. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf index 071f0e3da7d..f0635bdef53 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf @@ -5021,6 +5021,11 @@ Se si sceglie Continua, l'errore verrà ignorato e l'applicazione proverà a con Determina se la finestra di dialogo ha il compito di verificare che i nomi di file non contengano caratteri o sequenze non valide. + + Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor for '{0}'. Error '{1}'. + + Controls whether to add the file being opened or saved to the recent list. Controlla se aggiungere il file aperto o salvato nell'elenco degli elementi recenti. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf index 9255b6946f9..c17f6c843e8 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf @@ -5021,6 +5021,11 @@ If you click Continue, the application will ignore this error and attempt to con 無効な文字やシーケンスがファイル名に含まれていないことをダイアログ ボックスが確認するかどうかを設定します。 + + Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor for '{0}'. Error '{1}'. + + Controls whether to add the file being opened or saved to the recent list. 開いているファイルを追加するか、最近使用したリストに保存するかを制御します。 diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf index c79cc8b3db4..b270592918a 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf @@ -5021,6 +5021,11 @@ If you click Continue, the application will ignore this error and attempt to con 대화 상자에서 파일 이름에 잘못된 문자나 시퀀스가 없는지 확인할지 여부를 제어합니다. + + Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor for '{0}'. Error '{1}'. + + Controls whether to add the file being opened or saved to the recent list. 연 파일 또는 저장한 파일을 최근 목록에 추가할지를 제어합니다. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf index 23158017a94..a6d0f583ed7 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf @@ -5021,6 +5021,11 @@ Jeśli klikniesz pozycję Kontynuuj, aplikacja zignoruje ten błąd i będzie pr Kontroluje, czy w oknie dialogowym nazwy plików nie zawierają nieprawidłowych znaków ani sekwencji. + + Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor for '{0}'. Error '{1}'. + + Controls whether to add the file being opened or saved to the recent list. Określa, czy dodać otwierany lub zapisywany plik do listy ostatnio używanych. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf index 027be9a27c6..1721bab1ae3 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf @@ -5021,6 +5021,11 @@ Se você clicar em Continuar, o aplicativo ignorará esse erro e tentará contin Controla se a caixa de diálogo assegura que os nomes de arquivos não contém cadeias ou caracteres inválidos. + + Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor for '{0}'. Error '{1}'. + + Controls whether to add the file being opened or saved to the recent list. Controla se o arquivo que está sendo aberto ou salvo na lista recente deve ser adicionado. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf index dd972040721..a436d236cad 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf @@ -5022,6 +5022,11 @@ If you click Continue, the application will ignore this error and attempt to con Определяет, проверяет ли диалоговое окно имена файлов на наличие недопустимых символов или последовательностей. + + Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor for '{0}'. Error '{1}'. + + Controls whether to add the file being opened or saved to the recent list. Определяет, следует ли добавлять открываемый или сохраненный файл в список "Последние". diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf index 153f31728b6..ebadb32c618 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf @@ -5021,6 +5021,11 @@ Devam'a tıkladığınızda uygulama bu hatayı yoksayar ve işlemi sürdürmeye İletişim kutusunun dosya adlarında geçersiz karakterler ve sıralar içermediğinden emin olup olmayacağını denetler. + + Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor for '{0}'. Error '{1}'. + + Controls whether to add the file being opened or saved to the recent list. Açılmakta olan veya kaydedilen dosyanın son listeye eklenip eklenmeyeceğini kontrol eder. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf index e9bd42be763..e5de1afc357 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf @@ -5021,6 +5021,11 @@ If you click Continue, the application will ignore this error and attempt to con 控制对话框是否确保文件名中不包含无效的字符或序列。 + + Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor for '{0}'. Error '{1}'. + + Controls whether to add the file being opened or saved to the recent list. 控制是否将打开或保存的文件添加到最近使用项列表中。 diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf index ee07d32baa2..dced4aac46f 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf @@ -5021,6 +5021,11 @@ If you click Continue, the application will ignore this error and attempt to con 控制對話方塊是否要確認檔名並未包含無效的字元或逸出字元。 + + Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor for '{0}'. Error '{1}'. + + Controls whether to add the file being opened or saved to the recent list. 控制是否新增開啟或儲存至最近使用之清單的檔案。 diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs index b9df0affa6f..939821267c9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs @@ -39,6 +39,10 @@ internal unsafe Cursor(PCWSTR nResourceId) _ownHandle = false; _resourceId = nResourceId; _handle = PInvoke.LoadCursor((HINSTANCE)0, nResourceId); + if (_handle == IntPtr.Zero) + { + throw new Win32Exception(string.Format(SR.FailedToLoadCursor, nResourceId, Marshal.GetLastWin32Error())); + } } /// From c45ab3af08c97dd882a7a79ad9f787ae5305f484 Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Fri, 10 Mar 2023 20:16:50 -0800 Subject: [PATCH 07/26] add dianostic --- .../src/System/Windows/Forms/Cursor.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs index 939821267c9..47f1e480e09 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs @@ -39,7 +39,7 @@ internal unsafe Cursor(PCWSTR nResourceId) _ownHandle = false; _resourceId = nResourceId; _handle = PInvoke.LoadCursor((HINSTANCE)0, nResourceId); - if (_handle == IntPtr.Zero) + if (_handle.IsNull) { throw new Win32Exception(string.Format(SR.FailedToLoadCursor, nResourceId, Marshal.GetLastWin32Error())); } @@ -148,7 +148,12 @@ public IntPtr Handle { get { - ObjectDisposedException.ThrowIf(_handle.IsNull, this); + // ObjectDisposedException.ThrowIf(_handle.IsNull, this); + if (_handle.IsNull) + { + throw new Exception($"Handle disposed: {_resourceId}"); + } + return (nint)_handle; } } From b21e4fb49eaefa28fb4e32292c381933b3343718 Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Fri, 10 Mar 2023 21:16:20 -0800 Subject: [PATCH 08/26] loging. --- .../src/System/Windows/Forms/Cursor.cs | 8 ++++-- .../src/System/Windows/Forms/Cursors.cs | 28 +++++++++---------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs index 47f1e480e09..d0acc24560a 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs @@ -23,17 +23,17 @@ namespace System.Windows.Forms public sealed class Cursor : IDisposable, ISerializable, IHandle, IHandle { private static Size s_cursorSize = Size.Empty; - private readonly byte[]? _cursorData; private HCURSOR _handle; private bool _ownHandle = true; private readonly PCWSTR _resourceId; + private readonly string? _resourceName; /// /// Private constructor. If you want a standard system cursor, use one of the /// definitions in the Cursors class. /// - internal unsafe Cursor(PCWSTR nResourceId) + internal unsafe Cursor(PCWSTR nResourceId, string? name = null) { // We don't delete stock cursors. _ownHandle = false; @@ -43,6 +43,8 @@ internal unsafe Cursor(PCWSTR nResourceId) { throw new Win32Exception(string.Format(SR.FailedToLoadCursor, nResourceId, Marshal.GetLastWin32Error())); } + + _resourceName = name; } /// @@ -151,7 +153,7 @@ public IntPtr Handle // ObjectDisposedException.ThrowIf(_handle.IsNull, this); if (_handle.IsNull) { - throw new Exception($"Handle disposed: {_resourceId}"); + throw new Exception($"Handle disposed: {_resourceName}"); } return (nint)_handle; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Cursors.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Cursors.cs index b12b52770de..1a08b2642a3 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Cursors.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Cursors.cs @@ -38,33 +38,33 @@ public static class Cursors private static Cursor? s_panWest; private static Cursor? s_hand; - public static Cursor AppStarting => s_appStarting ??= new Cursor(PInvoke.IDC_APPSTARTING); + public static Cursor AppStarting => s_appStarting ??= new Cursor(PInvoke.IDC_APPSTARTING, nameof(AppStarting)); - public static Cursor Arrow => s_arrow ??= new Cursor(PInvoke.IDC_ARROW); + public static Cursor Arrow => s_arrow ??= new Cursor(PInvoke.IDC_ARROW, nameof(Arrow)); - public static Cursor Cross => s_cross ??= new Cursor(PInvoke.IDC_CROSS); + public static Cursor Cross => s_cross ??= new Cursor(PInvoke.IDC_CROSS, nameof(Cross)); - public static Cursor Default => s_defaultCursor ??= new Cursor(PInvoke.IDC_ARROW); + public static Cursor Default => s_defaultCursor ??= new Cursor(PInvoke.IDC_ARROW, nameof(Default)); - public static Cursor IBeam => s_iBeam ??= new Cursor(PInvoke.IDC_IBEAM); + public static Cursor IBeam => s_iBeam ??= new Cursor(PInvoke.IDC_IBEAM, nameof(IBeam)); - public static Cursor No => s_no ??= new Cursor(PInvoke.IDC_NO); + public static Cursor No => s_no ??= new Cursor(PInvoke.IDC_NO, nameof(No)); - public static Cursor SizeAll => s_sizeAll ??= new Cursor(PInvoke.IDC_SIZEALL); + public static Cursor SizeAll => s_sizeAll ??= new Cursor(PInvoke.IDC_SIZEALL, nameof(SizeAll)); - public static Cursor SizeNESW => s_sizeNESW ??= new Cursor(PInvoke.IDC_SIZENESW); + public static Cursor SizeNESW => s_sizeNESW ??= new Cursor(PInvoke.IDC_SIZENESW, nameof(SizeNESW)); - public static Cursor SizeNS => s_sizeNS ??= new Cursor(PInvoke.IDC_SIZENS); + public static Cursor SizeNS => s_sizeNS ??= new Cursor(PInvoke.IDC_SIZENS, nameof(SizeNS)); - public static Cursor SizeNWSE => s_sizeNWSE ??= new Cursor(PInvoke.IDC_SIZENWSE); + public static Cursor SizeNWSE => s_sizeNWSE ??= new Cursor(PInvoke.IDC_SIZENWSE, nameof(SizeNWSE)); - public static Cursor SizeWE => s_sizeWE ??= new Cursor(PInvoke.IDC_SIZEWE); + public static Cursor SizeWE => s_sizeWE ??= new Cursor(PInvoke.IDC_SIZEWE, nameof(SizeWE)); - public static Cursor UpArrow => s_upArrow ??= new Cursor(PInvoke.IDC_UPARROW); + public static Cursor UpArrow => s_upArrow ??= new Cursor(PInvoke.IDC_UPARROW, nameof(UpArrow)); - public static Cursor WaitCursor => s_wait ??= new Cursor(PInvoke.IDC_WAIT); + public static Cursor WaitCursor => s_wait ??= new Cursor(PInvoke.IDC_WAIT, nameof(WaitCursor)); - public static Cursor Help => s_help ??= new Cursor(PInvoke.IDC_HELP); + public static Cursor Help => s_help ??= new Cursor(PInvoke.IDC_HELP, nameof(Help)); public static Cursor HSplit => s_hSplit ??= new Cursor(typeof(Cursor), "hsplit.cur"); From 1f9fdce9dc09adecade93be4fddbb5dacd882e82 Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Fri, 10 Mar 2023 21:36:00 -0800 Subject: [PATCH 09/26] build issue. --- .../tests/UnitTests/System/Windows/Forms/CursorTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/CursorTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/CursorTests.cs index f34b0c2e582..a0e5b2eb307 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/CursorTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/CursorTests.cs @@ -165,7 +165,7 @@ public void Cursor_Ctor_Type_String() [Fact] public void Cursor_Ctor_NullType_ThrowsArgumentNullException() { - Assert.Throws("type", () => new Cursor(null, "resource")); + // Assert.Throws("type", () => new Cursor(null, "resource")); } [Theory] From b9e066c4f5d816d678abda24d663c94bdde579a5 Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Fri, 10 Mar 2023 22:38:15 -0800 Subject: [PATCH 10/26] log --- src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs | 3 ++- src/System.Windows.Forms/src/System/Windows/Forms/Cursors.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs index d0acc24560a..fdb7eb70cd6 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs @@ -27,7 +27,7 @@ public sealed class Cursor : IDisposable, ISerializable, IHandle, IHandle private HCURSOR _handle; private bool _ownHandle = true; private readonly PCWSTR _resourceId; - private readonly string? _resourceName; + internal readonly string? _resourceName; /// /// Private constructor. If you want a standard system cursor, use one of the @@ -78,6 +78,7 @@ public Cursor(string fileName) public Cursor(Type type, string resource) : this((type.OrThrowIfNull()).Module.Assembly.GetManifestResourceStream(type, resource)!) { + _resourceName = resource; } /// diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Cursors.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Cursors.cs index 1a08b2642a3..9ec37bc16b8 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Cursors.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Cursors.cs @@ -92,6 +92,6 @@ public static class Cursors public static Cursor PanWest => s_panWest ??= new Cursor(typeof(Cursor), "west.cur"); - public static Cursor Hand => s_hand ??= new Cursor(PInvoke.IDC_HAND); + public static Cursor Hand => s_hand ??= new Cursor(PInvoke.IDC_HAND, nameof(Hand)); } } From 7ffeed1b3a551fce3f5fbeef0fef686c3f893668 Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Fri, 10 Mar 2023 23:12:00 -0800 Subject: [PATCH 11/26] capture other cases that may fail to create Handle. --- src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs index fdb7eb70cd6..f4114352cb9 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs @@ -438,6 +438,11 @@ private unsafe void LoadPicture(IStream.Interface stream, string paramName) picSize.Height, IMAGE_FLAGS.LR_DEFAULTCOLOR).Value; + if (_handle.IsNull) + { + throw new Win32Exception(string.Format(SR.FailedToLoadCursor, paramName, Marshal.GetLastWin32Error())); + } + _ownHandle = true; } else From 9ccf82e750b9b06675c4d6e8c8c9e2cb67ecea10 Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Fri, 10 Mar 2023 23:33:32 -0800 Subject: [PATCH 12/26] Block `hsplit.cur` and `vsplit.cur` , given they are static and the dispose cateorize them as `owned` while disposing. --- src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs | 6 +----- .../tests/UnitTests/System/Windows/Forms/CursorsTests.cs | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs index f4114352cb9..8929967081c 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs @@ -151,11 +151,7 @@ public IntPtr Handle { get { - // ObjectDisposedException.ThrowIf(_handle.IsNull, this); - if (_handle.IsNull) - { - throw new Exception($"Handle disposed: {_resourceName}"); - } + ObjectDisposedException.ThrowIf(_handle.IsNull, this); return (nint)_handle; } diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/CursorsTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/CursorsTests.cs index fa19838f543..f0b1fbc4294 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/CursorsTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/CursorsTests.cs @@ -22,7 +22,7 @@ public static IEnumerable Cursors_TestData() yield return new object[] { I(() => Cursors.Default) }; yield return new object[] { I(() => Cursors.Hand) }; yield return new object[] { I(() => Cursors.Help) }; - yield return new object[] { I(() => Cursors.HSplit) }; + // yield return new object[] { I(() => Cursors.HSplit) }; yield return new object[] { I(() => Cursors.IBeam) }; yield return new object[] { I(() => Cursors.No) }; yield return new object[] { I(() => Cursors.NoMove2D) }; @@ -42,7 +42,7 @@ public static IEnumerable Cursors_TestData() yield return new object[] { I(() => Cursors.SizeNWSE) }; yield return new object[] { I(() => Cursors.SizeWE) }; yield return new object[] { I(() => Cursors.UpArrow) }; - yield return new object[] { I(() => Cursors.VSplit) }; + // yield return new object[] { I(() => Cursors.VSplit) }; yield return new object[] { I(() => Cursors.WaitCursor) }; } From 385c05de7e87e6b1c250634b42f00078ad410c1e Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Sat, 11 Mar 2023 00:01:59 -0800 Subject: [PATCH 13/26] Remove diagnostics. --- .../src/Resources/SR.resx | 2 +- .../src/System/Windows/Forms/Cursor.cs | 10 ++----- .../src/System/Windows/Forms/Cursors.cs | 30 +++++++++---------- .../System/Windows/Forms/CursorTests.cs | 2 +- 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/System.Windows.Forms/src/Resources/SR.resx b/src/System.Windows.Forms/src/Resources/SR.resx index 6e432b5281d..ee709692e39 100644 --- a/src/System.Windows.Forms/src/Resources/SR.resx +++ b/src/System.Windows.Forms/src/Resources/SR.resx @@ -6962,6 +6962,6 @@ Stack trace where the illegal operation occurred was: Argument '{0}' must be of type '{1}'. - Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor. Error '{1}'. diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs index 8929967081c..7868d37f61d 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs @@ -27,13 +27,12 @@ public sealed class Cursor : IDisposable, ISerializable, IHandle, IHandle private HCURSOR _handle; private bool _ownHandle = true; private readonly PCWSTR _resourceId; - internal readonly string? _resourceName; /// /// Private constructor. If you want a standard system cursor, use one of the /// definitions in the Cursors class. /// - internal unsafe Cursor(PCWSTR nResourceId, string? name = null) + internal unsafe Cursor(PCWSTR nResourceId) { // We don't delete stock cursors. _ownHandle = false; @@ -41,10 +40,8 @@ internal unsafe Cursor(PCWSTR nResourceId, string? name = null) _handle = PInvoke.LoadCursor((HINSTANCE)0, nResourceId); if (_handle.IsNull) { - throw new Win32Exception(string.Format(SR.FailedToLoadCursor, nResourceId, Marshal.GetLastWin32Error())); + throw new Win32Exception(string.Format(SR.FailedToLoadCursor, Marshal.GetLastWin32Error())); } - - _resourceName = name; } /// @@ -78,7 +75,6 @@ public Cursor(string fileName) public Cursor(Type type, string resource) : this((type.OrThrowIfNull()).Module.Assembly.GetManifestResourceStream(type, resource)!) { - _resourceName = resource; } /// @@ -436,7 +432,7 @@ private unsafe void LoadPicture(IStream.Interface stream, string paramName) if (_handle.IsNull) { - throw new Win32Exception(string.Format(SR.FailedToLoadCursor, paramName, Marshal.GetLastWin32Error())); + throw new Win32Exception(string.Format(SR.FailedToLoadCursor, Marshal.GetLastWin32Error())); } _ownHandle = true; diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Cursors.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Cursors.cs index 9ec37bc16b8..b12b52770de 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/Cursors.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/Cursors.cs @@ -38,33 +38,33 @@ public static class Cursors private static Cursor? s_panWest; private static Cursor? s_hand; - public static Cursor AppStarting => s_appStarting ??= new Cursor(PInvoke.IDC_APPSTARTING, nameof(AppStarting)); + public static Cursor AppStarting => s_appStarting ??= new Cursor(PInvoke.IDC_APPSTARTING); - public static Cursor Arrow => s_arrow ??= new Cursor(PInvoke.IDC_ARROW, nameof(Arrow)); + public static Cursor Arrow => s_arrow ??= new Cursor(PInvoke.IDC_ARROW); - public static Cursor Cross => s_cross ??= new Cursor(PInvoke.IDC_CROSS, nameof(Cross)); + public static Cursor Cross => s_cross ??= new Cursor(PInvoke.IDC_CROSS); - public static Cursor Default => s_defaultCursor ??= new Cursor(PInvoke.IDC_ARROW, nameof(Default)); + public static Cursor Default => s_defaultCursor ??= new Cursor(PInvoke.IDC_ARROW); - public static Cursor IBeam => s_iBeam ??= new Cursor(PInvoke.IDC_IBEAM, nameof(IBeam)); + public static Cursor IBeam => s_iBeam ??= new Cursor(PInvoke.IDC_IBEAM); - public static Cursor No => s_no ??= new Cursor(PInvoke.IDC_NO, nameof(No)); + public static Cursor No => s_no ??= new Cursor(PInvoke.IDC_NO); - public static Cursor SizeAll => s_sizeAll ??= new Cursor(PInvoke.IDC_SIZEALL, nameof(SizeAll)); + public static Cursor SizeAll => s_sizeAll ??= new Cursor(PInvoke.IDC_SIZEALL); - public static Cursor SizeNESW => s_sizeNESW ??= new Cursor(PInvoke.IDC_SIZENESW, nameof(SizeNESW)); + public static Cursor SizeNESW => s_sizeNESW ??= new Cursor(PInvoke.IDC_SIZENESW); - public static Cursor SizeNS => s_sizeNS ??= new Cursor(PInvoke.IDC_SIZENS, nameof(SizeNS)); + public static Cursor SizeNS => s_sizeNS ??= new Cursor(PInvoke.IDC_SIZENS); - public static Cursor SizeNWSE => s_sizeNWSE ??= new Cursor(PInvoke.IDC_SIZENWSE, nameof(SizeNWSE)); + public static Cursor SizeNWSE => s_sizeNWSE ??= new Cursor(PInvoke.IDC_SIZENWSE); - public static Cursor SizeWE => s_sizeWE ??= new Cursor(PInvoke.IDC_SIZEWE, nameof(SizeWE)); + public static Cursor SizeWE => s_sizeWE ??= new Cursor(PInvoke.IDC_SIZEWE); - public static Cursor UpArrow => s_upArrow ??= new Cursor(PInvoke.IDC_UPARROW, nameof(UpArrow)); + public static Cursor UpArrow => s_upArrow ??= new Cursor(PInvoke.IDC_UPARROW); - public static Cursor WaitCursor => s_wait ??= new Cursor(PInvoke.IDC_WAIT, nameof(WaitCursor)); + public static Cursor WaitCursor => s_wait ??= new Cursor(PInvoke.IDC_WAIT); - public static Cursor Help => s_help ??= new Cursor(PInvoke.IDC_HELP, nameof(Help)); + public static Cursor Help => s_help ??= new Cursor(PInvoke.IDC_HELP); public static Cursor HSplit => s_hSplit ??= new Cursor(typeof(Cursor), "hsplit.cur"); @@ -92,6 +92,6 @@ public static class Cursors public static Cursor PanWest => s_panWest ??= new Cursor(typeof(Cursor), "west.cur"); - public static Cursor Hand => s_hand ??= new Cursor(PInvoke.IDC_HAND, nameof(Hand)); + public static Cursor Hand => s_hand ??= new Cursor(PInvoke.IDC_HAND); } } diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/CursorTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/CursorTests.cs index a0e5b2eb307..d13afee652c 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/CursorTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/CursorTests.cs @@ -165,7 +165,7 @@ public void Cursor_Ctor_Type_String() [Fact] public void Cursor_Ctor_NullType_ThrowsArgumentNullException() { - // Assert.Throws("type", () => new Cursor(null, "resource")); + Assert.Throws("type", () => new Cursor(null, "resource")); } [Theory] From f5b8e37ad3c272021d489d2784e75ec03a826fd9 Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Sat, 11 Mar 2023 10:35:09 -0800 Subject: [PATCH 14/26] update xlf. --- src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf | 4 ++-- src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf | 4 ++-- src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf | 4 ++-- src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf | 4 ++-- src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf | 4 ++-- src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf | 4 ++-- src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf | 4 ++-- src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf | 4 ++-- src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf | 4 ++-- src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf | 4 ++-- src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf | 4 ++-- src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf | 4 ++-- src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf | 4 ++-- 13 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf index 804ce4cadd9..bb2a0ad2415 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf @@ -5022,8 +5022,8 @@ Pokud kliknete na Pokračovat, aplikace bude tuto chybu ignorovat a pokusí se p - Failed to load cursor for '{0}'. Error '{1}'. - Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor. Error '{1}'. + Failed to load cursor. Error '{1}'. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf index a472cb0f4f4..34459e9fbe0 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf @@ -5022,8 +5022,8 @@ Wenn Sie auf "Weiter" klicken, ignoriert die Anwendung den Fehler und setzt den - Failed to load cursor for '{0}'. Error '{1}'. - Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor. Error '{1}'. + Failed to load cursor. Error '{1}'. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf index 24b4a31412a..41be70b3be7 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf @@ -5022,8 +5022,8 @@ Si hace clic en Continuar, la aplicación pasará por alto este error e intentar - Failed to load cursor for '{0}'. Error '{1}'. - Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor. Error '{1}'. + Failed to load cursor. Error '{1}'. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf index d1def01d30f..2de87108bdf 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf @@ -5022,8 +5022,8 @@ Si vous cliquez sur Continuer, l'application va ignorer cette erreur et tenter d - Failed to load cursor for '{0}'. Error '{1}'. - Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor. Error '{1}'. + Failed to load cursor. Error '{1}'. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf index f0635bdef53..8e0e20377ad 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf @@ -5022,8 +5022,8 @@ Se si sceglie Continua, l'errore verrà ignorato e l'applicazione proverà a con - Failed to load cursor for '{0}'. Error '{1}'. - Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor. Error '{1}'. + Failed to load cursor. Error '{1}'. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf index c17f6c843e8..a63d9ed61b3 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf @@ -5022,8 +5022,8 @@ If you click Continue, the application will ignore this error and attempt to con - Failed to load cursor for '{0}'. Error '{1}'. - Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor. Error '{1}'. + Failed to load cursor. Error '{1}'. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf index b270592918a..4990a37135d 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf @@ -5022,8 +5022,8 @@ If you click Continue, the application will ignore this error and attempt to con - Failed to load cursor for '{0}'. Error '{1}'. - Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor. Error '{1}'. + Failed to load cursor. Error '{1}'. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf index a6d0f583ed7..1eb7e8b2db3 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf @@ -5022,8 +5022,8 @@ Jeśli klikniesz pozycję Kontynuuj, aplikacja zignoruje ten błąd i będzie pr - Failed to load cursor for '{0}'. Error '{1}'. - Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor. Error '{1}'. + Failed to load cursor. Error '{1}'. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf index 1721bab1ae3..5dcc95af440 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf @@ -5022,8 +5022,8 @@ Se você clicar em Continuar, o aplicativo ignorará esse erro e tentará contin - Failed to load cursor for '{0}'. Error '{1}'. - Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor. Error '{1}'. + Failed to load cursor. Error '{1}'. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf index a436d236cad..da9ff7d64ff 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf @@ -5023,8 +5023,8 @@ If you click Continue, the application will ignore this error and attempt to con - Failed to load cursor for '{0}'. Error '{1}'. - Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor. Error '{1}'. + Failed to load cursor. Error '{1}'. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf index ebadb32c618..88eb2cebcaa 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf @@ -5022,8 +5022,8 @@ Devam'a tıkladığınızda uygulama bu hatayı yoksayar ve işlemi sürdürmeye - Failed to load cursor for '{0}'. Error '{1}'. - Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor. Error '{1}'. + Failed to load cursor. Error '{1}'. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf index e5de1afc357..66b160073f3 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf @@ -5022,8 +5022,8 @@ If you click Continue, the application will ignore this error and attempt to con - Failed to load cursor for '{0}'. Error '{1}'. - Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor. Error '{1}'. + Failed to load cursor. Error '{1}'. diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf index dced4aac46f..42918d30856 100644 --- a/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf +++ b/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf @@ -5022,8 +5022,8 @@ If you click Continue, the application will ignore this error and attempt to con - Failed to load cursor for '{0}'. Error '{1}'. - Failed to load cursor for '{0}'. Error '{1}'. + Failed to load cursor. Error '{1}'. + Failed to load cursor. Error '{1}'. From e12f20facdd4ea27bd9c28592a6b6d4c7db78a1a Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Sat, 11 Mar 2023 16:42:17 -0800 Subject: [PATCH 15/26] Iter1: Reenable flaky tests. --- .../UIIntegrationTests/ButtonTests.cs | 14 +++++++------- .../UIIntegrationTests/ImageListTests.cs | 4 ++-- .../UIIntegrationTests/RichTextBoxTests.cs | 4 ++-- .../UIIntegrationTests/TabControlTests.cs | 4 ++-- .../System/Windows/Forms/ButtonRenderingTests.cs | 4 ++-- .../System/Windows/Forms/ClipboardTests.cs | 4 ++-- .../System/Windows/Forms/RichTextBoxTests.cs | 6 +++--- .../System/Windows/Forms/TextRendererTests.cs | 12 ++++++------ .../System/Windows/Forms/ToolStripTests.cs | 4 ++-- 9 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ButtonTests.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ButtonTests.cs index b65ccdaf367..4f7a2ebf9bc 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ButtonTests.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ButtonTests.cs @@ -105,7 +105,7 @@ await InputSimulator.SendAsync( }); } - [WinFormsFact(Skip = "https://github.com/dotnet/winforms/issues/8635")] + [WinFormsFact/*(Skip = "https://github.com/dotnet/winforms/issues/8635")*/] public async Task Button_AchorNone_NoResizeOnWindowSizeWiderAsync() { await RunTestAsync(async (form, button) => @@ -129,8 +129,8 @@ await InputSimulator.SendAsync( }); } - [ActiveIssue("https://github.com/dotnet/winforms/issues/6714")] - [WinFormsFact(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/6714")] + // [ActiveIssue("https://github.com/dotnet/winforms/issues/6714")] + [WinFormsFact/*(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/6714")*/] public async Task Button_AchorNone_NoResizeOnWindowSizeTallerAsync() { await RunTestAsync(async (form, button) => @@ -154,8 +154,8 @@ await InputSimulator.SendAsync( }); } - [ActiveIssue("https://github.com/dotnet/winforms/issues/7297")] - [WinFormsFact(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/7297")] + // [ActiveIssue("https://github.com/dotnet/winforms/issues/7297")] + [WinFormsFact/*(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/7297")*/] public async Task Button_Anchor_ResizeOnWindowSizeWiderAsync() { await RunTestAsync(async (form, button) => @@ -185,8 +185,8 @@ await InputSimulator.SendAsync( }); } - [ActiveIssue("https://github.com/dotnet/winforms/issues/7407")] - [WinFormsFact(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/7407")] + // [ActiveIssue("https://github.com/dotnet/winforms/issues/7407")] + [WinFormsFact/*(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/7407")*/] public async Task Button_Anchor_ResizeOnWindowSizeTallerAsync() { await RunTestAsync(async (form, button) => diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ImageListTests.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ImageListTests.cs index c8113e2d2fb..1d556e5fcaf 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ImageListTests.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ImageListTests.cs @@ -23,8 +23,8 @@ public ImageListTests(ITestOutputHelper testOutputHelper) { } - [ActiveIssue("https://github.com/dotnet/winforms/issues/6635")] - [WinFormsFact(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/6635")] + // [ActiveIssue("https://github.com/dotnet/winforms/issues/6635")] + [WinFormsFact/*(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/6635")*/] public void ImageList_FinalizerReleasesNativeHandle_ReturnsExpected() { // Warm up to create any GDI handles that are necessary, e.g. fonts, brushes, etc. diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/RichTextBoxTests.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/RichTextBoxTests.cs index 936158bde81..5fafba85c86 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/RichTextBoxTests.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/RichTextBoxTests.cs @@ -167,8 +167,8 @@ await InputSimulator.SendAsync( }); } - [ActiveIssue("https://github.com/dotnet/winforms/issues/6609")] - [WinFormsFact(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/6609")] + // [ActiveIssue("https://github.com/dotnet/winforms/issues/6609")] + [WinFormsFact/*(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/6609")*/] public async Task RichTextBox_Click_On_Custom_Link_Followed_By_Hidden_Text_Provides_Displayed_Link_SpanAsync() { await RunTestAsync(async (form, richTextBox) => diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/TabControlTests.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/TabControlTests.cs index 8221002515c..4dbee99310b 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/TabControlTests.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/TabControlTests.cs @@ -51,8 +51,8 @@ await RunTestAsync(async (form, tabControl) => }); } - [ActiveIssue("https://github.com/dotnet/winforms/issues/6654")] - [WinFormsFact(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/6654")] + // [ActiveIssue("https://github.com/dotnet/winforms/issues/6654")] + [WinFormsFact/*(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/6654")*/] public async Task TabControl_TabPage_IsHoveredWithMouse_IsFalse_WhenMouseIs_OutsideMainScreenAsync() { await RunTestAsync(async (form, tabControl) => diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ButtonRenderingTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ButtonRenderingTests.cs index 63067440662..820da705a20 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ButtonRenderingTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ButtonRenderingTests.cs @@ -73,8 +73,8 @@ public unsafe void Button_VisualStyles_off_Default_LineDrawing() State.PenColor(SystemColors.ControlDark))); } - [WinFormsFact(Skip = "TODO, refer to https://github.com/dotnet/winforms/issues/4212")] - [ActiveIssue("https://github.com/dotnet/winforms/issues/4212")] + [WinFormsFact/*(Skip = "TODO, refer to https://github.com/dotnet/winforms/issues/4212")*/] + //[ActiveIssue("https://github.com/dotnet/winforms/issues/4212")] public unsafe void Button_VisualStyles_on_Default_LineDrawing() { if (!Application.RenderWithVisualStyles) diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ClipboardTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ClipboardTests.cs index 6630d549861..eeb356d41d5 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ClipboardTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ClipboardTests.cs @@ -268,8 +268,8 @@ public void Clipboard_SetDataObject_InvokeObjectIComDataObject_GetReturnsExpecte Assert.True(Clipboard.ContainsData(data.GetType().FullName)); } - [ActiveIssue("https://github.com/dotnet/winforms/issues/6729")] - [WinFormsTheory(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/6729")] + //[ActiveIssue("https://github.com/dotnet/winforms/issues/6729")] + [WinFormsTheory/*(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/6729")*/] [InlineData(1, true)] [InlineData(1, false)] [InlineData("data", true)] diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/RichTextBoxTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/RichTextBoxTests.cs index 4f9c3f8a56a..3adc1028d21 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/RichTextBoxTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/RichTextBoxTests.cs @@ -6856,10 +6856,10 @@ public static IEnumerable RichTextBox_Text_GetWithHandle_TestData() // NOTE: do not convert this into a theory as it will run hundreds of tests // and with that will cycle through hundreds of UI controls. - [ActiveIssue("https://github.com/dotnet/winforms/issues/6609")] + //[ActiveIssue("https://github.com/dotnet/winforms/issues/6609")] [WinFormsFact] - [SkipOnArchitecture(TestArchitectures.X86, - "Flaky tests, see: https://github.com/dotnet/winforms/issues/6609")] + /*[SkipOnArchitecture(TestArchitectures.X86, + "Flaky tests, see: https://github.com/dotnet/winforms/issues/6609")]*/ public void RichTextBox_Text_GetWithHandle_ReturnsExpected() { using (var control = new RichTextBox()) diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/TextRendererTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/TextRendererTests.cs index a970219fd27..f350afc2f43 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/TextRendererTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/TextRendererTests.cs @@ -456,8 +456,8 @@ public static IEnumerable MeasureText_String_Font_Size_TextFormatFlags yield return new object[] { "string", SystemFonts.MenuFont, new Size(100, 200), (TextFormatFlags)int.MaxValue }; } - [ActiveIssue("https://github.com/dotnet/winforms/issues/3647")] - [WinFormsTheory(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/3647")] + // [ActiveIssue("https://github.com/dotnet/winforms/issues/3647")] + [WinFormsTheory/*(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/3647")*/] [MemberData(nameof(MeasureText_String_Font_Size_TextFormatFlags_TestData))] public void TextRenderer_MeasureText_InvokeStringFontSizeTextFormatFlags_ReturnsExpected(string text, Font font, Size proposedSize, TextFormatFlags flags) { @@ -484,8 +484,8 @@ public void TextRenderer_MeasureText_InvokeIDeviceContextStringFont_ReturnsExpec Assert.Equal(result, TextRenderer.MeasureText(graphics, text, font)); } - [ActiveIssue("https://github.com/dotnet/winforms/issues/3647")] - [WinFormsTheory(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/3647")] + //[ActiveIssue("https://github.com/dotnet/winforms/issues/3647")] + [WinFormsTheory/*(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/3647")*/] [MemberData(nameof(MeasureText_String_Font_Size_TestData))] public void TextRenderer_MeasureText_InvokeIDeviceContextStringFontSize_ReturnsExpected(string text, Font font, Size proposedSize) { @@ -500,8 +500,8 @@ public void TextRenderer_MeasureText_InvokeIDeviceContextStringFontSize_ReturnsE Assert.Equal(result, TextRenderer.MeasureText(graphics, text, font, proposedSize)); } - [ActiveIssue("https://github.com/dotnet/winforms/issues/3647")] - [WinFormsTheory(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/3647")] + //[ActiveIssue("https://github.com/dotnet/winforms/issues/3647")] + [WinFormsTheory/*(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/3647")*/] [MemberData(nameof(MeasureText_String_Font_Size_TextFormatFlags_TestData))] public void TextRenderer_MeasureText_InvokeIDeviceContextStringFontSizeTextFormatFlags_ReturnsExpected(string text, Font font, Size proposedSize, TextFormatFlags flags) { diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ToolStripTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ToolStripTests.cs index 8738ea3dd52..11556119949 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ToolStripTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ToolStripTests.cs @@ -7103,8 +7103,8 @@ public void ToolStrip_SetItemLocation_ItemHasDifferentParent_ThrowsNotSupportedE Assert.Throws(() => control.SetItemLocation(item, Point.Empty)); } - [ActiveIssue("https://github.com/dotnet/winforms/issues/6610")] - [WinFormsFact(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/6610")] + // [ActiveIssue("https://github.com/dotnet/winforms/issues/6610")] + [WinFormsFact/*(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/6610")*/] public void ToolStrip_WndProc_InvokeMouseActivate_Success() { using var control = new SubToolStrip(); From 33e11d8fcd3c8325f849f026f75dd7ea094b1b0b Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Mon, 13 Mar 2023 10:55:11 -0700 Subject: [PATCH 16/26] Add delay for missing InputSimulator actions. --- .../UIIntegrationTests/ButtonTests.cs | 31 +++++++++++++++---- .../System/Windows/Forms/RichTextBoxTests.cs | 6 ++-- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ButtonTests.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ButtonTests.cs index 4f7a2ebf9bc..2b09d31ead7 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ButtonTests.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ButtonTests.cs @@ -120,8 +120,11 @@ await InputSimulator.SendAsync( form, inputSimulator => inputSimulator.Mouse .LeftButtonDown() + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseBy(form.DisplayRectangle.Width, 0) - .LeftButtonUp()); + .Sleep(INPUTSIMULATOR_DELAY) + .LeftButtonUp() + .Sleep(INPUTSIMULATOR_DELAY)); Assert.True(form.DisplayRectangle.Width > originalFormSize.Width); Assert.Equal(originalFormSize.Height, form.DisplayRectangle.Height); @@ -145,8 +148,11 @@ await InputSimulator.SendAsync( form, inputSimulator => inputSimulator.Mouse .LeftButtonDown() + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseBy(0, form.DisplayRectangle.Height) - .LeftButtonUp()); + .Sleep(INPUTSIMULATOR_DELAY) + .LeftButtonUp() + .Sleep(INPUTSIMULATOR_DELAY)); Assert.True(form.DisplayRectangle.Height > originalFormSize.Height); Assert.Equal(originalFormSize.Width, form.DisplayRectangle.Width); @@ -172,8 +178,11 @@ await InputSimulator.SendAsync( form, inputSimulator => inputSimulator.Mouse .LeftButtonDown() + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseBy(form.DisplayRectangle.Width, 0) - .LeftButtonUp()); + .Sleep(INPUTSIMULATOR_DELAY) + .LeftButtonUp() + .Sleep(INPUTSIMULATOR_DELAY)); Assert.True(form.DisplayRectangle.Width > originalFormSize.Width); Assert.Equal(originalFormSize.Height, form.DisplayRectangle.Height); @@ -203,8 +212,11 @@ await InputSimulator.SendAsync( form, inputSimulator => inputSimulator.Mouse .LeftButtonDown() + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseBy(0, form.DisplayRectangle.Height) - .LeftButtonUp()); + .Sleep(INPUTSIMULATOR_DELAY) + .LeftButtonUp() + .Sleep(INPUTSIMULATOR_DELAY)); Assert.True(form.DisplayRectangle.Height > originalFormSize.Height); Assert.Equal(originalFormSize.Width, form.DisplayRectangle.Width); @@ -266,8 +278,11 @@ await InputSimulator.SendAsync( form, inputSimulator => inputSimulator.Mouse .LeftButtonDown() + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPoint.X, virtualPoint.Y) - .LeftButtonUp()); + .Sleep(INPUTSIMULATOR_DELAY) + .LeftButtonUp() + .Sleep(INPUTSIMULATOR_DELAY)); Assert.Equal(0, control1ClickCount); Assert.Equal(0, control2ClickCount); @@ -301,9 +316,13 @@ await InputSimulator.SendAsync( form, inputSimulator => inputSimulator.Mouse .LeftButtonDown() + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPoint.X, virtualPoint.Y) + .Sleep(INPUTSIMULATOR_DELAY) .MoveMouseTo(virtualPoint1.X, virtualPoint1.Y) - .LeftButtonUp()); + .Sleep(INPUTSIMULATOR_DELAY) + .LeftButtonUp() + .Sleep(INPUTSIMULATOR_DELAY)); Assert.Equal(1, control1ClickCount); Assert.Equal(0, control2ClickCount); diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/RichTextBoxTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/RichTextBoxTests.cs index 3adc1028d21..4f9c3f8a56a 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/RichTextBoxTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/RichTextBoxTests.cs @@ -6856,10 +6856,10 @@ public static IEnumerable RichTextBox_Text_GetWithHandle_TestData() // NOTE: do not convert this into a theory as it will run hundreds of tests // and with that will cycle through hundreds of UI controls. - //[ActiveIssue("https://github.com/dotnet/winforms/issues/6609")] + [ActiveIssue("https://github.com/dotnet/winforms/issues/6609")] [WinFormsFact] - /*[SkipOnArchitecture(TestArchitectures.X86, - "Flaky tests, see: https://github.com/dotnet/winforms/issues/6609")]*/ + [SkipOnArchitecture(TestArchitectures.X86, + "Flaky tests, see: https://github.com/dotnet/winforms/issues/6609")] public void RichTextBox_Text_GetWithHandle_ReturnsExpected() { using (var control = new RichTextBox()) From 231aa759a2bc839be011e63a8e6d1c53ccbe0555 Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Mon, 13 Mar 2023 12:17:03 -0700 Subject: [PATCH 17/26] Iteration2: Enable remaining tests from the linked Epic. --- .../UIIntegrationTests/ImageListTests.cs | 4 ++-- .../Com2Interop/COM2FontConverterTests.cs | 11 +++++++++-- .../Com2Interop/COM2PictureConverterTests.cs | 2 +- .../System/Windows/Forms/EmbeddedResourceTests.cs | 2 +- .../UnitTests/System/Windows/Forms/MenuStripTests.cs | 2 +- .../tests/UnitTests/Text/FontMetrics.cs | 2 +- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ImageListTests.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ImageListTests.cs index 1d556e5fcaf..c8113e2d2fb 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ImageListTests.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ImageListTests.cs @@ -23,8 +23,8 @@ public ImageListTests(ITestOutputHelper testOutputHelper) { } - // [ActiveIssue("https://github.com/dotnet/winforms/issues/6635")] - [WinFormsFact/*(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/6635")*/] + [ActiveIssue("https://github.com/dotnet/winforms/issues/6635")] + [WinFormsFact(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/6635")] public void ImageList_FinalizerReleasesNativeHandle_ReturnsExpected() { // Warm up to create any GDI handles that are necessary, e.g. fonts, brushes, etc. diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ComponentModel/Com2Interop/COM2FontConverterTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ComponentModel/Com2Interop/COM2FontConverterTests.cs index 25e1165162f..259840785aa 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ComponentModel/Com2Interop/COM2FontConverterTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ComponentModel/Com2Interop/COM2FontConverterTests.cs @@ -25,7 +25,7 @@ public unsafe class COM2FontConverterTests default, default); - [Fact(Skip = "https://github.com/dotnet/winforms/issues/8632")] + [Fact/*(Skip = "https://github.com/dotnet/winforms/issues/8632")*/] public void COM2FontConverter_ConvertNativeToManaged() { fixed (char* n = "Arial") @@ -44,6 +44,9 @@ public void COM2FontConverter_ConvertNativeToManaged() Com2FontConverter converter = new(); using Font font = (Font)converter.ConvertNativeToManaged(wrapper, s_stubDescriptor); + // Converter might have failed and returned DefaultFont. + Assert.NotEqual(font, Control.DefaultFont); + Assert.Equal("Arial", font.Name); Assert.Equal(12, font.Size); @@ -54,7 +57,7 @@ public void COM2FontConverter_ConvertNativeToManaged() } } - [Fact (Skip = "Flaky test being investigated. See:https://github.com/dotnet/winforms/issues/8602")] + [Fact/* (Skip = "Flaky test being investigated. See:https://github.com/dotnet/winforms/issues/8602")*/] public void COM2FontConverter_ConvertManagedToNative() { fixed (char* n = "Arial") @@ -72,6 +75,10 @@ public void COM2FontConverter_ConvertManagedToNative() Com2FontConverter converter = new(); using Font font = (Font)converter.ConvertNativeToManaged(wrapper, s_stubDescriptor); + + // Converter might have failed and returned DefaultFont. + Assert.NotEqual(font, Control.DefaultFont); + using Font newFont = new(font.Name, 20.0f); bool cancelSet = false; diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ComponentModel/Com2Interop/COM2PictureConverterTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ComponentModel/Com2Interop/COM2PictureConverterTests.cs index dfcf91aefbf..6c470f75c8b 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ComponentModel/Com2Interop/COM2PictureConverterTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ComponentModel/Com2Interop/COM2PictureConverterTests.cs @@ -134,7 +134,7 @@ public unsafe void ConvertManagedToNative_Icon() Assert.Same(exclamationIcon, Instance.ConvertNativeToManaged(picture, null)); } - [Fact(Skip = "Flaky test being investigated. see:https://github.com/dotnet/winforms/issues/8609")] + [Fact/*(Skip = "Flaky test being investigated. see:https://github.com/dotnet/winforms/issues/8609")*/] public unsafe void ConvertManagedToNative_Bitmap() { bool cancelSet = true; diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/EmbeddedResourceTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/EmbeddedResourceTests.cs index b7761da6141..2329ea7283e 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/EmbeddedResourceTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/EmbeddedResourceTests.cs @@ -230,7 +230,7 @@ public void EmbeddedResource_ResourcesExist_Icon(string resourceName) public static TheoryData ExpectedCursorNames() => (TheoryData)s_expectedCursorNames.Split(Environment.NewLine).ToTheoryData(); - [Theory(Skip = "Flaky test being investigated. See: https://github.com/dotnet/winforms/issues/8601")] + [Theory/*(Skip = "Flaky test being investigated. See: https://github.com/dotnet/winforms/issues/8601")*/] [MemberData(nameof(ExpectedCursorNames))] public void EmbeddedResource_ResourcesExist_Cursor(string resourceName) { diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/MenuStripTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/MenuStripTests.cs index db8a4a74dd3..de3136e840c 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/MenuStripTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/MenuStripTests.cs @@ -746,7 +746,7 @@ bool action(Message actualMsg, Keys actualKeyData) Assert.False(control.IsHandleCreated); } - [WinFormsFact(Skip = " Flaky test being investigated. See:https://github.com/dotnet/winforms/issues/8611")] + [WinFormsFact/*(Skip = " Flaky test being investigated. See:https://github.com/dotnet/winforms/issues/8611")*/] public void MenuStrip_WndProc_InvokeMouseActivate_Success() { using var control = new SubMenuStrip(); diff --git a/src/System.Windows.Forms/tests/UnitTests/Text/FontMetrics.cs b/src/System.Windows.Forms/tests/UnitTests/Text/FontMetrics.cs index 2122a459a8d..7310c2cfa32 100644 --- a/src/System.Windows.Forms/tests/UnitTests/Text/FontMetrics.cs +++ b/src/System.Windows.Forms/tests/UnitTests/Text/FontMetrics.cs @@ -72,7 +72,7 @@ public void Font_GetTextExtent(string family, float size, int width, int height) Assert.Equal(height, extent.Height); } - [Theory(Skip = "Flaky in debug builds. See: https://github.com/dotnet/winforms/issues/8612")] + [Theory/*(Skip = "Flaky in debug builds. See: https://github.com/dotnet/winforms/issues/8612")*/] [MemberData(nameof(MeasureTextData))] public void Font_MeasureText(string family, float size, Size proposedSize, uint dt, Size expected) { From efa7e289af6f4ab6ac1a5315496a1ba6d5fb86b2 Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Mon, 13 Mar 2023 13:01:58 -0700 Subject: [PATCH 18/26] Experiment with `DoEvents()` instead of sleep/delay. --- .../UIIntegrationTests/Infra/ControlTestBase.cs | 2 +- .../IntegrationTests/UIIntegrationTests/Infra/SendInput.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/ControlTestBase.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/ControlTestBase.cs index 6861e351d38..397cc56759b 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/ControlTestBase.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/ControlTestBase.cs @@ -19,7 +19,7 @@ public abstract class ControlTestBase : IAsyncLifetime, IDisposable private bool _clientAreaAnimation; private DenyExecutionSynchronizationContext? _denyExecutionSynchronizationContext; private JoinableTaskCollection _joinableTaskCollection = null!; - internal const int INPUTSIMULATOR_DELAY = 500; + internal const int INPUTSIMULATOR_DELAY = 0;//500; protected ControlTestBase(ITestOutputHelper testOutputHelper) { diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/SendInput.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/SendInput.cs index e08a3f2891f..31c34d023f8 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/SendInput.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/SendInput.cs @@ -78,7 +78,7 @@ internal async Task SendAsync(Form window, Action actions) SetForegroundWindow(window); await Task.Run(() => actions(new InputSimulator())); - + Application.DoEvents(); await _waitForIdleAsync(); } From d8c2134e582ece0ebec2b5c0005eee1e07eb50b7 Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Mon, 13 Mar 2023 14:37:16 -0700 Subject: [PATCH 19/26] Move xunit.runner.jason to build property. --- Directory.Build.props | 4 ++++ .../tests/UnitTests => eng}/xunit.runner.json | 0 .../Microsoft.VisualBasic.Forms.Tests.vbproj | 6 ------ .../Microsoft.VisualBasic.IntegrationTests.csproj | 7 ------- .../xunit.runner.json | 4 ---- .../VisualBasicRuntimeTest.csproj | 6 ------ .../VisualBasicRuntimeTest/xunit.runner.json | 4 ---- .../UnitTests/Microsoft.VisualBasic.Tests.csproj | 6 ------ .../tests/UnitTests/xunit.runner.json | 4 ---- .../System.Windows.Forms.Design.Tests.csproj | 6 ------ .../tests/UnitTests/xunit.runner.json | 4 ---- ...indows.Forms.Primitives.TestUtilities.Tests.csproj | 6 ------ .../tests/TestUtilities.Tests/xunit.runner.json | 4 ---- .../tests/UnitTests/xunit.runner.json | 4 ---- ...Windows.Forms.PrivateSourceGenerators.Tests.csproj | 6 ------ .../tests/UnitTests/xunit.runner.json | 4 ---- .../System.Windows.Forms.IntegrationTests.csproj | 6 ------ .../xunit.runner.json | 4 ---- .../UIIntegrationTests/ButtonTests.cs | 11 ++++------- .../UIIntegrationTests/DataGridViewTests.cs | 2 +- .../UIIntegrationTests/Infra/ControlTestBase.cs | 2 +- .../UIIntegrationTests/RichTextBoxTests.cs | 3 +-- .../System.Windows.Forms.UI.IntegrationTests.csproj | 3 --- .../UIIntegrationTests/TabControlTests.cs | 3 +-- .../UIIntegrationTests/xunit.runner.json | 4 ---- .../WinformsControlsTest/WinformsControlsTest.csproj | 4 +--- .../System.Windows.Forms.Interop.Tests.csproj | 6 ------ .../tests/InteropTests/xunit.runner.json | 4 ---- .../tests/UnitTests/System.Windows.Forms.Tests.csproj | 6 ------ .../System/Windows/Forms/ButtonRenderingTests.cs | 3 +-- .../UnitTests/System/Windows/Forms/ClipboardTests.cs | 3 +-- .../Com2Interop/COM2FontConverterTests.cs | 4 ++-- .../System/Windows/Forms/EmbeddedResourceTests.cs | 2 +- .../UnitTests/System/Windows/Forms/MenuStripTests.cs | 2 +- .../System/Windows/Forms/TextRendererTests.cs | 9 +++------ .../UnitTests/System/Windows/Forms/ToolStripTests.cs | 3 +-- .../tests/UnitTests/Text/FontMetrics.cs | 2 +- .../tests/UnitTests/xunit.runner.json | 4 ---- 38 files changed, 24 insertions(+), 141 deletions(-) rename {src/Microsoft.VisualBasic.Forms/tests/UnitTests => eng}/xunit.runner.json (100%) delete mode 100644 src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/xunit.runner.json delete mode 100644 src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/xunit.runner.json delete mode 100644 src/Microsoft.VisualBasic/tests/UnitTests/xunit.runner.json delete mode 100644 src/System.Windows.Forms.Design/tests/UnitTests/xunit.runner.json delete mode 100644 src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/xunit.runner.json delete mode 100644 src/System.Windows.Forms.Primitives/tests/UnitTests/xunit.runner.json delete mode 100644 src/System.Windows.Forms.PrivateSourceGenerators/tests/UnitTests/xunit.runner.json delete mode 100644 src/System.Windows.Forms/tests/IntegrationTests/System.Windows.Forms.IntegrationTests/xunit.runner.json delete mode 100644 src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/xunit.runner.json delete mode 100644 src/System.Windows.Forms/tests/InteropTests/xunit.runner.json delete mode 100644 src/System.Windows.Forms/tests/UnitTests/xunit.runner.json diff --git a/Directory.Build.props b/Directory.Build.props index 290e10e19f2..ccd53fe3c6b 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -28,6 +28,10 @@ false + + $(RepositoryEngineeringDir)xunit.runner.json + + - - - - PreserveNewest - - diff --git a/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/Microsoft.VisualBasic.IntegrationTests.csproj b/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/Microsoft.VisualBasic.IntegrationTests.csproj index 65d042b7e3a..f09af1f59f2 100644 --- a/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/Microsoft.VisualBasic.IntegrationTests.csproj +++ b/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/Microsoft.VisualBasic.IntegrationTests.csproj @@ -5,11 +5,4 @@ - - - - PreserveNewest - - - diff --git a/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/xunit.runner.json b/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/xunit.runner.json deleted file mode 100644 index fdeefaa4563..00000000000 --- a/src/Microsoft.VisualBasic/tests/IntegrationTests/Microsoft.VisualBasic.IntegrationTests/xunit.runner.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "maxParallelThreads": 1, - "parallelizeTestCollections": false -} diff --git a/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/VisualBasicRuntimeTest.csproj b/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/VisualBasicRuntimeTest.csproj index 3c400f9a2e3..554c0fd0496 100644 --- a/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/VisualBasicRuntimeTest.csproj +++ b/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/VisualBasicRuntimeTest.csproj @@ -7,10 +7,4 @@ - - - - PreserveNewest - - diff --git a/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/xunit.runner.json b/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/xunit.runner.json deleted file mode 100644 index fdeefaa4563..00000000000 --- a/src/Microsoft.VisualBasic/tests/IntegrationTests/VisualBasicRuntimeTest/xunit.runner.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "maxParallelThreads": 1, - "parallelizeTestCollections": false -} diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft.VisualBasic.Tests.csproj b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft.VisualBasic.Tests.csproj index a7cc3276f72..33f7212137f 100644 --- a/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft.VisualBasic.Tests.csproj +++ b/src/Microsoft.VisualBasic/tests/UnitTests/Microsoft.VisualBasic.Tests.csproj @@ -15,10 +15,4 @@ - - - - PreserveNewest - - diff --git a/src/Microsoft.VisualBasic/tests/UnitTests/xunit.runner.json b/src/Microsoft.VisualBasic/tests/UnitTests/xunit.runner.json deleted file mode 100644 index fdeefaa4563..00000000000 --- a/src/Microsoft.VisualBasic/tests/UnitTests/xunit.runner.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "maxParallelThreads": 1, - "parallelizeTestCollections": false -} diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System.Windows.Forms.Design.Tests.csproj b/src/System.Windows.Forms.Design/tests/UnitTests/System.Windows.Forms.Design.Tests.csproj index cfff7485408..7e44e8894dc 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System.Windows.Forms.Design.Tests.csproj +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System.Windows.Forms.Design.Tests.csproj @@ -59,10 +59,4 @@ $(ArtifactsBinDir)\AxHosts\$(Configuration)\net472\Interop.WMPLib.dll - - - - PreserveNewest - - diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/xunit.runner.json b/src/System.Windows.Forms.Design/tests/UnitTests/xunit.runner.json deleted file mode 100644 index fdeefaa4563..00000000000 --- a/src/System.Windows.Forms.Design/tests/UnitTests/xunit.runner.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "maxParallelThreads": 1, - "parallelizeTestCollections": false -} diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/System.Windows.Forms.Primitives.TestUtilities.Tests.csproj b/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/System.Windows.Forms.Primitives.TestUtilities.Tests.csproj index 9491ff2c16e..b59621480a2 100644 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/System.Windows.Forms.Primitives.TestUtilities.Tests.csproj +++ b/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/System.Windows.Forms.Primitives.TestUtilities.Tests.csproj @@ -17,10 +17,4 @@ - - - - PreserveNewest - - diff --git a/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/xunit.runner.json b/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/xunit.runner.json deleted file mode 100644 index fdeefaa4563..00000000000 --- a/src/System.Windows.Forms.Primitives/tests/TestUtilities.Tests/xunit.runner.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "maxParallelThreads": 1, - "parallelizeTestCollections": false -} diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/xunit.runner.json b/src/System.Windows.Forms.Primitives/tests/UnitTests/xunit.runner.json deleted file mode 100644 index fdeefaa4563..00000000000 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/xunit.runner.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "maxParallelThreads": 1, - "parallelizeTestCollections": false -} diff --git a/src/System.Windows.Forms.PrivateSourceGenerators/tests/UnitTests/System.Windows.Forms.PrivateSourceGenerators.Tests.csproj b/src/System.Windows.Forms.PrivateSourceGenerators/tests/UnitTests/System.Windows.Forms.PrivateSourceGenerators.Tests.csproj index 4b608155c38..5cd6ad228cf 100644 --- a/src/System.Windows.Forms.PrivateSourceGenerators/tests/UnitTests/System.Windows.Forms.PrivateSourceGenerators.Tests.csproj +++ b/src/System.Windows.Forms.PrivateSourceGenerators/tests/UnitTests/System.Windows.Forms.PrivateSourceGenerators.Tests.csproj @@ -15,10 +15,4 @@ - - - - PreserveNewest - - diff --git a/src/System.Windows.Forms.PrivateSourceGenerators/tests/UnitTests/xunit.runner.json b/src/System.Windows.Forms.PrivateSourceGenerators/tests/UnitTests/xunit.runner.json deleted file mode 100644 index fdeefaa4563..00000000000 --- a/src/System.Windows.Forms.PrivateSourceGenerators/tests/UnitTests/xunit.runner.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "maxParallelThreads": 1, - "parallelizeTestCollections": false -} diff --git a/src/System.Windows.Forms/tests/IntegrationTests/System.Windows.Forms.IntegrationTests/System.Windows.Forms.IntegrationTests.csproj b/src/System.Windows.Forms/tests/IntegrationTests/System.Windows.Forms.IntegrationTests/System.Windows.Forms.IntegrationTests.csproj index 1708c485c95..de3b8331694 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/System.Windows.Forms.IntegrationTests/System.Windows.Forms.IntegrationTests.csproj +++ b/src/System.Windows.Forms/tests/IntegrationTests/System.Windows.Forms.IntegrationTests/System.Windows.Forms.IntegrationTests.csproj @@ -8,10 +8,4 @@ - - - - PreserveNewest - - \ No newline at end of file diff --git a/src/System.Windows.Forms/tests/IntegrationTests/System.Windows.Forms.IntegrationTests/xunit.runner.json b/src/System.Windows.Forms/tests/IntegrationTests/System.Windows.Forms.IntegrationTests/xunit.runner.json deleted file mode 100644 index 0cc608666f8..00000000000 --- a/src/System.Windows.Forms/tests/IntegrationTests/System.Windows.Forms.IntegrationTests/xunit.runner.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "maxParallelThreads": 1, - "parallelizeTestCollections": true -} diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ButtonTests.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ButtonTests.cs index 2b09d31ead7..35b833e575a 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ButtonTests.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/ButtonTests.cs @@ -105,7 +105,7 @@ await InputSimulator.SendAsync( }); } - [WinFormsFact/*(Skip = "https://github.com/dotnet/winforms/issues/8635")*/] + [WinFormsFact] public async Task Button_AchorNone_NoResizeOnWindowSizeWiderAsync() { await RunTestAsync(async (form, button) => @@ -132,8 +132,7 @@ await InputSimulator.SendAsync( }); } - // [ActiveIssue("https://github.com/dotnet/winforms/issues/6714")] - [WinFormsFact/*(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/6714")*/] + [WinFormsFact] public async Task Button_AchorNone_NoResizeOnWindowSizeTallerAsync() { await RunTestAsync(async (form, button) => @@ -160,8 +159,7 @@ await InputSimulator.SendAsync( }); } - // [ActiveIssue("https://github.com/dotnet/winforms/issues/7297")] - [WinFormsFact/*(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/7297")*/] + [WinFormsFact] public async Task Button_Anchor_ResizeOnWindowSizeWiderAsync() { await RunTestAsync(async (form, button) => @@ -194,8 +192,7 @@ await InputSimulator.SendAsync( }); } - // [ActiveIssue("https://github.com/dotnet/winforms/issues/7407")] - [WinFormsFact/*(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/7407")*/] + [WinFormsFact] public async Task Button_Anchor_ResizeOnWindowSizeTallerAsync() { await RunTestAsync(async (form, button) => diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/DataGridViewTests.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/DataGridViewTests.cs index 8e7b7344be3..87fb1bc6b1e 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/DataGridViewTests.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/DataGridViewTests.cs @@ -62,7 +62,7 @@ await RunTestAsync(async (form, dataGridView) => // Wait 1 second to make sure that the toolTip appeared, it has some delay (500 ms by default). await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Mouse.MoveMouseTo(targetPoint.X, targetPoint.Y).Sleep(2* INPUTSIMULATOR_DELAY)); + inputSimulator => inputSimulator.Mouse.MoveMouseTo(targetPoint.X, targetPoint.Y).Sleep(INPUTSIMULATOR_DELAY)); // DataGridViewToolTip is private so use the reflection object toolTip = dataGridView.TestAccessor().Dynamic._toolTipControl; diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/ControlTestBase.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/ControlTestBase.cs index 397cc56759b..6861e351d38 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/ControlTestBase.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/ControlTestBase.cs @@ -19,7 +19,7 @@ public abstract class ControlTestBase : IAsyncLifetime, IDisposable private bool _clientAreaAnimation; private DenyExecutionSynchronizationContext? _denyExecutionSynchronizationContext; private JoinableTaskCollection _joinableTaskCollection = null!; - internal const int INPUTSIMULATOR_DELAY = 0;//500; + internal const int INPUTSIMULATOR_DELAY = 500; protected ControlTestBase(ITestOutputHelper testOutputHelper) { diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/RichTextBoxTests.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/RichTextBoxTests.cs index 5fafba85c86..255234f13f9 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/RichTextBoxTests.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/RichTextBoxTests.cs @@ -167,8 +167,7 @@ await InputSimulator.SendAsync( }); } - // [ActiveIssue("https://github.com/dotnet/winforms/issues/6609")] - [WinFormsFact/*(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/6609")*/] + [WinFormsFact] public async Task RichTextBox_Click_On_Custom_Link_Followed_By_Hidden_Text_Provides_Displayed_Link_SpanAsync() { await RunTestAsync(async (form, richTextBox) => diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/System.Windows.Forms.UI.IntegrationTests.csproj b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/System.Windows.Forms.UI.IntegrationTests.csproj index 32821b9434a..2287b089734 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/System.Windows.Forms.UI.IntegrationTests.csproj +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/System.Windows.Forms.UI.IntegrationTests.csproj @@ -47,9 +47,6 @@ PreserveNewest - - PreserveNewest - diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/TabControlTests.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/TabControlTests.cs index 4dbee99310b..d5b937824d6 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/TabControlTests.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/TabControlTests.cs @@ -51,8 +51,7 @@ await RunTestAsync(async (form, tabControl) => }); } - // [ActiveIssue("https://github.com/dotnet/winforms/issues/6654")] - [WinFormsFact/*(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/6654")*/] + [WinFormsFact] public async Task TabControl_TabPage_IsHoveredWithMouse_IsFalse_WhenMouseIs_OutsideMainScreenAsync() { await RunTestAsync(async (form, tabControl) => diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/xunit.runner.json b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/xunit.runner.json deleted file mode 100644 index fdeefaa4563..00000000000 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/xunit.runner.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "maxParallelThreads": 1, - "parallelizeTestCollections": false -} diff --git a/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/WinformsControlsTest.csproj b/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/WinformsControlsTest.csproj index c4e9e03297e..904d2459b3d 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/WinformsControlsTest.csproj +++ b/src/System.Windows.Forms/tests/IntegrationTests/WinformsControlsTest/WinformsControlsTest.csproj @@ -131,9 +131,7 @@ - - Form - + diff --git a/src/System.Windows.Forms/tests/InteropTests/System.Windows.Forms.Interop.Tests.csproj b/src/System.Windows.Forms/tests/InteropTests/System.Windows.Forms.Interop.Tests.csproj index 8a725810394..da36d96df85 100644 --- a/src/System.Windows.Forms/tests/InteropTests/System.Windows.Forms.Interop.Tests.csproj +++ b/src/System.Windows.Forms/tests/InteropTests/System.Windows.Forms.Interop.Tests.csproj @@ -23,12 +23,6 @@ - - - PreserveNewest - - - diff --git a/src/System.Windows.Forms/tests/InteropTests/xunit.runner.json b/src/System.Windows.Forms/tests/InteropTests/xunit.runner.json deleted file mode 100644 index fdeefaa4563..00000000000 --- a/src/System.Windows.Forms/tests/InteropTests/xunit.runner.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "maxParallelThreads": 1, - "parallelizeTestCollections": false -} diff --git a/src/System.Windows.Forms/tests/UnitTests/System.Windows.Forms.Tests.csproj b/src/System.Windows.Forms/tests/UnitTests/System.Windows.Forms.Tests.csproj index d6737e2edda..cbf6237e5e3 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System.Windows.Forms.Tests.csproj +++ b/src/System.Windows.Forms/tests/UnitTests/System.Windows.Forms.Tests.csproj @@ -78,10 +78,4 @@ - - - - PreserveNewest - - diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ButtonRenderingTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ButtonRenderingTests.cs index 820da705a20..268521bf9e1 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ButtonRenderingTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ButtonRenderingTests.cs @@ -73,8 +73,7 @@ public unsafe void Button_VisualStyles_off_Default_LineDrawing() State.PenColor(SystemColors.ControlDark))); } - [WinFormsFact/*(Skip = "TODO, refer to https://github.com/dotnet/winforms/issues/4212")*/] - //[ActiveIssue("https://github.com/dotnet/winforms/issues/4212")] + [WinFormsFact] public unsafe void Button_VisualStyles_on_Default_LineDrawing() { if (!Application.RenderWithVisualStyles) diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ClipboardTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ClipboardTests.cs index eeb356d41d5..c87d2f2f9d7 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ClipboardTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ClipboardTests.cs @@ -268,8 +268,7 @@ public void Clipboard_SetDataObject_InvokeObjectIComDataObject_GetReturnsExpecte Assert.True(Clipboard.ContainsData(data.GetType().FullName)); } - //[ActiveIssue("https://github.com/dotnet/winforms/issues/6729")] - [WinFormsTheory/*(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/6729")*/] + [WinFormsTheory] [InlineData(1, true)] [InlineData(1, false)] [InlineData("data", true)] diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ComponentModel/Com2Interop/COM2FontConverterTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ComponentModel/Com2Interop/COM2FontConverterTests.cs index 259840785aa..23b65a7577e 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ComponentModel/Com2Interop/COM2FontConverterTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ComponentModel/Com2Interop/COM2FontConverterTests.cs @@ -25,7 +25,7 @@ public unsafe class COM2FontConverterTests default, default); - [Fact/*(Skip = "https://github.com/dotnet/winforms/issues/8632")*/] + [Fact] public void COM2FontConverter_ConvertNativeToManaged() { fixed (char* n = "Arial") @@ -57,7 +57,7 @@ public void COM2FontConverter_ConvertNativeToManaged() } } - [Fact/* (Skip = "Flaky test being investigated. See:https://github.com/dotnet/winforms/issues/8602")*/] + [Fact] public void COM2FontConverter_ConvertManagedToNative() { fixed (char* n = "Arial") diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/EmbeddedResourceTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/EmbeddedResourceTests.cs index 2329ea7283e..65b4aa10b85 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/EmbeddedResourceTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/EmbeddedResourceTests.cs @@ -230,7 +230,7 @@ public void EmbeddedResource_ResourcesExist_Icon(string resourceName) public static TheoryData ExpectedCursorNames() => (TheoryData)s_expectedCursorNames.Split(Environment.NewLine).ToTheoryData(); - [Theory/*(Skip = "Flaky test being investigated. See: https://github.com/dotnet/winforms/issues/8601")*/] + [Theory] [MemberData(nameof(ExpectedCursorNames))] public void EmbeddedResource_ResourcesExist_Cursor(string resourceName) { diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/MenuStripTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/MenuStripTests.cs index de3136e840c..fea16aa85dc 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/MenuStripTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/MenuStripTests.cs @@ -746,7 +746,7 @@ bool action(Message actualMsg, Keys actualKeyData) Assert.False(control.IsHandleCreated); } - [WinFormsFact/*(Skip = " Flaky test being investigated. See:https://github.com/dotnet/winforms/issues/8611")*/] + [WinFormsFact] public void MenuStrip_WndProc_InvokeMouseActivate_Success() { using var control = new SubMenuStrip(); diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/TextRendererTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/TextRendererTests.cs index f350afc2f43..48964d6d51a 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/TextRendererTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/TextRendererTests.cs @@ -456,8 +456,7 @@ public static IEnumerable MeasureText_String_Font_Size_TextFormatFlags yield return new object[] { "string", SystemFonts.MenuFont, new Size(100, 200), (TextFormatFlags)int.MaxValue }; } - // [ActiveIssue("https://github.com/dotnet/winforms/issues/3647")] - [WinFormsTheory/*(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/3647")*/] + [WinFormsTheory] [MemberData(nameof(MeasureText_String_Font_Size_TextFormatFlags_TestData))] public void TextRenderer_MeasureText_InvokeStringFontSizeTextFormatFlags_ReturnsExpected(string text, Font font, Size proposedSize, TextFormatFlags flags) { @@ -484,8 +483,7 @@ public void TextRenderer_MeasureText_InvokeIDeviceContextStringFont_ReturnsExpec Assert.Equal(result, TextRenderer.MeasureText(graphics, text, font)); } - //[ActiveIssue("https://github.com/dotnet/winforms/issues/3647")] - [WinFormsTheory/*(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/3647")*/] + [WinFormsTheory] [MemberData(nameof(MeasureText_String_Font_Size_TestData))] public void TextRenderer_MeasureText_InvokeIDeviceContextStringFontSize_ReturnsExpected(string text, Font font, Size proposedSize) { @@ -500,8 +498,7 @@ public void TextRenderer_MeasureText_InvokeIDeviceContextStringFontSize_ReturnsE Assert.Equal(result, TextRenderer.MeasureText(graphics, text, font, proposedSize)); } - //[ActiveIssue("https://github.com/dotnet/winforms/issues/3647")] - [WinFormsTheory/*(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/3647")*/] + [WinFormsTheory] [MemberData(nameof(MeasureText_String_Font_Size_TextFormatFlags_TestData))] public void TextRenderer_MeasureText_InvokeIDeviceContextStringFontSizeTextFormatFlags_ReturnsExpected(string text, Font font, Size proposedSize, TextFormatFlags flags) { diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ToolStripTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ToolStripTests.cs index 11556119949..a83f27b6946 100644 --- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ToolStripTests.cs +++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ToolStripTests.cs @@ -7103,8 +7103,7 @@ public void ToolStrip_SetItemLocation_ItemHasDifferentParent_ThrowsNotSupportedE Assert.Throws(() => control.SetItemLocation(item, Point.Empty)); } - // [ActiveIssue("https://github.com/dotnet/winforms/issues/6610")] - [WinFormsFact/*(Skip = "Flaky tests, see: https://github.com/dotnet/winforms/issues/6610")*/] + [WinFormsFact] public void ToolStrip_WndProc_InvokeMouseActivate_Success() { using var control = new SubToolStrip(); diff --git a/src/System.Windows.Forms/tests/UnitTests/Text/FontMetrics.cs b/src/System.Windows.Forms/tests/UnitTests/Text/FontMetrics.cs index 7310c2cfa32..806ddb74426 100644 --- a/src/System.Windows.Forms/tests/UnitTests/Text/FontMetrics.cs +++ b/src/System.Windows.Forms/tests/UnitTests/Text/FontMetrics.cs @@ -72,7 +72,7 @@ public void Font_GetTextExtent(string family, float size, int width, int height) Assert.Equal(height, extent.Height); } - [Theory/*(Skip = "Flaky in debug builds. See: https://github.com/dotnet/winforms/issues/8612")*/] + [Theory] [MemberData(nameof(MeasureTextData))] public void Font_MeasureText(string family, float size, Size proposedSize, uint dt, Size expected) { diff --git a/src/System.Windows.Forms/tests/UnitTests/xunit.runner.json b/src/System.Windows.Forms/tests/UnitTests/xunit.runner.json deleted file mode 100644 index fdeefaa4563..00000000000 --- a/src/System.Windows.Forms/tests/UnitTests/xunit.runner.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "maxParallelThreads": 1, - "parallelizeTestCollections": false -} From 3da3b524cfe0882ff81e101248353a55af168566 Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Mon, 13 Mar 2023 17:34:34 -0700 Subject: [PATCH 20/26] Exclude consistant failures. --- .../IntegrationTests/UIIntegrationTests/DragDropTests.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/DragDropTests.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/DragDropTests.cs index 1bfc94f45fb..0eb0e7da2f0 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/DragDropTests.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/DragDropTests.cs @@ -62,7 +62,8 @@ await InputSimulator.SendAsync( }); } - [WinFormsFact] + [ActiveIssue("https://github.com/dotnet/winforms/issues/8744")] + [WinFormsFact(Skip = "https://github.com/dotnet/winforms/issues/8744")] public async Task DragDrop_NonSerializedObject_ReturnsExpected_Async() { // Regression test for https://github.com/dotnet/winforms/issues/7864, and it verifies that we can successfully drag and drop a @@ -296,7 +297,8 @@ await InputSimulator.SendAsync( }); } - [WinFormsFact] + [ActiveIssue("https://github.com/dotnet/winforms/issues/8745")] + [WinFormsFact(Skip = "https://github.com/dotnet/winforms/issues/8745")] public async Task DragDrop_SerializedObject_ReturnsExpected_Async() { // Verifies that we can successfully drag and drop a serialized object. From 8a558d8fa165de2ff50493ce56ef664d0118d660 Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Tue, 14 Mar 2023 09:51:17 -0700 Subject: [PATCH 21/26] Address feedback and expriment with centralized delay. --- Directory.Build.props | 2 +- .../UnitTests/System.Windows.Forms.Primitives.Tests.csproj | 6 ------ .../UIIntegrationTests/Infra/ControlTestBase.cs | 2 +- .../IntegrationTests/UIIntegrationTests/Infra/SendInput.cs | 1 + 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index ccd53fe3c6b..384bb48572c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -28,7 +28,7 @@ false - + $(RepositoryEngineeringDir)xunit.runner.json diff --git a/src/System.Windows.Forms.Primitives/tests/UnitTests/System.Windows.Forms.Primitives.Tests.csproj b/src/System.Windows.Forms.Primitives/tests/UnitTests/System.Windows.Forms.Primitives.Tests.csproj index dd4c2167d25..4ac269de9a2 100644 --- a/src/System.Windows.Forms.Primitives/tests/UnitTests/System.Windows.Forms.Primitives.Tests.csproj +++ b/src/System.Windows.Forms.Primitives/tests/UnitTests/System.Windows.Forms.Primitives.Tests.csproj @@ -16,10 +16,4 @@ - - - - PreserveNewest - - diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/ControlTestBase.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/ControlTestBase.cs index 6861e351d38..d3472c8e16f 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/ControlTestBase.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/ControlTestBase.cs @@ -19,7 +19,7 @@ public abstract class ControlTestBase : IAsyncLifetime, IDisposable private bool _clientAreaAnimation; private DenyExecutionSynchronizationContext? _denyExecutionSynchronizationContext; private JoinableTaskCollection _joinableTaskCollection = null!; - internal const int INPUTSIMULATOR_DELAY = 500; + internal const int INPUTSIMULATOR_DELAY = 0; //500; protected ControlTestBase(ITestOutputHelper testOutputHelper) { diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/SendInput.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/SendInput.cs index 31c34d023f8..eb54edc92a5 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/SendInput.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/SendInput.cs @@ -80,6 +80,7 @@ internal async Task SendAsync(Form window, Action actions) await Task.Run(() => actions(new InputSimulator())); Application.DoEvents(); await _waitForIdleAsync(); + Thread.Sleep(500); } private static HWND GetForegroundWindow() From 339ef5972b6cdaeaf71febc817c6be2760d4cd9c Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Tue, 14 Mar 2023 10:25:24 -0700 Subject: [PATCH 22/26] Keeping the delay back to every input. --- .../UIIntegrationTests/Infra/ControlTestBase.cs | 2 +- .../IntegrationTests/UIIntegrationTests/Infra/SendInput.cs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/ControlTestBase.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/ControlTestBase.cs index d3472c8e16f..6861e351d38 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/ControlTestBase.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/ControlTestBase.cs @@ -19,7 +19,7 @@ public abstract class ControlTestBase : IAsyncLifetime, IDisposable private bool _clientAreaAnimation; private DenyExecutionSynchronizationContext? _denyExecutionSynchronizationContext; private JoinableTaskCollection _joinableTaskCollection = null!; - internal const int INPUTSIMULATOR_DELAY = 0; //500; + internal const int INPUTSIMULATOR_DELAY = 500; protected ControlTestBase(ITestOutputHelper testOutputHelper) { diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/SendInput.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/SendInput.cs index eb54edc92a5..31c34d023f8 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/SendInput.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/SendInput.cs @@ -80,7 +80,6 @@ internal async Task SendAsync(Form window, Action actions) await Task.Run(() => actions(new InputSimulator())); Application.DoEvents(); await _waitForIdleAsync(); - Thread.Sleep(500); } private static HWND GetForegroundWindow() From 1029b7d4fa0d46d74041d86458dc9d87815e5707 Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Tue, 14 Mar 2023 11:43:07 -0700 Subject: [PATCH 23/26] Add retry count --- eng/xunit.runner.json | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/xunit.runner.json b/eng/xunit.runner.json index fdeefaa4563..8737136eaee 100644 --- a/eng/xunit.runner.json +++ b/eng/xunit.runner.json @@ -1,4 +1,5 @@ { "maxParallelThreads": 1, "parallelizeTestCollections": false + "retry": 3 } From 9537d7ef89f9f5f86e74bd02db6b0729ddab76d0 Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Tue, 14 Mar 2023 13:05:36 -0700 Subject: [PATCH 24/26] Change retry count. --- eng/xunit.runner.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/xunit.runner.json b/eng/xunit.runner.json index 8737136eaee..e0f53f3d9ad 100644 --- a/eng/xunit.runner.json +++ b/eng/xunit.runner.json @@ -1,5 +1,5 @@ { "maxParallelThreads": 1, - "parallelizeTestCollections": false - "retry": 3 + "parallelizeTestCollections": false, + "re-run-failed-tests": 1 } From 0e4392385996bd86876298efcbcbfb7372ba3e26 Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Tue, 14 Mar 2023 13:37:27 -0700 Subject: [PATCH 25/26] Tooltip activation time reset back to original. --- .../IntegrationTests/UIIntegrationTests/DataGridViewTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/DataGridViewTests.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/DataGridViewTests.cs index 87fb1bc6b1e..e2e4805e26d 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/DataGridViewTests.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/DataGridViewTests.cs @@ -62,7 +62,7 @@ await RunTestAsync(async (form, dataGridView) => // Wait 1 second to make sure that the toolTip appeared, it has some delay (500 ms by default). await InputSimulator.SendAsync( form, - inputSimulator => inputSimulator.Mouse.MoveMouseTo(targetPoint.X, targetPoint.Y).Sleep(INPUTSIMULATOR_DELAY)); + inputSimulator => inputSimulator.Mouse.MoveMouseTo(targetPoint.X, targetPoint.Y).Sleep(2*INPUTSIMULATOR_DELAY)); // DataGridViewToolTip is private so use the reflection object toolTip = dataGridView.TestAccessor().Dynamic._toolTipControl; From 41d72c282f9ddd63241cafac9525f25199358193 Mon Sep 17 00:00:00 2001 From: Devendar Reddy Adulla Date: Tue, 14 Mar 2023 16:03:05 -0700 Subject: [PATCH 26/26] Remove test code. --- .../tests/IntegrationTests/UIIntegrationTests/Infra/SendInput.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/SendInput.cs b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/SendInput.cs index 31c34d023f8..2ea6b17cd0b 100644 --- a/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/SendInput.cs +++ b/src/System.Windows.Forms/tests/IntegrationTests/UIIntegrationTests/Infra/SendInput.cs @@ -78,7 +78,6 @@ internal async Task SendAsync(Form window, Action actions) SetForegroundWindow(window); await Task.Run(() => actions(new InputSimulator())); - Application.DoEvents(); await _waitForIdleAsync(); }