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); 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(); return(AutomationTesterHarness.ShowWindowAndExectueTests(matterControlWindow, testToRun, maxTimeToRun)); }
//Test Works public void ClickOnCreateButton() { // Run a copy of MatterControl Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) => { AutomationRunner testRunner = new AutomationRunner(MatterControlUITests.DefaultTestImages); { //Make sure that plugin window does not exist bool pluginWindowExists1 = testRunner.WaitForName("Plugin Chooser Window", 0); resultsHarness.AddTestResult(pluginWindowExists1 == false, "Plugin window does not exist"); testRunner.ClickByName("Design Tool Button", 5); //Test that the plugin window does exist after the create button is clicked SystemWindow containingWindow; GuiWidget pluginWindowExists = testRunner.GetWidgetByName("Plugin Chooser Window", out containingWindow, secondsToWait: 3); resultsHarness.AddTestResult(pluginWindowExists != null, "Plugin Chooser Window"); pluginWindowExists.CloseOnIdle(); testRunner.Wait(.5); MatterControlUITests.CloseMatterControl(testRunner); } }; #if !__ANDROID__ // Set the static data to point to the directory of MatterControl StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData")); #endif bool showWindow; MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(out showWindow); AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(matterControlWindow, testToRun, 60); Assert.IsTrue(testHarness.AllTestsPassed); Assert.IsTrue(testHarness.TestCount == 2); // make sure we ran all our tests }
//DOES NOT WORK public void ClickingConfigureNotificationSettingsButtonOpensWindow() { // Run a copy of MatterControl Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) => { AutomationRunner testRunner = new AutomationRunner(MatterControlUITests.DefaultTestImages); { testRunner.ClickByName("SettingsAndControls", 5); testRunner.Wait(2); testRunner.ClickByName("Configuration Tab", 6); bool printNotificationsWindowExists1 = testRunner.WaitForName("Notification Options Window", 0); resultsHarness.AddTestResult(printNotificationsWindowExists1 == false, "Print Notification Window does not exist"); testRunner.ClickByName("Configure Notification Settings Button", 6); bool printNotificationsWindowExists2 = testRunner.WaitForName("Notification Options Window", 3); resultsHarness.AddTestResult(printNotificationsWindowExists2 == true, "Print Notifications Window exists after Configure button is clicked"); MatterControlUITests.CloseMatterControl(testRunner); } }; #if !__ANDROID__ // Set the static data to point to the directory of MatterControl StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData")); #endif bool showWindow; string testDBFolder = "MC_Three_Queue_Items"; MatterControlUITests.DataFolderState staticDataState = MatterControlUITests.MakeNewStaticDataForTesting(testDBFolder); MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(out showWindow); AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(matterControlWindow, testToRun, 45); MatterControlUITests.RestoreStaticDataAfterTesting(staticDataState, true); Assert.IsTrue(testHarness.AllTestsPassed); Assert.IsTrue(testHarness.TestCount == 2); // make sure we ran all our tests }
public void ClickOnBuyButton() { // Run a copy of MatterControl Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) => { AutomationRunner testRunner = new AutomationRunner(MatterControlUITests.DefaultTestImages); { //Make sure image does not exist before we click the buy button testRunner.MatchLimit = 500000; bool imageExists = testRunner.ImageExists("MatterHackersStoreImage.png"); resultsHarness.AddTestResult(imageExists == false, "Web page is not open"); //Click Buy button and test that the MatterHackers store web page is open testRunner.ClickByName("Buy Materials Button", secondsToWait: 5); bool imageExists2 = testRunner.ImageExists("MatterHackersStoreImage.png", 10); resultsHarness.AddTestResult(imageExists2 == true, "Web page is open"); MatterControlUITests.CloseMatterControl(testRunner); } }; #if !__ANDROID__ // Set the static data to point to the directory of MatterControl StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData")); #endif bool showWindow; MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(out showWindow); AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(matterControlWindow, testToRun, 60); Assert.IsTrue(testHarness.AllTestsPassed); Assert.IsTrue(testHarness.TestCount == 2); // make sure we ran all our tests }
public void QueueThumbnailWidgetOpensPartPreview() { // Run a copy of MatterControl Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) => { AutomationRunner testRunner = new AutomationRunner(MatterControlUITests.DefaultTestImages); { bool partPreviewWindowExists1 = testRunner.WaitForName("Part Preview Window Thumbnail", 0); resultsHarness.AddTestResult(partPreviewWindowExists1 == false, "Part Preview Window Does Not Exist"); testRunner.ClickByName("Queue Item Thumbnail"); SystemWindow containingWindow; GuiWidget partPreviewWindowExists = testRunner.GetWidgetByName("Part Preview Window Thumbnail", out containingWindow, secondsToWait: 3); resultsHarness.AddTestResult(partPreviewWindowExists != null, "Part Preview Window Exists"); partPreviewWindowExists.CloseOnIdle(); testRunner.Wait(.5); MatterControlUITests.CloseMatterControl(testRunner); } }; #if !__ANDROID__ // Set the static data to point to the directory of MatterControl StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData")); #endif bool showWindow; string testDBFolder = "MC_Three_Queue_Items"; MatterControlUITests.DataFolderState staticDataState = MatterControlUITests.MakeNewStaticDataForTesting(testDBFolder); MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(out showWindow); AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(matterControlWindow, testToRun, 300); MatterControlUITests.RestoreStaticDataAfterTesting(staticDataState, true); Assert.IsTrue(testHarness.AllTestsPassed); Assert.IsTrue(testHarness.TestCount == 2); // make sure we ran all our tests }
public void ExportButtonIsDisabledWithNoItemsInQueue() { // Run a copy of MatterControl Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) => { AutomationRunner testRunner = new AutomationRunner(MatterControlUITests.DefaultTestImages); { //bool exportButtonExists = testRunner.NameExists("Export Queue Button"); bool exportButtonExists = testRunner.WaitForName("Export Queue Button", 10); testRunner.Wait(5); resultsHarness.AddTestResult(exportButtonExists == false, "Export button is disabled"); MatterControlUITests.CloseMatterControl(testRunner); } }; #if !__ANDROID__ // Set the static data to point to the directory of MatterControl StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData")); #endif bool showWindow; string testDBFolder = "MC_Fresh_Installation"; MatterControlUITests.DataFolderState staticDataState = MatterControlUITests.MakeNewStaticDataForTesting(testDBFolder); MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(out showWindow); AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(matterControlWindow, testToRun, 300); MatterControlUITests.RestoreStaticDataAfterTesting(staticDataState, true); Assert.IsTrue(testHarness.AllTestsPassed); Assert.IsTrue(testHarness.TestCount == 1); // make sure we ran all our tests }
//Test Works public void ClickOnExportButton() { // Run a copy of MatterControl Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) => { AutomationRunner testRunner = new AutomationRunner(MatterControlUITests.DefaultTestImages); { //Make sure that the export window does not exist bool exportWindowExists1 = testRunner.WaitForName("Export Window Queue", 0); resultsHarness.AddTestResult(exportWindowExists1 == false, "Export window does not exist"); testRunner.ClickByName("Export Queue Button", 5); SystemWindow containingWindow; GuiWidget exportWindow = testRunner.GetWidgetByName("Export Window Queue", out containingWindow, secondsToWait: 5); resultsHarness.AddTestResult(exportWindow != null, "Export window does exist"); exportWindow.CloseOnIdle(); testRunner.Wait(.5); MatterControlUITests.CloseMatterControl(testRunner); } }; #if !__ANDROID__ // Set the static data to point to the directory of MatterControl StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData")); #endif bool showWindow; string testDBFolder = "MC_Three_Queue_Items"; MatterControlUITests.DataFolderState staticDataState = MatterControlUITests.MakeNewStaticDataForTesting(testDBFolder); MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(out showWindow); AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(matterControlWindow, testToRun, 60); MatterControlUITests.RestoreStaticDataAfterTesting(staticDataState, true); Assert.IsTrue(testHarness.AllTestsPassed); Assert.IsTrue(testHarness.TestCount == 2); // make sure we ran all our tests }
public void ClickOnLibraryCheckBoxes() { // Run a copy of MatterControl Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) => { AutomationRunner testRunner = new AutomationRunner(MatterControlUITests.DefaultTestImages); // Now do the actions specific to this test. (replace this for new tests) { testRunner.ClickByName("Library Tab"); testRunner.Wait(1); SystemWindow systemWindow; GuiWidget rowItem = testRunner.GetWidgetByName("Local Library Row Item Collection", out systemWindow); testRunner.Wait(1); SearchRegion rowItemRegion = testRunner.GetRegionByName("Local Library Row Item Collection"); testRunner.ClickByName("Library Edit Button"); testRunner.Wait(1); SystemWindow containingWindow; GuiWidget foundWidget = testRunner.GetWidgetByName("Row Item Select Checkbox", out containingWindow, searchRegion: rowItemRegion); CheckBox checkBoxWidget = foundWidget as CheckBox; resultsHarness.AddTestResult(checkBoxWidget != null, "We should have an actual checkbox"); resultsHarness.AddTestResult(checkBoxWidget.Checked == false, "currently not checked"); testRunner.ClickByName("Row Item Select Checkbox", searchRegion: rowItemRegion); testRunner.Wait(.5); resultsHarness.AddTestResult(checkBoxWidget.Checked == true, "currently checked"); testRunner.ClickByName("Local Library Row Item Collection"); testRunner.Wait(.5); resultsHarness.AddTestResult(checkBoxWidget.Checked == false, "currently not checked"); MatterControlUITests.CloseMatterControl(testRunner); } }; #if !__ANDROID__ // Set the static data to point to the directory of MatterControl StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData")); #endif bool showWindow; MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(out showWindow); AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(matterControlWindow, testToRun, 1000); // NOTE: In the future we may want to make the "Local Library Row Item Collection" not clickable. // If that is the case fix this test to click on a child of "Local Library Row Item Collection" instead. Assert.IsTrue(testHarness.AllTestsPassed); Assert.IsTrue(testHarness.TestCount == 4); // make sure we ran all our tests }
public static AutomationTesterHarness RunTest(Action <AutomationTesterHarness> testToRun, string testDbFolder = null, string staticDataPathOverride = null, double maxTimeToRun = 60) { 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 bool showWindow; MatterControlUtilities.DataFolderState staticDataState = MatterControlUtilities.MakeNewStaticDataForTesting2(testDbFolder); MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(out showWindow); AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(matterControlWindow, testToRun, maxTimeToRun); MatterControlUtilities.RestoreStaticDataAfterTesting(staticDataState, true); return(testHarness); }
public void CreateFolderStarsOutWithTextFiledFocusedAndEditable() { // Run a copy of MatterControl Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) => { AutomationRunner testRunner = new AutomationRunner(MatterControlUITests.DefaultTestImages); // Now do the actions specific to this test. (replace this for new tests) { testRunner.ClickByName("Library Tab"); testRunner.ClickByName("Create Folder Button"); testRunner.Wait(.5); testRunner.Type("Test Text"); testRunner.Wait(.5); SystemWindow containingWindow; GuiWidget textInputWidget = testRunner.GetWidgetByName("Create Folder - Text Input", out containingWindow); MHTextEditWidget textWidgetMH = textInputWidget as MHTextEditWidget; resultsHarness.AddTestResult(textWidgetMH != null, "Found Text Widget"); resultsHarness.AddTestResult(textWidgetMH.Text == "Test Text", "Had the right text"); containingWindow.CloseOnIdle(); testRunner.Wait(.5); CloseMatterControl(testRunner); } }; #if !__ANDROID__ // Set the static data to point to the directory of MatterControl StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData")); #endif bool showWindow; MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(out showWindow); AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(matterControlWindow, testToRun, 10); Assert.IsTrue(testHarness.AllTestsPassed); Assert.IsTrue(testHarness.TestCount == 2); // make sure we ran all our tests }