mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-21 13:53:11 -07:00
Fix Scientific mode UI tests, add Engineering smoketest
This commit is contained in:
parent
5ed7e55d65
commit
8fb959e296
3 changed files with 53 additions and 10 deletions
|
@ -17,8 +17,9 @@ namespace CalculatorUITestFramework
|
|||
|
||||
public enum FEButtonState
|
||||
{
|
||||
Normal,
|
||||
Exponential
|
||||
Auto,
|
||||
Scientific,
|
||||
Engineering
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -78,11 +79,14 @@ namespace CalculatorUITestFramework
|
|||
public WindowsElement RandButton => this.session.TryFindElementByAccessibilityId("randButton");
|
||||
public WindowsElement DmsButton => this.session.TryFindElementByAccessibilityId("dmsButton");
|
||||
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 ShiftButton => this.session.TryFindElementByAccessibilityId("shiftButton");
|
||||
public WindowsElement TrigFlyout => this.session.TryFindElementByAccessibilityId("Trigflyout");
|
||||
public WindowsElement LightDismiss => this.session.TryFindElementByAccessibilityId("Light Dismiss");
|
||||
private WindowsElement AutoSciEngButton => GetNumberFormatButton();
|
||||
private WindowsElement DegRadGradButton => GetAngleOperatorButton();
|
||||
private WindowsElement GetAngleOperatorButton()
|
||||
{
|
||||
|
@ -103,6 +107,25 @@ namespace CalculatorUITestFramework
|
|||
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>
|
||||
/// Set the state of the degrees, radians and gradians buttons.
|
||||
/// </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 Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
|
||||
namespace CalculatorUITests
|
||||
{
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace CalculatorUITests
|
|||
}
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees);
|
||||
page.ScientificOperators.ResetFEButton(FEButtonState.Normal);
|
||||
page.ScientificOperators.SetNumberFormat(FEButtonState.Auto);
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
|
@ -161,11 +161,22 @@ namespace CalculatorUITests
|
|||
|
||||
[TestMethod]
|
||||
[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();
|
||||
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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue