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

FindElement.Refresh stuck in infinite loop when setting a child's events source to the parent's #3491

Closed
ejserna opened this issue Oct 26, 2020 · 5 comments · Fixed by #3516
Labels
area-TestInfrastructure Issue in the test infrastructure (e.g. in Helix scripts) help wanted Issue ideal for external contributors team-Controls Issue for the Controls team

Comments

@ejserna
Copy link
Contributor

ejserna commented Oct 26, 2020

Describe the bug
If you set a control's events source to a parent's, the foreach loop in FindElement.Refresh() will get stuck in an infinite loop.

Steps to reproduce the bug
Try this code:
XAML:

<local:TestControl x:Name="CustomControl" AutomationProperties.Name="CustomControl">
                    <Button x:Name="Button1" Content="Button"/>
 </local:TestControl>

XAML.CS

namespace MUXControlsTestApp
{
    public sealed class TestControl : ContentControl
    {
        protected override AutomationPeer OnCreateAutomationPeer()
        {
            return new TestControlAutomationPeer(this);
        }
    }

    public sealed class TestControlAutomationPeer : FrameworkElementAutomationPeer
    {
        public TestControlAutomationPeer(TestControl owner) : base(owner){}
        protected override AutomationControlType GetAutomationControlTypeCore()
        {
            return AutomationControlType.Custom;
        }
    }

    [TopLevelTestPage(Name = "Expander")]
    public sealed partial class ExpanderPage : TestPage
    {
        public ExpanderPage()
        {
            this.InitializeComponent();
            var customControlPeer = FrameworkElementAutomationPeer.FromElement(CustomControl);
            var buttonPeer= FrameworkElementAutomationPeer.FromElement(Button1);

            buttonPeer.EventsSource = customControlPeer;
        }
    }
}

Expected behavior

Screenshots

Version Info

NuGet package version:

Windows app type:

UWP Win32
Windows 10 version Saw the problem?
Insider Build (xxxxx)
May 2020 Update (19041)
November 2019 Update (18363)
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop
Xbox
Surface Hub
IoT

Additional context

@ejserna ejserna added the area-TestInfrastructure Issue in the test infrastructure (e.g. in Helix scripts) label Oct 26, 2020
@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Oct 26, 2020
@ranjeshj ranjeshj added team-Controls Issue for the Controls team help wanted Issue ideal for external contributors and removed needs-triage Issue needs to be triaged by the area owners labels Oct 26, 2020
@ranjeshj
Copy link
Contributor

@ejserna Is this an issue with the test code in WinUI ?

@ejserna
Copy link
Contributor Author

ejserna commented Oct 27, 2020

@ranjeshj yes, this is an issue in the test infrastructure, in FindElement.cs.

@marcelwgn
Copy link
Collaborator

I would like to look into this.

@marcelwgn
Copy link
Collaborator

It seems that this is not an issue with the test infra, but rather the underlying framework/library that provides us with the UIObject objects. In the scenario described by @ejserna , the list of descendants seems to be infinite, at some point it keeps containing the same element over and over again. So the only efficient solution I can think of is save the previous element and break the for loop if the previous element is equal to the current item, does that sound reasonable as a workaround?

@ejserna
Copy link
Contributor Author

ejserna commented Oct 28, 2020

@chingucoding I think that's a good workaround, at least that's what @alexhinz and I thought would make sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-TestInfrastructure Issue in the test infrastructure (e.g. in Helix scripts) help wanted Issue ideal for external contributors team-Controls Issue for the Controls team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants