Automation updates
- Revise skirt_distance label per support team - Remove CreateInstance(showWindow) out variable - Remove embedded tools requiring showWindow out variable - Remove queueItemFolderToAdd variable/parameter - Change AfterFirstDraw event to null conditional invoke - Removed unused AutomationTest from MatterControlApplication - Refactor for style consistency and document new methods - Change queueItemFolderToAdd type to custom enum to ensure optional parameters are not mixed up - Ensure TestExportZip file is deleted before attempting export
This commit is contained in:
parent
d9823416cb
commit
9a5d872486
8 changed files with 85 additions and 128 deletions
|
|
@ -46,9 +46,7 @@ namespace MatterHackers.MatterControl.DataStorage
|
|||
private static readonly string applicationDataFolderName = "MatterControl";
|
||||
private readonly string datastoreName = "MatterControl.db";
|
||||
private string applicationPath;
|
||||
//private string testDataPath = Path.Combine("..", "..", "..", "..", "Tests", "TestData");
|
||||
|
||||
|
||||
private static string applicationUserDataPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData), applicationDataFolderName);
|
||||
|
||||
public ApplicationDataStorage()
|
||||
//Constructor - validates that local storage folder exists, creates if necessary
|
||||
|
|
@ -75,8 +73,6 @@ namespace MatterHackers.MatterControl.DataStorage
|
|||
}
|
||||
}
|
||||
|
||||
private static string applicationUserDataPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData), applicationDataFolderName);
|
||||
|
||||
public string ApplicationLibraryDataPath
|
||||
{
|
||||
get
|
||||
|
|
@ -93,10 +89,18 @@ namespace MatterHackers.MatterControl.DataStorage
|
|||
}
|
||||
}
|
||||
|
||||
internal void OverrideApplicationPath(string path)
|
||||
/// <summary>
|
||||
/// Overrides the AppData location.
|
||||
/// </summary>
|
||||
/// <param name="path">The new AppData path.</param>
|
||||
internal void OverrideAppDataLocation(string path)
|
||||
{
|
||||
// Ensure the target directory exists
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
applicationUserDataPath = path;
|
||||
|
||||
// Initialize a fresh datastore instance after overriding the AppData path
|
||||
Datastore.Instance = new Datastore();
|
||||
Datastore.Instance.Initialize();
|
||||
}
|
||||
|
|
@ -135,8 +139,8 @@ namespace MatterHackers.MatterControl.DataStorage
|
|||
{
|
||||
return applicationUserDataPath;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the path to the sqlite database
|
||||
/// </summary>
|
||||
|
|
@ -250,6 +254,8 @@ namespace MatterHackers.MatterControl.DataStorage
|
|||
}
|
||||
return globalInstance;
|
||||
}
|
||||
|
||||
// Special case to allow tests to set custom application paths
|
||||
internal set
|
||||
{
|
||||
globalInstance = value;
|
||||
|
|
|
|||
|
|
@ -114,11 +114,10 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
}
|
||||
|
||||
private MatterControlApplication(double width, double height, out bool showWindow)
|
||||
private MatterControlApplication(double width, double height)
|
||||
: base(width, height)
|
||||
{
|
||||
Name = "MatterControl";
|
||||
showWindow = false;
|
||||
|
||||
// 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;
|
||||
|
|
@ -136,51 +135,11 @@ namespace MatterHackers.MatterControl
|
|||
string commandUpper = command.ToUpper();
|
||||
switch (commandUpper)
|
||||
{
|
||||
case "TEST":
|
||||
CheckKnownAssemblyConditionalCompSymbols();
|
||||
return;
|
||||
|
||||
case "FORCE_SOFTWARE_RENDERING":
|
||||
forceSofwareRendering = true;
|
||||
GL.ForceSoftwareRendering();
|
||||
break;
|
||||
|
||||
case "MHSERIAL_TO_ANDROID":
|
||||
{
|
||||
Dictionary<string, string> vidPid_NameDictionary = new Dictionary<string, string>();
|
||||
string[] MHSerialLines = File.ReadAllLines(Path.Combine("..", "..", "StaticData", "Drivers", "MHSerial", "MHSerial.inf"));
|
||||
foreach (string line in MHSerialLines)
|
||||
{
|
||||
if (line.Contains("=DriverInstall,"))
|
||||
{
|
||||
string name = Regex.Match(line, "%(.*).name").Groups[1].Value;
|
||||
string vid = Regex.Match(line, "VID_(.*)&PID").Groups[1].Value;
|
||||
string pid = Regex.Match(line, "PID_([0-9a-fA-F]+)").Groups[1].Value;
|
||||
string vidPid = "{0},{1}".FormatWith(vid, pid);
|
||||
if (!vidPid_NameDictionary.ContainsKey(vidPid))
|
||||
{
|
||||
vidPid_NameDictionary.Add(vidPid, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using (StreamWriter deviceFilter = new StreamWriter("deviceFilter.txt"))
|
||||
{
|
||||
using (StreamWriter serialPort = new StreamWriter("serialPort.txt"))
|
||||
{
|
||||
foreach (KeyValuePair<string, string> vidPid_Name in vidPid_NameDictionary)
|
||||
{
|
||||
string[] vidPid = vidPid_Name.Key.Split(',');
|
||||
int vid = Int32.Parse(vidPid[0], System.Globalization.NumberStyles.HexNumber);
|
||||
int pid = Int32.Parse(vidPid[1], System.Globalization.NumberStyles.HexNumber);
|
||||
serialPort.WriteLine("customTable.AddProduct(0x{0:X4}, 0x{1:X4}, cdcDriverType); // {2}".FormatWith(vid, pid, vidPid_Name.Value));
|
||||
deviceFilter.WriteLine("<!-- {2} -->\n<usb-device vendor-id=\"{0}\" product-id=\"{1}\" />".FormatWith(vid, pid, vidPid_Name.Value));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
case "CLEAR_CACHE":
|
||||
AboutWidget.DeleteCacheData();
|
||||
break;
|
||||
|
|
@ -346,8 +305,6 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
DesktopPosition = new Point2D(xpos, ypos);
|
||||
}
|
||||
|
||||
showWindow = true;
|
||||
}
|
||||
|
||||
bool dropWasOnChild = true;
|
||||
|
|
@ -433,20 +390,15 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
if (instance == null)
|
||||
{
|
||||
bool showWindow;
|
||||
instance = CreateInstance(out showWindow);
|
||||
|
||||
if (showWindow)
|
||||
{
|
||||
instance.ShowAsSystemWindow();
|
||||
}
|
||||
instance = CreateInstance();
|
||||
instance.ShowAsSystemWindow();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
public static MatterControlApplication CreateInstance(out bool showWindow)
|
||||
public static MatterControlApplication CreateInstance()
|
||||
{
|
||||
// try and open our window matching the last size that we had for it.
|
||||
string windowSize = ApplicationSettings.Instance.get("WindowSize");
|
||||
|
|
@ -461,7 +413,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
using (new PerformanceTimer("Startup", "Total"))
|
||||
{
|
||||
instance = new MatterControlApplication(width, height, out showWindow);
|
||||
instance = new MatterControlApplication(width, height);
|
||||
}
|
||||
|
||||
return instance;
|
||||
|
|
@ -629,7 +581,6 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
if (firstDraw)
|
||||
{
|
||||
//Task.Run((Action)AutomationTest);
|
||||
UiThread.RunOnIdle(DoAutoConnectIfRequired);
|
||||
|
||||
firstDraw = false;
|
||||
|
|
@ -645,35 +596,14 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
TerminalWindow.ShowIfLeftOpen();
|
||||
|
||||
if (AfterFirstDraw != null)
|
||||
{
|
||||
AfterFirstDraw();
|
||||
}
|
||||
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
//StyledMessageBox.ShowMessageBox(null, "message that is long and wraps. message that is long and wraps. message that is long and wraps." , "caption", StyledMessageBox.MessageType.YES_NO);
|
||||
// show a dialog to tell the user there is an update
|
||||
});
|
||||
AfterFirstDraw?.Invoke();
|
||||
}
|
||||
|
||||
//msGraph.AddData("ms", totalDrawTime.ElapsedMilliseconds);
|
||||
//msGraph.Draw(MatterHackers.Agg.Transform.Affine.NewIdentity(), graphics2D);
|
||||
}
|
||||
|
||||
private void AutomationTest()
|
||||
{
|
||||
AutomationRunner test = new AutomationRunner("C:/TestImages");
|
||||
test.Wait(2);
|
||||
test.ClickByName("SettingsAndControls");
|
||||
test.Wait(2);
|
||||
test.ClickImage("BackButton.png");
|
||||
|
||||
|
||||
//ImageIO.SaveImageData("test.png", test.GetCurrentScreen());
|
||||
}
|
||||
|
||||
public override void OnMouseMove(MouseEventArgs mouseEvent)
|
||||
public override void OnMouseMove(MouseEventArgs mouseEvent)
|
||||
{
|
||||
if (GuiWidget.DebugBoundsUnderMouse)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -796,7 +796,7 @@
|
|||
},
|
||||
{
|
||||
"SlicerConfigName": "skirt_distance",
|
||||
"PresentationName": "Distance from Object",
|
||||
"PresentationName": "Distance From Object",
|
||||
"HelpText": "The distance to start drawing the first skirt loop. Make this 0 to create an anchor for the part to the bed.",
|
||||
"DataEditType": "POSITIVE_DOUBLE",
|
||||
"ExtraSettings": "mm",
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ namespace MatterHackers.MatterControl.UI
|
|||
{
|
||||
AutomationRunner testRunner = new AutomationRunner(MatterControlUtilities.DefaultTestImages);
|
||||
{
|
||||
|
||||
testRunner.ClickByName("SettingsAndControls", 5);
|
||||
testRunner.Wait(2);
|
||||
testRunner.ClickByName("Options Tab", 6);
|
||||
|
|
@ -33,7 +32,8 @@ namespace MatterHackers.MatterControl.UI
|
|||
resultsHarness.AddTestResult(terminalWindowExists1 == false, "Terminal Window does not exist");
|
||||
|
||||
testRunner.ClickByName("Show Terminal Button", 6);
|
||||
|
||||
testRunner.Wait(1);
|
||||
|
||||
SystemWindow containingWindow;
|
||||
GuiWidget terminalWindow = testRunner.GetWidgetByName("Gcode Terminal", out containingWindow, 3);
|
||||
resultsHarness.AddTestResult(terminalWindow != null, "Terminal Window exists after Show Terminal button is clicked");
|
||||
|
|
@ -44,7 +44,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
}
|
||||
};
|
||||
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, "MC_Three_Queue_Items");
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun);
|
||||
|
||||
Assert.IsTrue(testHarness.AllTestsPassed);
|
||||
Assert.IsTrue(testHarness.TestCount == 2); // make sure we ran all our tests
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
}
|
||||
};
|
||||
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, "MC_Three_Queue_Items");
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items);
|
||||
|
||||
Assert.IsTrue(testHarness.AllTestsPassed);
|
||||
Assert.IsTrue(testHarness.TestCount == 2); // make sure we ran all our tests
|
||||
|
|
@ -157,7 +157,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
}
|
||||
};
|
||||
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, null, null, "Three_Queue_Items");
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items);
|
||||
Assert.IsTrue(testHarness.AllTestsPassed);
|
||||
Assert.IsTrue(testHarness.TestCount == 2); // make sure we ran all our tests
|
||||
|
||||
|
|
@ -222,7 +222,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
}
|
||||
};
|
||||
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, null, null, "Three_Queue_Items");
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items);
|
||||
Assert.IsTrue(testHarness.AllTestsPassed);
|
||||
Assert.IsTrue(testHarness.TestCount == 2); // make sure we ran all our tests
|
||||
}
|
||||
|
|
@ -268,7 +268,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
}
|
||||
};
|
||||
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, null, null, "Three_Queue_Items");
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items);
|
||||
Assert.IsTrue(testHarness.AllTestsPassed);
|
||||
Assert.IsTrue(testHarness.TestCount == 2); // make sure we ran all our tests
|
||||
}
|
||||
|
|
@ -461,7 +461,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
}
|
||||
};
|
||||
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, null, null, "Three_Queue_Items");
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items);
|
||||
Assert.IsTrue(testHarness.AllTestsPassed);
|
||||
Assert.IsTrue(testHarness.TestCount == 3); // make sure we ran all our tests
|
||||
}
|
||||
|
|
@ -524,7 +524,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
}
|
||||
};
|
||||
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, null, null, "Three_Queue_Items");
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items);
|
||||
Assert.IsTrue(testHarness.AllTestsPassed);
|
||||
Assert.IsTrue(testHarness.TestCount == 3); // make sure we ran all our tests
|
||||
}
|
||||
|
|
@ -587,7 +587,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
}
|
||||
};
|
||||
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, null, null, "Three_Queue_Items");
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items);
|
||||
Assert.IsTrue(testHarness.AllTestsPassed);
|
||||
Assert.IsTrue(testHarness.TestCount == 3); // make sure we ran all our tests
|
||||
}
|
||||
|
|
@ -654,7 +654,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
}
|
||||
};
|
||||
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, null, null, "Three_Queue_Items");
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items);
|
||||
Assert.IsTrue(testHarness.AllTestsPassed);
|
||||
Assert.IsTrue(testHarness.TestCount == 4); // make sure we ran all our tests
|
||||
}
|
||||
|
|
@ -695,10 +695,15 @@ namespace MatterHackers.MatterControl.UI
|
|||
|
||||
testRunner.Wait(2);
|
||||
|
||||
|
||||
//Type in Absolute Path to Save
|
||||
string exportZipPath = MatterControlUtilities.PathToQueueItemsFolder("TestExportZip");
|
||||
|
||||
// Ensure file does not exist before save
|
||||
if(File.Exists(exportZipPath))
|
||||
{
|
||||
File.Delete(exportZipPath);
|
||||
}
|
||||
|
||||
testRunner.Type(exportZipPath);
|
||||
|
||||
testRunner.Wait(2);
|
||||
|
|
@ -745,7 +750,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
}
|
||||
};
|
||||
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, null, null, "Three_Queue_Items");
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items);
|
||||
Assert.IsTrue(testHarness.AllTestsPassed);
|
||||
Assert.IsTrue(testHarness.TestCount == 3); // make sure we ran all our tests
|
||||
}
|
||||
|
|
@ -796,7 +801,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
}
|
||||
};
|
||||
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, null, null, "Three_Queue_Items");
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items);
|
||||
Assert.IsTrue(testHarness.AllTestsPassed);
|
||||
Assert.IsTrue(testHarness.TestCount == 2); // make sure we ran all our tests
|
||||
}
|
||||
|
|
@ -867,7 +872,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
}
|
||||
};
|
||||
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, null, null, "Three_Queue_Items");
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items);
|
||||
Assert.IsTrue(testHarness.AllTestsPassed);
|
||||
Assert.IsTrue(testHarness.TestCount == 8); // make sure we ran all our tests
|
||||
}
|
||||
|
|
@ -931,7 +936,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
}
|
||||
};
|
||||
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, null, null, "Three_Queue_Items");
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items);
|
||||
Assert.IsTrue(testHarness.AllTestsPassed);
|
||||
Assert.IsTrue(testHarness.TestCount == 5); // make sure we ran all our tests
|
||||
}
|
||||
|
|
@ -1006,7 +1011,7 @@ namespace MatterHackers.MatterControl.UI
|
|||
}
|
||||
};
|
||||
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, null, null, "Three_Queue_Items");
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items);
|
||||
Assert.IsTrue(testHarness.AllTestsPassed);
|
||||
Assert.IsTrue(testHarness.TestCount == 7); // make sure we ran all our tests
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,13 +40,13 @@ namespace MatterHackers.MatterControl.UI
|
|||
resultsHarness.AddTestResult(testRunner.ClickByName("Save As Save Button", 1));
|
||||
|
||||
// ensure that it is now in the library folder (that the folder updated)
|
||||
resultsHarness.AddTestResult(testRunner.WaitForName("Row Item " + "Test Part", 5), "The part we added sholud be in the library");
|
||||
resultsHarness.AddTestResult(testRunner.WaitForName("Row Item " + "Test Part", 5), "The part we added should be in the library");
|
||||
|
||||
MatterControlUtilities.CloseMatterControl(testRunner);
|
||||
MatterControlUtilities.CloseMatterControl(testRunner);
|
||||
}
|
||||
};
|
||||
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, "MC_One_Queue_No_Library");
|
||||
AutomationTesterHarness testHarness = MatterControlUtilities.RunTest(testToRun, queueItemFolderToAdd: QueueTemplate.Three_Queue_Items);
|
||||
|
||||
Assert.IsTrue(testHarness.AllTestsPassed);
|
||||
Assert.IsTrue(testHarness.TestCount == 8); // make sure we ran all our tests
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ namespace MatterControl.Tests
|
|||
[Test, RunInApplicationDomain]
|
||||
public void LibraryProviderSqlite_NavigationWorking()
|
||||
{
|
||||
MatterControlUtilities.MakeNewMatterControlAppDataFolderForTesting();
|
||||
MatterControlUtilities.OverrideAppDataLocation();
|
||||
|
||||
LibraryProviderSQLite testProvider = new LibraryProviderSQLite(null, null, null, "Local Library");
|
||||
testProvider.DataReloaded += (sender, e) => { dataReloaded = true; };
|
||||
|
|
|
|||
|
|
@ -50,6 +50,10 @@ namespace MatterHackers.MatterControl.UI
|
|||
{
|
||||
private static bool saveImagesForDebug = true;
|
||||
|
||||
private static int testID = 0;
|
||||
|
||||
private static string runName = DateTime.Now.ToString("yyyy-MM-ddTHH-mm-ss");
|
||||
|
||||
private static void RemoveAllFromQueue(AutomationRunner testRunner)
|
||||
{
|
||||
Assert.IsTrue(testRunner.ClickByName("Queue... Menu", 2));
|
||||
|
|
@ -66,11 +70,8 @@ namespace MatterHackers.MatterControl.UI
|
|||
|
||||
public static string PathToQueueItemsFolder(string queueItemToLoad)
|
||||
{
|
||||
string temnp = Directory.GetCurrentDirectory();
|
||||
string pathToQueueItemFolder = Path.Combine("..", "..", "..", "..", "Tests", "TestData", "QueueItems");
|
||||
string fullPathToQueueItem = Path.Combine(pathToQueueItemFolder, queueItemToLoad);
|
||||
|
||||
return Path.GetFullPath(fullPathToQueueItem);
|
||||
return Path.GetFullPath(Path.Combine(pathToQueueItemFolder, queueItemToLoad));
|
||||
}
|
||||
|
||||
public static void CloseMatterControl(AutomationRunner testRunner)
|
||||
|
|
@ -107,18 +108,17 @@ namespace MatterHackers.MatterControl.UI
|
|||
OutputImage(test, "image-test.tga");
|
||||
}
|
||||
|
||||
private static int testID = 0;
|
||||
private static string runName = DateTime.Now.ToString("yyyy-MM-ddTHH-mm-ss");
|
||||
|
||||
public static void MakeNewMatterControlAppDataFolderForTesting(string testDBFolderName = null)
|
||||
/// <summary>
|
||||
/// Overrides the AppData location, ensuring each test starts with a fresh MatterControl database.
|
||||
/// </summary>
|
||||
public static void OverrideAppDataLocation()
|
||||
{
|
||||
string tempFolderPath = Path.Combine("..", "..", "..", "..", "Tests","temp");
|
||||
|
||||
string temp = Path.Combine("..", "..", "..", "..", "Tests","temp");
|
||||
ApplicationDataStorage.Instance.OverrideApplicationPath(Path.Combine(temp, runName, $"Test{testID++}"));
|
||||
|
||||
ApplicationDataStorage.Instance.OverrideAppDataLocation(
|
||||
Path.Combine(tempFolderPath, runName, $"Test{testID++}"));
|
||||
}
|
||||
|
||||
|
||||
public static void AddItemsToQueue(string queueItemFolderToLoad)
|
||||
{
|
||||
|
||||
|
|
@ -142,7 +142,9 @@ namespace MatterHackers.MatterControl.UI
|
|||
//CREATE EMPTY TESTPARTS FOLDER
|
||||
Directory.CreateDirectory(queueData);
|
||||
|
||||
foreach (string file in Directory.GetFiles(Path.Combine("..", "..", "..", "TestData", "QueueItems", queueItemFolderToLoad)))
|
||||
string queueItemTestDataFolder = Path.Combine("..", "..", "..", "TestData", "QueueItems");
|
||||
|
||||
foreach (string file in Directory.GetFiles(Path.Combine(queueItemTestDataFolder, queueItemFolderToLoad)))
|
||||
{
|
||||
string newFilePath = Path.Combine(queueData, Path.GetFileName(file));
|
||||
File.Copy(file, newFilePath, true);
|
||||
|
|
@ -178,8 +180,13 @@ namespace MatterHackers.MatterControl.UI
|
|||
return goodNavigate;
|
||||
}
|
||||
|
||||
public static AutomationTesterHarness RunTest(Action<AutomationTesterHarness> testToRun, string testDbFolder = null, string staticDataPathOverride = null, string queueItemFolderToAdd = null, double maxTimeToRun = 60)
|
||||
public static AutomationTesterHarness RunTest(
|
||||
Action<AutomationTesterHarness> testToRun,
|
||||
string staticDataPathOverride = null,
|
||||
double maxTimeToRun = 60,
|
||||
QueueTemplate queueItemFolderToAdd = QueueTemplate.None)
|
||||
{
|
||||
// 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);
|
||||
|
||||
|
|
@ -187,22 +194,31 @@ namespace MatterHackers.MatterControl.UI
|
|||
{
|
||||
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
|
||||
bool showWindow;
|
||||
/*MatterControlUtilities.DataFolderState staticDataState =*/MatterControlUtilities.MakeNewMatterControlAppDataFolderForTesting(testDbFolder);
|
||||
MatterControlUtilities.OverrideAppDataLocation();
|
||||
|
||||
if (queueItemFolderToAdd != null)
|
||||
if (queueItemFolderToAdd != QueueTemplate.None)
|
||||
{
|
||||
MatterControlUtilities.AddItemsToQueue(queueItemFolderToAdd);
|
||||
string queueTemplateDirectory = queueItemFolderToAdd.ToString();
|
||||
MatterControlUtilities.AddItemsToQueue(queueTemplateDirectory);
|
||||
}
|
||||
|
||||
MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(out showWindow);
|
||||
AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(matterControlWindow, testToRun, maxTimeToRun);
|
||||
|
||||
return testHarness;
|
||||
MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance();
|
||||
return AutomationTesterHarness.ShowWindowAndExectueTests(matterControlWindow, testToRun, maxTimeToRun);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a queue template folder on disk (located at Tests/TestData/QueueItems) that should be synced into the default
|
||||
/// queue during test init. The enum name and folder name *must* be the same in order to function
|
||||
/// </summary>
|
||||
public enum QueueTemplate
|
||||
{
|
||||
None,
|
||||
Three_Queue_Items
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue