mattercontrol/Tests/MatterControl.AutomationTests/FileMenuTest.cs

134 lines
3.8 KiB
C#
Raw Normal View History

using System;
using System.Threading;
using System.Threading.Tasks;
using MatterHackers.Agg.UI.Tests;
2016-03-04 14:36:49 -08:00
using MatterHackers.GuiAutomation;
using MatterHackers.MatterControl.PrintQueue;
using NUnit.Framework;
2016-03-04 14:36:49 -08:00
namespace MatterHackers.MatterControl.Tests.Automation
2016-03-04 14:36:49 -08:00
{
[TestFixture, Category("MatterControl.UI.Automation"), RunInApplicationDomain]
2016-03-04 14:36:49 -08:00
public class FileMenuTest
{
[Test, Apartment(ApartmentState.STA)]
public async Task FileMenuAddPrinter()
2016-03-04 14:36:49 -08:00
{
AutomationTest testToRun = (testRunner) =>
2016-03-04 14:36:49 -08:00
{
testRunner.CloseSignInAndPrinterSelect();
2016-03-04 14:36:49 -08:00
2016-10-19 11:10:30 -07:00
testRunner.ClickByName("File Menu");
testRunner.Wait(1);
testRunner.ClickByName("Add Printer Menu Item");
testRunner.Wait(1);
Assert.IsTrue(testRunner.WaitForName("Select Make", 3));
2016-03-04 14:36:49 -08:00
2016-10-19 11:10:30 -07:00
testRunner.ClickByName("Cancel Wizard Button");
return Task.FromResult(0);
2016-03-04 14:36:49 -08:00
};
await MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items);
2016-03-04 14:36:49 -08:00
}
[Test, Apartment(ApartmentState.STA)]
public async Task AddToQueueMenuItemAddsSingleFile()
2016-03-04 14:36:49 -08:00
{
AutomationTest testToRun = (testRunner) =>
2016-03-04 14:36:49 -08:00
{
testRunner.CloseSignInAndPrinterSelect();
2016-03-04 14:36:49 -08:00
2016-10-19 11:10:30 -07:00
testRunner.ClickByName("File Menu");
testRunner.Wait(1);
testRunner.ClickByName("Add File To Queue Menu Item");
testRunner.Wait(2);
2016-03-04 14:36:49 -08:00
2016-10-19 11:10:30 -07:00
string queueItemPath = MatterControlUtilities.GetTestItemPath("Fennec_Fox.stl");
2016-03-04 14:36:49 -08:00
2016-10-19 11:10:30 -07:00
int queueBeforeCount = QueueData.Instance.Count;
2016-10-19 11:10:30 -07:00
testRunner.Type(queueItemPath);
testRunner.Wait(1);
testRunner.Type("{Enter}");
testRunner.Wait(2);
Assert.IsTrue(testRunner.WaitForName("Queue Item Fennec_Fox", 2));
2016-03-04 14:36:49 -08:00
2016-10-19 11:10:30 -07:00
int queueAfterCount = QueueData.Instance.Count;
2016-03-04 14:36:49 -08:00
Assert.IsTrue(queueAfterCount == queueBeforeCount + 1);
return Task.FromResult(0);
2016-03-04 14:36:49 -08:00
};
await MatterControlUtilities.RunTest(testToRun);
2016-03-04 14:36:49 -08:00
}
[Test, Apartment(ApartmentState.STA)]
public async Task AddToQueueMenuItemAddsMultipleFiles()
2016-03-04 14:36:49 -08:00
{
AutomationTest testToRun = (testRunner) =>
2016-03-04 14:36:49 -08:00
{
testRunner.CloseSignInAndPrinterSelect();
2016-10-19 11:10:30 -07:00
testRunner.ClickByName("File Menu");
testRunner.Wait(1);
testRunner.ClickByName("Add File To Queue Menu Item");
testRunner.Wait(2);
2016-03-04 14:36:49 -08:00
2016-10-19 11:10:30 -07:00
string queueItemPath = MatterControlUtilities.GetTestItemPath("Fennec_Fox.stl");
2016-03-04 14:36:49 -08:00
2016-10-19 11:10:30 -07:00
string pathToSecondQueueItem = MatterControlUtilities.GetTestItemPath("Batman.stl");
string textForBothQueueItems = string.Format("\"{0}\" \"{1}\"", queueItemPath, pathToSecondQueueItem);
2016-03-04 14:36:49 -08:00
2016-10-19 11:10:30 -07:00
int queueBeforeAddCount = QueueData.Instance.Count;
2016-03-04 14:36:49 -08:00
2016-10-19 11:10:30 -07:00
testRunner.Type(textForBothQueueItems);
testRunner.Wait(2);
testRunner.Type("{Enter}");
testRunner.Wait(2);
Assert.IsTrue(testRunner.WaitForName("Queue Item Fennec_Fox", 2));
Assert.IsTrue(testRunner.WaitForName("Queue Item Batman", 2));
2016-10-19 11:10:30 -07:00
int queueAfterAddCount = QueueData.Instance.Count;
2016-03-04 14:36:49 -08:00
Assert.IsTrue(queueAfterAddCount == queueBeforeAddCount + 2);
return Task.FromResult(0);
2016-03-04 14:36:49 -08:00
};
await MatterControlUtilities.RunTest(testToRun);
2016-03-04 14:36:49 -08:00
}
[Test, Apartment(ApartmentState.STA)]
public async Task AddToQueueMenuItemAddsZipFiles()
2016-03-04 14:36:49 -08:00
{
AutomationTest testToRun = (testRunner) =>
2016-03-04 14:36:49 -08:00
{
testRunner.CloseSignInAndPrinterSelect();
2016-03-04 14:36:49 -08:00
2016-10-19 11:10:30 -07:00
testRunner.ClickByName("File Menu");
testRunner.Wait(1);
testRunner.ClickByName("Add File To Queue Menu Item");
testRunner.Wait(2);
2016-03-04 14:36:49 -08:00
2016-10-19 11:10:30 -07:00
int beforeCount = QueueData.Instance.Count;
2016-10-19 11:10:30 -07:00
string pathToType = MatterControlUtilities.GetTestItemPath("Batman.zip");
testRunner.Type(pathToType);
testRunner.Wait(1);
testRunner.Type("{Enter}");
testRunner.Wait(1);
2016-03-04 14:36:49 -08:00
Assert.IsTrue(testRunner.WaitForName("Queue Item Batman", 1));
Assert.IsTrue(testRunner.WaitForName("Queue Item 2013-01-25_Mouthpiece_v2", 1));
Assert.IsTrue(QueueData.Instance.Count == beforeCount + 2);
return Task.FromResult(0);
2016-03-04 14:36:49 -08:00
};
await MatterControlUtilities.RunTest(testToRun);
2016-03-04 14:36:49 -08:00
}
}
}