private void Deserialized(StreamingContext context) { var oemProfiles = MatterControlApplication.LoadCacheable <Dictionary <string, Dictionary <string, string> > >( "oemprofiles.json", "profiles", () => { string responseText = null; var autoResetEvent = new AutoResetEvent(false); var profileRequest = new PublicProfilesRequest(); profileRequest.RequestSucceeded += (s, e) => responseText = profileRequest.ResponseValues["ProfileList"]; profileRequest.RequestComplete += (s, e) => autoResetEvent.Set(); profileRequest.Request(); // Block on the current thread until the response has completed autoResetEvent.WaitOne(30000); return(responseText); }); OemProfiles = oemProfiles; SetManufacturers(oemProfiles.Select(m => new KeyValuePair <string, string>(m.Key, m.Key)).ToList()); }
private void RestartApplication() { UiThread.RunOnIdle(() => { // Iterate to the top SystemWindow GuiWidget parent = this; while (parent.Parent != null) { parent = parent.Parent; } // MatterControlApplication is the root child on the SystemWindow object MatterControlApplication app = parent.Children[0] as MatterControlApplication; #if !__ANDROID__ app.RestartOnClose = true; app.Close(); #else // Re-initialize and load LocalizedString.ResetTranslationMap(); ApplicationController.Instance.MainView = new TouchscreenView(); app.RemoveAllChildren(); app.AddChild(new SoftKeyboardContentOffset(ApplicationController.Instance.MainView)); app.AnchorAll(); #endif }); }
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 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 }
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 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)); }
//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 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 double ParseDouble(string textValue, double valueOnError = 0) { double value; if (!double.TryParse(textValue, out value)) { MatterControlApplication.BreakInDebugger("Slicing value is not a double."); return(valueOnError); } return(value); }
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 }
private void RestartApplication() { UiThread.RunOnIdle((state) => { //horrible hack - to be replaced GuiWidget parent = this; while (parent as MatterControlApplication == null) { parent = parent.Parent; } MatterControlApplication app = parent as MatterControlApplication; app.RestartOnClose = true; app.Close(); }); }
private static OemProfile LoadHttpOemProfile(string make, string model) { string deviceToken = OemSettings.Instance.OemProfiles[make][model]; return(MatterControlApplication.LoadCacheable <OemProfile>( String.Format("{0}.json", deviceToken), "profiles", () => { string responseText = null; responseText = RetrievePublicProfileRequest.DownloadPrinterProfile(deviceToken); return responseText; })); }
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 }
public void ClassicDebugComplicationFlagTests() { #if (!DEBUG) MatterControlApplication.CheckKnownAssemblyConditionalCompSymbols(); #endif }