calculator/src/CalculatorUITestFramework/ProgrammerOperatorsPanel.cs
Daniel-Parker 2cafb0dc88
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>
2020-04-28 10:54:55 -07:00

203 lines
12 KiB
C#

// 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();
}
}
}