Skip to content

Conversation

@jamesmcroft
Copy link
Member

Fixes #3517

Changes have been made to introduce an AutomationPeer for the BladeView and BladeItem control to improve the ability for UI testing.

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

When using a UI Automation tree tool, it is difficult to write automated UI tests for the BladeView as the rendered tree doesn't expose the hierarchy of the UI element and children in a sensible manner.

What is the new behavior?

A BladeViewAutomationPeer and BladeItemAutomationPeer have been added which is used by their respected control implementation in order to surface more automation properties and hierarchy.

The change includes minor changes to the BladeView and BladeItem controls exposed as internal for use by the new AutomationPeer classes.

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

Before

Before

After

After

As you can see from the after screenshot, the change surfaces up the BladeView and the associated child BladeItem elements within the UI Automation tree.

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 Oct 3, 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 October 3, 2020 14:38
@ghost ghost added the bug 🐛 An unexpected issue that highlights incorrect behavior label Oct 3, 2020
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.

The PR is failing CI because it does not meet some of our formatting requirements.
BaldeItem.cs and BladeView.cs. To keep on an eye on these erros, when you build your solution look out for warnings from StyleCop many of them fallowing the patern of SAxxxx.

@ghost
Copy link

ghost commented Oct 9, 2020

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

Rosuavio
Rosuavio previously approved these changes Oct 12, 2020
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.

Looks good now. Thanks, @jamesmcroft!

@michael-hawker
Copy link
Member

@jamesmcroft similar questions here to the comments on the Carousel one #3507

@ghost ghost removed the needs attention 👋 label Nov 10, 2020
@jamesmcroft
Copy link
Member Author

@jamesmcroft similar questions here to the comments on the Carousel one #3507

I'll bring the similar changes over to this.

/// </returns>
protected override string GetNameCore()
{
int? index = this.OwnerBladeItem.ParentBladeView.GetBladeItems().ToList().IndexOf(this.OwnerBladeItem);
Copy link
Contributor

Choose a reason for hiding this comment

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

You should probably add 1 to the index so the blades will be named "blade 1", "blade 2",.. instead of "blade 0", "blade 1",... This will be more "natural" for the users.

@Rosuavio Rosuavio dismissed their stale review November 12, 2020 19:08

@vgromfeld 's review points out some imporant issues that need addressing.

@michael-hawker
Copy link
Member

Also unit tests for this one too :) reference sample

}

if (this.OwnerBladeItem != null && !string.IsNullOrEmpty(this.OwnerBladeItem.Name))
TextBlock textBlock = this.OwnerBladeItem.FindDescendant<TextBlock>();
Copy link
Member

@michael-hawker michael-hawker Dec 3, 2020

Choose a reason for hiding this comment

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

@jamesmcroft the BladeItem.Header should be the 'Title' of the Blade, do we want to try and explicitly convert that to a string as a first step?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorted! Apologies for the delay on sorting this out.

@michael-hawker
Copy link
Member

@jamesmcroft think there's just the small comment I left and then this is good, eh?

@jamesmcroft
Copy link
Member Author

@michael-hawker ah yep, this has been on my radar. I'll get this sorted!

@jamesmcroft
Copy link
Member Author

@michael-hawker just an update on this, sorted out the comments above. Apologies for not notifying you earlier

@michael-hawker michael-hawker merged commit 8ccfaff into master Dec 15, 2020
@delete-merged-branch delete-merged-branch bot deleted the jamesmcroft/3517-bladeview-automation branch December 15, 2020 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐛 An unexpected issue that highlights incorrect behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BladeView isn't exposed correctly in UI Automation tree

4 participants