From 7662e45586b2ca24809909c2ee185122277f62ac Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Thu, 1 Dec 2016 18:03:40 -0800 Subject: [PATCH] Make it possible to pass command line arguments in test. Made a new argument to do thumbnails as orthographic Significantly speeds up tests --- MatterControlApplication.cs | 45 +++++++++++-------- Submodules/MatterSlice | 2 +- Submodules/agg-sharp | 2 +- .../MatterControl/MatterControlUtilities.cs | 2 +- 4 files changed, 30 insertions(+), 21 deletions(-) diff --git a/MatterControlApplication.cs b/MatterControlApplication.cs index 9d727be3d..d6061f457 100644 --- a/MatterControlApplication.cs +++ b/MatterControlApplication.cs @@ -68,7 +68,6 @@ namespace MatterHackers.MatterControl public bool RestartOnClose = false; private static readonly Vector2 minSize = new Vector2(600, 600); private static MatterControlApplication instance; - private string[] commandLineArgs = null; private string confirmExit = "Confirm Exit".Localize(); private bool DoCGCollectEveryDraw = false; private int drawCount = 0; @@ -100,6 +99,7 @@ namespace MatterHackers.MatterControl } public static bool IsLoading { get; private set; } = true; + static bool forceSofwareRendering = false; static MatterControlApplication() { @@ -121,21 +121,11 @@ namespace MatterHackers.MatterControl } } - private MatterControlApplication(double width, double height) - : base(width, height) + string[] commandLineArgs; + + void ProcessCommandLine(string[] commandLineArgs) { - ApplicationSettings.Instance.set("HardwareHasCamera", "false"); - - Name = "MatterControl"; - - // set this at startup so that we can tell next time if it got set to true in close - UserSettings.Instance.Fields.StartCount = UserSettings.Instance.Fields.StartCount + 1; - - this.commandLineArgs = Environment.GetCommandLineArgs(); - Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; - - bool forceSofwareRendering = false; - + this.commandLineArgs = commandLineArgs; for (int currentCommandIndex = 0; currentCommandIndex < commandLineArgs.Length; currentCommandIndex++) { string command = commandLineArgs[currentCommandIndex]; @@ -160,6 +150,10 @@ namespace MatterHackers.MatterControl DoCGCollectEveryDraw = true; break; + case "ORTHOGRAPHIC_THUMBNAILS": + UserSettings.Instance.set(UserSettingsKey.ThumbnailRenderingMode, "orthographic"); + break; + //case "CREATE_AND_SELECT_PRINTER": // if (currentCommandIndex + 1 <= commandLineArgs.Length) // { @@ -243,6 +237,21 @@ namespace MatterHackers.MatterControl // Else send these to the running instance so it can load them. } } + } + + private MatterControlApplication(string[] commandLine, double width, double height) + : base(width, height) + { + ApplicationSettings.Instance.set("HardwareHasCamera", "false"); + + Name = "MatterControl"; + + // set this at startup so that we can tell next time if it got set to true in close + UserSettings.Instance.Fields.StartCount = UserSettings.Instance.Fields.StartCount + 1; + + Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; + + ProcessCommandLine(commandLine); //WriteTestGCodeFile(); #if !DEBUG @@ -410,7 +419,7 @@ namespace MatterHackers.MatterControl { if (instance == null) { - instance = CreateInstance(); + instance = CreateInstance(Environment.GetCommandLineArgs()); instance.ShowAsSystemWindow(); } @@ -420,7 +429,7 @@ namespace MatterHackers.MatterControl public event EventHandler PictureTaken; - public static MatterControlApplication CreateInstance(int overrideWidth = -1, int overrideHeight = -1) + public static MatterControlApplication CreateInstance(string[] commandLine, int overrideWidth = -1, int overrideHeight = -1) { int width = 0; int height = 0; @@ -465,7 +474,7 @@ namespace MatterHackers.MatterControl using (new PerformanceTimer("Startup", "Total")) { - instance = new MatterControlApplication(width, height); + instance = new MatterControlApplication(commandLine, width, height); if (instance.DesktopPosition == new Point2D()) { diff --git a/Submodules/MatterSlice b/Submodules/MatterSlice index 2b305bb1c..3a04f46f4 160000 --- a/Submodules/MatterSlice +++ b/Submodules/MatterSlice @@ -1 +1 @@ -Subproject commit 2b305bb1ceb9d54d6af60c5aaa71092e8fdc1611 +Subproject commit 3a04f46f41c96a0ce5f084112d2ff0000a1d9ac3 diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 75c89c1d2..768f3a815 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 75c89c1d25b08a99a63a0f6725eba20e2cb1707c +Subproject commit 768f3a815077a9bda63781ed3199a7302d0403ff diff --git a/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs b/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs index b62d79d9d..5dbb8ef2c 100644 --- a/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs +++ b/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs @@ -401,7 +401,7 @@ namespace MatterHackers.MatterControl.Tests.Automation defaultTestImages = TestContext.CurrentContext.ResolveProjectPath(4, "Tests", "TestData", "TestImages"); } - MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(overrideWidth, overrideHeight); + MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(new string[] { "ORTHOGRAPHIC_THUMBNAILS" }, overrideWidth, overrideHeight); var config = TestAutomationConfig.Load();