Light Switch: Updating UI tests (#42225)

Updating UI tests to match new UI
This commit is contained in:
Jaylyn Barbee
2025-10-07 15:20:49 -04:00
committed by GitHub
parent e04e6a11d1
commit 3e213165a8
3 changed files with 62 additions and 13 deletions

View File

@@ -8,6 +8,7 @@ using System.Globalization;
using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Automation;
using Microsoft.UI.Xaml.Automation.Peers;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Shapes;
using Windows.Foundation;
@@ -79,6 +80,11 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
this.IsEnabledChanged += Timeline_IsEnabledChanged;
}
protected override AutomationPeer OnCreateAutomationPeer()
{
return new TimelineAutomationPeer(this);
}
private void Timeline_Loaded(object sender, RoutedEventArgs e)
{
CheckEnabledState();

View File

@@ -0,0 +1,39 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Automation;
using Microsoft.UI.Xaml.Automation.Peers;
namespace Microsoft.PowerToys.Settings.UI.Controls
{
public partial class TimelineAutomationPeer : FrameworkElementAutomationPeer
{
public TimelineAutomationPeer(Timeline owner)
: base(owner)
{
}
protected override string GetClassNameCore() => "Timeline";
protected override AutomationControlType GetAutomationControlTypeCore()
=> AutomationControlType.Custom;
protected override string GetAutomationIdCore()
{
var owner = (Timeline)Owner;
var id = AutomationProperties.GetAutomationId(owner);
return string.IsNullOrEmpty(id) ? base.GetAutomationIdCore() : id;
}
protected override string GetNameCore()
{
var owner = (Timeline)Owner;
var name = AutomationProperties.GetName(owner);
return !string.IsNullOrEmpty(name)
? name
: $"Timeline from {owner.StartTime} to {owner.EndTime}";
}
}
}