Now testing Mirror X Y & Z
This commit is contained in:
parent
37ec72c2af
commit
6e45ede3d5
2 changed files with 88 additions and 39 deletions
|
|
@ -239,47 +239,50 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
testRunner.CloseSignInAndPrinterSelect();
|
||||
testRunner.AddAndSelectPrinter("Airwolf 3D", "HD");
|
||||
|
||||
testRunner.AddDefaultFileToBedplate(partName: "Row Item MatterControl - Coin.stl");
|
||||
|
||||
// TODO: assert the part is centered on the bed
|
||||
|
||||
|
||||
// Get View3DWidget
|
||||
var view3D = testRunner.GetWidgetByName("View3DWidget", out _) as View3DWidget;
|
||||
var scene = view3D.InteractionLayer.Scene;
|
||||
var scene1 = view3D.InteractionLayer.Scene;
|
||||
|
||||
testRunner.ClickByName("MatterControl - Coin.stl");
|
||||
Assert.IsNotNull(scene.SelectedItem);
|
||||
|
||||
string scenePath = GetSceneTempPath();
|
||||
|
||||
// save the scene
|
||||
string preOpperation = Path.Combine(scenePath, "preOpperation.mcx");
|
||||
scene.Save(preOpperation, scenePath);
|
||||
// mirror the part
|
||||
testRunner.ClickByName("Mirror Button");
|
||||
testRunner.ClickByName("Mirror Button X");
|
||||
// save the scene
|
||||
string postOpperation = Path.Combine(scenePath, scenePath, "postOpperation.mcx");
|
||||
scene.Save(postOpperation, scenePath);
|
||||
|
||||
// assert new save is different
|
||||
SceneFilesAreSame(postOpperation, preOpperation, false);
|
||||
|
||||
// with the part selected
|
||||
AssertUndoRedo(testRunner, scene, scenePath, preOpperation, postOpperation);
|
||||
|
||||
// unselect the part
|
||||
testRunner.ClickByName("MatterControl - Coin.stl"); // place focus back in the scene
|
||||
testRunner.Type(" "); // clear the selection (type a space)
|
||||
testRunner.Delay(() =>
|
||||
RunDoUndoTest(testRunner, scene1, (scene) =>
|
||||
{
|
||||
return scene.SelectedItem == null;
|
||||
}, .5);
|
||||
Assert.IsNull(scene.SelectedItem);
|
||||
testRunner.AddDefaultFileToBedplate(partName: "Row Item MatterControl - Coin.stl");
|
||||
// TODO: assert the part is centered on the bed
|
||||
|
||||
// with the part unselected
|
||||
AssertUndoRedo(testRunner, scene, scenePath, preOpperation, postOpperation);
|
||||
testRunner.ClickByName("MatterControl - Coin.stl");
|
||||
Assert.IsNotNull(scene.SelectedItem);
|
||||
},
|
||||
(scene) =>
|
||||
{
|
||||
testRunner.ClickByName("Mirror Button");
|
||||
testRunner.ClickByName("Mirror Button X");
|
||||
});
|
||||
|
||||
RunDoUndoTest(testRunner, scene1, (scene) =>
|
||||
{
|
||||
testRunner.AddSelectedItemToBedplate();
|
||||
testRunner.Delay(.1);
|
||||
|
||||
testRunner.ClickByName("MatterControl - Coin.stl");
|
||||
Assert.IsNotNull(scene.SelectedItem);
|
||||
},
|
||||
(scene) =>
|
||||
{
|
||||
testRunner.ClickByName("Mirror Button");
|
||||
testRunner.ClickByName("Mirror Button Y");
|
||||
});
|
||||
|
||||
RunDoUndoTest(testRunner, scene1, (scene) =>
|
||||
{
|
||||
testRunner.AddSelectedItemToBedplate();
|
||||
testRunner.Delay(.1);
|
||||
|
||||
testRunner.ClickByName("MatterControl - Coin.stl");
|
||||
Assert.IsNotNull(scene.SelectedItem);
|
||||
},
|
||||
(scene) =>
|
||||
{
|
||||
testRunner.ClickByName("Mirror Button");
|
||||
testRunner.ClickByName("Mirror Button Z");
|
||||
});
|
||||
|
||||
view3D.CloseOnIdle();
|
||||
testRunner.Delay(.1);
|
||||
|
|
@ -288,6 +291,49 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
}, overrideWidth: 1300);
|
||||
}
|
||||
|
||||
private void RunDoUndoTest(AutomationRunner testRunner,
|
||||
InteractiveScene scene,
|
||||
Action<InteractiveScene> InitializeTest,
|
||||
Action<InteractiveScene> PerformOpperation)
|
||||
{
|
||||
string scenePath = GetSceneTempPath();
|
||||
|
||||
// clear the bed
|
||||
testRunner.ClickByName("Bed Options Menu");
|
||||
testRunner.ClickByName("Clear Bed Menu Item");
|
||||
|
||||
InitializeTest(scene);
|
||||
|
||||
// save the scene
|
||||
string preOpperation = Path.Combine(scenePath, "preOpperation.mcx");
|
||||
scene.Save(preOpperation, scenePath);
|
||||
|
||||
// Do the opperation
|
||||
PerformOpperation(scene);
|
||||
|
||||
// save the scene
|
||||
string postOpperation = Path.Combine(scenePath, scenePath, "postOpperation.mcx");
|
||||
scene.Save(postOpperation, scenePath);
|
||||
|
||||
// assert new save is different
|
||||
SceneFilesAreSame(postOpperation, preOpperation, false);
|
||||
|
||||
// with the part selected
|
||||
AssertUndoRedo(testRunner, scene, scenePath, preOpperation, postOpperation);
|
||||
|
||||
// unselect the part
|
||||
testRunner.ClickByName("View3DWidget"); // place focus back in the scene
|
||||
testRunner.Type(" "); // clear the selection (type a space)
|
||||
testRunner.Delay(() =>
|
||||
{
|
||||
return scene.SelectedItem == null;
|
||||
}, .5);
|
||||
Assert.IsNull(scene.SelectedItem);
|
||||
|
||||
// with the part unselected
|
||||
AssertUndoRedo(testRunner, scene, scenePath, preOpperation, postOpperation);
|
||||
}
|
||||
|
||||
private void SceneFilesAreSame(string fileName1, string fileName2, bool expectedResult)
|
||||
{
|
||||
bool areSame = true;
|
||||
|
|
|
|||
|
|
@ -403,9 +403,12 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
|
||||
public static void AddDefaultFileToBedplate(this AutomationRunner testRunner, string containerName = "Calibration Parts Row Item Collection", string partName = "Row Item Calibration - Box.stl")
|
||||
{
|
||||
testRunner.NavigateToFolder(containerName);
|
||||
testRunner.ClickByName(partName);
|
||||
if (!testRunner.NameExists(partName))
|
||||
{
|
||||
testRunner.NavigateToFolder(containerName);
|
||||
}
|
||||
|
||||
testRunner.ClickByName(partName);
|
||||
testRunner.AddSelectedItemToBedplate();
|
||||
testRunner.Delay(1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue