Пример #1
0
        public async Task TuningAdjustmentsDefaultToOneAndPersists()
        {
            double targetExtrusionRate = 1.5;
            double targetFeedRate      = 2;

            await MatterControlUtilities.RunTest((testRunner) =>
            {
                testRunner.WaitForName("Cancel Wizard Button");

                using (var emulator = testRunner.LaunchAndConnectToPrinterEmulator())
                {
                    Assert.IsTrue(ProfileManager.Instance.ActiveProfile != null);

                    testRunner.AddItemToBedplate();

                    testRunner.SwitchToControlsTab();

                    // Wait for printing to complete
                    var printFinishedResetEvent = new AutoResetEvent(false);
                    ApplicationController.Instance.ActivePrinter.Connection.PrintFinished.RegisterEvent((s, e) =>
                    {
                        printFinishedResetEvent.Set();
                    }, ref unregisterEvents);

                    testRunner.StartPrint();

                    var container = testRunner.GetWidgetByName("ManualPrinterControls.ControlsContainer", out _, 5);

                    // Scroll the widget into view
                    var scrollable = container.Parents <ManualPrinterControls>().First() as ScrollableWidget;
                    var width      = scrollable.Width;

                    // Workaround needed to scroll to the bottom of the Controls panel
                    //scrollable.ScrollPosition = new Vector2();
                    scrollable.ScrollPosition = new Vector2(0, 30);

                    // Workaround to force layout to fix problems with size of Tuning Widgets after setting ScrollPosition manually
                    scrollable.Width = width - 1;
                    scrollable.Width = width;

                    // Tuning values should default to 1 when missing
                    ConfirmExpectedSpeeds(testRunner, 1, 1, "Initial case");

                    testRunner.Delay();
                    testRunner.ClickByName("Extrusion Multiplier NumberEdit");
                    testRunner.Type(targetExtrusionRate.ToString());

                    testRunner.ClickByName("Feed Rate NumberEdit");
                    testRunner.Type(targetFeedRate.ToString());

                    // Force focus away from the feed rate field, causing an persisted update
                    testRunner.ClickByName("Extrusion Multiplier NumberEdit");

                    ConfirmExpectedSpeeds(testRunner, targetExtrusionRate, targetFeedRate, "After setting TextEdit values");

                    // Wait for slicing to complete before setting target values
                    testRunner.WaitFor(() => ApplicationController.Instance.ActivePrinter.Connection.DetailedPrintingState == DetailedPrintingState.Printing, 8);
                    testRunner.Delay();

                    ConfirmExpectedSpeeds(testRunner, targetExtrusionRate, targetFeedRate, "While printing");

                    // Wait up to 60 seconds for the print to finish
                    printFinishedResetEvent.WaitOne(60 * 1000);

                    // Values should match entered values
                    ConfirmExpectedSpeeds(testRunner, targetExtrusionRate, targetFeedRate, "After print finished");

                    testRunner.WaitForPrintFinished();

                    // Restart the print
                    testRunner.StartPrint();
                    testRunner.Delay(2);

                    // Values should match entered values
                    ConfirmExpectedSpeeds(testRunner, targetExtrusionRate, targetFeedRate, "After print restarted");

                    testRunner.CancelPrint();
                    testRunner.Delay(1);

                    // Values should match entered values
                    ConfirmExpectedSpeeds(testRunner, targetExtrusionRate, targetFeedRate, "After canceled print");
                }

                return(Task.CompletedTask);
            }, overrideHeight : 900, maxTimeToRun : 120);
        }
Пример #2
0
        /// <summary>
        /// Adds the given asset names to the local library and validates the result
        /// </summary>
        /// <param name="testRunner"></param>
        /// <param name="assetNames">The test assets to add to the library</param>
        public static void AddTestAssetsToLibrary(this AutomationRunner testRunner, params string[] assetNames)
        {
            // Switch to the Local Library tab
            testRunner.NavigateToFolder("Local Library Row Item Collection");

            // Assert that the requested items are *not* in the list
            foreach (string assetName in assetNames)
            {
                string friendlyName = Path.GetFileNameWithoutExtension(assetName);
                Assert.IsFalse(testRunner.WaitForName($"Row Item {friendlyName}", .1), $"{friendlyName} part should not exist at test start");
            }

            // Add Library item
            testRunner.InvokeLibraryAddDialog();

            // Generate the full, quoted paths for the requested assets
            string fullQuotedAssetPaths = string.Join(" ", assetNames.Select(name => $"\"{MatterControlUtilities.GetTestItemPath(name)}\""));

            testRunner.CompleteDialog(fullQuotedAssetPaths);

            // Assert that the added items *are* in the list
            foreach (string assetName in assetNames)
            {
                string friendlyName = Path.GetFileNameWithoutExtension(assetName);
                Assert.IsTrue(testRunner.WaitForName($"Row Item {friendlyName}"), $"{friendlyName} part should exist after adding");
            }
        }
Пример #3
0
        public static async Task RunTest(
            AutomationTest testMethod,
            string staticDataPathOverride      = null,
            double maxTimeToRun                = 60,
            QueueTemplate queueItemFolderToAdd = QueueTemplate.None,
            int overrideWidth        = -1,
            int overrideHeight       = -1,
            string defaultTestImages = null)
        {
            // Walk back a step in the stack and output the callers name
            //StackTrace st = new StackTrace(false);
            //Debug.WriteLine("\r\n ***** Running automation test: {0} {1} ", st.GetFrames().Skip(1).First().GetMethod().Name, DateTime.Now);

            if (staticDataPathOverride == null)
            {
                // Popping one directory above MatterControl, then back down into MatterControl ensures this works in MCCentral as well and MatterControl
                staticDataPathOverride = TestContext.CurrentContext.ResolveProjectPath(5, "MatterControl", "StaticData");
            }

#if DEBUG
            string outputDirectory = "Debug";
#else
            string outputDirectory = "Release";
#endif

            Environment.CurrentDirectory = TestContext.CurrentContext.ResolveProjectPath(5, "MatterControl", "bin", outputDirectory);

            // Override the default SystemWindow type without config.json
            AggContext.Config.ProviderTypes.SystemWindowProvider = "MatterHackers.Agg.UI.OpenGLWinformsWindowProvider, agg_platform_win32";

#if !__ANDROID__
            // Set the static data to point to the directory of MatterControl
            AggContext.StaticData = new FileSystemStaticData(staticDataPathOverride);
#endif
            // Popping one directory above MatterControl, then back down into MatterControl ensures this works in MCCentral as well and MatterControl
            MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(5, "MatterControl"));

            if (queueItemFolderToAdd != QueueTemplate.None)
            {
                MatterControlUtilities.AddItemsToQueue(queueItemFolderToAdd.ToString());
            }

            if (defaultTestImages == null)
            {
                defaultTestImages = TestContext.CurrentContext.ResolveProjectPath(4, "Tests", "TestData", "TestImages");
            }

            UserSettings.Instance.set(UserSettingsKey.ThumbnailRenderingMode, "orthographic");
            //GL.HardwareAvailable = false;

            var config = TestAutomationConfig.Load();
            if (config.UseAutomationDialogs)
            {
                AggContext.Config.ProviderTypes.DialogProvider = "MatterHackers.Agg.Platform.AutomationDialogProvider, GuiAutomation";
            }

            // Extract mouse speed from config
            AutomationRunner.TimeToMoveMouse = config.TimeToMoveMouse;
            AutomationRunner.UpDelaySeconds  = config.MouseUpDelay;

            // Automation runner must do as much as program.cs to spin up platform
            string platformFeaturesProvider = "MatterHackers.MatterControl.WindowsPlatformsFeatures, MatterControl.Winforms";
            AppContext.Platform = AggContext.CreateInstanceFrom <INativePlatformFeatures>(platformFeaturesProvider);
            AppContext.Platform.ProcessCommandline();

            var(width, height) = RootSystemWindow.GetStartupBounds();

            rootSystemWindow = Application.LoadRootWindow(
                overrideWidth == -1 ? width : overrideWidth,
                overrideHeight == -1 ? height : overrideHeight);

            OemSettings.Instance.ShowShopButton = false;

            if (!config.UseAutomationMouse)
            {
                AutomationRunner.InputMethod = new WindowsInputMethods();
            }

            await AutomationRunner.ShowWindowAndExecuteTests(
                rootSystemWindow,
                testMethod,
                maxTimeToRun,
                defaultTestImages,
                closeWindow : () =>
            {
                if (ApplicationController.Instance.ActivePrinter.Connection.CommunicationState == CommunicationStates.Printing)
                {
                    ApplicationController.Instance.ActivePrinter.Connection.Disable();
                }

                rootSystemWindow.Close();
            });
        }
Пример #4
0
        public async Task CancelingPrintTurnsHeatAndFanOff()
        {
            await MatterControlUtilities.RunTest((testRunner) =>
            {
                testRunner.WaitForName("Cancel Wizard Button");

                using (var emulator = testRunner.LaunchAndConnectToPrinterEmulator())
                {
                    var resetEvent = new AutoResetEvent(false);

                    Assert.AreEqual(1, ApplicationController.Instance.ActivePrinters.Count(), "One printer should exist after add");

                    testRunner.AddItemToBedplate();

                    testRunner.StartPrint();

                    int fanChangedCount       = 0;
                    emulator.FanSpeedChanged += (s, e) =>
                    {
                        fanChangedCount++;
                    };

                    var printer = ApplicationController.Instance.ActivePrinters.First();

                    emulator.WaitForLayer(printer.Settings, 2);
                    emulator.RunSlow = true;

                    // Click close but cancel
                    testRunner.CloseMatterControl();
                    testRunner.ClickByName("No Button");

                    // Wait for close
                    testRunner.WaitForWidgetDisappear("Yes Button", 4);
                    testRunner.Delay(2);

                    // Confirm abort
                    Assert.IsFalse(AppContext.RootSystemWindow.HasBeenClosed, "Canceling Close dialog should *not* close MatterControl");

                    // Close MatterControl and cancel print
                    testRunner.CloseMatterControl();
                    testRunner.ClickByName("Yes Button");

                    // Wait for Disconnected CommunicationState which occurs after PrinterConnection.Disable()
                    testRunner.WaitForCommunicationStateDisconnected(maxSeconds: 30);

                    // Wait for close
                    testRunner.WaitForWidgetDisappear("Yes Button", 4);
                    testRunner.Delay(2);

                    // Confirm close
                    Assert.IsTrue(AppContext.RootSystemWindow.HasBeenClosed, "Confirming Close dialog *should* close MatterControl");

                    // Wait for M106 change
                    testRunner.WaitFor(() => fanChangedCount > 0, 15, 500);

                    // Assert expected temp targets and fan transitions
                    Assert.AreEqual(0, (int)emulator.CurrentExtruder.TargetTemperature, "Unexpected target temperature - MC close should call Connection.Disable->TurnOffBedAndExtruders to shutdown heaters");
                    Assert.AreEqual(0, (int)emulator.HeatedBed.TargetTemperature, "Unexpected target temperature - MC close should call Connection.Disable->TurnOffBedAndExtruders to shutdown heaters");
                    Assert.AreEqual(1, fanChangedCount, "Unexpected fan speed change count - MC close should call Connection.Disable which shuts down fans via M106");
                }

                return(Task.CompletedTask);
            }, overrideHeight : 900, maxTimeToRun : 90);
        }
Пример #5
0
        public async Task DualExtrusionShowsCorrectHotendData()
        {
            await MatterControlUtilities.RunTest((testRunner) =>
            {
                using (var emulator = testRunner.LaunchAndConnectToPrinterEmulator())
                {
                    testRunner.ClickByName("Features Tab");

                    // only 1 hotend and 1 extruder
                    Assert.IsTrue(testRunner.NameExists("Hotend 0"));
                    Assert.IsTrue(testRunner.NameExists("Bed TemperatureWidget"));
                    Assert.IsFalse(testRunner.NameExists("Hotend 1", .1));

                    testRunner.ClickByName("Hotend 0");

                    // assert the temp is set when we first open (it comes from the material)
                    MHNumberEdit tempWidget = testRunner.GetWidgetByName("Temperature Input", out _) as MHNumberEdit;
                    Assert.AreEqual(240, (int)tempWidget.Value);

                    // change material
                    var dropDownLists = testRunner.GetWidgetsByName("Hotend Preset Selector");
                    Assert.AreEqual(1, dropDownLists.Count, "There is one. The slice settings and the pop out.");
                    DropDownList materialSelector = dropDownLists[0].Widget as DropDownList;
                    Assert.AreEqual("", materialSelector.SelectedValue);

                    testRunner.ClickByName("Hotend Preset Selector");
                    testRunner.ClickByName("HIPS Menu");

                    // check the extruder count
                    var extrudeButtons = testRunner.GetWidgetsByName("Extrude Button");
                    Assert.AreEqual(1, extrudeButtons.Count, "There should be just one.");

                    int hipsGoalTemp = 220;

                    // assert the temp changed to a new temp
                    Assert.AreEqual(hipsGoalTemp, (int)tempWidget.Value, "The goal temp should match the material temp");
                    // and the printer heat is off
                    Assert.AreEqual(0, (int)emulator.CurrentExtruder.TargetTemperature, "The printer should report the heaters are off");

                    // turn on the heater
                    testRunner.ClickByName("Toggle Heater");
                    testRunner.Delay(2);

                    // assert the printer is heating
                    Assert.AreEqual(hipsGoalTemp, (int)emulator.CurrentExtruder.TargetTemperature, "The printer should report the expected goal temp");

                    // turn off the heater
                    testRunner.ClickByName("Toggle Heater");
                    testRunner.Delay(2);

                    // assert the printer is off
                    Assert.AreEqual(0, (int)emulator.CurrentExtruder.TargetTemperature, "The printer should report the heaters are off");

                    // type in a temp when the heating is off
                    testRunner.ClickByName("Temperature Input");
                    testRunner.Type("110");
                    testRunner.Type("{Enter}");
                    testRunner.Delay();

                    // assert the printer is off
                    Assert.AreEqual(0, (int)emulator.CurrentExtruder.TargetTemperature);

                    // and the heat toggle is showing on
                    ICheckbox heatToggle = testRunner.GetWidgetByName("Toggle Heater", out _) as ICheckbox;
                    Assert.IsFalse(heatToggle.Checked);

                    // turn it on
                    testRunner.ClickByName("Toggle Heater");
                    Assert.AreEqual(110, (int)emulator.CurrentExtruder.TargetTemperature);

                    // adjust when on
                    testRunner.ClickByName("Temperature Input");
                    testRunner.Type("104");
                    testRunner.Type("{Enter}");
                    testRunner.Delay();
                    Assert.AreEqual(104, (int)emulator.CurrentExtruder.TargetTemperature);

                    // type in 0 and have the heater turn off
                    testRunner.ClickByName("Temperature Input");
                    testRunner.Type("^a");
                    testRunner.Type("0");
                    testRunner.Type("{Enter}");
                    testRunner.Delay();

                    // assert the printer is not heating
                    Assert.AreEqual(0, (int)emulator.CurrentExtruder.TargetTemperature);
                    // and the on toggle is showing off
                    Assert.IsFalse(heatToggle.Checked);

                    // Collapse the popup and switch back to the general tab
                    testRunner.ClickByName("Hotend 0");
                    testRunner.ClickByName("General Tab");

                    testRunner.SelectSliceSettingsField("Printer", SettingsKey.extruder_count);
                    testRunner.Type("2");
                    testRunner.Type("{Enter}");

                    // there are now 2 hotends and 2 extruders
                    Assert.IsTrue(testRunner.NameExists("Hotend 0"));
                    Assert.IsTrue(testRunner.NameExists("Hotend 1"));

                    SetCheckBoxSetting(testRunner, SettingsKey.extruders_share_temperature, true, true);

                    // there is one hotend and 2 extruders
                    Assert.IsTrue(testRunner.NameExists("Hotend 0"));
                    Assert.IsFalse(testRunner.NameExists("Hotend 1", .1));

                    testRunner.ClickByName("Hotend 0");

                    extrudeButtons = testRunner.GetWidgetsByName("Extrude Button");
                    Assert.AreEqual(2, extrudeButtons.Count, "Now there should be two.");
                }

                return(Task.CompletedTask);
            }, maxTimeToRun : 666, overrideWidth : 1224, overrideHeight : 900);
        }
Пример #6
0
        public void UndoRedoDelete()
        {
            // Run a copy of MatterControl
            Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
            {
                AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
                {
                    SystemWindow systemWindow;

                    //Navigate to Local Library
                    testRunner.ClickByName("Library Tab");
                    MatterControlUtilities.NavigateToFolder(testRunner, "Local Library Row Item Collection");
                    testRunner.Wait(1);
                    testRunner.ClickByName("Row Item Calibration - Box");
                    testRunner.ClickByName("Row Item Calibration - Box Print Button");
                    testRunner.Wait(1);

                    //Get View3DWidget and count MeshGroups before Copy button is clicked
                    GuiWidget    partPreview = testRunner.GetWidgetByName("View3DWidget", out systemWindow, 3);
                    View3DWidget view3D      = partPreview as View3DWidget;

                    string copyButtonName = "3D View Copy";

                    //Click Edit button to make edit controls visible
                    testRunner.ClickByName("3D View Edit");
                    testRunner.Wait(1);
                    int partCountBeforeCopy = view3D.MeshGroups.Count();
                    resultsHarness.AddTestResult(partCountBeforeCopy == 1);

                    for (int i = 0; i <= 4; i++)
                    {
                        testRunner.ClickByName(copyButtonName);
                        testRunner.Wait(1);
                    }

                    testRunner.Wait(1);

                    int meshCountAfterCopy = view3D.MeshGroups.Count();
                    testRunner.ClickByName("3D View Remove");
                    System.Threading.Thread.Sleep(2000);
                    int meshCountAfterRemove = view3D.MeshGroups.Count();
                    resultsHarness.AddTestResult(meshCountAfterRemove == 5);


                    testRunner.ClickByName("3D View Undo");
                    System.Threading.Thread.Sleep(2000);
                    int meshCountAfterUndo = view3D.MeshGroups.Count();
                    resultsHarness.AddTestResult(meshCountAfterUndo == 6);

                    testRunner.ClickByName("3D View Redo");
                    System.Threading.Thread.Sleep(2000);
                    int meshCountAfterRedo = view3D.MeshGroups.Count();
                    resultsHarness.AddTestResult(meshCountAfterRedo == 5);

                    MatterControlUtilities.CloseMatterControl(testRunner);
                }
            };

            AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun);

            Assert.IsTrue(testHarness.AllTestsPassed);
            Assert.IsTrue(testHarness.TestCount == 4);             // make sure we ran all our tests
        }
Пример #7
0
        public async Task PrinterRecoveryTest()
        {
            await MatterControlUtilities.RunTest((testRunner) =>
            {
                using (var emulator = testRunner.LaunchAndConnectToPrinterEmulator())
                {
                    Assert.AreEqual(1, ApplicationController.Instance.ActivePrinters.Count(), "One printer should exist after add");

                    var printer = ApplicationController.Instance.ActivePrinters.First();
                    printer.Settings.SetValue(SettingsKey.recover_is_enabled, "1");
                    printer.Settings.SetValue(SettingsKey.has_hardware_leveling, "0");

                    // TODO: Delay needed to work around timing issue in MatterHackers/MCCentral#2415
                    testRunner.Delay(1);

                    testRunner.OpenPrintPopupMenu();
                    testRunner.ClickByName("Layer(s) To Pause Field");
                    testRunner.Type("2;4;6");

                    Assert.IsTrue(printer.Connection.RecoveryIsEnabled);

                    // print a part
                    testRunner.AddItemToBedplate();
                    testRunner.StartPrint();

                    // Dismiss pause dialog
                    testRunner.WaitForName("Yes Button", 90);                     // the yes button is 'Resume'

                    // validate the current layer
                    Assert.AreEqual(1, printer.Connection.CurrentlyPrintingLayer);
                    testRunner.ClickByName("Yes Button");

                    // the printer is now paused
                    // close the pause dialog pop-up do not resume
                    ClickDialogButton(testRunner, "No Button", 3);

                    // Disconnect
                    testRunner.ClickByName("Disconnect from printer button");

                    // Reconnect
                    testRunner.WaitForName("Connect to printer button", 10);
                    testRunner.ClickByName("Connect to printer button");

                    testRunner.WaitFor(() => printer.Connection.CommunicationState == CommunicationStates.Connected);

                    // Assert that recovery happens

                    // Recover the print
                    ClickDialogButton(testRunner, "Yes Button", -1);

                    // The first pause that we get after recovery should be layer 6.
                    // wait for the pause and continue
                    ClickDialogButton(testRunner, "Yes Button", 5);

                    // Wait for done
                    testRunner.WaitForPrintFinished();
                }

                return(Task.CompletedTask);
            }, maxTimeToRun : 180);
        }
        public void SaveAsToQueue()
        {
            // Run a copy of MatterControl
            Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
            {
                AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
                {
                    MatterControlUtilities.PrepForTestRun(testRunner);

                    //Navigate to Local Library
                    testRunner.ClickByName("Library Tab");
                    MatterControlUtilities.NavigateToFolder(testRunner, "Local Library Row Item Collection");
                    testRunner.Wait(1);
                    testRunner.ClickByName("Row Item Calibration - Box");
                    MatterControlUtilities.LibraryEditSelectedItem(testRunner);
                    testRunner.Wait(1);

                    //Click Edit button to make edit controls visible
                    testRunner.ClickByName("3D View Edit");
                    testRunner.Wait(1);

                    SystemWindow systemWindow;
                    GuiWidget    partPreview = testRunner.GetWidgetByName("View3DWidget", out systemWindow, 3);
                    View3DWidget view3D      = partPreview as View3DWidget;

                    for (int i = 0; i <= 2; i++)
                    {
                        testRunner.ClickByName("3D View Copy");
                        testRunner.Wait(1);
                    }

                    //Click Save As button to save changes to the part
                    testRunner.ClickByName("Save As Menu");
                    testRunner.Wait(1);
                    testRunner.ClickByName("Save As Menu Item");
                    testRunner.Wait(1);

                    //Type in name of new part and then save to Print Queue
                    testRunner.Type("Save As Print Queue");
                    MatterControlUtilities.NavigateToFolder(testRunner, "Print Queue Row Item Collection");
                    testRunner.Wait(1);
                    testRunner.ClickByName("Save As Save Button");

                    view3D.CloseOnIdle();
                    testRunner.Wait(.5);

                    //Make sure there is a new Queue item with a name that matches the new part
                    testRunner.Wait(1);
                    testRunner.ClickByName("Queue Tab");
                    testRunner.Wait(1);
                    resultsHarness.AddTestResult(testRunner.WaitForName("Queue Item Save As Print Queue", 5));

                    MatterControlUtilities.CloseMatterControl(testRunner);
                }
            };

            AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun);

            Assert.IsTrue(testHarness.AllTestsPassed);
            Assert.IsTrue(testHarness.TestCount == 1);             // make sure we ran all our tests
        }
Пример #9
0
        public async Task ReSliceHasCorrectEPositions()
        {
            Assert.AreEqual(8, IntPtr.Size, "Test requires 64bit environment as Reslice is disabled in 32bit");

            await MatterControlUtilities.RunTest((testRunner) =>
            {
                // testRunner.ClickByName("Connection Wizard Skip Sign In Button");

                using (var emulator = testRunner.LaunchAndConnectToPrinterEmulator())
                {
                    var printer = testRunner.FirstPrinter();
                    printer.Settings.SetValue(SettingsKey.enable_line_splitting, "0");

                    var view3D = testRunner.GetWidgetByName("View3DWidget", out _) as View3DWidget;
                    var scene  = view3D.InteractionLayer.Scene;

                    // Add a callback to check that every line has an extruder
                    // distance greater than the largest distance minus the max retraction
                    // amount and less than some amount that is reasonable
                    double lastAbsoluteEPosition    = 0;
                    double largestAbsoluteEPosition = 0;
                    double largestRetraction        = 0;

                    emulator.EPositionChanged += (e, s) =>
                    {
                        largestAbsoluteEPosition = Math.Max(largestAbsoluteEPosition, emulator.CurrentExtruder.AbsoluteEPosition);
                        var delta = emulator.CurrentExtruder.AbsoluteEPosition - lastAbsoluteEPosition;
                        if (delta < largestRetraction)
                        {
                            largestRetraction = delta;
                        }

                        double printerRetraction = 7 + .1;                         // the airwolf has a retraction of 7 mm
                        Assert.GreaterOrEqual(delta, -printerRetraction, "We should never move back more than the retraction amount");
                        Assert.GreaterOrEqual(emulator.CurrentExtruder.AbsoluteEPosition, largestAbsoluteEPosition - printerRetraction, "Never go back more than the retraction amount");
                        Assert.LessOrEqual(emulator.CurrentExtruder.AbsoluteEPosition, lastAbsoluteEPosition + 10, "We should never move up more than 10 mm");
                        lastAbsoluteEPosition = emulator.CurrentExtruder.AbsoluteEPosition;
                    };

                    // Add a cube to the bed
                    testRunner.NavigateToFolder("Print Queue Row Item Collection");
                    testRunner.ClickByName("Row Item cube_20x20x20");
                    testRunner.ClickByName("Print Library Overflow Menu");
                    testRunner.ClickByName("Add to Bed Menu Item");
                    testRunner.ClickByName("Print Library Overflow Menu");
                    testRunner.ClickByName("Add to Bed Menu Item");

                    // start the print
                    testRunner.StartPrint(pauseAtLayers: "50;60");

                    // Wait for pause
                    testRunner.WaitForName("No Button", 80);                     // the yes button is 'Resume'
                    testRunner.ClickByName("No Button");

                    // Delete the cube
                    testRunner.ClickByName("Bed Options Menu");
                    testRunner.ClickByName("Clear Bed Menu Item");

                    testRunner.Delay();

                    // ensure there is nothing on the bed
                    Assert.AreEqual(0, scene.Children.Count);

                    // Add a cylinder
                    testRunner.NavigateToFolder("Print Queue Row Item Collection");
                    testRunner.ClickByName("Row Item cylinder_5x20");
                    testRunner.ClickByName("Print Library Overflow Menu");
                    testRunner.ClickByName("Add to Bed Menu Item");
                    testRunner.ClickByName("Add Content Menu");

                    // re-slice the part
                    testRunner.ClickByName("Re-Slice Button");
                    testRunner.WaitForName("Switch Button", 10);                     // The change to new g-code
                    testRunner.ClickByName("Switch Button");

                    // and resume the print
                    testRunner.ClickByName("Resume Task Button");

                    // Wait for next pause
                    testRunner.WaitForName("No Button", 80);                     // the yes button is 'Resume'
                    testRunner.ClickByName("No Button");

                    // Switch back to the cube
                    // Delete the cylinder
                    testRunner.ClickByName("Bed Options Menu");
                    testRunner.ClickByName("Clear Bed Menu Item");

                    // ensure there is nothing on the bed
                    Assert.AreEqual(0, scene.Children.Count);

                    // add the cube
                    testRunner.NavigateToFolder("Print Queue Row Item Collection");
                    testRunner.ClickByName("Row Item cube_20x20x20");
                    testRunner.ClickByName("Print Library Overflow Menu");
                    testRunner.ClickByName("Add to Bed Menu Item");
                    testRunner.ClickByName("Add Content Menu");

                    // re-slice the part
                    testRunner.ClickByName("Re-Slice Button");
                    testRunner.WaitForName("Switch Button", 10);                     // The change to new g-code
                    testRunner.ClickByName("Switch Button");

                    // and resume the print
                    testRunner.ClickByName("Resume Task Button");

                    // Wait for done
                    testRunner.WaitForPrintFinished(printer);

                    // this will make sure we turned off line splitting and had good data about the extruder position
                    Assert.AreEqual(-7, largestRetraction, "Airwolf HD has a retraction of 7mm, make sure we had one");
                }

                return(Task.CompletedTask);
            },
                                                 maxTimeToRun : 290,
                                                 queueItemFolderToAdd : QueueTemplate.ReSliceParts);
        }
Пример #10
0
        public void AddToQueueFromLibraryButtonAddsItemsToQueue()
        {
            // Run a copy of MatterControl
            Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
            {
                AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
                {
                    MatterControlUtilities.PrepForTestRun(testRunner);

                    //Navigate to Local Library
                    testRunner.ClickByName("Library Tab");
                    MatterControlUtilities.NavigateToFolder(testRunner, "Local Library Row Item Collection");

                    //Add an item to the library
                    string libraryItemToAdd = MatterControlUtilities.GetTestItemPath("Fennec_Fox.stl");
                    testRunner.ClickByName("Library Add Button");

                    testRunner.Wait(2);
                    testRunner.Type(libraryItemToAdd);
                    testRunner.Wait(2);
                    testRunner.Type("{Enter}");

                    testRunner.Wait(1);
                    testRunner.ClickByName("Library Edit Button");
                    testRunner.Wait(1);

                    int queueCountBeforeAdd = QueueData.Instance.Count;

                    //Select both Library Items
                    string rowItemOne = "Row Item " + "Calibration - Box";
                    testRunner.ClickByName(rowItemOne);

                    string rowItemTwo = "Row Item " + "Fennec Fox";
                    testRunner.ClickByName(rowItemTwo);


                    //Click the Add To Queue button
                    testRunner.Wait(1);
                    MatterControlUtilities.LibraryAddSelectionToQueue(testRunner);
                    testRunner.Wait(2);

                    //Make sure Queue Count increases by the correct amount
                    int queueCountAfterAdd = QueueData.Instance.Count;

                    resultsHarness.AddTestResult(queueCountAfterAdd == queueCountBeforeAdd + 2);

                    //Navigate to the Print Queue
                    testRunner.ClickByName("Queue Tab");
                    testRunner.Wait(1);


                    //Test that both added print items exist
                    string queueItemOne         = "Queue Item " + "Calibration - Box";
                    string queueItemTwo         = "Queue Item " + "Fennec_Fox";
                    bool   queueItemOneWasAdded = testRunner.WaitForName(queueItemOne, 2);
                    bool   queueItemTwoWasAdded = testRunner.WaitForName(queueItemTwo, 2);

                    resultsHarness.AddTestResult(queueItemOneWasAdded == true);
                    resultsHarness.AddTestResult(queueItemTwoWasAdded == true);

                    MatterControlUtilities.CloseMatterControl(testRunner);
                }
            };

            AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun);

            Assert.IsTrue(testHarness.AllTestsPassed(3));
        }
Пример #11
0
        public void ExportToZipMenuItemClicked()
        {
            // Run a copy of MatterControl
            Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
            {
                AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
                {
                    MatterControlUtilities.PrepForTestRun(testRunner);

                    /*
                     * Tests Export to Zip menu item is clicked the queue is compressed and exported to location on disk
                     * 1. Check that there are items in the queue
                     * 2. Export Queue and make sure file exists on disk
                     */

                    bool queueEmpty = true;
                    int  queueItemCountBeforeRemoveAllClicked = QueueData.Instance.Count;

                    if (queueItemCountBeforeRemoveAllClicked > 0)
                    {
                        queueEmpty = false;
                    }

                    resultsHarness.AddTestResult(queueEmpty == false);

                    testRunner.ClickByName("Queue... Menu", 2);

                    testRunner.ClickByName(" Export to Zip Menu Item", 2);

                    testRunner.Wait(2);

                    //Type in Absolute Path to Save
                    string exportZipPath = MatterControlUtilities.GetTestItemPath("TestExportZip.zip");

                    // Ensure file does not exist before save
                    if (File.Exists(exportZipPath))
                    {
                        File.Delete(exportZipPath);
                    }

                    testRunner.Type(exportZipPath);

                    testRunner.Wait(2);

                    testRunner.Type("{Enter}");

                    testRunner.Wait(1);

                    bool queueWasExportedToZip = File.Exists(exportZipPath);

                    testRunner.Wait(2);

                    resultsHarness.AddTestResult(queueWasExportedToZip == true);

                    //Add the exprted zip file to the Queue and confirm that the Queue Count increases by 3
                    testRunner.ClickByName("Queue Add Button");
                    testRunner.Wait(1);
                    testRunner.Type(exportZipPath);
                    testRunner.Wait(1);
                    testRunner.Type("{Enter}");

                    int  queueCountAfterZipIsAdded        = QueueData.Instance.Count;
                    bool allItemsInZipWereAddedToTheQueue = false;

                    if (queueCountAfterZipIsAdded == queueItemCountBeforeRemoveAllClicked * 2)
                    {
                        allItemsInZipWereAddedToTheQueue = true;
                    }

                    resultsHarness.AddTestResult(allItemsInZipWereAddedToTheQueue == true);

                    if (File.Exists(exportZipPath))
                    {
                        File.Delete(exportZipPath);
                    }

                    MatterControlUtilities.CloseMatterControl(testRunner);
                }
            };

            AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items);

            Assert.IsTrue(testHarness.AllTestsPassed(3));
        }
Пример #12
0
        public void GroupAndUngroup()
        {
            // Run a copy of MatterControl
            Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
            {
                AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
                {
                    MatterControlUtilities.PrepForTestRun(testRunner);

                    SystemWindow systemWindow;

                    //Navigate to Local Library
                    testRunner.ClickByName("Library Tab");
                    MatterControlUtilities.NavigateToFolder(testRunner, "Local Library Row Item Collection");
                    testRunner.Wait(1);
                    testRunner.ClickByName("Row Item Calibration - Box");
                    MatterControlUtilities.LibraryEditSelectedItem(testRunner);
                    testRunner.Wait(1);

                    //Get View3DWidget and count MeshGroups before Copy button is clicked
                    GuiWidget    partPreview = testRunner.GetWidgetByName("View3DWidget", out systemWindow, 3);
                    View3DWidget view3D      = partPreview as View3DWidget;

                    string copyButtonName = "3D View Copy";

                    //Click Edit button to make edit controls visible
                    testRunner.ClickByName("3D View Edit");
                    testRunner.Wait(1);
                    int partCountBeforeCopy = view3D.MeshGroups.Count();
                    resultsHarness.AddTestResult(partCountBeforeCopy == 1);

                    for (int i = 0; i <= 4; i++)
                    {
                        testRunner.ClickByName(copyButtonName);
                        testRunner.Wait(1);
                    }

                    //Get MeshGroupCount before Group is clicked
                    System.Threading.Thread.Sleep(2000);
                    int partsOnBedBeforeGroup = view3D.MeshGroups.Count();
                    resultsHarness.AddTestResult(partsOnBedBeforeGroup == 6);

                    //Click Group Button and get MeshGroup count after Group button is clicked
                    testRunner.ClickByName("3D View Group");
                    System.Threading.Thread.Sleep(2000);
                    int partsOnBedAfterGroup = view3D.MeshGroups.Count();
                    resultsHarness.AddTestResult(partsOnBedAfterGroup == 1);

                    testRunner.ClickByName("3D View Ungroup");
                    System.Threading.Thread.Sleep(2000);
                    int partsOnBedAfterUngroup = view3D.MeshGroups.Count();
                    resultsHarness.AddTestResult(partsOnBedAfterUngroup == 6);

                    MatterControlUtilities.CloseMatterControl(testRunner);
                }
            };

            AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun);

            Assert.IsTrue(testHarness.AllTestsPassed(4));
        }
Пример #13
0
        public async Task DimensionsWorkWhenNoSheet()
        {
            await MatterControlUtilities.RunTest((testRunner) =>
            {
                testRunner.OpenEmptyPartTab();

                var primitive     = "Cube";
                var primitiveName = "Row Item " + primitive;
                testRunner.DoubleClickByName(primitiveName);

                // Get View3DWidget
                View3DWidget view3D = testRunner.GetWidgetByName("View3DWidget", out _, 3) as View3DWidget;
                var scene           = view3D.Object3DControlLayer.Scene;

                testRunner.WaitForName(primitive);
                Assert.AreEqual(1, scene.Children.Count, "Should have 1 part");

                var cube = testRunner.GetObjectByName(primitive, out _) as CubeObject3D;

                Assert.AreEqual(20, cube.Width.Value(cube), .001);

                // Select scene object
                testRunner.Select3DPart(primitive);

                // Scale it wider
                testRunner.DragDropByName("ScaleWidthRight",
                                          "ScaleWidthRight",
                                          offsetDrag: new Point2D(0, 0),
                                          offsetDrop: new Point2D(0, 10));
                Assert.Greater(cube.Width.Value(cube), 20.0);

                testRunner.ClickByName("3D View Undo");
                Assert.AreEqual(20, cube.Width.Value(cube), .0001);

                // try scaling by text entry
                testRunner.ClickByName("ScaleWidthLeft")
                .ClickByName("XValueDisplay")
                .Type("35")
                .Type("{Enter}");

                Assert.AreEqual(35, cube.Width.Value(cube));

                testRunner.ClickByName("3D View Undo");
                Assert.AreEqual(20, cube.Width.Value(cube), .0001);

                // try scaling by text entry of an equation
                testRunner.ClickByName("Width Field")
                .Type("=40 + 5")
                .Type("{Enter}");

                Assert.AreEqual(45, cube.Width.Value(cube));

                // Select Nothing
                testRunner.ClickByName("View3DWidget");
                testRunner.SelectNone();
                Assert.AreEqual(null, scene.SelectedItem);
                // and re-select the object
                testRunner.SelectAll();
                Assert.AreEqual(1, scene.Children.Count);
                Assert.AreEqual(cube, scene.SelectedItem);

                // now that has an equation in the width it should not have an x edge controls
                Assert.IsFalse(testRunner.NameExists("ScaleWidthRight", .2));

                testRunner.ClickByName("3D View Undo");
                Assert.AreEqual(20, cube.Width.Value(cube), .0001);

                return(Task.CompletedTask);
            }, overrideWidth : 1300, maxTimeToRun : 60);
        }
Пример #14
0
 public void TestSetup()
 {
     StaticData.RootPath = TestContext.CurrentContext.ResolveProjectPath(4, "StaticData");
     MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4));
 }
Пример #15
0
 public void Setup()
 {
     MatterControlUtilities.CreateDownloadsSubFolder();
 }
Пример #16
0
        public async Task TuningAdjustmentControlsBoundToStreamValues()
        {
            double targetExtrusionRate = 1.5;
            double targetFeedRate      = 2;

            double initialExtrusionRate = 0.6;
            double initialFeedRate      = 0.7;

            AutomationTest testToRun = (testRunner) =>
            {
                SystemWindow systemWindow;

                testRunner.WaitForName("Cancel Wizard Button", 1);

                // Set custom adjustment values
                FeedRateMultiplyerStream.FeedRateRatio   = initialFeedRate;
                ExtrusionMultiplyerStream.ExtrusionRatio = initialExtrusionRate;

                // Then validate that they are picked up
                using (var emulatorDisposable = testRunner.LaunchAndConnectToPrinterEmulator())
                {
                    Assert.IsTrue(ProfileManager.Instance.ActiveProfile != null);

                    testRunner.SwitchToSettingsAndControls();

                    testRunner.ClickByName("Controls Tab", 1);

                    testRunner.ClickByName("Start Print Button", 1);

                    var container = testRunner.GetWidgetByName("ManualPrinterControls.ControlsContainer", out systemWindow, 5);

                    // Scroll the widget into view
                    var scrollable = container.Parents <ManualPrinterControls>().First().Children <ScrollableWidget>().First();
                    var width      = scrollable.Width;

                    // Workaround needed to scroll to the bottom of the Controls panel
                    //scrollable.ScrollPosition = new Vector2();
                    scrollable.ScrollPosition = new Vector2(0, 30);

                    // Workaround to force layout to fix problems with size of Tuning Widgets after setting ScrollPosition manually
                    scrollable.Width = width - 1;
                    scrollable.Width = width;

                    // Tuning values should match
                    ConfirmExpectedSpeeds(testRunner, initialExtrusionRate, initialFeedRate);

                    testRunner.Delay();
                    testRunner.ClickByName("Extrusion Multiplier NumberEdit");
                    testRunner.Type(targetExtrusionRate.ToString());

                    testRunner.ClickByName("Feed Rate NumberEdit");
                    testRunner.Type(targetFeedRate.ToString());

                    // Force focus away from the feed rate field, causing an persisted update
                    testRunner.ClickByName("Controls Tab", 1);
                    testRunner.Delay();

                    ConfirmExpectedSpeeds(testRunner, targetExtrusionRate, targetFeedRate);

                    // Wait for slicing to complete before setting target values
                    testRunner.Delay(() => PrinterConnectionAndCommunication.Instance.PrintingState == PrinterConnectionAndCommunication.DetailedPrintingState.Printing, 8);
                    testRunner.Delay();

                    // Values should remain after print completes
                    ConfirmExpectedSpeeds(testRunner, targetExtrusionRate, targetFeedRate);

                    // Wait for printing to complete
                    var resetEvent = new AutoResetEvent(false);
                    PrinterConnectionAndCommunication.Instance.PrintFinished.RegisterEvent((s, e) => resetEvent.Set(), ref unregisterEvents);
                    resetEvent.WaitOne();

                    testRunner.WaitForName("Done Button", 30);
                    testRunner.WaitForName("Print Again Button", 1);

                    // Values should match entered values
                    testRunner.ClickByName("Print Again Button", 1);
                    testRunner.Delay(2);

                    // Values should match entered values
                    ConfirmExpectedSpeeds(testRunner, targetExtrusionRate, targetFeedRate);

                    testRunner.CancelPrint();
                    testRunner.Delay(1);

                    // Values should match entered values
                    ConfirmExpectedSpeeds(testRunner, targetExtrusionRate, targetFeedRate);
                }

                return(Task.FromResult(0));
            };

            await MatterControlUtilities.RunTest(testToRun, overrideHeight : 900, maxTimeToRun : 990);
        }
Пример #17
0
 public void TearDown()
 {
     MatterControlUtilities.DeleteDownloadsSubFolder();
 }
Пример #18
0
        public async Task SwitchingMaterialsCausesSettingsChangedEvents()
        {
            await MatterControlUtilities.RunTest((testRunner) =>
            {
                testRunner.AddAndSelectPrinter();

                var printer = testRunner.FirstPrinter();

                printer.Settings.OemLayer[SettingsKey.layer_height] = ".2";

                int layerHeightChangedCount = 0;

                PrinterSettings.AnyPrinterSettingChanged += (s, stringEvent) =>
                {
                    if (stringEvent != null)
                    {
                        if (stringEvent.Data == SettingsKey.layer_height)
                        {
                            layerHeightChangedCount++;
                        }
                    }
                };

                // Navigate to Local Library
                testRunner.SwitchToSliceSettings();

                // Navigate to General Tab -> Layers / Surface Tab
                testRunner.SelectSliceSettingsField(SettingsKey.layer_height);
                Assert.AreEqual(0, layerHeightChangedCount, "No change to layer height yet.");

                var theme     = ApplicationController.Instance.Theme;
                var indicator = testRunner.GetWidgetByName("Layer Thickness OverrideIndicator", out _);

                Assert.AreEqual(Color.Transparent, indicator.BackgroundColor);

                testRunner.ClickByName("Quality")
                .ClickByName("Fine Menu")
                .Delay(.5);
                Assert.AreEqual(1, layerHeightChangedCount, "Changed to fine.");
                Assert.AreEqual(theme.PresetColors.QualityPreset, indicator.BackgroundColor);

                testRunner.ClickByName("Quality")
                .ClickByName("Standard Menu")
                .Delay(.5);
                Assert.AreEqual(2, layerHeightChangedCount, "Changed to standard.");
                Assert.AreEqual(theme.PresetColors.QualityPreset, indicator.BackgroundColor);

                testRunner.ClickByName("Quality")
                .ClickByName("- none - Menu Item")
                .Delay(.5);
                Assert.AreEqual(Color.Transparent, indicator.BackgroundColor);
                Assert.AreEqual(3, layerHeightChangedCount, "Changed to - none -.");

                testRunner.ClickByName("Quality")
                .ClickByName("Standard Menu")
                .Delay(.5);
                Assert.AreEqual(4, layerHeightChangedCount, "Changed to standard.");
                Assert.AreEqual(theme.PresetColors.QualityPreset, indicator.BackgroundColor);

                // TODO: delete one of the settings
                // asserts that the deleted setting has been removed from the list

                return(Task.CompletedTask);
            }, maxTimeToRun : 1000);
        }
Пример #19
0
        public async Task CompletingPrintTurnsoffHeat()
        {
            await MatterControlUtilities.RunTest((testRunner) =>
            {
                testRunner.WaitForName("Cancel Wizard Button", 1);

                using (var emulator = testRunner.LaunchAndConnectToPrinterEmulator())
                {
                    Assert.AreEqual(1, ApplicationController.Instance.ActivePrinters.Count(), "One printer should be defined after add");

                    testRunner.SelectSliceSettingsField("Printer", "end_gcode");

                    testRunner.Type("^a");
                    testRunner.Type("{BACKSPACE}");
                    testRunner.Type("G28");

                    testRunner.SelectSliceSettingsField("Printer", "start_gcode");

                    var printer = ApplicationController.Instance.ActivePrinters.First();

                    // Validate GCode fields persist values
                    Assert.AreEqual(
                        "G28",
                        printer.Settings.GetValue(SettingsKey.end_gcode),
                        "Failure persisting GCode/MultilineTextField value");

                    testRunner.AddItemToBedplate();

                    // Shorten the delay so the test runs in a reasonable time
                    printer.Connection.TimeToHoldTemperature = 5;

                    testRunner.StartPrint();

                    // Wait for print to finish
                    testRunner.WaitForPrintFinished();

                    // Wait for expected temp
                    testRunner.WaitFor(() => printer.Connection.GetActualHotendTemperature(0) <= 0, 10);
                    Assert.Less(printer.Connection.GetActualHotendTemperature(0), 30);

                    // Wait for expected temp
                    testRunner.WaitFor(() => printer.Connection.ActualBedTemperature <= 10);
                    Assert.Less(printer.Connection.ActualBedTemperature, 10);

                    // Make sure we can run this whole thing again
                    testRunner.StartPrint();

                    // Wait for print to finish
                    testRunner.WaitForPrintFinished();

                    // Wait for expected temp
                    testRunner.WaitFor(() => printer.Connection.GetActualHotendTemperature(0) <= 0, 10);
                    Assert.Less(printer.Connection.GetActualHotendTemperature(0), 30);

                    // Wait for expected temp
                    testRunner.WaitFor(() => printer.Connection.ActualBedTemperature <= 10);
                    Assert.Less(printer.Connection.ActualBedTemperature, 10);
                }

                return(Task.CompletedTask);
            }, maxTimeToRun : 95);
        }
Пример #20
0
        public async Task QualitySettingsStayAsOverrides()
        {
            await MatterControlUtilities.RunTest((testRunner) =>
            {
                testRunner.WaitForFirstDraw();

                // Add Guest printers
                testRunner.AddAndSelectPrinter("Airwolf 3D", "HD")
                .SwitchToSliceSettings();

                var printer = testRunner.FirstPrinter();

                testRunner.SelectSliceSettingsField(SettingsKey.layer_height)
                .Type(".5")
                // Force lose focus
                .SelectSliceSettingsField(SettingsKey.first_layer_height)
                .WaitFor(() => printer.Settings.GetValue <double>(SettingsKey.layer_height) == 0.5);

                Assert.AreEqual(printer.Settings.GetValue <double>(SettingsKey.layer_height).ToString(), "0.5", "Layer height is what we set it to");

                testRunner.ClickByName("Quality")
                .ClickByName("Fine Menu");

                testRunner.WaitFor(() => printer.Settings.GetValue <double>(SettingsKey.layer_height) == 0.1);
                Assert.AreEqual(printer.Settings.GetValue <double>(SettingsKey.layer_height).ToString(), "0.1", "Layer height is the fine override");

                // Close Airwolf
                testRunner.CloseFirstPrinterTab();

                // Assert printer counts
                Assert.AreEqual(1, ProfileManager.Instance.ActiveProfiles.Count(), "ProfileManager should have 1 profile after Airwolf close");
                Assert.AreEqual(0, ApplicationController.Instance.ActivePrinters.Count(), "Zero printers should be active after Airwolf close");

                testRunner.AddAndSelectPrinter("BCN3D", "Sigma");

                // Assert printer counts
                Assert.AreEqual(2, ProfileManager.Instance.ActiveProfiles.Count(), "ProfileManager has 2 profiles");
                Assert.AreEqual(1, ApplicationController.Instance.ActivePrinters.Count(), "One printer should be active after BCN add");

                // Close BCN
                testRunner.CloseFirstPrinterTab()
                // Reopen Airwolf
                .SwitchToHardwareTab()
                .DoubleClickByName("Airwolf 3D HD Node")
                .Delay(0.2);

                printer = testRunner.FirstPrinter();

                testRunner.WaitFor(() => printer.Settings.GetValue <double>(SettingsKey.layer_height) == 0.1);
                Assert.AreEqual(printer.Settings.GetValue <double>(SettingsKey.layer_height).ToString(), "0.1", "Layer height is the fine override");

                // Switch to Slice Settings Tab
                testRunner.ClickByName("Slice Settings Tab")
                .ClickByName("Quality")
                .ClickByName("- none - Menu Item")
                .WaitFor(() => printer.Settings.GetValue <double>(SettingsKey.layer_height) == 0.5);

                Assert.AreEqual(printer.Settings.GetValue <double>(SettingsKey.layer_height).ToString(), "0.5", "Layer height is what we set it to");

                return(Task.CompletedTask);
            }, maxTimeToRun : 120);
        }
Пример #21
0
        public async Task TuningAdjustmentControlsBoundToStreamValues()
        {
            double targetExtrusionRate = 1.5;
            double targetFeedRate      = 2;

            double initialExtrusionRate = 0.6;
            double initialFeedRate      = 0.7;

            await MatterControlUtilities.RunTest((testRunner) =>
            {
                testRunner.WaitForName("Cancel Wizard Button");

                // Set custom adjustment values
                FeedRateMultiplyerStream.FeedRateRatio   = initialFeedRate;
                ExtrusionMultiplyerStream.ExtrusionRatio = initialExtrusionRate;

                // Then validate that they are picked up
                using (var emulator = testRunner.LaunchAndConnectToPrinterEmulator())
                {
                    Assert.AreEqual(1, ApplicationController.Instance.ActivePrinters.Count(), "One printer should be defined after add");

                    testRunner.AddItemToBedplate();

                    testRunner.SwitchToControlsTab();

                    var printer = ApplicationController.Instance.ActivePrinter;

                    var printFinishedResetEvent       = new AutoResetEvent(false);
                    printer.Connection.PrintFinished += (s, e) => printFinishedResetEvent.Set();

                    testRunner.StartPrint();

                    var container = testRunner.GetWidgetByName("ManualPrinterControls.ControlsContainer", out _, 5);

                    // Scroll the widget into view
                    var scrollable = container.Parents <ManualPrinterControls>().FirstOrDefault() as ScrollableWidget;
                    var width      = scrollable.Width;

                    // Workaround needed to scroll to the bottom of the Controls panel
                    //scrollable.ScrollPosition = new Vector2();
                    scrollable.ScrollPosition = new Vector2(0, 30);

                    // Workaround to force layout to fix problems with size of Tuning Widgets after setting ScrollPosition manually
                    scrollable.Width = width - 1;
                    scrollable.Width = width;

                    // Tuning values should match
                    ConfirmExpectedSpeeds(testRunner, initialExtrusionRate, initialFeedRate, "Initial case");

                    testRunner.Delay();
                    testRunner.ClickByName("Extrusion Multiplier NumberEdit");
                    testRunner.Type(targetExtrusionRate.ToString());

                    testRunner.ClickByName("Feed Rate NumberEdit");
                    testRunner.Type(targetFeedRate.ToString());

                    // Force focus away from the feed rate field, causing an persisted update
                    testRunner.ClickByName("Extrusion Multiplier NumberEdit");

                    ConfirmExpectedSpeeds(testRunner, targetExtrusionRate, targetFeedRate, "After setting TextEdit values");

                    // Wait for slicing to complete before setting target values
                    testRunner.WaitFor(() => printer.Connection.DetailedPrintingState == DetailedPrintingState.Printing, 8);
                    testRunner.Delay();

                    // Values should remain after print completes
                    ConfirmExpectedSpeeds(testRunner, targetExtrusionRate, targetFeedRate, "While printing");

                    // Wait for printing to complete
                    printFinishedResetEvent.WaitOne();

                    testRunner.WaitForPrintFinished();

                    // Values should match entered values
                    testRunner.StartPrint();
                    testRunner.WaitFor(() => printer.Connection.CommunicationState == CommunicationStates.Printing, 15);

                    // Values should match entered values
                    ConfirmExpectedSpeeds(testRunner, targetExtrusionRate, targetFeedRate, "While reprinting");

                    testRunner.CancelPrint();
                    testRunner.WaitFor(() => printer.Connection.CommunicationState == CommunicationStates.Connected, 15);

                    // Values should match entered values
                    ConfirmExpectedSpeeds(testRunner, targetExtrusionRate, targetFeedRate, "After cancel");
                }

                return(Task.CompletedTask);
            }, overrideHeight : 900, maxTimeToRun : 120);
        }
        public async Task ExportStreamG92HandlingTest()
        {
            await MatterControlUtilities.RunTest(testRunner =>
            {
                testRunner.WaitForFirstDraw();

                testRunner.CloneAndSelectPrinter("No Retraction after Purge");

                var printer = testRunner.FirstPrinter();

                //Navigate to Downloads Library Provider
                testRunner.NavigateToFolder("Print Queue Row Item Collection");
                testRunner.InvokeLibraryAddDialog();

                //Get parts to add
                string rowItemPath = MatterControlUtilities.GetTestItemPath("Batman.stl");
                testRunner.Delay()
                .Type(MatterControlUtilities.GetTestItemPath("Batman.stl"))
                .Delay()
                .Type("{Enter}");

                //Get test results
                testRunner.ClickByName("Row Item Batman.stl")
                .ClickByName("Print Library Overflow Menu")
                .ClickByName("Export Menu Item")
                .WaitForName("Export Item Window");

                testRunner.ClickByName("Machine File (G-Code) Button")
                .ClickByName("Export Button");

                string gcodeOutputPath = MatterControlUtilities.PathToExportGcodeFolder;

                Directory.CreateDirectory(gcodeOutputPath);

                string fullPathToGcodeFile = Path.Combine(gcodeOutputPath, "Batman");
                testRunner.Type(fullPathToGcodeFile);
                testRunner.Type("{Enter}");

                var filename = fullPathToGcodeFile + ".gcode";
                testRunner.WaitFor(() => File.Exists(filename), 10)
                .WaitFor(() => !IsFileLocked(filename), 1000)
                .Delay(2);

                // validate that the actual printer output has the right lines
                var expectedLines = new string[]
                {
                    "G28                    ; home all axes",
                    "M280 P0 S160",
                    "G4 P400",
                    "M280 P0 S90",
                    "M109 S205",
                    "G1 X5 Y5 Z3.13 F1800",
                    "G92 E0                 ; Purge line",
                    "G1 X5.83 Y5 Z3.04 E0.833 F900",
                    "G1 X6.67 Y5 Z2.96 E1.667",
                    "G1 X7.5 Y5 Z2.87 E2.5",
                    "G1 X8.33 Y5 Z2.79 E3.333",
                    "G1 X9.17 Y5 Z2.7 E4.167",
                    "G1 X10 Y5 Z2.62 E5",
                    "G92 E0                 ; Purge line",
                    "G1 X10 Y5 Z2.62 E-2 F2400",
                    "M75                    ; start print timer",
                };

                var actualLines = File.ReadAllLines(filename);
                ValidateLinesStartingWithFirstExpected(expectedLines, actualLines);

                // make sure the file has the expected header

                return(Task.FromResult(0));
            }, maxTimeToRun : 200);
        }
Пример #23
0
        public async Task PulseRequiresLevelingAndLevelingWorks()
        {
            await MatterControlUtilities.RunTest((testRunner) =>
            {
                AutomationRunner.TimeToMoveMouse = .2;
                testRunner.WaitForName("Cancel Wizard Button", 1);

                using (var emulator = testRunner.LaunchAndConnectToPrinterEmulator("Pulse", "A-134"))
                {
                    Assert.AreEqual(1, ApplicationController.Instance.ActivePrinters.Count(), "One printer should be defined after add");

                    testRunner.ClickByName("Finish Setup Button");

                    testRunner.Complete9StepLeveling();

                    // print a part
                    testRunner.AddItemToBedplate();

                    var printer = ApplicationController.Instance.ActivePrinters.FirstOrDefault();

                    var currentSettings = printer.Settings;
                    currentSettings.SetValue(SettingsKey.pause_gcode, "");
                    currentSettings.SetValue(SettingsKey.resume_gcode, "");

                    testRunner.OpenPrintPopupMenu();
                    testRunner.ClickByName("Layer(s) To Pause Field");
                    testRunner.Type("2");

                    testRunner.StartPrint();

                    testRunner.WaitForName("Yes Button", 20);                    // the yes button is 'Resume'

                    // the user types in the pause layer 1 based and we are 0 based, so we should be on: user 2, printer 1.
                    Assert.AreEqual(1, printer.Connection.CurrentlyPrintingLayer);

                    // assert the leveling is working
                    Assert.AreEqual(11.15, emulator.ZPosition);

                    testRunner.CancelPrint();

                    // now run leveling again and make sure we get the same result
                    testRunner.SwitchToControlsTab();
                    testRunner.ClickByName("Run Leveling Button");
                    testRunner.Complete9StepLeveling(2);

                    testRunner.OpenPrintPopupMenu();
                    testRunner.ClickByName("Layer(s) To Pause Field");
                    testRunner.Type("2");

                    testRunner.StartPrint();

                    testRunner.WaitForName("Yes Button", 20);                    // the yes button is 'Resume'

                    // the user types in the pause layer 1 based and we are 0 based, so we should be on: user 2, printer 1.
                    Assert.AreEqual(1, printer.Connection.CurrentlyPrintingLayer);
                    // assert the leveling is working
                    Assert.AreEqual(12.15, emulator.ZPosition);

                    testRunner.CancelPrint();

                    // now modify the leveling data manualy and assert that it is applied when printing
                    testRunner.SwitchToControlsTab();
                    testRunner.ClickByName("Edit Leveling Data Button");
                    for (int i = 0; i < 3; i++)
                    {
                        var name = $"z Position {i}";
                        testRunner.ClickByName(name);
                        testRunner.Type("^a");                         // select all
                        testRunner.Type("5");
                    }

                    testRunner.ClickByName("Save Leveling Button");

                    testRunner.OpenPrintPopupMenu();
                    testRunner.ClickByName("Layer(s) To Pause Field");
                    testRunner.Type("2");

                    testRunner.StartPrint();

                    testRunner.WaitForName("Yes Button", 20);                    // the yes button is 'Resume'

                    // the user types in the pause layer 1 based and we are 0 based, so we should be on: user 2, printer 1.
                    Assert.AreEqual(1, printer.Connection.CurrentlyPrintingLayer);

                    // assert the leveling is working
                    Assert.AreEqual(5.15, emulator.ZPosition);
                }

                return(Task.CompletedTask);
            }, maxTimeToRun : 130);
        }
Пример #24
0
        public async Task PulseRequiresLevelingAndLevelingWorks()
        {
            await MatterControlUtilities.RunTest((testRunner) =>
            {
                testRunner.WaitForName("Cancel Wizard Button", 1);

                using (var emulator = testRunner.LaunchAndConnectToPrinterEmulator("Pulse", "A-134"))
                {
                    Assert.IsTrue(ProfileManager.Instance.ActiveProfile != null);

                    testRunner.ClickByName("Finish Setup Button");

                    testRunner.Complete9StepLeveling();

                    // print a part
                    testRunner.AddItemToBedplate();

                    var currentSettings = ApplicationController.Instance.ActivePrinter.Settings;
                    currentSettings.SetValue(SettingsKey.pause_gcode, "");
                    currentSettings.SetValue(SettingsKey.resume_gcode, "");

                    testRunner.OpenPrintPopupMenu();
                    testRunner.ClickByName("Layer(s) To Pause Field");
                    testRunner.Type("2");

                    testRunner.StartPrint();

                    testRunner.WaitForName("Yes Button", 20);                    // the yes button is 'Resume'

                    var printer = ApplicationController.Instance.ActivePrinter;

                    // the usre types in the pause layer 1 based and we are 0 based, so we should be on: user 2, printer 1.
                    Assert.AreEqual(1, printer.Connection.CurrentlyPrintingLayer);

                    // assert the leveling is working
                    Assert.AreEqual(11.15, emulator.ZPosition);

                    testRunner.CancelPrint();

                    // now run leveling again and make sure we get the same result
                    testRunner.SwitchToControlsTab();
                    testRunner.ClickByName("Run Leveling Button");
                    testRunner.Complete9StepLeveling(2);

                    testRunner.OpenPrintPopupMenu();
                    testRunner.ClickByName("Layer(s) To Pause Field");
                    testRunner.Type("2");

                    testRunner.StartPrint();

                    testRunner.WaitForName("Yes Button", 20);                    // the yes button is 'Resume'

                    // the usre types in the pause layer 1 based and we are 0 based, so we should be on: user 2, printer 1.
                    Assert.AreEqual(1, printer.Connection.CurrentlyPrintingLayer);
                    // assert the leveling is working
                    Assert.AreEqual(12.15, emulator.ZPosition);
                }

                return(Task.CompletedTask);
            }, maxTimeToRun : 90);
        }