Made the emulator parse commands better (temps)

Made LaunchAndConnectToPrinterEmulator
Working on pause on layer test
Updated version to 1.6
This commit is contained in:
Lars Brubaker 2016-09-19 14:46:47 -07:00
parent 5e46a182cf
commit cb3d518d35
4 changed files with 116 additions and 9 deletions

View file

@ -1,8 +1,10 @@
using MatterHackers.Agg.UI.Tests;
using MatterHackers.Agg.PlatformAbstract;
using MatterHackers.Agg.UI.Tests;
using MatterHackers.GuiAutomation;
using MatterHackers.MatterControl.SlicerConfiguration;
using NUnit.Framework;
using System;
using System.IO;
using System.Linq;
namespace MatterHackers.MatterControl.Tests.Automation
@ -57,6 +59,32 @@ namespace MatterHackers.MatterControl.Tests.Automation
Assert.IsTrue(testHarness.TestCount == 1); // make sure we ran all our tests
}
[Test, RequiresSTA, RunInApplicationDomain]
public void PauseOnLayerDoesPauseOnPrint()
{
Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
{
AutomationRunner testRunner = new AutomationRunner();
{
MatterControlUtilities.PrepForTestRun(testRunner, MatterControlUtilities.PrepAction.CloseSignInAndPrinterSelect);
var emualtorProccess = MatterControlUtilities.LaunchAndConnectToPrinterEmulator(testRunner);
resultsHarness.AddTestResult(ProfileManager.Instance.ActiveProfile != null);
testRunner.Wait(200);
emualtorProccess.Kill();
MatterControlUtilities.CloseMatterControl(testRunner);
}
};
string staticDataPathOverride = Path.Combine("..", "..", "..", "..", "..", "MatterControl", "StaticData");
StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(staticDataPathOverride);
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, staticDataPathOverride: staticDataPathOverride, maxTimeToRun: 200);
Assert.IsTrue(testHarness.AllTestsPassed);
}
[Test, RequiresSTA, RunInApplicationDomain]
public void ClearingCheckBoxClearsUserOverride()
{

View file

@ -37,6 +37,7 @@ using MatterHackers.MatterControl.PrintLibrary.Provider;
using Newtonsoft.Json;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
@ -134,18 +135,71 @@ namespace MatterHackers.MatterControl.Tests.Automation
}
}
public static Process StartPrinterEmulator(string emulatorCom)
public static Process LaunchAndConnectToPrinterEmulator(AutomationRunner testRunner)
{
// check for the settings file
string testConfigDataPath = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "MCTestConfig");
var emulatorPath = Path.Combine(testConfigDataPath, "PrinterEmulatorConfig.json");
// if no file create it
if(!File.Exists(emulatorPath))
{
Directory.CreateDirectory(testConfigDataPath);
Dictionary<string, string> userSettings = new Dictionary<string, string>()
{
["MCPort"] = "",
["Printer"] = "",
};
File.WriteAllText(emulatorPath, JsonConvert.SerializeObject(userSettings, Formatting.Indented));
}
// open the settings file
var jsonDict = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(emulatorPath));
// if no com port set, issue instructions on how to set it
if(!jsonDict.ContainsKey("MCPort")
|| !jsonDict.ContainsKey("Printer")
|| string.IsNullOrEmpty(jsonDict["MCPort"])
|| string.IsNullOrEmpty(jsonDict["Printer"]))
{
throw new Exception("You must set the port and printer in: " + emulatorPath);
}
// create the printer
//Create printer for sync to see
MatterControlUtilities.AddAndSelectPrinter(testRunner, "Airwolf 3D", "HD");
string comPort = jsonDict["MCPort"];
string printerPort = jsonDict["Printer"];
var process = new Process();
process.StartInfo = new ProcessStartInfo()
{
FileName = "python",
Arguments = string.Format("{0} {1}", StaticData.Instance.MapPath("../PrinterEmulator.py"), emulatorCom),
Arguments = string.Format("{0} {1}", StaticData.Instance.MapPath("../PrinterEmulator.py"), printerPort),
WindowStyle = ProcessWindowStyle.Minimized
};
process.Start();
// edit the com port
testRunner.ClickByName("Edit Printer Button");
testRunner.Wait(2);
testRunner.ClickByName("Com Port Dropdown");
testRunner.ClickByName(comPort + " Menu Item", 1);
testRunner.ClickByName("Cancel Wizard Button");
// connect to the created printer
testRunner.ClickByName("Connect to printer button", 2);
testRunner.Wait(2);
return process;
}