mattercontrol/Tests/MatterControl.AutomationTests/LocalLibraryTests.cs

259 lines
7.8 KiB
C#
Raw Normal View History

using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MatterHackers.Agg.UI;
using MatterHackers.MatterControl.PrintQueue;
using NUnit.Framework;
namespace MatterHackers.MatterControl.Tests.Automation
{
[TestFixture, Category("MatterControl.UI.Automation"), RunInApplicationDomain, Apartment(ApartmentState.STA)]
public class LocalLibraryTests
{
[Test]
public async Task LocalLibraryAddButtonAddSingleItemToLibrary()
{
await MatterControlUtilities.RunTest((testRunner) =>
{
2018-10-10 13:33:16 -07:00
testRunner.AddAndSelectPrinter();
testRunner.AddTestAssetsToLibrary(new[] { "Batman.stl" });
return Task.CompletedTask;
});
}
[Test]
public async Task LocalLibraryAddButtonAddsMultipleItemsToLibrary()
{
await MatterControlUtilities.RunTest((testRunner) =>
{
2018-10-10 13:33:16 -07:00
testRunner.AddAndSelectPrinter();
testRunner.AddTestAssetsToLibrary(new[] { "Rook.amf", "Batman.stl" });
return Task.CompletedTask;
});
}
[Test]
public async Task LocalLibraryAddButtonAddAMFToLibrary()
{
await MatterControlUtilities.RunTest((testRunner) =>
{
2018-10-10 13:33:16 -07:00
testRunner.AddAndSelectPrinter();
testRunner.AddTestAssetsToLibrary(new[] { "Rook.amf" });
return Task.CompletedTask;
}, overrideWidth: 1024, overrideHeight: 800);
}
[Test]
public async Task ParentFolderRefreshedOnPathPop()
{
// Expected: When descending into a child folder and moving items into the parent, popping the path to the parent should refresh and show the moved content
await MatterControlUtilities.RunTest(testRunner =>
{
2018-10-10 13:33:16 -07:00
testRunner.AddAndSelectPrinter();
// Navigate to Local Library
testRunner.NavigateToFolder("Local Library Row Item Collection");
string folderID = testRunner.CreateChildFolder("New Folder");
testRunner.DoubleClickByName(folderID);
// Add Library item
testRunner.InvokeLibraryAddDialog();
testRunner.Delay(2);
testRunner.Type(MatterControlUtilities.GetTestItemPath("Batman.stl"));
testRunner.Delay(1);
testRunner.Type("{Enter}");
string newFileID = "Row Item Batman";
testRunner.ClickByName(newFileID);
testRunner.LibraryMoveSelectedItem();
testRunner.NavigateToFolder("Local Library Row Item Collection");
// Click Move
testRunner.ClickByName("Accept Button");
// Wait for closed window/closed row
testRunner.WaitForWidgetDisappear("Move Item Window", 5);
testRunner.WaitForWidgetDisappear("Row Item Batman", 2);
// Return to the Local Library folder
testRunner.ClickByName("Library Up Button");
// Assert that the expected item appears in the parent after popping the path
testRunner.ClickByName(newFileID);
return Task.CompletedTask;
});
}
[Test]
public async Task LocalLibraryAddButtonAddZipToLibrary()
{
await MatterControlUtilities.RunTest((testRunner) =>
{
2018-10-10 13:33:16 -07:00
testRunner.AddAndSelectPrinter();
2016-10-19 11:10:30 -07:00
// Navigate to Local Library
testRunner.NavigateToFolder("Local Library Row Item Collection");
2016-10-19 11:10:30 -07:00
// Make sure that Item does not exist before the test begins
Assert.IsFalse(testRunner.WaitForName("Row Item Batman", 1), "Batman part should not exist at test start");
Assert.IsFalse(testRunner.WaitForName("Row Item 2013-01-25 Mouthpiece V2", 1), "Mouthpiece part should not exist at test start");
2016-10-19 11:10:30 -07:00
// Add Library item
testRunner.InvokeLibraryAddDialog();
2017-02-01 10:12:31 -08:00
testRunner.Delay(2);
testRunner.Type(MatterControlUtilities.GetTestItemPath("Batman.zip"));
2017-02-01 10:12:31 -08:00
testRunner.Delay(1);
2016-10-19 11:10:30 -07:00
testRunner.Type("{Enter}");
2022-02-06 08:22:31 -08:00
testRunner.WaitForName("Batman.zip Row Item Collection");
2022-02-06 08:22:31 -08:00
testRunner.DoubleClickByName("Batman.zip Row Item Collection");
Assert.IsTrue(testRunner.WaitForName("Row Item Batman.stl"), "Batman part should exist after adding");
Assert.IsTrue(testRunner.WaitForName("Row Item 2013-01-25_Mouthpiece_v2.stl"), "Mouthpiece part should exist after adding");
return Task.CompletedTask;
});
}
[Test]
public async Task DoubleClickSwitchesToOpenTab()
{
await MatterControlUtilities.RunTest((testRunner) =>
{
2022-02-17 17:48:48 -08:00
MatterControlUtilities.CreateDownloadsSubFolder();
2018-10-10 13:33:16 -07:00
testRunner.AddAndSelectPrinter();
2021-06-06 22:18:29 -07:00
testRunner.AddItemToBed()
2021-09-14 10:22:13 -07:00
.ClickByName("Save Menu SplitButton", offset: new Agg.Point2D(30, 0))
.ClickByName("Save As Menu Item")
2022-02-17 17:48:48 -08:00
.NavigateToFolder("Downloads Row Item Collection")
.NavigateToFolder("-Temporary Row Item Collection")
.ClickByName("Design Name Edit Field")
.Type("Cube Design")
.ClickByName("Accept Button");
var mainViewWidget = ApplicationController.Instance.MainView;
var tabControl = mainViewWidget.TabControl;
2022-01-07 16:30:46 -08:00
Assert.AreEqual(5, mainViewWidget.TabControl.AllTabs.Count());
// open the design for editing
testRunner.ClickByName("Library Tab")
2022-02-17 17:48:48 -08:00
.NavigateToFolder("Downloads Row Item Collection")
.NavigateToFolder("-Temporary Row Item Collection")
.DoubleClickByName("Row Item Cube Design.mcx")
2022-01-07 16:30:46 -08:00
.WaitFor(() => mainViewWidget.TabControl.AllTabs.Count() == 6);
// we have opened a new tab
2022-01-07 16:30:46 -08:00
Assert.AreEqual(6, mainViewWidget.TabControl.AllTabs.Count());
// we are on the design tab
2022-01-07 16:30:46 -08:00
Assert.AreEqual(5, tabControl.SelectedTabIndex);
2022-02-17 17:48:48 -08:00
Assert.AreEqual("New Design", tabControl.SelectedTabKey);
// double click it again and prove that it goes to the currently open tab
testRunner.ClickByName("Library Tab")
2022-02-17 17:48:48 -08:00
.DoubleClickByName("Row Item Cube Design.mcx");
// we have not opened a new tab
2022-01-07 16:30:46 -08:00
Assert.AreEqual(6, mainViewWidget.TabControl.AllTabs.Count());
// we are on the design tab
2022-01-07 16:30:46 -08:00
Assert.AreEqual(5, tabControl.SelectedTabIndex);
2021-03-26 18:21:38 -07:00
// rename in the library tab
// assert tab name has change
// rename from the tab
// assert name in library tab has changed
2022-02-17 17:48:48 -08:00
MatterControlUtilities.DeleteDownloadsSubFolder();
2021-03-26 18:21:38 -07:00
return Task.CompletedTask;
});
}
[Test]
public async Task RenameButtonRenamesLocalLibraryFolder()
{
await MatterControlUtilities.RunTest((testRunner) =>
{
2018-10-10 13:33:16 -07:00
testRunner.AddAndSelectPrinter();
// Navigate to Local Library
testRunner.NavigateToFolder("Local Library Row Item Collection");
2016-10-19 11:10:30 -07:00
// Create New Folder
2018-10-05 14:21:55 -07:00
string folderID = testRunner.CreateChildFolder("New Folder");
2016-10-19 11:10:30 -07:00
2018-10-05 14:21:55 -07:00
testRunner.ClickByName(folderID);
2017-02-01 10:12:31 -08:00
testRunner.Delay(.2);
testRunner.LibraryRenameSelectedItem();
2017-02-01 10:12:31 -08:00
testRunner.Delay(.5);
2016-10-19 11:10:30 -07:00
testRunner.Type("Renamed Library Folder");
testRunner.ClickByName("InputBoxPage Action Button");
2017-02-01 10:12:31 -08:00
testRunner.Delay(.2);
2016-10-19 11:10:30 -07:00
// Make sure the renamed Library Folder exists
2017-06-14 14:02:29 -07:00
Assert.IsTrue(testRunner.WaitForName("Renamed Library Folder Row Item Collection"), "Renamed folder should exist");
return Task.CompletedTask;
});
}
[Test]
public async Task RemoveButtonClickedRemovesSingleItem()
{
await MatterControlUtilities.RunTest((testRunner) =>
{
2018-10-10 13:33:16 -07:00
testRunner.AddAndSelectPrinter();
testRunner.AddTestAssetsToLibrary(new[] { "Rook.amf" });
// Select and remove item
testRunner.ClickByName("Row Item Rook");
testRunner.LibraryRemoveSelectedItem();
// Make sure that the item has been removed
Assert.IsFalse(testRunner.WaitForName("Row Item Rook", .5));
return Task.CompletedTask;
});
}
[Test]
public async Task RemoveButtonClickedRemovesMultipleItems()
{
await MatterControlUtilities.RunTest((testRunner) =>
{
2018-10-10 13:33:16 -07:00
testRunner.AddAndSelectPrinter();
testRunner.AddTestAssetsToLibrary(new[] { "Rook.amf", "Batman.stl" });
// Select both items
testRunner.SelectListItems("Row Item Rook", "Row Item Batman");
// Remove items
testRunner.LibraryRemoveSelectedItem();
2017-02-01 10:12:31 -08:00
testRunner.Delay(1);
// Make sure both selected items are removed
Assert.IsFalse(testRunner.WaitForName("Row Item Rook", 1), "Rook part should *not* exist after remove");
Assert.IsFalse(testRunner.WaitForName("Row Item Batman", 1), "Batman part *not* exist after remove");
return Task.CompletedTask;
});
}
}
}