Revert PR#1964 (#2032)

* Revert PR#1964

* Replace keyboard input of decimal with mouse input in UI test

* Update UI test
This commit is contained in:
hanzhang54 2023-08-01 19:44:49 +08:00 committed by GitHub
commit fbc6598770
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 216 additions and 122 deletions

View file

@ -3,7 +3,6 @@
<packageSources> <packageSources>
<clear /> <clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" /> <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="Toolkit Labs" value="https://pkgs.dev.azure.com/dotnet/CommunityToolkit/_packaging/CommunityToolkit-Labs/nuget/v3/index.json" />
</packageSources> </packageSources>
<disabledPackageSources> <disabledPackageSources>
<clear /> <clear />

View file

@ -793,9 +793,6 @@
</Page> </Page>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="CommunityToolkit.Labs.Uwp.SettingsControls">
<Version>0.0.16</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform"> <PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.2.14</Version> <Version>6.2.14</Version>
</PackageReference> </PackageReference>

View file

@ -4714,11 +4714,11 @@
<value>Appearance</value> <value>Appearance</value>
<comment>Subtitle of appearance setting on Settings page</comment> <comment>Subtitle of appearance setting on Settings page</comment>
</data> </data>
<data name="AppThemeExpander.Header" xml:space="preserve"> <data name="SettingsAppThemeTitle.Text" xml:space="preserve">
<value>App theme</value> <value>App theme</value>
<comment>Title of App theme expander</comment> <comment>Title of App theme expander</comment>
</data> </data>
<data name="AppThemeExpander.Description" xml:space="preserve"> <data name="SettingsAppThemeDescription.Text" xml:space="preserve">
<value>Select which app theme to display</value> <value>Select which app theme to display</value>
<comment>Description of App theme expander</comment> <comment>Description of App theme expander</comment>
</data> </data>

View file

@ -3,7 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:automation="using:CalculatorApp.ViewModel.Common.Automation" xmlns:automation="using:CalculatorApp.ViewModel.Common.Automation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:labs="using:CommunityToolkit.Labs.WinUI"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls" xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:utils="using:CalculatorApp.Utils" xmlns:utils="using:CalculatorApp.Utils"
@ -15,7 +14,7 @@
<ResourceDictionary> <ResourceDictionary>
<Style x:Key="SettingsContentScrollViewStyle" TargetType="ScrollViewer"> <Style x:Key="SettingsContentScrollViewStyle" TargetType="ScrollViewer">
<Setter Property="HorizontalAlignment" Value="Stretch"/> <Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Stretch"/> <Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="HorizontalScrollBarVisibility" Value="Disabled"/> <Setter Property="HorizontalScrollBarVisibility" Value="Disabled"/>
<Setter Property="HorizontalScrollMode" Value="Disabled"/> <Setter Property="HorizontalScrollMode" Value="Disabled"/>
<Setter Property="IsHorizontalRailEnabled" Value="False"/> <Setter Property="IsHorizontalRailEnabled" Value="False"/>
@ -32,19 +31,11 @@
<Setter Property="TextWrapping" Value="Wrap"/> <Setter Property="TextWrapping" Value="Wrap"/>
</Style> </Style>
<Style x:Key="SettingsCategoryTitleTextBlockStyle"
BasedOn="{StaticResource BodyStrongTextBlockStyle}"
TargetType="TextBlock">
<Setter Property="Margin" Value="0,29,0,5"/>
</Style>
<automation:NarratorNotifier x:Name="NarratorNotifier"/> <automation:NarratorNotifier x:Name="NarratorNotifier"/>
<!-- Override default hyperlink button background color --> <!-- Override default hyperlink button background color -->
<StaticResource x:Key="HyperlinkButtonBackgroundPointerOver" ResourceKey="SubtleFillColorTransparentBrush"/> <StaticResource x:Key="HyperlinkButtonBackgroundPointerOver" ResourceKey="SubtleFillColorTransparentBrush"/>
<StaticResource x:Key="HyperlinkButtonBackgroundPressed" ResourceKey="SubtleFillColorTransparentBrush"/> <StaticResource x:Key="HyperlinkButtonBackgroundPressed" ResourceKey="SubtleFillColorTransparentBrush"/>
<x:Double x:Key="SettingsCardSpacing">3</x:Double>
</ResourceDictionary> </ResourceDictionary>
</UserControl.Resources> </UserControl.Resources>
@ -53,6 +44,42 @@
<RowDefinition Height="{x:Bind TitleBarHeight, Mode=OneWay}"/> <RowDefinition Height="{x:Bind TitleBarHeight, Mode=OneWay}"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="LayoutVisualStates">
<VisualState x:Name="LargeWideView">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowHeight="0" MinWindowWidth="690"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="ColumnAbout.Width" Value="324"/>
<Setter Target="AboutContentGrid.(Grid.Row)" Value="0"/>
<Setter Target="AboutContentGrid.(Grid.RowSpan)" Value="3"/>
<Setter Target="AboutContentGrid.(Grid.Column)" Value="1"/>
<Setter Target="AboutGroupTitle.Margin" Value="0"/>
<Setter Target="AboutContentGrid.Margin" Value="60,0,0,0"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="SideVisible">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowHeight="0" MinWindowWidth="632"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="ColumnMain.Width" Value="*"/>
<Setter Target="ColumnAbout.Width" Value="*"/>
<Setter Target="AboutContentGrid.(Grid.Row)" Value="0"/>
<Setter Target="AboutContentGrid.(Grid.RowSpan)" Value="3"/>
<Setter Target="AboutContentGrid.(Grid.Column)" Value="1"/>
<Setter Target="AboutGroupTitle.Margin" Value="0"/>
<Setter Target="AboutContentGrid.Margin" Value="60,0,0,0"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="DefaultLayout">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowHeight="0" MinWindowWidth="0"/>
</VisualState.StateTriggers>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Button x:Name="BackButton" <Button x:Name="BackButton"
Grid.Row="0" Grid.Row="0"
@ -77,28 +104,62 @@
</Grid> </Grid>
<ScrollViewer Grid.Row="1" <ScrollViewer Grid.Row="1"
Margin="0,30,0,0" Margin="0,60,0,0"
Padding="24,0,24,16" Padding="24,0,24,16"
Style="{StaticResource SettingsContentScrollViewStyle}"> Style="{StaticResource SettingsContentScrollViewStyle}">
<Grid x:Name="ContentGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="ColumnMain" Width="*"/>
<ColumnDefinition x:Name="ColumnAbout" Width="0"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" Spacing="{StaticResource SettingsCardSpacing}"> <Grid.RowDefinitions>
<StackPanel.ChildrenTransitions> <RowDefinition x:Name="AppearanceTitleRow" Height="Auto"/>
<EntranceThemeTransition FromVerticalOffset="50" IsStaggeringEnabled="True"/> <RowDefinition x:Name="AppearanceExpanderRow" Height="Auto"/>
<RepositionThemeTransition IsStaggeringEnabled="False"/> <RowDefinition x:Name="AboutTitleContentRow" Height="*"/>
</StackPanel.ChildrenTransitions> </Grid.RowDefinitions>
<TextBlock Style="{StaticResource SettingsCategoryTitleTextBlockStyle}"
<TextBlock Style="{StaticResource BodyStrongTextBlockStyle}"
AutomationProperties.HeadingLevel="Level1" AutomationProperties.HeadingLevel="Level1"
Text="{utils:ResourceString Name=SettingsAppearance/Text}"/> Text="{utils:ResourceString Name=SettingsAppearance/Text}"/>
<labs:SettingsExpander x:Name="AppThemeExpander"
Description="Select which app theme to display" <muxc:Expander x:Name="AppThemeExpander"
Header="App theme"> Grid.Row="1"
<labs:SettingsExpander.HeaderIcon> Margin="0,8,0,0"
<FontIcon Glyph="&#xE790;"/> HorizontalAlignment="Stretch"
</labs:SettingsExpander.HeaderIcon> VerticalAlignment="Top"
<labs:SettingsExpander.Items> HorizontalContentAlignment="Left"
<labs:SettingsCard ContentAlignment="Left"> AutomationProperties.Name="{utils:ResourceString Name=AppThemeExpander/[using:Windows.UI.Xaml.Automation]AutomationProperties/Name}"
ExpandDirection="Down"
IsExpanded="False">
<muxc:Expander.Header>
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<FontIcon Margin="0,0,12,0"
VerticalAlignment="Center"
Foreground="{ThemeResource TextFillColorPrimaryBrush}"
FontFamily="{ThemeResource CalculatorFontFamily}"
FontSize="16"
Glyph="&#xE790;"/>
<StackPanel Grid.Column="1"
Margin="0,12"
Orientation="Vertical">
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{utils:ResourceString Name=SettingsAppThemeTitle/Text}"/>
<TextBlock Style="{StaticResource CaptionTextBlockStyle}"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Text="{utils:ResourceString Name=SettingsAppThemeDescription/Text}"
TextWrapping="WrapWholeWords"/>
</StackPanel>
</Grid>
</muxc:Expander.Header>
<muxc:Expander.Content>
<muxc:RadioButtons x:Name="ThemeRadioButtons" <muxc:RadioButtons x:Name="ThemeRadioButtons"
Margin="0,-8,0,0" Margin="32,0,0,0"
SelectionChanged="OnThemeSelectionChanged"> SelectionChanged="OnThemeSelectionChanged">
<RadioButton x:Name="LightThemeRadioButton" <RadioButton x:Name="LightThemeRadioButton"
Content="{utils:ResourceString Name=LightThemeRadioButton/Content}" Content="{utils:ResourceString Name=LightThemeRadioButton/Content}"
@ -110,28 +171,34 @@
Content="{utils:ResourceString Name=SystemThemeRadioButton/Content}" Content="{utils:ResourceString Name=SystemThemeRadioButton/Content}"
Tag="Default"/> Tag="Default"/>
</muxc:RadioButtons> </muxc:RadioButtons>
</labs:SettingsCard> </muxc:Expander.Content>
</labs:SettingsExpander.Items> </muxc:Expander>
</labs:SettingsExpander>
<Grid x:Name="AboutContentGrid" Grid.Row="2">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock x:Name="AboutGroupTitle" <TextBlock x:Name="AboutGroupTitle"
Style="{ThemeResource SettingsCategoryTitleTextBlockStyle}" Margin="0,20,0,0"
Style="{ThemeResource BodyStrongTextBlockStyle}"
AutomationProperties.HeadingLevel="Level1" AutomationProperties.HeadingLevel="Level1"
Text="{utils:ResourceString Name=AboutGroupTitle/Text}"/> Text="{utils:ResourceString Name=AboutGroupTitle/Text}"/>
<labs:SettingsExpander x:Name="AboutExpander"> <StackPanel Grid.Row="1"
<labs:SettingsExpander.HeaderIcon> Margin="0,8,0,0"
<BitmapIcon AutomationProperties.AccessibilityView="Raw" UriSource="ms-appx:///Assets/CalculatorAppList.png"/> Orientation="Vertical">
</labs:SettingsExpander.HeaderIcon> <RichTextBlock x:Name="AboutContentBody" Style="{StaticResource SettingsRichTextBlockStyle}">
<TextBlock x:Name="AboutBuildVersion" <Paragraph>
Foreground="{ThemeResource TextFillColorSecondaryBrush}" <Run x:Name="AboutBuildVersion"/>
IsTextSelectionEnabled="True"/> <LineBreak/>
<labs:SettingsExpander.Items> <Run x:Name="AboutControlCopyrightRun"/>
<labs:SettingsCard ContentAlignment="Left"> </Paragraph>
<StackPanel Margin="0,4,0,6" </RichTextBlock>
Orientation="Vertical"
Spacing="12">
<HyperlinkButton x:Name="AboutEULA" <HyperlinkButton x:Name="AboutEULA"
Margin="0,16,0,0"
Padding="0" Padding="0"
NavigateUri="https://go.microsoft.com/fwlink/?LinkID=529064" NavigateUri="https://go.microsoft.com/fwlink/?LinkID=529064"
ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?LinkID=529064"> ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?LinkID=529064">
@ -141,6 +208,7 @@
</HyperlinkButton> </HyperlinkButton>
<HyperlinkButton x:Name="AboutControlServicesAgreement" <HyperlinkButton x:Name="AboutControlServicesAgreement"
Margin="0,16,0,0"
Padding="0" Padding="0"
NavigateUri="https://go.microsoft.com/fwlink/?LinkID=822631" NavigateUri="https://go.microsoft.com/fwlink/?LinkID=822631"
ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?LinkID=822631"> ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?LinkID=822631">
@ -150,6 +218,7 @@
</HyperlinkButton> </HyperlinkButton>
<HyperlinkButton x:Name="AboutControlPrivacyStatement" <HyperlinkButton x:Name="AboutControlPrivacyStatement"
Margin="0,16,0,0"
Padding="0" Padding="0"
NavigateUri="https://go.microsoft.com/fwlink/?LinkID=521839" NavigateUri="https://go.microsoft.com/fwlink/?LinkID=521839"
ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?LinkID=521839"> ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?LinkID=521839">
@ -157,40 +226,38 @@
Text="{utils:ResourceString Name=AboutControlPrivacyStatement/Text}" Text="{utils:ResourceString Name=AboutControlPrivacyStatement/Text}"
TextWrapping="Wrap"/> TextWrapping="Wrap"/>
</HyperlinkButton> </HyperlinkButton>
</StackPanel>
</labs:SettingsCard>
</labs:SettingsExpander.Items>
</labs:SettingsExpander>
<HyperlinkButton x:Name="FeedbackButton" <Button x:Name="FeedbackButton"
MinWidth="120" MinWidth="120"
Margin="-12,4,0,0" Margin="0,24,0,0"
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Top" VerticalAlignment="Top"
FontSize="{StaticResource BodyFontSize}" FontSize="{StaticResource BodyFontSize}"
Click="FeedbackButton_Click" Click="FeedbackButton_Click"
Content="{utils:ResourceString Name=FeedbackButton/Content}"/> Content="{utils:ResourceString Name=FeedbackButton/Content}"/>
</StackPanel>
<RichTextBlock x:Name="AboutContribute" <RichTextBlock x:Name="AboutContribute"
Grid.Row="2" Grid.Row="2"
Margin="1,9,0,0" Margin="0,16,0,0"
Style="{StaticResource SettingsRichTextBlockStyle}"> Style="{StaticResource SettingsRichTextBlockStyle}">
<Paragraph> <Paragraph>
<!-- <!--
Note: don't put Hyperlink element start to the next line Note: don't put Hyperlink element start to the next line
otherwise unexpected whitespace will be add. otherwise unexpected whitespace will be add.
--> -->
<Run x:Name="ContributeRunBeforeLink"/><Hyperlink Foreground="{x:Bind AboutEULA.Foreground, Mode=OneWay}" <Run x:Name="ContributeRunBeforeLink"/>
<Hyperlink Foreground="{x:Bind AboutEULA.Foreground, Mode=OneWay}"
NavigateUri="https://go.microsoft.com/fwlink/?linkid=2099939" NavigateUri="https://go.microsoft.com/fwlink/?linkid=2099939"
TextDecorations="None" TextDecorations="None"
ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?linkid=2099939" ToolTipService.ToolTip="https://go.microsoft.com/fwlink/?linkid=2099939"
UnderlineStyle="None"> UnderlineStyle="None">
<Run x:Name="ContributeRunLink"/> <Run x:Name="ContributeRunLink"/>
</Hyperlink><Run x:Name="ContributeRunAfterLink"/> </Hyperlink>
<Run x:Name="ContributeRunAfterLink"/>
</Paragraph> </Paragraph>
</RichTextBlock> </RichTextBlock>
</Grid>
</StackPanel> </Grid>
</ScrollViewer> </ScrollViewer>
</Grid> </Grid>
</UserControl> </UserControl>

View file

@ -45,7 +45,7 @@ namespace CalculatorApp
var copyrightText = var copyrightText =
LocalizationStringUtil.GetLocalizedString(resourceLoader.GetResourceString("AboutControlCopyright"), BUILD_YEAR); LocalizationStringUtil.GetLocalizedString(resourceLoader.GetResourceString("AboutControlCopyright"), BUILD_YEAR);
AboutExpander.Description = copyrightText; AboutControlCopyrightRun.Text = copyrightText;
InitializeContributeTextBlock(); InitializeContributeTextBlock();
} }
@ -108,8 +108,8 @@ namespace CalculatorApp
private void SetVersionString() private void SetVersionString()
{ {
PackageVersion version = Package.Current.Id.Version; PackageVersion version = Package.Current.Id.Version;
AboutExpander.Header = AppResourceProvider.GetInstance().GetResourceString("AppName"); string appName = AppResourceProvider.GetInstance().GetResourceString("AppName");
AboutBuildVersion.Text = version.Major + "." + version.Minor + "." + version.Build + "." + version.Revision; AboutBuildVersion.Text = appName + " " + version.Major + "." + version.Minor + "." + version.Build + "." + version.Revision;
} }
private void InitializeContributeTextBlock() private void InitializeContributeTextBlock()

View file

@ -316,8 +316,11 @@ namespace CalculatorUITests
Assert.AreEqual("square (9)", page.CalculatorResults.GetCalculatorExpressionText()); //verifies squared hotkey Assert.AreEqual("square (9)", page.CalculatorResults.GetCalculatorExpressionText()); //verifies squared hotkey
} }
// Ignore this test and add a new test KeyboardInput_PercentSquareRootBackspaceNegateOneZero below
// to avoid the issue of decimal keyboard input
[TestMethod] [TestMethod]
[Priority(1)] [Priority(1)]
[Ignore]
public void KeyboardInput_PercentSquareRootBackspaceDecimalNegateOneZero() public void KeyboardInput_PercentSquareRootBackspaceDecimalNegateOneZero()
{ {
//Verifies the %, square root, backspace, decimal, negate, 1, and 0 button //Verifies the %, square root, backspace, decimal, negate, 1, and 0 button
@ -345,6 +348,34 @@ namespace CalculatorUITests
Assert.AreEqual("9.9", page.CalculatorResults.GetCalculatorResultText()); //verifies calculation with decimal point and negative number Assert.AreEqual("9.9", page.CalculatorResults.GetCalculatorResultText()); //verifies calculation with decimal point and negative number
} }
[TestMethod]
[Priority(1)]
public void KeyboardInput_PercentSquareRootBackspaceNegateOneZero()
{
//Verifies the %, square root, backspace, negate, 1, and 0 button
CalculatorApp.EnsureCalculatorHasFocus();
CalculatorApp.Window.SendKeys("100");
CalculatorApp.Window.SendKeys(Keys.Backspace);
Assert.AreEqual("10", page.CalculatorResults.GetCalculatorResultText()); // verifies using the 1 key, the 0 key, and the backspace key
CalculatorApp.Window.SendKeys(Keys.Add);
CalculatorApp.EnsureCalculatorHasFocus();
CalculatorApp.Window.SendKeys(Keys.Shift + "5" + Keys.Shift);
Assert.AreEqual("1", page.CalculatorResults.GetCalculatorResultText()); //verifies percent calculation
Assert.AreEqual("10 + 1", page.CalculatorResults.GetCalculatorExpressionText()); //verifies percent hotkey
CalculatorApp.Window.SendKeys(Keys.Shift);
CalculatorApp.Window.SendKeys(Keys.Shift + "5" + Keys.Shift);
CalculatorApp.Window.SendKeys(Keys.Shift);
CalculatorApp.Window.SendKeys(Keys.Shift + "2" + Keys.Shift);
Assert.AreEqual("0.3162277660168379", page.CalculatorResults.GetCalculatorResultText()); //verifies square root calculation
Assert.AreEqual("10 + √(0.1)", page.CalculatorResults.GetCalculatorExpressionText()); //verifies 2√x hotkey
CalculatorApp.Window.SendKeys("1");
CalculatorApp.Window.SendKeys(Keys.Shift + "5" + Keys.Shift);
CalculatorApp.Window.SendKeys(Keys.F9);
Assert.AreEqual("-0.1", page.CalculatorResults.GetCalculatorResultText()); //verifies negate hotkey
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("9.9", page.CalculatorResults.GetCalculatorResultText()); //verifies calculation with decimal point and negative number
}
[TestMethod] [TestMethod]
[Priority(1)] [Priority(1)]
public void KeyboardInput_MemoryHotkeys() public void KeyboardInput_MemoryHotkeys()