We now check the undo data to see if we need to save

This commit is contained in:
Lars Brubaker 2022-02-04 15:38:58 -08:00
parent f83bdbeb7d
commit e839cb6e1c
4 changed files with 45 additions and 51 deletions

View file

@ -136,7 +136,6 @@ namespace MatterHackers.MatterControl.Tests.Automation
testRunner.AddItemToBed()
.ClickByName("Save Menu SplitButton", offset: new Agg.Point2D(30, 0))
.ClickByName("Save As Menu Item")
.DoubleClickByName("Library Row Item Collection")
.DoubleClickByName("Local Library Row Item Collection")
.ClickByName("Design Name Edit Field")
.Type("Cube Design")
@ -148,7 +147,6 @@ namespace MatterHackers.MatterControl.Tests.Automation
// open the design for editing
testRunner.ClickByName("Library Tab")
.DoubleClickByName("Library Row Item Collection")
.DoubleClickByName("Local Library Row Item Collection")
.DoubleClickByName("Row Item Cube Design")
.WaitFor(() => mainViewWidget.TabControl.AllTabs.Count() == 6);

View file

@ -61,11 +61,11 @@ namespace MatterHackers.MatterControl.Tests.Automation
testRunner.Select3DPart("Calibration - Box.stl")
// Click Copy button and count Scene.Children
.ClickByName("Duplicate Button")
.Require(() => scene.Children.Count == 2, "Should have 2 parts after copy");
.Assert(() => scene.Children.Count == 2, "Should have 2 parts after copy");
// Click Copy button a second time and count Scene.Children
testRunner.ClickByName("Duplicate Button");
testRunner.Require(() => scene.Children.Count == 3, "Should have 3 parts after 2nd copy");
testRunner.Assert(() => scene.Children.Count == 3, "Should have 3 parts after 2nd copy");
return Task.CompletedTask;
}, overrideWidth: 1300, maxTimeToRun: 60);
@ -82,8 +82,6 @@ namespace MatterHackers.MatterControl.Tests.Automation
var view3D = testRunner.GetWidgetByName("View3DWidget", out SystemWindow systemWindow, 3) as View3DWidget;
var scene = view3D.Object3DControlLayer.Scene;
testRunner.Require(() => scene.Children.Count == 1, "Should have 1 part (the phil)");
var tempFilaname = "Temp Test Save.mcx";
var tempFullPath = Path.Combine(ApplicationDataStorage.Instance.DownloadsDirectory, tempFilaname);
@ -98,56 +96,49 @@ namespace MatterHackers.MatterControl.Tests.Automation
DeleteTempFile();
// Make sure the tab is named 'New Design'
testRunner.Require(() => systemWindow.GetVisibleWigetWithText("New Design") != null, "Must have New Design");
// add a new part to the bed
testRunner.AddItemToBed();
// Click the save button
testRunner.ClickByName("Save")
testRunner.Assert(() => scene.Children.Count == 1, "Should have 1 part (the phil)")
// Make sure the tab is named 'New Design'
.Assert(() => systemWindow.GetVisibleWigetWithText("New Design") != null, "Must have New Design")
// add a new part to the bed
.AddItemToBed()
// Click the save button
.ClickByName("Save")
// Cancle the save as
.ClickByName("Cancel Wizard Button");
// Make sure the tab is named 'New Design'
Assert.IsNotNull(systemWindow.GetVisibleWigetWithText("New Design"));
// Click the close tab button
testRunner.ClickByName("Close Tab Button")
.ClickByName("Cancel Wizard Button")
// Make sure the tab is named 'New Design'
.Assert(() => systemWindow.GetVisibleWigetWithText("New Design") != null, "Have a new design tab")
// Click the close tab button
.ClickByName("Close Tab Button")
// Select Cancel
.ClickByName("Cancel Button");
// Make sure the tab is named 'New Design'
Assert.IsNotNull(systemWindow.GetVisibleWigetWithText("New Design"));
// Click the close tab button
testRunner.ClickByName("Close Tab Button")
.ClickByName("Cancel Button")
// Make sure the tab is named 'New Design'
.Assert(() => systemWindow.GetVisibleWigetWithText("New Design") != null, "Still have design tab")
// Click the close tab button
.ClickByName("Close Tab Button")
// Select 'Save'
.ClickByName("Yes Button")
// Cancel the 'Save As'
.ClickByName("Cancel Wizard Button");
// Make sure the window is still open and the tab is named 'New Design'
Assert.IsNotNull(systemWindow.GetVisibleWigetWithText("New Design"));
// Click the save button
testRunner.ClickByName("Save")
.ClickByName("Cancel Wizard Button")
// Make sure the window is still open and the tab is named 'New Design'
.Assert(() => systemWindow.GetVisibleWigetWithText("New Design") != null, "still have desin tab")
// Click the save button
.ClickByName("Save")
// Save a temp file to the downloads folder
.DoubleClickByName("Computer Row Item Collection")
.DoubleClickByName("Downloads Row Item Collection")
.ClickByName("Design Name Edit Field")
.Type(tempFilaname)
.ClickByName("Accept Button");
// Verify it is there
Assert.IsTrue(File.Exists(tempFullPath));
// And that the tab got the name
Assert.IsNotNull(systemWindow.GetVisibleWigetWithText(tempFilaname));
// and the tooltip is right
Assert.IsTrue(systemWindow.GetVisibleWigetWithText(tempFilaname).ToolTipText == tempFullPath);
// Add a part to the bed
testRunner.AddItemToBed();
// Click the close tab button (we have an edit so it should show the save request)
testRunner.ClickByName("Close Tab Button")
.ClickByName("Accept Button")
// Verify it is there
.Assert(() => File.Exists(tempFullPath), "Must save the file")
// And that the tab got the name
.Assert(() => systemWindow.GetVisibleWigetWithText(tempFilaname) != null, "Tab was renamed")
// and the tooltip is right
.Assert(() => systemWindow.GetVisibleWigetWithText(tempFilaname).ToolTipText == tempFullPath, "Correct tool tip name")
// Add a part to the bed
.AddItemToBed()
// Click the close tab button (we have an edit so it should show the save request)
.ClickByName("Close Tab Button")
// Click the 'Cancel'
.ClickByName("Cancel Button")
// Click the 'Save' button
@ -156,7 +147,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
.ClickByName("Close Tab Button");
// Verify the tab closes without requesting save
testRunner.Require(() => systemWindow.GetVisibleWigetWithText(tempFilaname) == null, "The tab should have closed");
testRunner.Assert(() => systemWindow.GetVisibleWigetWithText(tempFilaname) == null, "The tab should have closed");
// delete the temp file if it exists in the Downloads folder
DeleteTempFile();
@ -187,7 +178,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
for (int i = 2; i <= 6; i++)
{
testRunner.ClickByName("Duplicate Button")
.Require(() => scene.Children.Count == i, $"Should have {i} parts after copy");
.Assert(() => scene.Children.Count == i, $"Should have {i} parts after copy");
}
// Get MeshGroupCount before Group is clicked
@ -198,10 +189,10 @@ namespace MatterHackers.MatterControl.Tests.Automation
// select all
.Type("^a")
.ClickByName("Group Button")
.Require(() => scene.Children.Count == 1, $"Should have 1 parts after group");
.Assert(() => scene.Children.Count == 1, $"Should have 1 parts after group");
testRunner.ClickByName("Ungroup Button")
.Require(() => scene.Children.Count == 6, $"Should have 6 parts after ungroup");
.Assert(() => scene.Children.Count == 6, $"Should have 6 parts after ungroup");
return Task.CompletedTask;
}, overrideWidth: 1300);