Editor opening tests (#1633)

* editor opening tests
* moved fancy zones opening method
* moved settings restore to base class
* changed launch
* fixed tray button search 
* added exit function
This commit is contained in:
Seraphima Zykova
2020-03-19 19:25:51 +03:00
committed by GitHub
parent f507ef5e56
commit 35054c1f59
5 changed files with 446 additions and 101 deletions

View File

@@ -14,9 +14,7 @@ namespace PowerToysTests
{
[TestClass]
public class FancyZonesSettingsTests : PowerToysSession
{
private static string _settingsPath = "";
private string _initialSettings = "";
{
private JObject _initialSettingsJson;
private static WindowsElement _saveButton;
@@ -41,23 +39,19 @@ namespace PowerToysTests
_scrollDown = new Actions(session).MoveToElement(_saveButton).MoveByOffset(0, _saveButton.Rect.Height).ContextClick()
.SendKeys(OpenQA.Selenium.Keys.PageDown + OpenQA.Selenium.Keys.PageDown);
Assert.IsNotNull(_scrollDown);
}
private static void OpenFancyZonesSettings()
{
WindowsElement fzNavigationButton = session.FindElementByXPath("//Button[@Name=\"FancyZones\"]");
Assert.IsNotNull(fzNavigationButton);
fzNavigationButton.Click();
fzNavigationButton.Click();
ShortWait();
}
private JObject getProperties()
{
JObject settings = JObject.Parse(File.ReadAllText(_settingsPath));
return settings["properties"].ToObject<JObject>();
}
private JObject getProperties()
{
try
{
JObject settings = JObject.Parse(File.ReadAllText(_settingsPath));
return settings["properties"].ToObject<JObject>();
}
catch (Newtonsoft.Json.JsonReaderException)
{
return new JObject();
}
}
private T getPropertyValue<T>(string propertyName)
@@ -237,19 +231,7 @@ namespace PowerToysTests
WindowsElement fzTitle = session.FindElementByName("FancyZones Settings");
Assert.IsNotNull(fzTitle);
}
/*
[TestMethod]
public void EditorOpen()
{
session.FindElementByXPath("//Button[@Name=\"Edit zones\"]").Click();
ShortWait();
WindowsElement editorWindow = session.FindElementByName("FancyZones Editor");
Assert.IsNotNull(editorWindow);
editorWindow.SendKeys(OpenQA.Selenium.Keys.Alt + OpenQA.Selenium.Keys.F4);
}
*/
/*
* click each toggle,
* save changes,
@@ -721,14 +703,6 @@ namespace PowerToysTests
public static void ClassInitialize(TestContext context)
{
Setup(context);
string settingsFolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft/PowerToys/FancyZones");
if (!Directory.Exists(settingsFolderPath))
{
Directory.CreateDirectory(settingsFolderPath);
}
_settingsPath = settingsFolderPath + "/settings.json";
Init();
}
@@ -751,31 +725,25 @@ namespace PowerToysTests
}
TearDown();
}
[TestInitialize]
public void TestInitialize()
{
try
{
_initialSettings = File.ReadAllText(_settingsPath);
_initialSettingsJson = JObject.Parse(_initialSettings);
}
catch (System.IO.FileNotFoundException)
{
_initialSettings = "";
}
}
[TestInitialize]
public void TestInitialize()
{
try
{
_initialSettingsJson = JObject.Parse(_initialSettings);
}
catch (Newtonsoft.Json.JsonReaderException)
{
//empty settings
}
}
[TestCleanup]
public void TestCleanup()
{
ScrollUp();
if (_initialSettings.Length > 0)
{
File.WriteAllText(_settingsPath, _initialSettings);
}
ScrollUp();
}
}
}