Scientific and Programmer tests (#779)

* Maximize window during setup, and added divide by zero error test

* Added Error_CubedNegativeNumber test and AOT buttons

* Made Added AoT Tests and test are faster

* Hotkey and Mouse Input BVT Test added, Memory Test started

* Started Aligning BVTs with manual tests.  Added TC23466694, TC17416429, and TC17416884, and a test to switching mode test

* Basic Scientific Mode Functional Test Tests

* Added history panel test, and history flyout test for Standard calculator, and added the supporting framework

* Added some functional tests for Scientific mode.

* Basic Scientific Mode functional tests, added solution to set Angle Operator button correctly.

* Created functions to resize the app to display history panel, to display history button, display memory panel, and memory button.  Then I applied them to reduce areas with rewritten code, and to help with over all test stability and speed.

* I added the trigonometry functional tests

* Pull from latetest master, and retargeted solution

* Added a GetCalculatorWindowPostion function, when resizing window to show history/memory label, set window position to (0,0), and the same when resizing KOT calculator.  This will make tests more stable by keeping calculator on screen. It will also help with any testing that may require tracking the apps postion. To fix a test failure, changed function from ResizeToDiplayHistoryButton to ResizeToNotDisplayHistoryLabel.

* Sorted Using Statements, modified .gitignore to ignore **src/out, etc...

* Merged CalcMemoryFlyout into MemoryPanel, and deleted CalcMemoryFlyout. Merged CalcHistoryFlyout in HistoryPanel, and deleted CalcMemory.  Created GlobalCalculatorUI.cs.  Updated tests to work with these changes.

* hold on to changes

* Changed all KOT to Aot,
Removed equal button click in Test Cleanup/History method uses page source,
Removed extra line in Calculator.vcxproj.filters, Removed Try/Catch in the ClearHistory method

* Removed unused elses
Added CalculatorResults class
Added StandardAoTCalculatorPage
Removed manual test case info in the comments

* - In test framework, where it worked,
made some elements private
- Created EnsureCalculatorHasFocus() in GlobalCalculatorUI.cs
- Due to new classes, moved some methods to more correct classes
- Moved "page.MemoryPanel.ResizeWindowToDiplayMemoryLabel();" from
SetupCalculatorSession() to ClassInitialize()

* Sorted Using

* Updating fork from latest master

* Don't stand so

* Minor edits, fixing things from PR comments

* Merging scientific and standard mode tests, minor merge conflict fixes

* Method work
- Created ResizeAoTWindowToDiplayInvertButton()
    - Applied to test method AoT_ErrorMessage()
- Added page.ScientificOperators.ResetFEButton(fEButtonState.Normal);
to TestIniT in ScientificModeFunctionalTests
- Fixed if statement in public void ResetFEButton(fEButtonState value)

* Added StandardOperatorsPanel and removed duplicated code

* Created tests for Programmer mode, fixed a typo that appeared in multiple locations

* Fixed clear entry not working in Scientific test

* This time I really fixed the problem with clear memory not being found every time

* Revert shared changes

* Rebased onto master and resolved conflicts

* Fixed the 15 second delay on every scientific mode test

* Greatly shortened bitflipkeypad test

Co-authored-by: Crystal Edwards (Insight Global Inc) <v-credwa@microsoft.com>
Co-authored-by: Crystal Edwards <45952655+v-credwa@users.noreply.github.com>
This commit is contained in:
Daniel-Parker 2020-04-28 10:54:55 -07:00 committed by GitHub
parent fcbea550c8
commit 2cafb0dc88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 2047 additions and 21 deletions

View File

@ -205,4 +205,7 @@
<Filter>DataLoaders</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Page Include="$(MSBuildThisFileDirectory)DensityStyles\Compact.xaml" />
</ItemGroup>
</Project>

View File

@ -3,16 +3,16 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29009.5
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Calculator", "Calculator\Calculator.vcxproj", "{9447424A-0E05-4911-BEB8-E0354405F39A}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CalcManager", "CalcManager\CalcManager.vcxproj", "{311E866D-8B93-4609-A691-265941FEE101}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3A5DF651-B8A1-45CA-9135-964A6FC7F5D1}"
ProjectSection(SolutionItems) = preProject
..\.clang-format = ..\.clang-format
nuget.config = nuget.config
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Calculator", "Calculator\Calculator.vcxproj", "{9447424A-0E05-4911-BEB8-E0354405F39A}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CalcManager", "CalcManager\CalcManager.vcxproj", "{311E866D-8B93-4609-A691-265941FEE101}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CalcViewModel", "CalcViewModel\CalcViewModel.vcxproj", "{90E9761D-9262-4773-942D-CAEAE75D7140}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CalculatorUnitTests", "CalculatorUnitTests\CalculatorUnitTests.vcxproj", "{D3BAED2C-4B07-4E1D-8807-9D6499450349}"

View File

@ -1,12 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="Current">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<UpgradeBackupLocation>C:\Users\v-dapark\Source\Repos\Daniel-Parker\calculator\src\Backup\CalculatorUITestFramework\</UpgradeBackupLocation>
<OldToolsVersion>2.0</OldToolsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Appium.WebDriver" Version="4.0.0.6-beta" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
</ItemGroup>
</Project>

View File

@ -42,7 +42,7 @@ public void OpenMemoryPanel()
/// <summary>
/// Gets all of the memory items listed in the Memory Pane.
/// </summary>
/// <returns>A readonly collection of memory items.</returns>
/// <returns>A read-only collection of memory items.</returns>
public ReadOnlyCollection<AppiumWebElement> GetAllMemoryListViewItems()
{
OpenMemoryPanel();
@ -62,6 +62,10 @@ public void ClearMemoryPanel()
{
this.PanelClearMemoryButton.Click();
}
else
{
return;
}
}
catch (WebDriverException ex)
{
@ -70,7 +74,6 @@ public void ClearMemoryPanel()
Assert.IsNotNull(this.MemoryPaneEmptyLabel);
return;
}
throw;
}
}

View File

@ -0,0 +1,54 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Appium.Windows;
namespace CalculatorUITestFramework
{
/// <summary>
/// This class contains the UI automation objects and helper methods available when the Calculator is in Scientific Mode.
/// </summary>
public class ProgrammerCalculatorPage
{
private WindowsDriver<WindowsElement> session => WinAppDriver.Instance.CalculatorSession;
public ScientificOperatorsPanel ScientificOperators = new ScientificOperatorsPanel();
public StandardOperatorsPanel StandardOperators = new StandardOperatorsPanel();
public ProgrammerOperatorsPanel ProgrammerOperators = new ProgrammerOperatorsPanel();
public MemoryPanel MemoryPanel = new MemoryPanel();
public HistoryPanel HistoryPanel = new HistoryPanel();
public NavigationMenu NavigationMenu = new NavigationMenu();
public WindowsElement Header => this.session.TryFindElementByAccessibilityId("Header");
public CalculatorResults CalculatorResults = new CalculatorResults();
public void NavigateToProgrammerCalculator()
{
// Ensure that calculator is in scientific mode
NavigationMenu.ChangeCalculatorMode(CalculatorMode.ProgrammerCalculator);
}
/// <summary>
/// Clear the Calculator display, Memory Panel and optionally the History Panel
/// </summary>
public void ClearAll()
{
string source = this.session.PageSource;
if (source.Contains("clearEntryButton"))
{
StandardOperators.ClearEntryButton.Click();
StandardOperators.ClearButton.Click();
}
if (source.Contains("clearButton"))
{
StandardOperators.ClearButton.Click();
}
MemoryPanel.ResizeWindowToDisplayMemoryLabel();
if (source.Contains("ClearMemory"))
{
MemoryPanel.NumberpadMCButton.Click();
}
}
}
}

View File

@ -0,0 +1,202 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using OpenQA.Selenium;
using OpenQA.Selenium.Appium.Windows;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Runtime.InteropServices.ComTypes;
using System;
using System.Diagnostics;
namespace CalculatorUITestFramework
{
/// <summary>
/// UI elements unique to programmer mode
/// </summary>
public class ProgrammerOperatorsPanel
{
private WindowsDriver<WindowsElement> session => WinAppDriver.Instance.CalculatorSession;
public NumberPad NumberPad = new NumberPad();
public WindowsElement HexButton => this.session.TryFindElementByAccessibilityId("hexButton");
public WindowsElement DecButton => this.session.TryFindElementByAccessibilityId("decimalButton");
public WindowsElement OctButton => this.session.TryFindElementByAccessibilityId("octolButton");
public WindowsElement BinButton => this.session.TryFindElementByAccessibilityId("binaryButton");
public WindowsElement FullKeypad => this.session.TryFindElementByAccessibilityId("fullKeypad");
public WindowsElement BitFlip => this.session.TryFindElementByAccessibilityId("bitFlip");
public WindowsElement WordButton => this.session.TryFindElementByAccessibilityId("wordButton");
public WindowsElement QWordButton => this.session.TryFindElementByAccessibilityId("qwordButton");
public WindowsElement DWordButton => this.session.TryFindElementByAccessibilityId("dwordButton");
public WindowsElement ByteButton => this.session.TryFindElementByAccessibilityId("byteButton");
public WindowsElement BitwiseButton => this.session.TryFindElementByAccessibilityId("bitwiseButton");
public WindowsElement BitShiftButton => this.session.TryFindElementByAccessibilityId("bitShiftButton");
public WindowsElement AndButton => this.session.TryFindElementByAccessibilityId("andButton");
public WindowsElement NandButton => this.session.TryFindElementByAccessibilityId("nandButton");
public WindowsElement OrButton => this.session.TryFindElementByAccessibilityId("orButton");
public WindowsElement NorButton => this.session.TryFindElementByAccessibilityId("norButton");
public WindowsElement NotButton => this.session.TryFindElementByAccessibilityId("notButton");
public WindowsElement XorButton => this.session.TryFindElementByAccessibilityId("xorButton");
public WindowsElement ArithmeticShiftButton => this.session.TryFindElementByAccessibilityId("arithmeticShiftButton");
public WindowsElement LogicalShiftButton => this.session.TryFindElementByAccessibilityId("logicalShiftButton");
public WindowsElement RotateCircularButton => this.session.TryFindElementByAccessibilityId("rotateCircularButton");
public WindowsElement RotateCarryShiftButton => this.session.TryFindElementByAccessibilityId("rotateCarryShiftButton");
public WindowsElement AButton => this.session.TryFindElementByAccessibilityId("aButton");
public WindowsElement BButton => this.session.TryFindElementByAccessibilityId("bButton");
public WindowsElement CButton => this.session.TryFindElementByAccessibilityId("cButton");
public WindowsElement DButton => this.session.TryFindElementByAccessibilityId("dButton");
public WindowsElement EButton => this.session.TryFindElementByAccessibilityId("eButton");
public WindowsElement FButton => this.session.TryFindElementByAccessibilityId("fButton");
public WindowsElement LeftShiftButton => this.session.TryFindElementByAccessibilityId("lshButton");
public WindowsElement RightShiftButton => this.session.TryFindElementByAccessibilityId("rshButton");
public WindowsElement LeftShiftLogicalButton => this.session.TryFindElementByAccessibilityId("lshLogicalButton");
public WindowsElement RightShiftLogicalButton => this.session.TryFindElementByAccessibilityId("rshLogicalButton");
public WindowsElement RoLButton => this.session.TryFindElementByAccessibilityId("rolButton");
public WindowsElement RoRButton => this.session.TryFindElementByAccessibilityId("rorButton");
public WindowsElement RoRCarryButton => this.session.TryFindElementByAccessibilityId("rorCarryButton");
public WindowsElement Bit0 => this.session.TryFindElementByAccessibilityId("Bit0");
public WindowsElement Bit1 => this.session.TryFindElementByAccessibilityId("Bit1");
public WindowsElement Bit2 => this.session.TryFindElementByAccessibilityId("Bit2");
public WindowsElement Bit3 => this.session.TryFindElementByAccessibilityId("Bit3");
public WindowsElement Bit4 => this.session.TryFindElementByAccessibilityId("Bit4");
public WindowsElement Bit5 => this.session.TryFindElementByAccessibilityId("Bit5");
public WindowsElement Bit6 => this.session.TryFindElementByAccessibilityId("Bit6");
public WindowsElement Bit7 => this.session.TryFindElementByAccessibilityId("Bit7");
public WindowsElement Bit8 => this.session.TryFindElementByAccessibilityId("Bit8");
public WindowsElement Bit9 => this.session.TryFindElementByAccessibilityId("Bit9");
public WindowsElement Bit10 => this.session.TryFindElementByAccessibilityId("Bit10");
public WindowsElement Bit11 => this.session.TryFindElementByAccessibilityId("Bit11");
public WindowsElement Bit12 => this.session.TryFindElementByAccessibilityId("Bit12");
public WindowsElement Bit13 => this.session.TryFindElementByAccessibilityId("Bit13");
public WindowsElement Bit14 => this.session.TryFindElementByAccessibilityId("Bit14");
public WindowsElement Bit15 => this.session.TryFindElementByAccessibilityId("Bit15");
public WindowsElement Bit16 => this.session.TryFindElementByAccessibilityId("Bit16");
public WindowsElement Bit17 => this.session.TryFindElementByAccessibilityId("Bit17");
public WindowsElement Bit18 => this.session.TryFindElementByAccessibilityId("Bit18");
public WindowsElement Bit19 => this.session.TryFindElementByAccessibilityId("Bit19");
public WindowsElement Bit20 => this.session.TryFindElementByAccessibilityId("Bit20");
public WindowsElement Bit21 => this.session.TryFindElementByAccessibilityId("Bit21");
public WindowsElement Bit22 => this.session.TryFindElementByAccessibilityId("Bit22");
public WindowsElement Bit23 => this.session.TryFindElementByAccessibilityId("Bit23");
public WindowsElement Bit24 => this.session.TryFindElementByAccessibilityId("Bit24");
public WindowsElement Bit25 => this.session.TryFindElementByAccessibilityId("Bit25");
public WindowsElement Bit26 => this.session.TryFindElementByAccessibilityId("Bit26");
public WindowsElement Bit27 => this.session.TryFindElementByAccessibilityId("Bit27");
public WindowsElement Bit28 => this.session.TryFindElementByAccessibilityId("Bit28");
public WindowsElement Bit29 => this.session.TryFindElementByAccessibilityId("Bit29");
public WindowsElement Bit30 => this.session.TryFindElementByAccessibilityId("Bit30");
public WindowsElement Bit31 => this.session.TryFindElementByAccessibilityId("Bit31");
public WindowsElement Bit32 => this.session.TryFindElementByAccessibilityId("Bit32");
public WindowsElement Bit33 => this.session.TryFindElementByAccessibilityId("Bit33");
public WindowsElement Bit34 => this.session.TryFindElementByAccessibilityId("Bit34");
public WindowsElement Bit35 => this.session.TryFindElementByAccessibilityId("Bit35");
public WindowsElement Bit36 => this.session.TryFindElementByAccessibilityId("Bit36");
public WindowsElement Bit37 => this.session.TryFindElementByAccessibilityId("Bit37");
public WindowsElement Bit38 => this.session.TryFindElementByAccessibilityId("Bit38");
public WindowsElement Bit39 => this.session.TryFindElementByAccessibilityId("Bit39");
public WindowsElement Bit40 => this.session.TryFindElementByAccessibilityId("Bit40");
public WindowsElement Bit41 => this.session.TryFindElementByAccessibilityId("Bit41");
public WindowsElement Bit42 => this.session.TryFindElementByAccessibilityId("Bit42");
public WindowsElement Bit43 => this.session.TryFindElementByAccessibilityId("Bit43");
public WindowsElement Bit44 => this.session.TryFindElementByAccessibilityId("Bit44");
public WindowsElement Bit45 => this.session.TryFindElementByAccessibilityId("Bit45");
public WindowsElement Bit46 => this.session.TryFindElementByAccessibilityId("Bit46");
public WindowsElement Bit47 => this.session.TryFindElementByAccessibilityId("Bit47");
public WindowsElement Bit48 => this.session.TryFindElementByAccessibilityId("Bit48");
public WindowsElement Bit49 => this.session.TryFindElementByAccessibilityId("Bit49");
public WindowsElement Bit50 => this.session.TryFindElementByAccessibilityId("Bit50");
public WindowsElement Bit51 => this.session.TryFindElementByAccessibilityId("Bit51");
public WindowsElement Bit52 => this.session.TryFindElementByAccessibilityId("Bit52");
public WindowsElement Bit53 => this.session.TryFindElementByAccessibilityId("Bit53");
public WindowsElement Bit54 => this.session.TryFindElementByAccessibilityId("Bit54");
public WindowsElement Bit55 => this.session.TryFindElementByAccessibilityId("Bit55");
public WindowsElement Bit56 => this.session.TryFindElementByAccessibilityId("Bit56");
public WindowsElement Bit57 => this.session.TryFindElementByAccessibilityId("Bit57");
public WindowsElement Bit58 => this.session.TryFindElementByAccessibilityId("Bit58");
public WindowsElement Bit59 => this.session.TryFindElementByAccessibilityId("Bit59");
public WindowsElement Bit60 => this.session.TryFindElementByAccessibilityId("Bit60");
public WindowsElement Bit61 => this.session.TryFindElementByAccessibilityId("Bit61");
public WindowsElement Bit62 => this.session.TryFindElementByAccessibilityId("Bit62");
public WindowsElement Bit63 => this.session.TryFindElementByAccessibilityId("Bit63");
public void SetArithmeticShift()
{
BitShiftButton.Click();
if (this.ArithmeticShiftButton.GetAttribute("isEnabled") != "True")
{
ArithmeticShiftButton.Click();
}
else
{
BitShiftButton.Click();
}
}
public void SetLogicalShift()
{
BitShiftButton.Click();
if (this.LogicalShiftButton.GetAttribute("isEnabled") != "True")
{
LogicalShiftButton.Click();
}
else
{
BitShiftButton.Click();
}
}
public void SetRotateCircularShift()
{
BitShiftButton.Click();
if (this.RotateCircularButton.GetAttribute("isEnabled") != "True")
{
RotateCircularButton.Click();
}
else
{
BitShiftButton.Click();
}
}
public void SetRotateThroughCarryCircularShift()
{
BitShiftButton.Click();
if (this.RotateCarryShiftButton.GetAttribute("isEnabled") != "True")
{
RotateCarryShiftButton.Click();
}
else
{
BitShiftButton.Click();
}
}
public void ResetWordSize()
{
string source = this.session.PageSource;
if (source.Contains("qwordButton"))
{
return;
}
else if (source.Contains("dwordButton"))
{
DWordButton.Click();
WordButton.Click();
ByteButton.Click();
}
else if (source.Contains("wordButton"))
{
WordButton.Click();
ByteButton.Click();
}
else if (source.Contains("byteButton"))
{
ByteButton.Click();
}
else
{
throw new NotFoundException("Could not find word size buttons in page source");
}
}
public void ResetNumberSystem()
{
DecButton.Click();
}
}
}

View File

@ -0,0 +1,50 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Appium.Windows;
namespace CalculatorUITestFramework
{
/// <summary>
/// This class contains the UI automation objects and helper methods available when the Calculator is in Scientific Mode.
/// </summary>
public class ScientificCalculatorPage
{
private WindowsDriver<WindowsElement> session => WinAppDriver.Instance.CalculatorSession;
public ScientificOperatorsPanel ScientificOperators = new ScientificOperatorsPanel();
public StandardOperatorsPanel StandardOperators = new StandardOperatorsPanel();
public MemoryPanel MemoryPanel = new MemoryPanel();
public HistoryPanel HistoryPanel = new HistoryPanel();
public NavigationMenu NavigationMenu = new NavigationMenu();
public WindowsElement Header => this.session.TryFindElementByAccessibilityId("Header");
public CalculatorResults CalculatorResults = new CalculatorResults();
public void NavigateToScientificCalculator()
{
// Ensure that calculator is in scientific mode
this.NavigationMenu.ChangeCalculatorMode(CalculatorMode.ScientificCalculator);
}
/// <summary>
/// Clear the Calculator display, Memory Panel and optionally the History Panel
/// </summary>
public void ClearAll()
{
string source = this.session.PageSource;
if (source.Contains("clearEntryButton"))
{
this.StandardOperators.ClearEntryButton.Click();
source = this.session.PageSource;
}
if (source.Contains("clearButton"))
{
this.StandardOperators.ClearButton.Click();
}
MemoryPanel.ResizeWindowToDisplayMemoryLabel();
HistoryPanel.ClearHistory();
}
}
}

View File

@ -0,0 +1,167 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using OpenQA.Selenium;
using OpenQA.Selenium.Appium.Windows;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Runtime.InteropServices.ComTypes;
using System;
using System.Diagnostics;
namespace CalculatorUITestFramework
{
public enum AngleOperatorState
{
Degrees,
Radians,
Gradians
}
public enum fEButtonState
{
Normal,
Exponential
}
/// <summary>
/// UI elements unique to Scientific mode
/// </summary>
public class ScientificOperatorsPanel
{
private WindowsDriver<WindowsElement> session => WinAppDriver.Instance.CalculatorSession;
public WindowsElement XPower3Button => this.session.TryFindElementByAccessibilityId("xpower3Button");
public WindowsElement XPowerYButton => this.session.TryFindElementByAccessibilityId("powerButton");
public WindowsElement PowerOf10Button => this.session.TryFindElementByAccessibilityId("powerOf10Button");
public WindowsElement LogButton => this.session.TryFindElementByAccessibilityId("logBase10Button");
public WindowsElement LnButton => this.session.TryFindElementByAccessibilityId("logBaseEButton");
public WindowsElement PiButton => this.session.TryFindElementByAccessibilityId("piButton");
public WindowsElement EulerButton => this.session.TryFindElementByAccessibilityId("eulerButton");
public WindowsElement AbsButton => this.session.TryFindElementByAccessibilityId("absButton");
public WindowsElement ExpButton => this.session.TryFindElementByAccessibilityId("expButton");
public WindowsElement ModButton => this.session.TryFindElementByAccessibilityId("modButton");
public WindowsElement ParenthesisLeftButton => this.session.TryFindElementByAccessibilityId("openParenthesisButton");
public WindowsElement ParenthesisRightButton => this.session.TryFindElementByAccessibilityId("closeParenthesisButton");
public WindowsElement FactorialButton => this.session.TryFindElementByAccessibilityId("factorialButton");
public WindowsElement BackSpaceButton => this.session.TryFindElementByAccessibilityId("backSpaceButton");
public WindowsElement DegButton => this.session.TryFindElementByAccessibilityId("degButton");
public WindowsElement RadButton => this.session.TryFindElementByAccessibilityId("radButton");
public WindowsElement GradButton => this.session.TryFindElementByAccessibilityId("gradButton");
public WindowsElement AngleOperator => this.session.TryFindElementByAccessibilityId("ScientificAngleOperators");
public WindowsElement TrigButton => this.session.TryFindElementByAccessibilityId("trigButton");
public WindowsElement FuncButton => this.session.TryFindElementByAccessibilityId("funcButton");
public WindowsElement SinButton => this.session.TryFindElementByAccessibilityId("sinButton");
public WindowsElement CosButton => this.session.TryFindElementByAccessibilityId("cosButton");
public WindowsElement TanButton => this.session.TryFindElementByAccessibilityId("tanButton");
public WindowsElement CscButton => this.session.TryFindElementByAccessibilityId("cscButton");
public WindowsElement SecButton => this.session.TryFindElementByAccessibilityId("secButton");
public WindowsElement CotButton => this.session.TryFindElementByAccessibilityId("cotButton");
public WindowsElement TrigShiftButton => this.session.TryFindElementByAccessibilityId("trigShiftButton");
public WindowsElement HypShiftButton => this.session.TryFindElementByAccessibilityId("hypShiftButton");
public WindowsElement InvSinButton => this.session.TryFindElementByAccessibilityId("invsinButton");
public WindowsElement InvCosButton => this.session.TryFindElementByAccessibilityId("invcosButton");
public WindowsElement InvTanButton => this.session.TryFindElementByAccessibilityId("invtanButton");
public WindowsElement InvCscButton => this.session.TryFindElementByAccessibilityId("invcscButton");
public WindowsElement InvSecButton => this.session.TryFindElementByAccessibilityId("invsecButton");
public WindowsElement InvCotButton => this.session.TryFindElementByAccessibilityId("invcotButton");
public WindowsElement SinhButton => this.session.TryFindElementByAccessibilityId("sinhButton");
public WindowsElement CoshButton => this.session.TryFindElementByAccessibilityId("coshButton");
public WindowsElement TanhButton => this.session.TryFindElementByAccessibilityId("tanhButton");
public WindowsElement CschButton => this.session.TryFindElementByAccessibilityId("cschButton");
public WindowsElement SechButton => this.session.TryFindElementByAccessibilityId("sechButton");
public WindowsElement CothButton => this.session.TryFindElementByAccessibilityId("cothButton");
public WindowsElement InvSinhButton => this.session.TryFindElementByAccessibilityId("invsinhButton");
public WindowsElement InvCoshButton => this.session.TryFindElementByAccessibilityId("invcoshButton");
public WindowsElement InvTanhButton => this.session.TryFindElementByAccessibilityId("invtanhButton");
public WindowsElement InvCschButton => this.session.TryFindElementByAccessibilityId("invcschButton");
public WindowsElement InvSechButton => this.session.TryFindElementByAccessibilityId("invsechButton");
public WindowsElement InvCothButton => this.session.TryFindElementByAccessibilityId("invcothButton");
public WindowsElement FloorButton => this.session.TryFindElementByAccessibilityId("floorButton");
public WindowsElement CeilButton => this.session.TryFindElementByAccessibilityId("ceilButton");
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 NegateButton => this.session.TryFindElementByAccessibilityId("negateButton");
public WindowsElement TrigFlyout => this.session.TryFindElementByAccessibilityId("Trigflyout");
public WindowsElement LightDismiss => this.session.TryFindElementByAccessibilityId("Light Dismiss");
private WindowsElement DegRadGradButton => GetAngleOperatorButton();
private WindowsElement GetAngleOperatorButton()
{
string source = this.session.PageSource;
if (source.Contains("degButton"))
{
return DegButton;
}
else if (source.Contains("gradButton"))
{
return GradButton;
}
else if (source.Contains("radButton"))
{
return RadButton;
}
throw new NotFoundException("Could not find deg, rad or grad button in page source");
}
/// <summary>
/// Set the state of the degrees, radians and gradians buttons.
/// </summary>
public void SetAngleOperator(AngleOperatorState value)
{
//set the desired string value for the button
string desiredId;
switch (value)
{
case AngleOperatorState.Degrees:
desiredId = "degButton";
break;
case AngleOperatorState.Gradians:
desiredId = "gradButton";
break;
case AngleOperatorState.Radians:
desiredId = "radButton";
break;
default:
throw new NotImplementedException();
}
while (this.DegRadGradButton.GetAttribute("AutomationId") != desiredId)
{
this.DegRadGradButton.Click();
}
}
public void ResetFEButton(fEButtonState value)
{
if (this.FixedToExponentialButton.GetAttribute("Toggle.ToggleState") != "0")
{
FixedToExponentialButton.Click();
}
}
public WindowsElement ResetTrigDropdownToggles()
{
TrigButton.Click();
string source = this.session.PageSource;
if (source.Contains("sinButton"))
{
LightDismiss.Click();
}
else if (source.Contains("invsinButton"))
{
TrigShiftButton.Click();
}
else if (source.Contains("sinhButton"))
{
HypShiftButton.Click();
}
else if (source.Contains("invsinhButton"))
{
TrigShiftButton.Click();
HypShiftButton.Click();
}
throw new NotFoundException("Could not find trig drop-down buttons in page source");
}
}
}

View File

@ -160,5 +160,43 @@ private void GrowWindowToShowInvertButton(int height)
GrowWindowToShowInvertButton(width + 100);
}
}
/// <summary>
/// If the Invert button is not displayed, resize the window
/// Two attempts are made, the the button is not found a "not found" exception is thrown
/// </summary>
public void ResizeAoTWindowToDiplayInvertButton()
{
Point newWindowPostion = new Point(8, 8);
WinAppDriver.Instance.CalculatorSession.Manage().Window.Position = newWindowPostion;
string source0 = this.session.PageSource;
if (source0.Contains("invertButton"))
{
return;
}
else
{
Size newWindowSize = new Size(502, 502);
WinAppDriver.Instance.CalculatorSession.Manage().Window.Size = newWindowSize;
string source1 = this.session.PageSource;
if (source1.Contains("invertButton"))
{
return;
}
else
{
Size newWindowSize2 = new Size(750, 750);
WinAppDriver.Instance.CalculatorSession.Manage().Window.Size = newWindowSize2;
}
string source2 = this.session.PageSource;
if (source2.Contains("invertButton"))
{
return;
}
else
{
throw new NotFoundException("Could not find the Invert Button");
}
}
}
}
}

View File

@ -75,6 +75,7 @@ public void EnsureCalculatorIsInStandardMode()
this.StandardAoTCalculatorPage.NavigateToStandardMode();
}
}
}
}

View File

@ -27,6 +27,5 @@ public class StandardOperatorsPanel
public WindowsElement ClearButton => this.session.TryFindElementByAccessibilityId("clearButton");
public WindowsElement BackSpaceButton => this.session.TryFindElementByAccessibilityId("backSpaceButton");
public WindowsElement NegateButton => this.session.TryFindElementByAccessibilityId("negateButton");
}
}

View File

@ -12,6 +12,7 @@ namespace CalculatorUITestFramework
public sealed class WinAppDriver
{
private WindowsDriverLocalService windowsDriverService = null;
public MemoryPanel MemoryPanel = new MemoryPanel();
private const string defaultAppId = "Microsoft.WindowsCalculator.Dev_8wekyb3d8bbwe!App";
private static WinAppDriver instance = null;
public static WinAppDriver Instance

View File

@ -1,22 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="Current">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<IsPackable>false</IsPackable>
<UpgradeBackupLocation>C:\Users\v-dapark\Source\Repos\Daniel-Parker\calculator\src\Backup\CalculatorUITests\</UpgradeBackupLocation>
<OldToolsVersion>2.0</OldToolsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="Appium.WebDriver" Version="4.0.0.6-beta" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CalculatorUITestFramework\CalculatorUITestFramework.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="CalculatorUITests.release.runsettings">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@ -25,5 +22,4 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -0,0 +1,892 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using CalculatorUITestFramework;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Appium.Windows;
using System;
using System.Collections.Generic;
namespace CalculatorUITests
{
[TestClass]
public class ProgrammerModeFunctionalTests
{
private static ProgrammerCalculatorPage page = new ProgrammerCalculatorPage();
/// <summary>
/// Initializes the WinAppDriver web driver session.
/// </summary>
/// <param name="context"></param>
[ClassInitialize]
public static void ClassInitialize(TestContext context)
{
// Create session to launch a Calculator window
WinAppDriver.Instance.SetupCalculatorSession(context);
// Ensure that calculator is in programmer mode
page.NavigateToProgrammerCalculator();
// Ensure that calculator window is large enough to display the memory/history panel; a good size for most tests
page.MemoryPanel.ResizeWindowToDisplayMemoryLabel();
}
/// <summary>
/// Closes the app and WinAppDriver web driver session.
/// </summary>
[ClassCleanup]
public static void ClassCleanup()
{
// Tear down Calculator session.
WinAppDriver.Instance.TearDownCalculatorSession();
}
/// <summary>
/// Ensures the calculator is in a cleared state with the correct default options
/// </summary>
[TestInitialize]
public void TestInit()
{
if ("0" != page.CalculatorResults.GetCalculatorResultText())
{
page.ClearAll();
}
CalculatorApp.EnsureCalculatorHasFocus();
page.ProgrammerOperators.SetArithmeticShift();
page.ProgrammerOperators.ResetWordSize();
page.ProgrammerOperators.ResetNumberSystem();
}
[TestCleanup]
public void TestCleanup()
{
page.ClearAll();
}
/// <summary>
/// Arithmetic shift, decimal notation, QWord
/// </summary>
#region Smoke Tests
[TestMethod]
[Priority(0)]
public void SmokeTest_Arithmetic_Decimal_LeftShift()
{
page.StandardOperators.NumberPad.Input(5);
page.ProgrammerOperators.LeftShiftButton.Click();
page.StandardOperators.NumberPad.Input(1);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("10", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(0)]
public void SmokeTest_Arithmetic_Decimal_RightShift()
{
page.StandardOperators.NumberPad.Input(25);
page.StandardOperators.NegateButton.Click();
page.ProgrammerOperators.RightShiftButton.Click();
page.StandardOperators.NumberPad.Input(1);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("-13", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(0)]
public void SmokeTest_Arithmetic_Decimal_And()
{
page.StandardOperators.NumberPad.Input(25);
page.ProgrammerOperators.BitwiseButton.Click();
page.ProgrammerOperators.AndButton.Click();
page.StandardOperators.NumberPad.Input(7);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(0)]
public void SmokeTest_Arithmetic_Decimal_Nand()
{
page.StandardOperators.NumberPad.Input(25);
page.ProgrammerOperators.BitwiseButton.Click();
page.ProgrammerOperators.NandButton.Click();
page.StandardOperators.NumberPad.Input(7);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("-2", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(0)]
public void SmokeTest_Arithmetic_Decimal_Or()
{
page.StandardOperators.NumberPad.Input(25);
page.ProgrammerOperators.BitwiseButton.Click();
page.ProgrammerOperators.OrButton.Click();
page.StandardOperators.NumberPad.Input(7);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("31", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(0)]
public void SmokeTest_Arithmetic_Decimal_Nor()
{
page.StandardOperators.NumberPad.Input(25);
page.ProgrammerOperators.BitwiseButton.Click();
page.ProgrammerOperators.NorButton.Click();
page.StandardOperators.NumberPad.Input(7);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("-32", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(0)]
public void SmokeTest_Arithmetic_Decimal_Not()
{
page.StandardOperators.NumberPad.Input(25);
page.ProgrammerOperators.BitwiseButton.Click();
page.ProgrammerOperators.NotButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("-26", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(0)]
public void SmokeTest_Arithmetic_Decimal_Xor()
{
page.StandardOperators.NumberPad.Input(25);
page.ProgrammerOperators.BitwiseButton.Click();
page.ProgrammerOperators.XorButton.Click();
page.StandardOperators.NumberPad.Input(7);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("30", page.CalculatorResults.GetCalculatorResultText());
}
/// <summary>
/// Checks for the highest value bit that should be enabled according to the Word size setting
/// </summary>
[TestMethod]
[Priority(0)]
public void SmokeTest_WordSize()
{
page.ProgrammerOperators.BitFlip.Click();
if (page.ProgrammerOperators.Bit63.GetAttribute("IsEnabled") != "True")
{
throw new NotFoundException("According to the current Word size setting, some bits that should be enabled are disabled");
}
else
{
page.ProgrammerOperators.QWordButton.Click();
if (page.ProgrammerOperators.Bit31.GetAttribute("IsEnabled") != "True")
{
throw new NotFoundException("According to the current Word size setting, some bits that should be enabled are disabled");
}
else
{
page.ProgrammerOperators.DWordButton.Click();
if (page.ProgrammerOperators.Bit15.GetAttribute("IsEnabled") != "True")
{
throw new NotFoundException("According to the current Word size setting, some bits that should be enabled are disabled");
}
else
{
page.ProgrammerOperators.WordButton.Click();
if (page.ProgrammerOperators.Bit7.GetAttribute("IsEnabled") != "True")
{
throw new NotFoundException("According to the current Word size setting, some bits that should be enabled are disabled");
}
else
{
page.ProgrammerOperators.ByteButton.Click();
if (page.ProgrammerOperators.Bit63.GetAttribute("IsEnabled") != "True")
{
throw new NotFoundException("According to the current Word size setting, some bits that should be enabled are disabled");
}
}
}
}
page.ProgrammerOperators.FullKeypad.Click();
}
}
/// <summary>
/// Toggles each bit on and off
/// </summary>
[TestMethod]
[Priority(0)]
public void SmokeTest_BitFlipKeypad()
{
page.ProgrammerOperators.BitFlip.Click();
page.ProgrammerOperators.Bit63.Click();
Assert.AreEqual("-9,223,372,036,854,775,808", page.CalculatorResults.GetCalculatorResultText());
page.ProgrammerOperators.FullKeypad.Click();
}
#endregion
/// <summary>
/// Arithmetic shift, octal notation, QWord
/// </summary>
#region Arithmetic logic operators
[TestMethod]
[Priority(1)]
public void Arithmetic_Operator_Octal_LeftShift()
{
page.ProgrammerOperators.OctButton.Click();
page.StandardOperators.NumberPad.Input(7);
page.ProgrammerOperators.LeftShiftButton.Click();
page.StandardOperators.NumberPad.Input(1);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1 6", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Arithmetic_Operator_Octal_RightShift()
{
page.ProgrammerOperators.OctButton.Click();
page.StandardOperators.NumberPad.Input(25);
page.StandardOperators.NegateButton.Click();
page.ProgrammerOperators.RightShiftButton.Click();
page.StandardOperators.NumberPad.Input(1);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 6 5", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Arithmetic_Operator_Octal_And()
{
page.ProgrammerOperators.OctButton.Click();
page.StandardOperators.NumberPad.Input(16);
page.ProgrammerOperators.BitwiseButton.Click();
page.ProgrammerOperators.AndButton.Click();
page.StandardOperators.NumberPad.Input(7);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("6", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Arithmetic_Operator_Octal_Nand()
{
page.ProgrammerOperators.OctButton.Click();
page.StandardOperators.NumberPad.Input(16);
page.ProgrammerOperators.BitwiseButton.Click();
page.ProgrammerOperators.NandButton.Click();
page.StandardOperators.NumberPad.Input(7);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 1", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Arithmetic_Operator_Octal_Or()
{
page.ProgrammerOperators.OctButton.Click();
page.StandardOperators.NumberPad.Input(16);
page.ProgrammerOperators.BitwiseButton.Click();
page.ProgrammerOperators.OrButton.Click();
page.StandardOperators.NumberPad.Input(7);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1 7", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Arithmetic_Operator_Octal_Nor()
{
page.ProgrammerOperators.OctButton.Click();
page.StandardOperators.NumberPad.Input(16);
page.ProgrammerOperators.BitwiseButton.Click();
page.ProgrammerOperators.NorButton.Click();
page.StandardOperators.NumberPad.Input(7);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 6 0", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Arithmetic_Operator_Octal_Not()
{
page.ProgrammerOperators.OctButton.Click();
page.StandardOperators.NumberPad.Input(16);
page.ProgrammerOperators.BitwiseButton.Click();
page.ProgrammerOperators.NotButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 6 1", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Arithmetic_Operator_Octal_Xor()
{
page.ProgrammerOperators.OctButton.Click();
page.StandardOperators.NumberPad.Input(16);
page.ProgrammerOperators.BitwiseButton.Click();
page.ProgrammerOperators.XorButton.Click();
page.StandardOperators.NumberPad.Input(7);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1 1", page.CalculatorResults.GetCalculatorResultText());
}
/// <summary>
/// Arithmetic shift, binary notation, QWord
/// </summary>
[TestMethod]
[Priority(1)]
public void Arithmetic_Operator_Binary_LeftShift()
{
page.ProgrammerOperators.BinButton.Click();
page.StandardOperators.NumberPad.Input(1010);
page.ProgrammerOperators.LeftShiftButton.Click();
page.StandardOperators.NumberPad.Input(1);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1 0 1 0 0", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Arithmetic_Operator_Binary_RightShift()
{
page.ProgrammerOperators.BinButton.Click();
page.StandardOperators.NumberPad.Input(1010);
page.ProgrammerOperators.RightShiftButton.Click();
page.StandardOperators.NumberPad.Input(1);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1 0 1", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Arithmetic_Operator_Binary_And()
{
page.ProgrammerOperators.BinButton.Click();
page.StandardOperators.NumberPad.Input(1010);
page.ProgrammerOperators.BitwiseButton.Click();
page.ProgrammerOperators.AndButton.Click();
page.StandardOperators.NumberPad.Input(1000);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1 0 0 0", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Arithmetic_Operator_Binary_Nand()
{
page.ProgrammerOperators.BinButton.Click();
page.StandardOperators.NumberPad.Input(1010);
page.ProgrammerOperators.BitwiseButton.Click();
page.ProgrammerOperators.NandButton.Click();
page.StandardOperators.NumberPad.Input(1000);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Arithmetic_Operator_Binary_Or()
{
page.ProgrammerOperators.BinButton.Click();
page.StandardOperators.NumberPad.Input(1010);
page.ProgrammerOperators.BitwiseButton.Click();
page.ProgrammerOperators.OrButton.Click();
page.StandardOperators.NumberPad.Input(1100);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1 1 1 0", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Arithmetic_Operator_Binary_Nor()
{
page.ProgrammerOperators.BinButton.Click();
page.StandardOperators.NumberPad.Input(1010);
page.ProgrammerOperators.BitwiseButton.Click();
page.ProgrammerOperators.NorButton.Click();
page.StandardOperators.NumberPad.Input(1100);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Arithmetic_Operator_Binary_Not()
{
page.ProgrammerOperators.BinButton.Click();
page.StandardOperators.NumberPad.Input(1010);
page.ProgrammerOperators.BitwiseButton.Click();
page.ProgrammerOperators.NotButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Arithmetic_Operator_Binary_Xor()
{
page.ProgrammerOperators.BinButton.Click();
page.StandardOperators.NumberPad.Input(1010);
page.ProgrammerOperators.BitwiseButton.Click();
page.ProgrammerOperators.XorButton.Click();
page.StandardOperators.NumberPad.Input(1100);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1 1 0", page.CalculatorResults.GetCalculatorResultText());
}
/// <summary>
/// Arithmetic shift, hexadecimal notation, QWord
/// </summary>
[TestMethod]
[Priority(1)]
public void Arithmetic_Operator_Hex_LeftShift()
{
page.ProgrammerOperators.HexButton.Click();
page.ProgrammerOperators.AButton.Click();
page.ProgrammerOperators.LeftShiftButton.Click();
page.ProgrammerOperators.BButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("5 0 0 0", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Arithmetic_Operator_Hex_RightShift()
{
page.ProgrammerOperators.HexButton.Click();
page.ProgrammerOperators.FButton.Click();
page.ProgrammerOperators.RightShiftButton.Click();
page.StandardOperators.NumberPad.Input(2);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("3", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Arithmetic_Operator_Hex_And()
{
page.ProgrammerOperators.HexButton.Click();
page.ProgrammerOperators.AButton.Click();
page.ProgrammerOperators.BButton.Click();
page.ProgrammerOperators.CButton.Click();
page.ProgrammerOperators.BitwiseButton.Click();
page.ProgrammerOperators.AndButton.Click();
page.ProgrammerOperators.FButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("C", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Arithmetic_Operator_Hex_Nand()
{
page.ProgrammerOperators.HexButton.Click();
page.ProgrammerOperators.AButton.Click();
page.ProgrammerOperators.BButton.Click();
page.ProgrammerOperators.CButton.Click();
page.ProgrammerOperators.BitwiseButton.Click();
page.ProgrammerOperators.NandButton.Click();
page.ProgrammerOperators.FButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("F F F F F F F F F F F F F F F 3", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Arithmetic_Operator_Hex_Or()
{
page.ProgrammerOperators.HexButton.Click();
page.ProgrammerOperators.AButton.Click();
page.ProgrammerOperators.BButton.Click();
page.ProgrammerOperators.CButton.Click();
page.ProgrammerOperators.BitwiseButton.Click();
page.ProgrammerOperators.OrButton.Click();
page.ProgrammerOperators.FButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("A B F", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Arithmetic_Operator_Hex_Nor()
{
page.ProgrammerOperators.HexButton.Click();
page.ProgrammerOperators.AButton.Click();
page.ProgrammerOperators.BButton.Click();
page.ProgrammerOperators.CButton.Click();
page.ProgrammerOperators.BitwiseButton.Click();
page.ProgrammerOperators.NorButton.Click();
page.ProgrammerOperators.FButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("F F F F F F F F F F F F F 5 4 0", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Arithmetic_Operator_Hex_Not()
{
page.ProgrammerOperators.HexButton.Click();
page.ProgrammerOperators.AButton.Click();
page.ProgrammerOperators.BButton.Click();
page.ProgrammerOperators.CButton.Click();
page.ProgrammerOperators.BitwiseButton.Click();
page.ProgrammerOperators.NotButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("F F F F F F F F F F F F F 5 4 3", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Arithmetic_Operator_Hex_Xor()
{
page.ProgrammerOperators.HexButton.Click();
page.ProgrammerOperators.AButton.Click();
page.ProgrammerOperators.BButton.Click();
page.ProgrammerOperators.CButton.Click();
page.ProgrammerOperators.BitwiseButton.Click();
page.ProgrammerOperators.XorButton.Click();
page.ProgrammerOperators.FButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("A B 3", page.CalculatorResults.GetCalculatorResultText());
}
#endregion
/// <summary>
/// Logical shift, decimal notation, QWord - AND/NAND/OR/NOR/NOT/XOR will always be the same regardless of what shift setting is selected, so the previous section should have those covered
/// </summary>
#region Logical-shift operators
[TestMethod]
[Priority(1)]
public void Logical_Operator_Decimal_LeftShift()
{
page.ProgrammerOperators.SetLogicalShift();
page.StandardOperators.NumberPad.Input(7);
page.ProgrammerOperators.LeftShiftLogicalButton.Click();
page.StandardOperators.NumberPad.Input(1);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("14", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Logical_Operator_Decimal_RightShift()
{
page.ProgrammerOperators.SetLogicalShift();
page.StandardOperators.NumberPad.Input(16);
page.StandardOperators.NegateButton.Click();
page.ProgrammerOperators.RightShiftLogicalButton.Click();
page.StandardOperators.NumberPad.Input(1);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("9,223,372,036,854,775,800", page.CalculatorResults.GetCalculatorResultText());
}
/// <summary>
/// Logical shift, octal notation, QWord
/// </summary>
[TestMethod]
[Priority(1)]
public void Logical_Operator_Octal_LeftShift()
{
page.ProgrammerOperators.OctButton.Click();
page.ProgrammerOperators.SetLogicalShift();
page.StandardOperators.NumberPad.Input(7);
page.ProgrammerOperators.LeftShiftLogicalButton.Click();
page.StandardOperators.NumberPad.Input(1);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1 6", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Logical_Operator_Octal_RightShift()
{
page.ProgrammerOperators.OctButton.Click();
page.ProgrammerOperators.SetLogicalShift();
page.StandardOperators.NumberPad.Input(16);
page.StandardOperators.NegateButton.Click();
page.ProgrammerOperators.RightShiftLogicalButton.Click();
page.StandardOperators.NumberPad.Input(1);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 1", page.CalculatorResults.GetCalculatorResultText());
}
/// <summary>
/// Logical shift, binary notation, QWord
/// </summary>
[TestMethod]
[Priority(1)]
public void Logical_Operator_Binary_LeftShift()
{
page.ProgrammerOperators.BinButton.Click();
page.ProgrammerOperators.SetLogicalShift();
page.StandardOperators.NumberPad.Input(1010);
page.ProgrammerOperators.LeftShiftLogicalButton.Click();
page.StandardOperators.NumberPad.Input(1);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1 0 1 0 0", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Logical_Operator_Binary_RightShift()
{
page.ProgrammerOperators.BinButton.Click();
page.ProgrammerOperators.SetLogicalShift();
page.StandardOperators.NumberPad.Input(1010);
page.StandardOperators.NegateButton.Click();
page.ProgrammerOperators.RightShiftLogicalButton.Click();
page.StandardOperators.NumberPad.Input(1);
page.StandardOperators.EqualButton.Click();
Assert.IsTrue(String.Equals(page.CalculatorResults.GetCalculatorResultText(), "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1", StringComparison.OrdinalIgnoreCase));
}
/// <summary>
/// Logical shift, hexadecimal notation, QWord
/// </summary>
[TestMethod]
[Priority(1)]
public void Logical_Operator_Hex_LeftShift()
{
page.ProgrammerOperators.HexButton.Click();
page.ProgrammerOperators.SetLogicalShift();
page.ProgrammerOperators.AButton.Click();
page.ProgrammerOperators.LeftShiftLogicalButton.Click();
page.ProgrammerOperators.BButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("5 0 0 0", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Logical_Operator_Hex_RightShift()
{
page.ProgrammerOperators.HexButton.Click();
page.ProgrammerOperators.SetLogicalShift();
page.ProgrammerOperators.FButton.Click();
page.StandardOperators.NegateButton.Click();
page.ProgrammerOperators.RightShiftLogicalButton.Click();
page.StandardOperators.NumberPad.Input(1);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("7 F F F F F F F F F F F F F F 8", page.CalculatorResults.GetCalculatorResultText());
}
#endregion
/// <summary>
/// Rotate circular shift, decimal notation, QWord
/// </summary>
#region Rotate-Circular-shift operators
[TestMethod]
[Priority(1)]
public void Circular_Operator_Decimal_LeftShift()
{
page.ProgrammerOperators.SetRotateCircularShift();
page.StandardOperators.NumberPad.Input(7);
page.ProgrammerOperators.RoLButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("14", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Circular_Operator_Decimal_RightShift()
{
page.ProgrammerOperators.SetRotateCircularShift();
page.StandardOperators.NumberPad.Input(16);
page.StandardOperators.NegateButton.Click();
page.ProgrammerOperators.RoRButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("9,223,372,036,854,775,800", page.CalculatorResults.GetCalculatorResultText());
}
/// <summary>
/// Rotate circular shift, octal notation, QWord
/// </summary>
[TestMethod]
[Priority(1)]
public void Circular_Operator_Octal_LeftShift()
{
page.ProgrammerOperators.OctButton.Click();
page.ProgrammerOperators.SetRotateCircularShift();
page.StandardOperators.NumberPad.Input(25);
page.ProgrammerOperators.RoLButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("5 2", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Circular_Operator_Octal_RightShift()
{
page.ProgrammerOperators.OctButton.Click();
page.ProgrammerOperators.SetRotateCircularShift();
page.StandardOperators.NumberPad.Input(25);
page.ProgrammerOperators.RoRButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2", page.CalculatorResults.GetCalculatorResultText());
}
/// <summary>
/// Rotate circular shift, binary notation, QWord
/// </summary>
[TestMethod]
[Priority(1)]
public void Circular_Operator_Binary_LeftShift()
{
page.ProgrammerOperators.BinButton.Click();
page.ProgrammerOperators.SetRotateCircularShift();
page.StandardOperators.NumberPad.Input(1011);
page.ProgrammerOperators.RoLButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1 0 1 1 0", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Circular_Operator_Binary_RightShift()
{
page.ProgrammerOperators.BinButton.Click();
page.ProgrammerOperators.SetRotateCircularShift();
page.StandardOperators.NumberPad.Input(1011);
page.ProgrammerOperators.RoRButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1", page.CalculatorResults.GetCalculatorResultText());
}
/// <summary>
/// Rotate circular shift, hexadecimal notation, QWord
/// </summary>
[TestMethod]
[Priority(1)]
public void Circular_Operator_Hex_LeftShift()
{
page.ProgrammerOperators.HexButton.Click();
page.ProgrammerOperators.SetRotateCircularShift();
page.ProgrammerOperators.AButton.Click();
page.ProgrammerOperators.RoLButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1 4", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Circular_Operator_Hex_RightShift()
{
page.ProgrammerOperators.HexButton.Click();
page.ProgrammerOperators.SetRotateCircularShift();
page.ProgrammerOperators.FButton.Click();
page.ProgrammerOperators.RoRButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7", page.CalculatorResults.GetCalculatorResultText());
}
#endregion
/// <summary>
/// Rotate through carry circular shift, decimal notation, QWord
/// </summary>
#region Rotate-Through-Carry-Circular-shift operators
[TestMethod]
[Priority(1)]
public void ThroughCarry_Operator_Decimal_LeftShift()
{
page.ProgrammerOperators.SetRotateThroughCarryCircularShift();
page.StandardOperators.NumberPad.Input(7);
page.StandardOperators.NegateButton.Click();
page.ProgrammerOperators.RoLButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("-14", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void ThroughCarry_Operator_Decimal_RightShift()
{
page.ProgrammerOperators.SetRotateThroughCarryCircularShift();
page.StandardOperators.NumberPad.Input(17);
page.ProgrammerOperators.RoRCarryButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("8", page.CalculatorResults.GetCalculatorResultText());
}
/// <summary>
/// Rotate through carry circular shift, octal notation, QWord
/// </summary>
[TestMethod]
[Priority(1)]
public void ThroughCarry_Operator_Octal_LeftShift()
{
page.ProgrammerOperators.OctButton.Click();
page.ProgrammerOperators.SetRotateThroughCarryCircularShift();
page.StandardOperators.NumberPad.Input(111);
page.ProgrammerOperators.RoLButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("2 2 2", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void ThroughCarry_Operator_Octal_RightShift()
{
page.ProgrammerOperators.OctButton.Click();
page.ProgrammerOperators.SetRotateThroughCarryCircularShift();
page.StandardOperators.NumberPad.Input(111);
page.ProgrammerOperators.RoRCarryButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("4 4", page.CalculatorResults.GetCalculatorResultText());
}
/// <summary>
/// Rotate through carry circular shift, binary notation, QWord
/// </summary>
[TestMethod]
[Priority(1)]
public void ThroughCarry_Operator_Binary_LeftShift()
{
page.ProgrammerOperators.BinButton.Click();
page.ProgrammerOperators.SetRotateThroughCarryCircularShift();
page.StandardOperators.NumberPad.Input(1010);
page.ProgrammerOperators.RoLButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1 0 1 0 0", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void ThroughCarry_Operator_Binary_RightShift()
{
page.ProgrammerOperators.BinButton.Click();
page.ProgrammerOperators.SetRotateThroughCarryCircularShift();
page.StandardOperators.NumberPad.Input(1011);
page.ProgrammerOperators.RoRCarryButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1 0 1", page.CalculatorResults.GetCalculatorResultText());
}
/// <summary>
/// Rotate through carry circular shift, hexadecimal notation, QWord
/// </summary>
[TestMethod]
[Priority(1)]
public void ThroughCarry_Operator_Hex_LeftShift()
{
page.ProgrammerOperators.HexButton.Click();
page.ProgrammerOperators.SetRotateThroughCarryCircularShift();
page.StandardOperators.NumberPad.Input(1010);
page.ProgrammerOperators.RoLButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("2 0 2 0", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void ThroughCarry_Operator_Hex_RightShift()
{
page.ProgrammerOperators.HexButton.Click();
page.ProgrammerOperators.SetRotateThroughCarryCircularShift();
page.StandardOperators.NumberPad.Input(1010);
page.ProgrammerOperators.RoRCarryButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("8 0 8", page.CalculatorResults.GetCalculatorResultText());
}
#endregion
}
}

View File

@ -0,0 +1,621 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using CalculatorUITestFramework;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Appium.Windows;
using System;
using System.Collections.Generic;
namespace CalculatorUITests
{
[TestClass]
public class ScientificModeFunctionalTests
{
private static ScientificCalculatorPage page = new ScientificCalculatorPage();
/// <summary>
/// Initializes the WinAppDriver web driver session.
/// </summary>
/// <param name="context"></param>
[ClassInitialize]
public static void ClassInitialize(TestContext context)
{
// Create session to launch a Calculator window
WinAppDriver.Instance.SetupCalculatorSession(context);
// Ensure that calculator is in scientific mode
page.NavigateToScientificCalculator();
// Ensure that calculator window is large enough to display the memory/history panel; a good size for most tests
page.MemoryPanel.ResizeWindowToDisplayMemoryLabel();
}
/// <summary>
/// Closes the app and WinAppDriver web driver session.
/// </summary>
[ClassCleanup]
public static void ClassCleanup()
{
// Tear down Calculator session.
WinAppDriver.Instance.TearDownCalculatorSession();
}
/// <summary>
/// Ensures the calculator is in a cleared state
/// </summary>
[TestInitialize]
public void TestInit()
{
if ("0" != page.CalculatorResults.GetCalculatorResultText())
{
page.ClearAll();
}
CalculatorApp.EnsureCalculatorHasFocus();
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees);
page.ScientificOperators.ResetFEButton(fEButtonState.Normal);
}
[TestCleanup]
public void TestCleanup()
{
page.ClearAll();
}
#region Smoke Tests
[TestMethod]
[Priority(0)]
public void SmokeTest_Cube()
{
page.StandardOperators.NumberPad.Input(3);
page.ScientificOperators.XPower3Button.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("27", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(0)]
public void SmokeTest_Sin()
{
page.StandardOperators.NumberPad.Input(90);
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.SinButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(0)]
public void SmokeTest_Tanh()
{
page.StandardOperators.NumberPad.Input(90);
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.HypShiftButton.Click();
page.ScientificOperators.TanhButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(0)]
public void SmokeTest_InvCos()
{
page.StandardOperators.NumberPad.Input(1);
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.TrigShiftButton.Click();
page.ScientificOperators.InvCosButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("0", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(0)]
public void SmokeTest_Floor()
{
page.StandardOperators.NumberPad.Input(5.9);
page.ScientificOperators.FuncButton.Click();
page.ScientificOperators.FloorButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("5", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(0)]
public void SmokeTest_Parentheses()
{
page.StandardOperators.NumberPad.Input(3);
page.StandardOperators.MultiplyButton.Click();
page.ScientificOperators.ParenthesisLeftButton.Click();
page.StandardOperators.NumberPad.Input(2);
page.StandardOperators.PlusButton.Click();
page.StandardOperators.NumberPad.Input(2);
page.ScientificOperators.ParenthesisRightButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("12", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(0)]
public void SmokeTest_RadianAngleOperator()
{
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Radians);
page.ScientificOperators.PiButton.Click();
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.CosButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("-1", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(0)]
public void SmokeTest_GradianAngleOperator()
{
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Gradians);
page.StandardOperators.NumberPad.Input(100);
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.SinButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(0)]
public void SmokeTest_FixedToExponential()
{
page.ScientificOperators.FixedToExponentialButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("0.e+0", page.CalculatorResults.GetCalculatorResultText());
}
#endregion
#region Advanced Arithmetic Tests
[TestMethod]
[Priority(1)]
public void Operator_XPowerY()
{
page.StandardOperators.NumberPad.Input(3);
page.ScientificOperators.XPowerYButton.Click();
page.StandardOperators.NumberPad.Input(5);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("243", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Operator_PowerOf10Button()
{
page.StandardOperators.NumberPad.Input(5);
page.ScientificOperators.PowerOf10Button.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("100,000", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Operator_LogButton()
{
page.StandardOperators.NumberPad.Input(10000);
page.ScientificOperators.LogButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("4", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Operator_LnButton()
{
page.ScientificOperators.EulerButton.Click();
page.ScientificOperators.LnButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Operator_AbsButton()
{
page.StandardOperators.NumberPad.Input(25);
page.ScientificOperators.NegateButton.Click();
page.ScientificOperators.AbsButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("25", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Operator_ExpButton()
{
page.StandardOperators.NumberPad.Input(4);
page.ScientificOperators.ExpButton.Click();
page.StandardOperators.NumberPad.Input(4);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("40,000", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Operator_ModButton()
{
page.StandardOperators.NumberPad.Input(53);
page.ScientificOperators.ModButton.Click();
page.StandardOperators.NumberPad.Input(10);
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("3", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Operator_FactorialButton()
{
page.StandardOperators.NumberPad.Input(4);
page.ScientificOperators.FactorialButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("24", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Operator_CeilingButton()
{
page.StandardOperators.NumberPad.Input(4.1);
page.ScientificOperators.FuncButton.Click();
page.ScientificOperators.CeilButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("5", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Operator_RandomButton()
{
page.ScientificOperators.FuncButton.Click();
page.ScientificOperators.RandButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.IsTrue(page.CalculatorResults.GetCalculatorResultText().StartsWith("0."));
}
[TestMethod]
[Priority(1)]
public void Operator_DmsButton()
{
page.StandardOperators.NumberPad.Input(2.999);
page.ScientificOperators.FuncButton.Click();
page.ScientificOperators.DmsButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("2.59564", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(1)]
public void Operator_DegreesButton()
{
page.StandardOperators.NumberPad.Input(2.59564);
page.ScientificOperators.FuncButton.Click();
page.ScientificOperators.DegreesButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("2.999", page.CalculatorResults.GetCalculatorResultText());
}
#endregion
#region Trigonometry Tests
[TestMethod]
[Priority(2)]
public void Trig_CosButton()
{
page.StandardOperators.NumberPad.Input(180);
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.CosButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("-1", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(2)]
public void Trig_TanButton()
{
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees);
page.StandardOperators.NumberPad.Input(45);
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.TanButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(2)]
public void Trig_SecButton()
{
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees);
page.StandardOperators.NumberPad.Input(180);
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.SecButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("-1", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(2)]
public void Trig_CscButton()
{
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees);
page.StandardOperators.NumberPad.Input(90);
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.CscButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(2)]
public void Trig_CotButton()
{
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees);
page.StandardOperators.NumberPad.Input(45);
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.CotButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(2)]
public void Trig_InvSinButton()
{
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees);
page.StandardOperators.NumberPad.Input(1);
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.TrigShiftButton.Click();
page.ScientificOperators.InvSinButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("90", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(2)]
public void Trig_InvTanButton()
{
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees);
page.StandardOperators.NumberPad.Input(1);
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.TrigShiftButton.Click();
page.ScientificOperators.InvTanButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("45", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(2)]
public void Trig_InvSecButton()
{
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees);
page.StandardOperators.NumberPad.Input(1);
page.ScientificOperators.NegateButton.Click();
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.TrigShiftButton.Click();
page.ScientificOperators.InvSecButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("180", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(2)]
public void Trig_InvCscButton()
{
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees);
page.StandardOperators.NumberPad.Input(1);
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.TrigShiftButton.Click();
page.ScientificOperators.InvCscButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("90", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(2)]
public void Trig_InvCotButton()
{
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees);
page.StandardOperators.NumberPad.Input(1);
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.TrigShiftButton.Click();
page.ScientificOperators.InvCotButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("45", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(2)]
public void Trig_SinhButton()
{
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees);
page.StandardOperators.NumberPad.Input(1);
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.HypShiftButton.Click();
page.ScientificOperators.SinhButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.IsTrue(page.CalculatorResults.GetCalculatorResultText().StartsWith("1.175201"));
}
[TestMethod]
[Priority(2)]
public void Trig_CoshButton()
{
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees);
page.StandardOperators.NumberPad.Input(1);
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.HypShiftButton.Click();
page.ScientificOperators.CoshButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.IsTrue(page.CalculatorResults.GetCalculatorResultText().StartsWith("1.54308"));
}
[TestMethod]
[Priority(2)]
public void Trig_SechButton()
{
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees);
page.StandardOperators.NumberPad.Input(1);
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.HypShiftButton.Click();
page.ScientificOperators.SechButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.IsTrue(page.CalculatorResults.GetCalculatorResultText().StartsWith("0.64805"));
}
[TestMethod]
[Priority(2)]
public void Trig_CschButton()
{
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees);
page.StandardOperators.NumberPad.Input(1);
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.HypShiftButton.Click();
page.ScientificOperators.CschButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.IsTrue(page.CalculatorResults.GetCalculatorResultText().StartsWith("0.850918"));
}
[TestMethod]
[Priority(2)]
public void Trig_CothButton()
{
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees);
page.StandardOperators.NumberPad.Input(45);
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.HypShiftButton.Click();
page.ScientificOperators.CothButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("1", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(2)]
public void Trig_InvSinhButton()
{
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees);
page.StandardOperators.NumberPad.Input(1);
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.TrigShiftButton.Click();
page.ScientificOperators.HypShiftButton.Click();
page.ScientificOperators.InvSinhButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.IsTrue(page.CalculatorResults.GetCalculatorResultText().StartsWith("0.881373"));
}
[TestMethod]
[Priority(2)]
public void Trig_InvCoshButton()
{
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees);
page.StandardOperators.NumberPad.Input(1);
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.TrigShiftButton.Click();
page.ScientificOperators.HypShiftButton.Click();
page.ScientificOperators.InvCoshButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("0", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(2)]
public void Trig_InvTanhButton()
{
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees);
page.StandardOperators.NumberPad.Input(0.0);
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.TrigShiftButton.Click();
page.ScientificOperators.HypShiftButton.Click();
page.ScientificOperators.InvTanhButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("0", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(2)]
public void Trig_InvSechButton()
{
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees);
page.StandardOperators.NumberPad.Input(1);
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.TrigShiftButton.Click();
page.ScientificOperators.HypShiftButton.Click();
page.ScientificOperators.InvSechButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.AreEqual("0", page.CalculatorResults.GetCalculatorResultText());
}
[TestMethod]
[Priority(2)]
public void Trig_InvCschButton()
{
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees);
page.StandardOperators.NumberPad.Input(1);
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.TrigShiftButton.Click();
page.ScientificOperators.HypShiftButton.Click();
page.ScientificOperators.InvCschButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.IsTrue(page.CalculatorResults.GetCalculatorResultText().StartsWith("0.881373"));
}
[TestMethod]
[Priority(2)]
public void Trig_InvCothButton()
{
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees);
page.StandardOperators.NumberPad.Input(2);
page.ScientificOperators.TrigButton.Click();
page.ScientificOperators.TrigShiftButton.Click();
page.ScientificOperators.HypShiftButton.Click();
page.ScientificOperators.InvCothButton.Click();
page.StandardOperators.EqualButton.Click();
Assert.IsTrue(page.CalculatorResults.GetCalculatorResultText().StartsWith("0.549306"));
}
#endregion
}
}