add automation name for history and memory list item (#1628)
* add automation name for history and memory list item * fix UI tests Co-authored-by: Yiyi Zhang <Yiyi.Zhang@microsoft.com>
This commit is contained in:
parent
8ebeaa6356
commit
d54403c578
@ -4,6 +4,7 @@
|
||||
xmlns:automation="using:CalculatorApp.ViewModel.Common.Automation"
|
||||
xmlns:converters="using:CalculatorApp.Converters"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="using:CalculatorApp"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:model="using:CalculatorApp.ViewModel"
|
||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||
@ -56,14 +57,14 @@
|
||||
</MenuFlyout>
|
||||
|
||||
<DataTemplate x:Key="HistoryItemTemplate" x:DataType="model:HistoryItemViewModel">
|
||||
<muxc:SwipeControl RightItems="{StaticResource HistorySwipeItems}">
|
||||
<muxc:SwipeControl AutomationProperties.Name="{x:Bind local:HistoryList.GetHistoryItemAutomationName(AccExpression, AccResult)}" RightItems="{StaticResource HistorySwipeItems}">
|
||||
<StackPanel Margin="0,6,16,6" Background="Transparent">
|
||||
<TextBlock x:Name="ExprTextBlock"
|
||||
Margin="0,0,0,4"
|
||||
HorizontalAlignment="Right"
|
||||
Style="{ThemeResource BodyTextBlockMediumStyle}"
|
||||
AutomationProperties.AccessibilityView="Raw"
|
||||
AutomationProperties.AutomationId="HistoryItemExpression"
|
||||
AutomationProperties.Name="{x:Bind AccExpression}"
|
||||
IsTextSelectionEnabled="True"
|
||||
Text="{x:Bind Expression}"
|
||||
TextAlignment="Right"
|
||||
@ -71,8 +72,8 @@
|
||||
<TextBlock x:Name="ResultTextBlock"
|
||||
HorizontalAlignment="Right"
|
||||
Style="{ThemeResource SubtitleTextBlockStyle}"
|
||||
AutomationProperties.AccessibilityView="Raw"
|
||||
AutomationProperties.AutomationId="HistoryItemValue"
|
||||
AutomationProperties.Name="{x:Bind AccResult}"
|
||||
IsTextSelectionEnabled="True"
|
||||
Text="{x:Bind Result}"
|
||||
TextAlignment="Right"
|
||||
|
@ -43,6 +43,11 @@ public Windows.UI.Xaml.GridLength RowHeight
|
||||
public static readonly DependencyProperty RowHeightProperty =
|
||||
DependencyProperty.Register(nameof(RowHeight), typeof(Windows.UI.Xaml.GridLength), typeof(HistoryList), new PropertyMetadata(default(Windows.UI.Xaml.GridLength)));
|
||||
|
||||
public static string GetHistoryItemAutomationName(string accExpression, string accResult)
|
||||
{
|
||||
return $"{accExpression} {accResult}";
|
||||
}
|
||||
|
||||
private void ListView_ItemClick(object sender, ItemClickEventArgs e)
|
||||
{
|
||||
HistoryViewModel historyVM = (DataContext as HistoryViewModel);
|
||||
|
@ -1,4 +1,4 @@
|
||||
<UserControl x:Class="CalculatorApp.Memory"
|
||||
<UserControl x:Class="CalculatorApp.Memory"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:common="using:CalculatorApp.Common"
|
||||
@ -36,7 +36,7 @@
|
||||
</MenuFlyout>
|
||||
|
||||
<DataTemplate x:Key="MemoryItemTemplate" x:DataType="model:MemoryItemViewModel">
|
||||
<local:MemoryListItem Model="{x:Bind Mode=OneWay}"/>
|
||||
<local:MemoryListItem AutomationProperties.Name="{x:Bind Value, Mode=OneWay}" Model="{x:Bind Mode=OneWay}"/>
|
||||
</DataTemplate>
|
||||
<Style x:Key="MemoryItemContainerStyle"
|
||||
BasedOn="{StaticResource ConditionalHistoryMemoryItemContainerStyle}"
|
||||
|
@ -1,4 +1,4 @@
|
||||
<UserControl x:Class="CalculatorApp.MemoryListItem"
|
||||
<UserControl x:Class="CalculatorApp.MemoryListItem"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
@ -52,6 +52,7 @@
|
||||
<TextBlock Margin="0,4,20,0"
|
||||
HorizontalAlignment="Right"
|
||||
Style="{ThemeResource SubtitleTextBlockStyle}"
|
||||
AutomationProperties.AccessibilityView="Raw"
|
||||
AutomationProperties.AutomationId="MemoryItemValue"
|
||||
FlowDirection="LeftToRight"
|
||||
IsTextSelectionEnabled="True"
|
||||
|
@ -19,11 +19,13 @@ public HistoryItem(AppiumWebElement item)
|
||||
|
||||
public string GetValue()
|
||||
{
|
||||
return Item.FindElementByAccessibilityId("HistoryItemValue")?.Text;
|
||||
var equalSignIndex = Item.Text.IndexOf("=");
|
||||
return Item.Text.Substring(equalSignIndex + 1).Trim();
|
||||
}
|
||||
public string GetExpression()
|
||||
{
|
||||
return Item.FindElementByAccessibilityId("HistoryItemExpression")?.Text;
|
||||
var equalSignIndex = Item.Text.IndexOf("=");
|
||||
return Item.Text.Substring(0, equalSignIndex + 1).Trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public MemoryItem(AppiumWebElement item)
|
||||
|
||||
public string GetValue()
|
||||
{
|
||||
return Item.FindElementByAccessibilityId("MemoryItemValue")?.Text;
|
||||
return Item.Text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -88,9 +88,9 @@ public void StandardHistory_Panel()
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
|
||||
var historyItems = page.HistoryPanel.GetAllHistoryListViewItems();
|
||||
Assert.IsTrue(historyItems[0].GetValue().Equals("-1", StringComparison.InvariantCultureIgnoreCase));
|
||||
Assert.IsTrue(historyItems[0].GetExpression().Equals("2 - 3 =", StringComparison.InvariantCultureIgnoreCase));
|
||||
Assert.IsTrue(historyItems[1].GetValue().Equals("-5.6", StringComparison.InvariantCultureIgnoreCase));
|
||||
Assert.IsTrue(historyItems[0].GetValue().Equals("Minus (1", StringComparison.InvariantCultureIgnoreCase));
|
||||
Assert.IsTrue(historyItems[0].GetExpression().Equals("2 Minus ( 3=", StringComparison.InvariantCultureIgnoreCase));
|
||||
Assert.IsTrue(historyItems[1].GetValue().Equals("Minus (5.6", StringComparison.InvariantCultureIgnoreCase));
|
||||
Assert.IsTrue(historyItems[1].GetExpression().Equals("-3 + -2.6=", StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
Assert.AreEqual("-1", page.CalculatorResults.GetCalculatorResultText());
|
||||
|
Loading…
Reference in New Issue
Block a user