public static AutomationTesterHarness RunTest( Action <AutomationTesterHarness> testToRun, string staticDataPathOverride = null, double maxTimeToRun = 60, QueueTemplate queueItemFolderToAdd = QueueTemplate.None, int overrideWidth = -1, int overrideHeight = -1) { 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 !__ANDROID__ // Set the static data to point to the directory of MatterControl StaticData.Instance = 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) { string queueTemplateDirectory = queueItemFolderToAdd.ToString(); MatterControlUtilities.AddItemsToQueue(queueTemplateDirectory); } MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(overrideWidth, overrideHeight); return(AutomationTesterHarness.ShowWindowAndExecuteTests(matterControlWindow, testToRun, maxTimeToRun)); }
public static AutomationTesterHarness RunTest( Action <AutomationTesterHarness> testToRun, string staticDataPathOverride = null, double maxTimeToRun = 60, QueueTemplate queueItemFolderToAdd = QueueTemplate.None, int overrideWidth = -1, int overrideHeight = -1) { // Walk back a step in the stack and output the callers name StackTrace st = new StackTrace(false); Console.WriteLine("\r\nRunning automation test: " + st.GetFrames().Skip(1).First().GetMethod().Name); if (staticDataPathOverride == null) { staticDataPathOverride = Path.Combine("..", "..", "..", "..", "StaticData"); } #if !__ANDROID__ // Set the static data to point to the directory of MatterControl StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(staticDataPathOverride); #endif MatterControlUtilities.OverrideAppDataLocation(); if (queueItemFolderToAdd != QueueTemplate.None) { string queueTemplateDirectory = queueItemFolderToAdd.ToString(); MatterControlUtilities.AddItemsToQueue(queueTemplateDirectory); } MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(overrideWidth, overrideHeight); return(AutomationTesterHarness.ShowWindowAndExecuteTests(matterControlWindow, testToRun, maxTimeToRun)); }
public void CopyFromTest() { StaticData.RootPath = TestContext.CurrentContext.ResolveProjectPath(4, "StaticData"); MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4)); var settings = new PrinterSettings(); settings.ID = "12345-print"; settings.SetValue(SettingsKey.auto_connect, "1"); settings.SetValue(SettingsKey.com_port, "some_com_port"); settings.SetValue(SettingsKey.cancel_gcode, "hello world"); settings.Macros.Add(new GCodeMacro() { Name = "Macro1", GCode = "G28 ; Home Printer" }); settings.StagedUserSettings["retract_restart_extra_time_to_apply"] = "4"; settings.StagedUserSettings["retract_restart_extra"] = "0.3"; settings.StagedUserSettings["bridge_fan_speed"] = "50"; var sha1 = settings.ComputeSHA1(); var clone = new PrinterSettings(); clone.CopyFrom(settings); Assert.AreEqual(settings.ToJson(), clone.ToJson(), "Cloned settings via CopyFrom should equal source"); Assert.AreEqual(sha1, clone.ComputeSHA1(), "Cloned settings via CopyFrom should equal source"); }
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); #if !__ANDROID__ // Set the static data to point to the directory of MatterControl StaticData.Instance = 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) { string queueTemplateDirectory = queueItemFolderToAdd.ToString(); MatterControlUtilities.AddItemsToQueue(queueTemplateDirectory); } if (defaultTestImages == null) { defaultTestImages = TestContext.CurrentContext.ResolveProjectPath(4, "Tests", "TestData", "TestImages"); } UserSettings.Instance.set(UserSettingsKey.ThumbnailRenderingMode, "orthographic"); //GL.HardwareAvailable = false; MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(overrideWidth, overrideHeight); var config = TestAutomationConfig.Load(); // Extract mouse speed from config AutomationRunner.TimeToMoveMouse = config.TimeToMoveMouse; await AutomationRunner.ShowWindowAndExecuteTests(matterControlWindow, testMethod, maxTimeToRun, defaultTestImages, config.AutomationInputType); }
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(); }); }
public void TestSetup() { StaticData.RootPath = TestContext.CurrentContext.ResolveProjectPath(4, "StaticData"); MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(4)); }