mattercontrol/Tests/MatterControl.AutomationTests/LibraryDownloadsTest.cs

223 lines
6.2 KiB
C#
Raw Normal View History

using System;
using System.Threading;
using System.Threading.Tasks;
using MatterHackers.Agg.UI.Tests;
using MatterHackers.GuiAutomation;
using NUnit.Framework;
namespace MatterHackers.MatterControl.Tests.Automation
{
[TestFixture, Category("MatterControl.UI.Automation"), RunInApplicationDomain]
public class LibraryDownloadsTests
{
[Test, Apartment(ApartmentState.STA)]
public async Task DownloadsAddButtonAddsMultipleFiles()
{
AutomationTest testToRun = (testRunner) =>
{
testRunner.CloseSignInAndPrinterSelect();
2016-10-19 11:10:30 -07:00
MatterControlUtilities.CreateDownloadsSubFolder();
//Navigate to Downloads Library Provider
testRunner.NavigateToFolder("Downloads Row Item Collection");
testRunner.NavigateToFolder("-Temporary Row Item Collection");
2016-10-19 11:10:30 -07:00
testRunner.ClickByName("Library Add Button");
2017-02-01 10:12:31 -08:00
testRunner.Delay(3);
2016-10-19 11:10:30 -07:00
2017-02-01 10:12:31 -08:00
testRunner.Delay(2);
2016-10-19 11:10:30 -07:00
// Add both files to the FileOpen dialog
testRunner.Type(
string.Format(
"\"{0}\" \"{1}\"",
MatterControlUtilities.GetTestItemPath("Fennec_Fox.stl"),
MatterControlUtilities.GetTestItemPath("Batman.stl")));
2017-02-01 10:12:31 -08:00
testRunner.Delay(1);
2016-10-19 11:10:30 -07:00
testRunner.Type("{Enter}");
Assert.IsTrue(testRunner.WaitForName("Row Item Fennec Fox", 2), "Fennec Fox item exists");
Assert.IsTrue(testRunner.WaitForName("Row Item Batman", 2), "Batman item exists");
2017-02-01 10:12:31 -08:00
testRunner.Delay(1);
return Task.CompletedTask;
};
2016-10-19 11:10:30 -07:00
// TODO: The standard assignment without a try/catch should be used and DeleteDownloadsSubFolder should be called from a TearDown method
try
{
await MatterControlUtilities.RunTest(testToRun);
}
catch { }
finally
{
MatterControlUtilities.DeleteDownloadsSubFolder();
}
}
[Test, Apartment(ApartmentState.STA)]
public async Task DownloadsAddButtonAddsAMFFiles()
{
AutomationTest testToRun = (testRunner) =>
{
testRunner.CloseSignInAndPrinterSelect();
2016-10-19 11:10:30 -07:00
MatterControlUtilities.CreateDownloadsSubFolder();
//Navigate to Downloads Library Provider
testRunner.NavigateToFolder("Downloads Row Item Collection");
testRunner.NavigateToFolder("-Temporary Row Item Collection");
2016-10-19 11:10:30 -07:00
testRunner.ClickByName("Library Add Button");
2017-02-01 10:12:31 -08:00
testRunner.Delay(2);
2016-10-19 11:10:30 -07:00
//Add AMF part items to Downloads and then type paths into file dialog
2017-02-01 10:12:31 -08:00
testRunner.Delay(2);
2016-10-19 11:10:30 -07:00
testRunner.Type(MatterControlUtilities.GetTestItemPath("Rook.amf"));
2017-02-01 10:12:31 -08:00
testRunner.Delay(1);
2016-10-19 11:10:30 -07:00
testRunner.Type("{Enter}");
Assert.IsTrue(testRunner.WaitForName("Row Item Rook", 2), "Rook item exists");
2017-02-01 10:12:31 -08:00
testRunner.Delay(1);
return Task.CompletedTask;
};
try
{
await MatterControlUtilities.RunTest(testToRun);
}
catch { }
finally
{
MatterControlUtilities.DeleteDownloadsSubFolder();
}
}
[Test, Apartment(ApartmentState.STA)]
public async Task DownloadsAddButtonAddsZipFiles()
{
AutomationTest testToRun = (testRunner) =>
{
testRunner.CloseSignInAndPrinterSelect();
2016-10-19 11:10:30 -07:00
MatterControlUtilities.CreateDownloadsSubFolder();
// Navigate to Downloads Library Provider
testRunner.NavigateToFolder("Downloads Row Item Collection");
testRunner.NavigateToFolder("-Temporary Row Item Collection");
2016-10-19 11:10:30 -07:00
testRunner.ClickByName("Library Add Button");
2017-02-01 10:12:31 -08:00
testRunner.Delay(2);
2016-10-19 11:10:30 -07:00
// Add AMF part items to Downloads and then type paths into file dialogs
2017-02-01 10:12:31 -08:00
testRunner.Delay(2);
2016-10-19 11:10:30 -07:00
testRunner.Type(MatterControlUtilities.GetTestItemPath("Test.zip"));
2017-02-01 10:12:31 -08:00
testRunner.Delay(1);
2016-10-19 11:10:30 -07:00
testRunner.Type("{Enter}");
Assert.IsTrue(testRunner.WaitForName("Row Item Chinese Dragon", 2), "Chinese Dragon item exists");
Assert.IsTrue(testRunner.WaitForName("Row Item chichen-itza pyramid", 2), "chichen-itza item exists");
Assert.IsTrue(testRunner.WaitForName("Row Item Circle Calibration", 2), "Circle Calibration item exists");
2016-10-19 11:10:30 -07:00
2017-02-01 10:12:31 -08:00
testRunner.Delay(1);
2016-10-19 11:10:30 -07:00
return Task.CompletedTask;
};
try
{
MatterControlUtilities.RunTest(testToRun);
}
catch { }
// Give MatterControl a moment to shutdown
Thread.Sleep(2000);
try
{
// Then attempt to clean up
MatterControlUtilities.DeleteDownloadsSubFolder();
}
catch { }
}
[Test, Apartment(ApartmentState.STA)]
public async Task RenameDownloadsPrintItem()
{
AutomationTest testToRun = (testRunner) =>
{
testRunner.CloseSignInAndPrinterSelect();
2016-10-19 11:10:30 -07:00
MatterControlUtilities.CreateDownloadsSubFolder();
//Navigate to Downloads Library Provider
testRunner.NavigateToFolder("Downloads Row Item Collection");
testRunner.NavigateToFolder("-Temporary Row Item Collection");
2016-10-19 11:10:30 -07:00
testRunner.ClickByName("Library Add Button");
2017-02-01 10:12:31 -08:00
testRunner.Delay(2);
2016-10-19 11:10:30 -07:00
testRunner.Type(MatterControlUtilities.GetTestItemPath("Batman.stl"));
2017-02-01 10:12:31 -08:00
testRunner.Delay(1);
2016-10-19 11:10:30 -07:00
testRunner.Type("{Enter}");
//Rename added item
2017-06-14 09:56:51 -07:00
testRunner.ClickByName("Library Edit Button");
2016-10-19 11:10:30 -07:00
testRunner.ClickByName("Row Item Batman");
testRunner.LibraryRenameSelectedItem();
2017-02-01 10:12:31 -08:00
testRunner.Delay(.5);
2016-10-19 11:10:30 -07:00
testRunner.Type("Batman Renamed");
testRunner.ClickByName("Rename Button");
Assert.IsTrue(testRunner.WaitForName("Row Item Batman Renamed", 2));
2016-10-19 11:10:30 -07:00
return Task.CompletedTask;
};
try
{
await MatterControlUtilities.RunTest(testToRun);
}
catch { }
finally
{
MatterControlUtilities.DeleteDownloadsSubFolder();
}
}
[Test, Apartment(ApartmentState.STA)]
public async Task CreateFolder()
{
AutomationTest testToRun = (testRunner) =>
{
testRunner.CloseSignInAndPrinterSelect();
2016-10-19 11:10:30 -07:00
MatterControlUtilities.CreateDownloadsSubFolder();
2016-10-19 11:10:30 -07:00
//Navigate to Downloads Library Provider
testRunner.NavigateToFolder("Downloads Row Item Collection");
testRunner.NavigateToFolder("-Temporary Row Item Collection");
2016-10-19 11:10:30 -07:00
string newFolderName = "New Folder";
2016-10-19 11:10:30 -07:00
testRunner.ClickByName("Create Folder From Library Button");
2017-02-01 10:12:31 -08:00
testRunner.Delay(2);
2016-10-19 11:10:30 -07:00
testRunner.Type(newFolderName);
testRunner.ClickByName("Create Folder Button");
2017-02-01 10:12:31 -08:00
testRunner.Delay(2);
Assert.IsTrue(testRunner.WaitForName(newFolderName + " Row Item Collection", 2), $"{newFolderName} exists");
return Task.CompletedTask;
};
2016-09-19 17:13:00 -07:00
try
{
await MatterControlUtilities.RunTest(testToRun);
2016-09-19 17:13:00 -07:00
}
catch { }
finally
{
MatterControlUtilities.DeleteDownloadsSubFolder();
2016-09-19 17:13:00 -07:00
}
}
}
}