2018-10-17 17:26:29 -07:00
|
|
|
|
using System.Threading;
|
2016-10-25 06:17:37 -07:00
|
|
|
|
using System.Threading.Tasks;
|
2016-05-11 09:13:56 -07:00
|
|
|
|
using MatterHackers.MatterControl.PartPreviewWindow;
|
2017-06-06 18:19:02 -07:00
|
|
|
|
using MatterHackers.MatterControl.PrintQueue;
|
2016-03-01 11:25:15 -08:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
2016-05-11 09:13:56 -07:00
|
|
|
|
namespace MatterHackers.MatterControl.Tests.Automation
|
2016-03-01 11:25:15 -08:00
|
|
|
|
{
|
2017-06-04 23:07:05 -07:00
|
|
|
|
[TestFixture, Category("MatterControl.UI.Automation"), RunInApplicationDomain, Apartment(ApartmentState.STA)]
|
2016-03-01 11:25:15 -08:00
|
|
|
|
public class PartPreviewTests
|
|
|
|
|
|
{
|
2017-06-04 23:07:05 -07:00
|
|
|
|
[Test]
|
2016-11-02 06:24:23 -07:00
|
|
|
|
public async Task CopyButtonMakesCopyOfPart()
|
2016-03-01 11:25:15 -08:00
|
|
|
|
{
|
2017-06-04 23:07:05 -07:00
|
|
|
|
await MatterControlUtilities.RunTest((testRunner) =>
|
2016-03-01 11:25:15 -08:00
|
|
|
|
{
|
2018-04-19 07:58:03 -07:00
|
|
|
|
testRunner.OpenEmptyPartTab();
|
|
|
|
|
|
|
2017-10-27 14:19:26 -07:00
|
|
|
|
testRunner.AddItemToBedplate();
|
2016-10-19 11:10:30 -07:00
|
|
|
|
|
2016-11-02 07:02:19 -07:00
|
|
|
|
// Get View3DWidget
|
2017-06-05 07:23:44 -07:00
|
|
|
|
View3DWidget view3D = testRunner.GetWidgetByName("View3DWidget", out _, 3) as View3DWidget;
|
2020-09-11 19:59:14 -07:00
|
|
|
|
var scene = view3D.Object3DControlLayer.Scene;
|
2016-10-19 11:10:30 -07:00
|
|
|
|
|
2017-06-05 07:23:44 -07:00
|
|
|
|
testRunner.WaitForName("Calibration - Box.stl");
|
2017-09-16 01:11:44 -07:00
|
|
|
|
Assert.AreEqual(1, scene.Children.Count, "Should have 1 part before copy");
|
2016-11-02 06:24:23 -07:00
|
|
|
|
|
2017-06-05 07:23:44 -07:00
|
|
|
|
// Select scene object
|
2017-06-04 23:07:05 -07:00
|
|
|
|
testRunner.Select3DPart("Calibration - Box.stl");
|
2016-10-19 11:10:30 -07:00
|
|
|
|
|
2018-10-10 22:32:08 -07:00
|
|
|
|
// Click Copy button and count Scene.Children
|
2018-01-08 23:34:40 -08:00
|
|
|
|
testRunner.ClickByName("Duplicate Button");
|
2017-12-15 20:24:58 -08:00
|
|
|
|
testRunner.WaitFor(() => scene.Children.Count == 2);
|
2017-09-16 01:11:44 -07:00
|
|
|
|
Assert.AreEqual(2, scene.Children.Count, "Should have 2 parts after copy");
|
2016-10-19 11:10:30 -07:00
|
|
|
|
|
2017-03-15 16:17:06 -07:00
|
|
|
|
// Click Copy button a second time and count Scene.Children
|
2018-01-08 23:34:40 -08:00
|
|
|
|
testRunner.ClickByName("Duplicate Button");
|
2017-12-15 20:24:58 -08:00
|
|
|
|
testRunner.WaitFor(() => scene.Children.Count > 2);
|
2017-09-16 01:11:44 -07:00
|
|
|
|
Assert.AreEqual(3, scene.Children.Count, "Should have 3 parts after 2nd copy");
|
2016-10-25 06:17:37 -07:00
|
|
|
|
|
2017-06-04 08:35:29 -07:00
|
|
|
|
return Task.CompletedTask;
|
2017-06-04 23:07:05 -07:00
|
|
|
|
}, overrideWidth: 1300, maxTimeToRun: 60);
|
2016-03-01 11:25:15 -08:00
|
|
|
|
}
|
2016-03-01 13:00:18 -08:00
|
|
|
|
|
2017-06-04 23:07:05 -07:00
|
|
|
|
[Test]
|
2016-10-25 06:17:37 -07:00
|
|
|
|
public async Task GroupAndUngroup()
|
2016-03-01 13:00:18 -08:00
|
|
|
|
{
|
2017-06-05 07:23:44 -07:00
|
|
|
|
await MatterControlUtilities.RunTest((testRunner) =>
|
2016-03-01 13:00:18 -08:00
|
|
|
|
{
|
2018-04-19 07:58:03 -07:00
|
|
|
|
testRunner.OpenEmptyPartTab();
|
|
|
|
|
|
|
2017-10-27 14:19:26 -07:00
|
|
|
|
testRunner.AddItemToBedplate();
|
2016-03-01 13:00:18 -08:00
|
|
|
|
|
2017-06-05 07:23:44 -07:00
|
|
|
|
// Get View3DWidget and count Scene.Children before Copy button is clicked
|
|
|
|
|
|
View3DWidget view3D = testRunner.GetWidgetByName("View3DWidget", out _, 3) as View3DWidget;
|
2020-09-11 19:59:14 -07:00
|
|
|
|
var scene = view3D.Object3DControlLayer.Scene;
|
2016-03-01 13:00:18 -08:00
|
|
|
|
|
2017-06-05 07:23:44 -07:00
|
|
|
|
// Assert expected start count
|
2017-09-16 01:11:44 -07:00
|
|
|
|
Assert.AreEqual(1, scene.Children.Count, "Should have one part before copy");
|
2017-06-05 07:23:44 -07:00
|
|
|
|
|
|
|
|
|
|
// Select scene object
|
|
|
|
|
|
testRunner.Select3DPart("Calibration - Box.stl");
|
2016-03-01 13:00:18 -08:00
|
|
|
|
|
2017-06-05 07:23:44 -07:00
|
|
|
|
for (int i = 2; i <= 6; i++)
|
2016-10-19 11:10:30 -07:00
|
|
|
|
{
|
2018-01-08 23:34:40 -08:00
|
|
|
|
testRunner.ClickByName("Duplicate Button");
|
2017-12-15 20:24:58 -08:00
|
|
|
|
testRunner.WaitFor(() => scene.Children.Count == i);
|
2017-09-16 01:11:44 -07:00
|
|
|
|
Assert.AreEqual(i, scene.Children.Count, $"Should have {i} parts after copy");
|
2016-10-19 11:10:30 -07:00
|
|
|
|
}
|
2016-10-07 13:49:01 -07:00
|
|
|
|
|
2017-06-05 07:23:44 -07:00
|
|
|
|
// Get MeshGroupCount before Group is clicked
|
2017-09-16 01:11:44 -07:00
|
|
|
|
Assert.AreEqual(6, scene.Children.Count, "Scene should have 6 parts after copy loop");
|
2017-03-15 16:17:06 -07:00
|
|
|
|
|
2018-01-15 20:39:57 -08:00
|
|
|
|
// Duplicate button moved to new container - move focus back to View3DWidget so CTRL-A below is seen by expected control
|
|
|
|
|
|
testRunner.Select3DPart("Calibration - Box.stl");
|
|
|
|
|
|
|
2017-10-27 14:19:26 -07:00
|
|
|
|
// select all
|
2017-03-15 16:17:06 -07:00
|
|
|
|
testRunner.Type("^a");
|
2016-03-01 13:00:18 -08:00
|
|
|
|
|
2018-01-08 23:34:40 -08:00
|
|
|
|
testRunner.ClickByName("Group Button");
|
2017-12-15 20:24:58 -08:00
|
|
|
|
testRunner.WaitFor(() => scene.Children.Count == 1);
|
2017-09-16 01:11:44 -07:00
|
|
|
|
Assert.AreEqual(1, scene.Children.Count, $"Should have 1 parts after group");
|
2016-03-01 13:00:18 -08:00
|
|
|
|
|
2018-01-08 23:34:40 -08:00
|
|
|
|
testRunner.ClickByName("Ungroup Button");
|
2017-12-15 20:24:58 -08:00
|
|
|
|
testRunner.WaitFor(() => scene.Children.Count == 6);
|
2017-09-16 01:11:44 -07:00
|
|
|
|
Assert.AreEqual(6, scene.Children.Count, $"Should have 6 parts after ungroup");
|
2016-10-25 06:17:37 -07:00
|
|
|
|
|
2017-06-04 08:35:29 -07:00
|
|
|
|
return Task.CompletedTask;
|
2017-06-05 07:23:44 -07:00
|
|
|
|
}, overrideWidth: 1300);
|
2016-03-01 13:00:18 -08:00
|
|
|
|
}
|
2016-03-01 15:15:48 -08:00
|
|
|
|
|
2017-06-04 23:07:05 -07:00
|
|
|
|
[Test]
|
2016-10-25 06:17:37 -07:00
|
|
|
|
public async Task RemoveButtonRemovesParts()
|
2016-03-01 15:15:48 -08:00
|
|
|
|
{
|
2017-06-05 23:06:50 -07:00
|
|
|
|
await MatterControlUtilities.RunTest((testRunner) =>
|
2016-03-01 15:15:48 -08:00
|
|
|
|
{
|
2018-04-19 07:58:03 -07:00
|
|
|
|
testRunner.OpenEmptyPartTab();
|
|
|
|
|
|
|
2017-10-27 14:19:26 -07:00
|
|
|
|
testRunner.AddItemToBedplate();
|
2017-09-16 01:11:44 -07:00
|
|
|
|
|
2017-06-05 23:06:50 -07:00
|
|
|
|
var view3D = testRunner.GetWidgetByName("View3DWidget", out _) as View3DWidget;
|
2020-09-11 19:59:14 -07:00
|
|
|
|
var scene = view3D.Object3DControlLayer.Scene;
|
2016-03-01 15:15:48 -08:00
|
|
|
|
|
2017-06-05 23:06:50 -07:00
|
|
|
|
testRunner.Select3DPart("Calibration - Box.stl");
|
2016-03-01 15:15:48 -08:00
|
|
|
|
|
2017-09-16 01:11:44 -07:00
|
|
|
|
Assert.AreEqual(1, scene.Children.Count, "There should be 1 part on the bed after AddDefaultFileToBedplate()");
|
2016-03-01 15:15:48 -08:00
|
|
|
|
|
2017-06-05 23:06:50 -07:00
|
|
|
|
// Add 5 items
|
2016-10-19 11:10:30 -07:00
|
|
|
|
for (int i = 0; i <= 4; i++)
|
|
|
|
|
|
{
|
2018-01-08 23:34:40 -08:00
|
|
|
|
testRunner.ClickByName("Duplicate Button");
|
2017-02-01 10:12:31 -08:00
|
|
|
|
testRunner.Delay(.5);
|
2016-10-19 11:10:30 -07:00
|
|
|
|
}
|
2016-03-01 15:15:48 -08:00
|
|
|
|
|
2017-09-16 01:11:44 -07:00
|
|
|
|
Assert.AreEqual(6, scene.Children.Count, "There should be 6 parts on the bed after the copy loop");
|
2016-03-01 15:15:48 -08:00
|
|
|
|
|
2017-06-05 23:06:50 -07:00
|
|
|
|
// Remove an item
|
2018-01-08 23:34:40 -08:00
|
|
|
|
testRunner.ClickByName("Remove Button");
|
2016-10-25 06:17:37 -07:00
|
|
|
|
|
2017-06-05 23:06:50 -07:00
|
|
|
|
// Confirm
|
2017-09-16 01:11:44 -07:00
|
|
|
|
Assert.AreEqual(5, scene.Children.Count, "There should be 5 parts on the bed after remove");
|
2016-03-01 15:15:48 -08:00
|
|
|
|
|
2017-06-05 23:06:50 -07:00
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
|
}, overrideWidth:1300);
|
2016-03-01 15:15:48 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-06-04 23:07:05 -07:00
|
|
|
|
[Test]
|
2016-10-25 06:17:37 -07:00
|
|
|
|
public async Task SaveAsToQueue()
|
2016-03-01 18:19:28 -08:00
|
|
|
|
{
|
2017-06-06 18:19:02 -07:00
|
|
|
|
await MatterControlUtilities.RunTest((testRunner) =>
|
2016-03-01 18:19:28 -08:00
|
|
|
|
{
|
2018-10-10 13:33:16 -07:00
|
|
|
|
testRunner.AddAndSelectPrinter();
|
2016-03-01 18:19:28 -08:00
|
|
|
|
|
2017-10-27 14:19:26 -07:00
|
|
|
|
testRunner.AddItemToBedplate();
|
2017-06-06 18:19:02 -07:00
|
|
|
|
|
|
|
|
|
|
var view3D = testRunner.GetWidgetByName("View3DWidget", out _) as View3DWidget;
|
2016-03-01 18:19:28 -08:00
|
|
|
|
|
2017-06-06 18:19:02 -07:00
|
|
|
|
testRunner.Select3DPart("Calibration - Box.stl");
|
2016-03-01 18:19:28 -08:00
|
|
|
|
|
2016-10-19 11:10:30 -07:00
|
|
|
|
for (int i = 0; i <= 2; i++)
|
|
|
|
|
|
{
|
2018-01-08 23:34:40 -08:00
|
|
|
|
testRunner.ClickByName("Duplicate Button");
|
2017-02-01 10:12:31 -08:00
|
|
|
|
testRunner.Delay(.5);
|
2016-10-19 11:10:30 -07:00
|
|
|
|
}
|
2016-03-01 18:19:28 -08:00
|
|
|
|
|
2017-06-06 18:19:02 -07:00
|
|
|
|
int expectedCount = QueueData.Instance.ItemCount + 1;
|
|
|
|
|
|
|
|
|
|
|
|
testRunner.SaveBedplateToFolder("Test PartA", "Print Queue Row Item Collection");
|
2016-03-01 18:19:28 -08:00
|
|
|
|
|
2017-06-06 18:19:02 -07:00
|
|
|
|
// Click Home -> Local Library
|
2017-06-18 10:02:34 -07:00
|
|
|
|
testRunner.NavigateToLibraryHome();
|
2016-10-26 06:58:20 -07:00
|
|
|
|
testRunner.NavigateToFolder("Print Queue Row Item Collection");
|
2016-08-01 17:21:31 -07:00
|
|
|
|
|
2017-06-06 18:19:02 -07:00
|
|
|
|
Assert.IsTrue(testRunner.WaitForName("Row Item Test PartA", 5), "The part we added should be in the library");
|
|
|
|
|
|
Assert.AreEqual(expectedCount, QueueData.Instance.ItemCount, "Queue count should increase by one after Save operation");
|
2016-10-25 06:17:37 -07:00
|
|
|
|
|
2017-06-04 08:35:29 -07:00
|
|
|
|
return Task.CompletedTask;
|
2017-06-06 18:19:02 -07:00
|
|
|
|
}, overrideWidth: 1300);
|
2016-03-01 18:19:28 -08:00
|
|
|
|
}
|
2016-03-01 11:25:15 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|