Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Flaky test] toolstriptests.toolstrip_wndproc_invokemouseactivate_success #8604

Closed
Tracked by #8607
runfoapp bot opened this issue Feb 9, 2023 · 4 comments
Closed
Tracked by #8607

Comments

@runfoapp
Copy link

runfoapp bot commented Feb 9, 2023

Runfo Tracking Issue: [Flaky test] toolstriptests.toolstrip_wndproc_invokemouseactivate_success

Build Definition Kind Run Name

Build Result Summary

Day Hit Count Week Hit Count Month Hit Count
0 0 0
@dreddy-work
Copy link
Member

Assert.Equal() Failure\r\nExpected: 0\r\nActual: 2

Stack trace
at System.Windows.Forms.Tests.ToolStripTests.ToolStrip_WndProc_InvokeMouseActivate_Success() in /_/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ToolStripTests.cs:line 7095
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)

@dreddy-work
Copy link
Member

           using var control = new SubToolStrip();
            var m = new Message
            {
                Msg = (int)User32.WM.MOUSEACTIVATE,
                Result = (IntPtr)250
            };
            control.WndProc(ref m);
            Assert.Equal(IntPtr.Zero, m.Result);
            Assert.True(control.IsHandleCreated);

@lonitra
Copy link
Member

lonitra commented Mar 1, 2023

WM.MOUSEACTIVATE message for ToolStrip calls to WindowsFormsUtils.LastCursorPoint , which is the cursor position for the last message received.

if (m.MsgInternal == User32.WM.MOUSEACTIVATE)
{
// we want to prevent taking focus if someone clicks on the toolstrip dropdown
// itself. the mouse message will still go through, but focus won't be taken.
// if someone clicks on a child control (combobox, textbox, etc) focus will
// be taken - but we'll handle that in WM_NCACTIVATE handler.
Point pt = PointToClient(WindowsFormsUtils.LastCursorPoint);
IntPtr hwndClicked = User32.ChildWindowFromPointEx(this, pt, User32.CWP.SKIPINVISIBLE | User32.CWP.SKIPDISABLED | User32.CWP.SKIPTRANSPARENT);

It is possible that running other tests in parallel cause an unexpected cursor position to be given. We might want to ensure that this test does not run in parallel with other tests.
The cause for this test's flakiness is also likely the same cause for #6610
The cause for this test's flakiness is also likely the same cause for #8611 since MenuStrip's WndProc message will defer to ToolStrip's WndProc

@ghost ghost added 🚧 work in progress Work that is current in progress and removed 🚧 work in progress Work that is current in progress labels Mar 14, 2023
@dreddy-work
Copy link
Member

closing against #8864

@ghost ghost locked as resolved and limited conversation to collaborators Apr 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants