Skip to content

Conversation

@jamesmcroft
Copy link
Member

Fixes #3502

Changes have been made to introduce an AutomationPeer for the Expander control to improve the ability for UI testing this control.

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

Currently, when trying to access an Expander control by an Automation ID or other automation property, it is not possible as this is not propagated correctly.

What is the new behavior?

A ExpanderAutomationPeer has been added which is used by the Expander control in order to surface automation properties correctly.

The automation peer not only surfaces up the Automation ID but has been coded so that the toggle state of the control is also available.

Below is the before and after of the UI Automation tree.

Before

Before

After

After

As you can tell from the change, the ability to traverse the UI Automation tree is vastly improved allowing the Expander's content to be surfaced correctly instead of separate UI elements.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • Pull Request has been submitted to the documentation repository instructions. Link:
  • Sample in sample app has been added / updated (for bug fixes / features)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes

@ghost
Copy link

ghost commented Sep 26, 2020

Thanks jamesmcroft for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌

@ghost ghost requested review from Kyaa-dost, azchohfi and michael-hawker September 26, 2020 18:57
@ghost ghost added the bug 🐛 An unexpected issue that highlights incorrect behavior label Sep 26, 2020
Copy link
Member

@michael-hawker michael-hawker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @jamesmcroft can we move the peers to their own namespace like the platform does?

Thanks!

@ghost
Copy link

ghost commented Sep 29, 2020

This PR has been marked as "needs attention 👋" and awaiting a response from the team.

Copy link
Contributor

@Rosuavio Rosuavio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement 👍

@ghost
Copy link

ghost commented Oct 9, 2020

Hello @RosarioPulella!

Because this pull request has the auto merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@Rosuavio
Copy link
Contributor

Rosuavio commented Oct 9, 2020

@msftbot make sure @michael-hawker has a chance to review before you merge.

@ghost
Copy link

ghost commented Oct 9, 2020

Hello @RosarioPulella!

Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:

If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you".

@ghost ghost removed the needs attention 👋 label Oct 9, 2020
@ghost ghost merged commit fd511a4 into master Oct 28, 2020
@ghost ghost deleted the jamesmcroft/3502-expander-automation branch October 28, 2020 18:14
/// <summary>
/// Defines a framework element automation peer for the <see cref="Expander"/> control.
/// </summary>
public class ExpanderAutomationPeer : FrameworkElementAutomationPeer, IToggleProvider
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamesmcroft I missed we should have used the IExpandCollapseProvider in addition or instead of maybe? Thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me take a look, I don't see why not though. Would you want this to be inclusive of IToggleProvider or in favor of?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamesmcroft good question. I don't know if it's a problem to provide multiple interfaces, probably best to include both if possible? I know some other code will probably look for one over the other, so I imagine having both would allow it to be used by the most other code parts looking for certain types of peers. @chingucoding @ranjeshj any thoughts?

Would it make sense to add unit tests like in #3544 as well?

Copy link
Contributor

@marcelwgn marcelwgn Nov 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if it's a problem to provide multiple interfaces, probably best to include both if possible?

I would argue that having both interfaces only makes sense if you expose both patterns in GetPatternCore. So at least implement what you are providing as part of GetPatternCore. For what it's worth, the WinUI expander control only specifies the ExpandCollapsePattern, so I am inclined to say that that pattern/interface is sufficient.

Would it make sense to add unit tests like in #3544 as well?

Yes, I think testing that peer and the exposed functions of the peer should be done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can have multiple patterns supported for sure. ExpandCollapse pattern made sense for Expander.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamesmcroft if you've got some cycles still to continue helping with this, mind submitting a follow-on PR with the tweaks? Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michael-hawker I'll get another PR open for these changes 😄

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accessibility ♿ auto merge ⚡ bug 🐛 An unexpected issue that highlights incorrect behavior Completed 🔥

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expander control doesn't project Automation ID correctly in UI Automation tree

6 participants