mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 06:13:14 -07:00
Merge 8fb959e296
into 5b21e4c58b
This commit is contained in:
commit
63e51d0f5e
12 changed files with 140 additions and 32 deletions
|
@ -822,6 +822,11 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
|
||||||
DisplayNum();
|
DisplayNum();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case IDC_ENG:
|
||||||
|
m_nFE = NumberFormat::Engineering;
|
||||||
|
DisplayNum();
|
||||||
|
break;
|
||||||
|
|
||||||
case IDC_EXP:
|
case IDC_EXP:
|
||||||
if (m_bRecord && !m_fIntegerMode && m_input.TryBeginExponent())
|
if (m_bRecord && !m_fIntegerMode && m_input.TryBeginExponent())
|
||||||
{
|
{
|
||||||
|
|
|
@ -66,6 +66,7 @@ namespace CalculationManager
|
||||||
CommandGRAD = 323,
|
CommandGRAD = 323,
|
||||||
CommandDegrees = 324,
|
CommandDegrees = 324,
|
||||||
CommandHYP = 325,
|
CommandHYP = 325,
|
||||||
|
CommandENG = 326,
|
||||||
|
|
||||||
CommandNULL = 0,
|
CommandNULL = 0,
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#define IDM_RAD 322
|
#define IDM_RAD 322
|
||||||
#define IDM_GRAD 323
|
#define IDM_GRAD 323
|
||||||
#define IDM_DEGREES 324
|
#define IDM_DEGREES 324
|
||||||
|
#define IDC_ENG 326
|
||||||
|
|
||||||
#define IDC_HEX IDM_HEX
|
#define IDC_HEX IDM_HEX
|
||||||
#define IDC_DEC IDM_DEC
|
#define IDC_DEC IDM_DEC
|
||||||
|
|
|
@ -1171,7 +1171,7 @@ wstring NumberToString(_Inout_ PNUMBER& pnum, NumberFormat format, uint32_t radi
|
||||||
{
|
{
|
||||||
if (format == NumberFormat::Engineering)
|
if (format == NumberFormat::Engineering)
|
||||||
{
|
{
|
||||||
exponent = (eout % 3);
|
exponent = (3 + (eout % 3)) % 3;
|
||||||
eout -= exponent;
|
eout -= exponent;
|
||||||
exponent++;
|
exponent++;
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ namespace CalculatorApp::ViewModel::Common
|
||||||
Radians = (int)CM::Command::CommandRAD,
|
Radians = (int)CM::Command::CommandRAD,
|
||||||
Grads = (int)CM::Command::CommandGRAD,
|
Grads = (int)CM::Command::CommandGRAD,
|
||||||
Degrees = (int)CM::Command::CommandDegrees,
|
Degrees = (int)CM::Command::CommandDegrees,
|
||||||
|
Engineering = (int)CM::Command::CommandENG,
|
||||||
OpenParenthesis = (int)CM::Command::CommandOPENP,
|
OpenParenthesis = (int)CM::Command::CommandOPENP,
|
||||||
CloseParenthesis = (int)CM::Command::CommandCLOSEP,
|
CloseParenthesis = (int)CM::Command::CommandCLOSEP,
|
||||||
Pi = (int)CM::Command::CommandPI,
|
Pi = (int)CM::Command::CommandPI,
|
||||||
|
|
|
@ -499,6 +499,12 @@ void StandardCalculatorViewModel::FtoEButtonToggled()
|
||||||
OnButtonPressed(NumbersAndOperatorsEnum::FToE);
|
OnButtonPressed(NumbersAndOperatorsEnum::FToE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StandardCalculatorViewModel::EngButton()
|
||||||
|
{
|
||||||
|
OnButtonPressed(NumbersAndOperatorsEnum::Engineering);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void StandardCalculatorViewModel::HandleUpdatedOperandData(Command cmdenum)
|
void StandardCalculatorViewModel::HandleUpdatedOperandData(Command cmdenum)
|
||||||
{
|
{
|
||||||
DisplayExpressionToken ^ displayExpressionToken = ExpressionTokens->GetAt(m_TokenPosition);
|
DisplayExpressionToken ^ displayExpressionToken = ExpressionTokens->GetAt(m_TokenPosition);
|
||||||
|
|
|
@ -267,6 +267,7 @@ namespace CalculatorApp
|
||||||
void SetOpenParenthesisCountNarratorAnnouncement();
|
void SetOpenParenthesisCountNarratorAnnouncement();
|
||||||
void SwitchAngleType(CalculatorApp::ViewModel::Common::NumbersAndOperatorsEnum num);
|
void SwitchAngleType(CalculatorApp::ViewModel::Common::NumbersAndOperatorsEnum num);
|
||||||
void FtoEButtonToggled();
|
void FtoEButtonToggled();
|
||||||
|
void EngButton();
|
||||||
|
|
||||||
void OnCopyCommand(Platform::Object ^ parameter);
|
void OnCopyCommand(Platform::Object ^ parameter);
|
||||||
void OnPasteCommand(Platform::Object ^ parameter);
|
void OnPasteCommand(Platform::Object ^ parameter);
|
||||||
|
|
|
@ -98,21 +98,32 @@
|
||||||
CommandParameter="2"
|
CommandParameter="2"
|
||||||
Content="GRAD"
|
Content="GRAD"
|
||||||
Visibility="Collapsed"/>
|
Visibility="Collapsed"/>
|
||||||
<ToggleButton x:Name="FtoeButton"
|
|
||||||
Grid.Column="1"
|
<Button x:Name="AutoButton"
|
||||||
Style="{StaticResource CaptionToggleButtonWithIndicatorStyle}"
|
x:Uid="AutoButton"
|
||||||
Background="{ThemeResource SystemControlBackgroundTransparentBrush}"
|
Grid.Column="1"
|
||||||
common:KeyboardShortcutManager.VirtualKey="{utils:ResourceVirtualKey Name=ftoeButton/[using:CalculatorApp.Common]KeyboardShortcutManager/VirtualKey}"
|
Style="{StaticResource CaptionButtonSmallStyle}"
|
||||||
AutomationProperties.AutomationId="ftoeButton"
|
AutomationProperties.AutomationId="autoButton"
|
||||||
AutomationProperties.Name="{utils:ResourceString Name=ftoeButton/[using:Windows.UI.Xaml.Automation]AutomationProperties/Name}"
|
Command="{x:Bind NotationPressed}"
|
||||||
Checked="FToEButton_Toggled"
|
CommandParameter="0"
|
||||||
Content="F-E"
|
Content="AUTO"/>
|
||||||
IsChecked="{x:Bind Model.IsFToEChecked, Mode=OneWay}"
|
<Button x:Name="SciButton"
|
||||||
Unchecked="FToEButton_Toggled"
|
x:Uid="SciButton"
|
||||||
IsEnabled="{x:Bind Model.IsFToEEnabled, Mode=OneWay}">
|
Grid.Column="1"
|
||||||
<ToggleButton.CommandParameter>
|
Style="{StaticResource CaptionButtonSmallStyle}"
|
||||||
<local:NumbersAndOperatorsEnum>FToE</local:NumbersAndOperatorsEnum>
|
AutomationProperties.AutomationId="sciButton"
|
||||||
</ToggleButton.CommandParameter>
|
Command="{x:Bind NotationPressed}"
|
||||||
</ToggleButton>
|
CommandParameter="1"
|
||||||
|
Content="SCI"
|
||||||
|
Visibility="Collapsed"/>
|
||||||
|
<Button x:Name="EngButton"
|
||||||
|
x:Uid="EngButton"
|
||||||
|
Grid.Column="1"
|
||||||
|
Style="{StaticResource CaptionButtonSmallStyle}"
|
||||||
|
AutomationProperties.AutomationId="engButton"
|
||||||
|
Command="{x:Bind NotationPressed}"
|
||||||
|
CommandParameter="2"
|
||||||
|
Content="ENG"
|
||||||
|
Visibility="Collapsed"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|
|
@ -17,10 +17,10 @@ namespace CalculatorApp
|
||||||
[Windows.Foundation.Metadata.WebHostHidden]
|
[Windows.Foundation.Metadata.WebHostHidden]
|
||||||
public sealed partial class CalculatorScientificAngleButtons
|
public sealed partial class CalculatorScientificAngleButtons
|
||||||
{
|
{
|
||||||
public CalculatorScientificAngleButtons()
|
public CalculatorScientificAngleButtons()
|
||||||
{
|
{
|
||||||
m_isErrorVisualState = false;
|
m_isErrorVisualState = false;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public StandardCalculatorViewModel Model => (StandardCalculatorViewModel)this.DataContext;
|
public StandardCalculatorViewModel Model => (StandardCalculatorViewModel)this.DataContext;
|
||||||
|
@ -84,10 +84,49 @@ namespace CalculatorApp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FToEButton_Toggled(object sender, RoutedEventArgs e)
|
public System.Windows.Input.ICommand NotationPressed
|
||||||
{
|
{
|
||||||
var viewModel = (StandardCalculatorViewModel)this.DataContext;
|
get
|
||||||
viewModel.FtoEButtonToggled();
|
{
|
||||||
|
if (donotuse_NotationPressed == null)
|
||||||
|
{
|
||||||
|
donotuse_NotationPressed = DelegateCommandUtils.MakeDelegateCommand(this,
|
||||||
|
(that, param) =>
|
||||||
|
{
|
||||||
|
that.OnNotationButtonPressed(param);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return donotuse_NotationPressed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private System.Windows.Input.ICommand donotuse_NotationPressed;
|
||||||
|
|
||||||
|
private void OnNotationButtonPressed(object commandParameter)
|
||||||
|
{
|
||||||
|
string buttonId = (string)commandParameter;
|
||||||
|
|
||||||
|
AutoButton.Visibility = Visibility.Collapsed;
|
||||||
|
SciButton.Visibility = Visibility.Collapsed;
|
||||||
|
EngButton.Visibility = Visibility.Collapsed;
|
||||||
|
|
||||||
|
if (buttonId == "0")
|
||||||
|
{
|
||||||
|
Model.FtoEButtonToggled();
|
||||||
|
SciButton.Visibility = Visibility.Visible;
|
||||||
|
SciButton.Focus(FocusState.Programmatic);
|
||||||
|
}
|
||||||
|
else if (buttonId == "1")
|
||||||
|
{
|
||||||
|
Model.EngButton();
|
||||||
|
EngButton.Visibility = Visibility.Visible;
|
||||||
|
EngButton.Focus(FocusState.Programmatic);
|
||||||
|
}
|
||||||
|
else if (buttonId == "2")
|
||||||
|
{
|
||||||
|
Model.FtoEButtonToggled();
|
||||||
|
AutoButton.Visibility = Visibility.Visible;
|
||||||
|
AutoButton.Focus(FocusState.Programmatic);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool m_isErrorVisualState;
|
private bool m_isErrorVisualState;
|
||||||
|
|
|
@ -17,8 +17,9 @@ namespace CalculatorUITestFramework
|
||||||
|
|
||||||
public enum FEButtonState
|
public enum FEButtonState
|
||||||
{
|
{
|
||||||
Normal,
|
Auto,
|
||||||
Exponential
|
Scientific,
|
||||||
|
Engineering
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -78,11 +79,14 @@ namespace CalculatorUITestFramework
|
||||||
public WindowsElement RandButton => this.session.TryFindElementByAccessibilityId("randButton");
|
public WindowsElement RandButton => this.session.TryFindElementByAccessibilityId("randButton");
|
||||||
public WindowsElement DmsButton => this.session.TryFindElementByAccessibilityId("dmsButton");
|
public WindowsElement DmsButton => this.session.TryFindElementByAccessibilityId("dmsButton");
|
||||||
public WindowsElement DegreesButton => this.session.TryFindElementByAccessibilityId("degreesButton");
|
public WindowsElement DegreesButton => this.session.TryFindElementByAccessibilityId("degreesButton");
|
||||||
public WindowsElement FixedToExponentialButton => this.session.TryFindElementByAccessibilityId("ftoeButton");
|
public WindowsElement AutoButton => this.session.TryFindElementByAccessibilityId("autoButton");
|
||||||
|
public WindowsElement SciButton => this.session.TryFindElementByAccessibilityId("sciButton");
|
||||||
|
public WindowsElement EngButton => this.session.TryFindElementByAccessibilityId("engButton");
|
||||||
public WindowsElement NegateButton => this.session.TryFindElementByAccessibilityId("negateButton");
|
public WindowsElement NegateButton => this.session.TryFindElementByAccessibilityId("negateButton");
|
||||||
public WindowsElement ShiftButton => this.session.TryFindElementByAccessibilityId("shiftButton");
|
public WindowsElement ShiftButton => this.session.TryFindElementByAccessibilityId("shiftButton");
|
||||||
public WindowsElement TrigFlyout => this.session.TryFindElementByAccessibilityId("Trigflyout");
|
public WindowsElement TrigFlyout => this.session.TryFindElementByAccessibilityId("Trigflyout");
|
||||||
public WindowsElement LightDismiss => this.session.TryFindElementByAccessibilityId("Light Dismiss");
|
public WindowsElement LightDismiss => this.session.TryFindElementByAccessibilityId("Light Dismiss");
|
||||||
|
private WindowsElement AutoSciEngButton => GetNumberFormatButton();
|
||||||
private WindowsElement DegRadGradButton => GetAngleOperatorButton();
|
private WindowsElement DegRadGradButton => GetAngleOperatorButton();
|
||||||
private WindowsElement GetAngleOperatorButton()
|
private WindowsElement GetAngleOperatorButton()
|
||||||
{
|
{
|
||||||
|
@ -103,6 +107,25 @@ namespace CalculatorUITestFramework
|
||||||
throw new NotFoundException("Could not find deg, rad or grad button in page source");
|
throw new NotFoundException("Could not find deg, rad or grad button in page source");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private WindowsElement GetNumberFormatButton()
|
||||||
|
{
|
||||||
|
string source = this.session.PageSource;
|
||||||
|
if (source.Contains("autoButton"))
|
||||||
|
{
|
||||||
|
return AutoButton;
|
||||||
|
}
|
||||||
|
else if (source.Contains("sciButton"))
|
||||||
|
{
|
||||||
|
return SciButton;
|
||||||
|
}
|
||||||
|
else if (source.Contains("engButton"))
|
||||||
|
{
|
||||||
|
return EngButton;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new NotFoundException("Could not find auto, sci, or eng button in page source");
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the state of the degrees, radians and gradians buttons.
|
/// Set the state of the degrees, radians and gradians buttons.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -122,11 +145,19 @@ namespace CalculatorUITestFramework
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetFEButton(FEButtonState value)
|
public void SetNumberFormat(FEButtonState value)
|
||||||
{
|
{
|
||||||
if (this.FixedToExponentialButton.GetAttribute("Toggle.ToggleState") != "0")
|
//set the desired string value for the button
|
||||||
|
string desiredId = value switch
|
||||||
{
|
{
|
||||||
FixedToExponentialButton.Click();
|
FEButtonState.Auto => "autoButton",
|
||||||
|
FEButtonState.Scientific => "sciButton",
|
||||||
|
FEButtonState.Engineering => "engButton",
|
||||||
|
_ => throw new NotImplementedException()
|
||||||
|
};
|
||||||
|
while (this.AutoSciEngButton.GetAttribute("AutomationId") != desiredId)
|
||||||
|
{
|
||||||
|
this.AutoSciEngButton.Click();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
using CalculatorUITestFramework;
|
using CalculatorUITestFramework;
|
||||||
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace CalculatorUITests
|
namespace CalculatorUITests
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,7 +52,7 @@ namespace CalculatorUITests
|
||||||
}
|
}
|
||||||
CalculatorApp.EnsureCalculatorHasFocus();
|
CalculatorApp.EnsureCalculatorHasFocus();
|
||||||
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees);
|
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees);
|
||||||
page.ScientificOperators.ResetFEButton(FEButtonState.Normal);
|
page.ScientificOperators.SetNumberFormat(FEButtonState.Auto);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCleanup]
|
[TestCleanup]
|
||||||
|
@ -237,11 +237,22 @@ namespace CalculatorUITests
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
[Priority(0)]
|
[Priority(0)]
|
||||||
public void SmokeTest_FixedToExponential()
|
public void SmokeTest_ScientificFormat()
|
||||||
{
|
{
|
||||||
page.ScientificOperators.FixedToExponentialButton.Click();
|
page.ScientificOperators.SetNumberFormat(FEButtonState.Scientific);
|
||||||
|
page.StandardOperators.NumberPad.Input(0.123);
|
||||||
page.StandardOperators.EqualButton.Click();
|
page.StandardOperators.EqualButton.Click();
|
||||||
Assert.AreEqual("0.e+0", page.CalculatorResults.GetCalculatorResultText());
|
Assert.AreEqual("1.23e-1", page.CalculatorResults.GetCalculatorResultText());
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
[Priority(0)]
|
||||||
|
public void SmokeTest_EngineeringFormat()
|
||||||
|
{
|
||||||
|
page.ScientificOperators.SetNumberFormat(FEButtonState.Engineering);
|
||||||
|
page.StandardOperators.NumberPad.Input(0.123);
|
||||||
|
page.StandardOperators.EqualButton.Click();
|
||||||
|
Assert.AreEqual("123.e-3", page.CalculatorResults.GetCalculatorResultText());
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue