2020-03-17 23:03:02 +08:00
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
2020-04-01 22:05:01 +08:00
|
|
|
|
using OpenQA.Selenium.Appium;
|
2020-03-17 23:03:02 +08:00
|
|
|
|
using OpenQA.Selenium.Appium.Windows;
|
|
|
|
|
using OpenQA.Selenium.Interactions;
|
|
|
|
|
|
|
|
|
|
namespace PowerToysTests
|
|
|
|
|
{
|
|
|
|
|
[TestClass]
|
|
|
|
|
public class PowerToysTrayTests : PowerToysSession
|
|
|
|
|
{
|
|
|
|
|
private bool isSettingsOpened;
|
|
|
|
|
private bool isTrayOpened;
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void SettingsOpen()
|
|
|
|
|
{
|
|
|
|
|
OpenSettings();
|
|
|
|
|
|
|
|
|
|
//check settings window opened
|
2020-04-10 23:52:16 +08:00
|
|
|
|
WindowsElement settingsWindow = WaitElementByName("PowerToys Settings");
|
2020-03-17 23:03:02 +08:00
|
|
|
|
Assert.IsNotNull(settingsWindow);
|
|
|
|
|
|
|
|
|
|
isSettingsOpened = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void SettingsOpenWithContextMenu()
|
|
|
|
|
{
|
|
|
|
|
//open tray
|
|
|
|
|
trayButton.Click();
|
|
|
|
|
isTrayOpened = true;
|
|
|
|
|
|
|
|
|
|
//open PowerToys context menu
|
|
|
|
|
WindowsElement pt = session.FindElementByName("PowerToys");
|
|
|
|
|
Assert.IsNotNull(pt);
|
|
|
|
|
|
|
|
|
|
new Actions(session).MoveToElement(pt).ContextClick().Perform();
|
2020-04-10 23:52:16 +08:00
|
|
|
|
|
2020-03-17 23:03:02 +08:00
|
|
|
|
//open settings
|
2020-04-10 23:52:16 +08:00
|
|
|
|
WaitElementByXPath("//MenuItem[@Name=\"Settings\"]").Click();
|
|
|
|
|
|
2020-03-17 23:03:02 +08:00
|
|
|
|
//check settings window opened
|
2020-04-10 23:52:16 +08:00
|
|
|
|
WindowsElement settingsWindow = WaitElementByName("PowerToys Settings");
|
2020-03-17 23:03:02 +08:00
|
|
|
|
Assert.IsNotNull(settingsWindow);
|
|
|
|
|
|
|
|
|
|
isSettingsOpened = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void PowerToysExit()
|
|
|
|
|
{
|
|
|
|
|
//open PowerToys context menu
|
|
|
|
|
trayButton.Click();
|
|
|
|
|
isTrayOpened = true;
|
|
|
|
|
|
2020-04-01 22:05:01 +08:00
|
|
|
|
WindowsElement notificationOverflow = session.FindElementByName("Notification Overflow");
|
|
|
|
|
AppiumWebElement overflowArea = notificationOverflow.FindElementByName("Overflow Notification Area");
|
|
|
|
|
AppiumWebElement powerToys = overflowArea.FindElementByName("PowerToys");
|
|
|
|
|
Assert.IsNotNull(powerToys);
|
2020-03-17 23:03:02 +08:00
|
|
|
|
|
2020-04-01 22:05:01 +08:00
|
|
|
|
new Actions(session).MoveToElement(powerToys).ContextClick().Perform();
|
2020-04-10 23:52:16 +08:00
|
|
|
|
|
2020-03-17 23:03:02 +08:00
|
|
|
|
//exit
|
2020-04-10 23:52:16 +08:00
|
|
|
|
WaitElementByXPath("//MenuItem[@Name=\"Exit\"]").Click();
|
|
|
|
|
|
2020-03-17 23:03:02 +08:00
|
|
|
|
//check PowerToys exited
|
2020-04-01 22:05:01 +08:00
|
|
|
|
powerToys = null;
|
2020-03-17 23:03:02 +08:00
|
|
|
|
try
|
|
|
|
|
{
|
2020-04-01 22:05:01 +08:00
|
|
|
|
notificationOverflow = session.FindElementByName("Notification Overflow");
|
|
|
|
|
overflowArea = notificationOverflow.FindElementByName("Overflow Notification Area");
|
|
|
|
|
powerToys = overflowArea.FindElementByName("PowerToys");
|
2020-03-17 23:03:02 +08:00
|
|
|
|
}
|
|
|
|
|
catch (OpenQA.Selenium.WebDriverException)
|
|
|
|
|
{
|
|
|
|
|
//expected, PowerToys shouldn't be here
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LaunchPowerToys();
|
2020-04-01 22:05:01 +08:00
|
|
|
|
Assert.IsNull(powerToys);
|
2020-03-17 23:03:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ClassInitialize]
|
|
|
|
|
public static void ClassInitialize(TestContext context)
|
|
|
|
|
{
|
|
|
|
|
Setup(context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ClassCleanup]
|
|
|
|
|
public static void ClassCleanup()
|
|
|
|
|
{
|
|
|
|
|
TearDown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestInitialize]
|
|
|
|
|
public void TestInitialize()
|
|
|
|
|
{
|
|
|
|
|
isSettingsOpened = false;
|
|
|
|
|
isTrayOpened = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestCleanup]
|
|
|
|
|
public void TestCleanup()
|
|
|
|
|
{
|
|
|
|
|
if (isSettingsOpened)
|
|
|
|
|
{
|
|
|
|
|
CloseSettings();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isTrayOpened)
|
|
|
|
|
{
|
|
|
|
|
trayButton.Click();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|