This repository was archived by the owner on Feb 25, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
🧪 Add UI Tests for Gridsplitter #4090
Merged
michael-hawker
merged 11 commits into
CommunityToolkit:main
from
michael-hawker:user/mhawker/gridsplitter-tests
Jul 19, 2021
Merged
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
602a24b
XAML Styler GridSplitter Control XAML (no changes)
michael-hawker 9a14546
Add Custom Command Function to AppService Pipe
michael-hawker 9945868
Add Vertical Splitter tests to compliment bound tests for horizontal …
michael-hawker da0abbf
Add extra log messages to help debug UI test in CI
michael-hawker caf0d7f
Add more diagnostics output on Service Connection Closed
michael-hawker aa1c557
Update UITests/UITests.App/App.AppService.xaml.cs
Rosuavio dfe88cf
Add extendedBackgroundTaskTime capability to try and prevent AppServi…
michael-hawker c6f8fee
Address PR comments
michael-hawker 90ae117
Merge branch 'main' into user/mhawker/gridsplitter-tests
Rosuavio 9799606
Merge branch 'main' into user/mhawker/gridsplitter-tests
Rosuavio 9a338f7
Merge branch 'main' into user/mhawker/gridsplitter-tests
michael-hawker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
UITests/UITests.App/Commands/VisualTreeHelperCommands.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| // 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. | ||
|
|
||
| using System; | ||
| using System.Linq; | ||
| using System.Reflection; | ||
| using System.Text.Json; | ||
| using System.Text.Json.Serialization; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.Toolkit; | ||
| using Microsoft.Toolkit.Uwp; | ||
| using Microsoft.Toolkit.Uwp.UI; | ||
| using UITests.App.Pages; | ||
| using Windows.Foundation.Collections; | ||
| using Windows.System; | ||
| using Windows.UI.Xaml; | ||
| using Windows.UI.Xaml.Controls; | ||
|
|
||
| namespace UITests.App.Commands | ||
| { | ||
| public static class VisualTreeHelperCommands | ||
| { | ||
| private static DispatcherQueue Queue { get; set; } | ||
|
|
||
| private static JsonSerializerOptions SerializerOptions { get; } = new JsonSerializerOptions(JsonSerializerDefaults.General) | ||
| { | ||
| NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals, | ||
| }; | ||
|
|
||
| public static void Initialize(DispatcherQueue uiThread) | ||
| { | ||
| Queue = uiThread; | ||
|
|
||
| (App.Current as App).RegisterCustomCommand("VisualTreeHelper.FindElementProperty", FindElementProperty); | ||
| } | ||
|
|
||
| public static async Task<ValueSet> FindElementProperty(ValueSet arguments) | ||
| { | ||
| ValueSet results = new ValueSet(); | ||
|
|
||
| if (Queue == null) | ||
| { | ||
| Log.Error("VisualTreeHelper - Missing UI DispatcherQueue"); | ||
| return null; | ||
| } | ||
|
|
||
| await Queue.EnqueueAsync(() => | ||
| { | ||
| // Dispatch? | ||
| var content = Window.Current.Content as Frame; | ||
|
|
||
| if (content == null) | ||
| { | ||
| Log.Error("VisualTreeHelper.FindElementProperty - Window has no content."); | ||
| return; | ||
| } | ||
|
|
||
| if (arguments.TryGetValue("ElementName", out object value) && value is string name && | ||
| arguments.TryGetValue("Property", out object value2) && value2 is string propertyName) | ||
| { | ||
| Log.Comment("VisualTreeHelper.FindElementProperty('{0}', '{1}')", name, propertyName); | ||
|
|
||
| // 1. Find Element in Visual Tree | ||
| var element = content.FindDescendant(name); | ||
|
|
||
| try | ||
| { | ||
| Log.Comment("VisualTreeHelper.FindElementProperty - Found Element? {0}", element != null); | ||
|
|
||
| var typeinfo = element.GetType().GetTypeInfo(); | ||
|
|
||
| Log.Comment("Element Type: {0}", typeinfo.FullName); | ||
|
|
||
| var prop = element.GetType().GetTypeInfo().GetProperty(propertyName); | ||
|
|
||
| if (prop == null) | ||
| { | ||
| Log.Error("VisualTreeHelper.FindElementProperty - Couldn't find Property named {0} on type {1}", propertyName, typeinfo.FullName); | ||
| return; | ||
| } | ||
|
|
||
| // 2. Get the property using reflection | ||
| var propValue = prop.GetValue(element); | ||
|
|
||
| // 3. Serialize and return the result | ||
| results.Add("Result", JsonSerializer.Serialize(propValue, SerializerOptions)); | ||
| } | ||
| catch (Exception e) | ||
| { | ||
| Log.Error("Error {0}", e.Message); | ||
| Log.Error("StackTrace:\n{0}", e.StackTrace); | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| if (results.Count > 0) | ||
| { | ||
| return results; | ||
| } | ||
|
|
||
| return null; // Failure | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.