diff options
author | Manish Sinha <manish.sinha@xamarin.com> | 2015-09-30 21:37:13 +0300 |
---|---|---|
committer | Manish Sinha <manish.sinha@xamarin.com> | 2015-09-30 22:41:45 +0300 |
commit | 7321bd1da819f23c8afb21b1c825847e1f71ac13 (patch) | |
tree | f225405915faf6a0ca40524fd34dd6732ca81e31 /main/tests | |
parent | 067546042ed5ffcfc19ea3b31f723a6f860a465c (diff) |
[UITest] Implement WaitForIdeIdle to wait for same status message
Diffstat (limited to 'main/tests')
5 files changed, 66 insertions, 29 deletions
diff --git a/main/tests/UserInterfaceTests/Ide.cs b/main/tests/UserInterfaceTests/Ide.cs index 12620ec47b..1a6c9ae995 100644 --- a/main/tests/UserInterfaceTests/Ide.cs +++ b/main/tests/UserInterfaceTests/Ide.cs @@ -165,6 +165,40 @@ namespace UserInterfaceTests } }, pollStep: pollStepInSecs * 1000, timeout: timeoutInSecs * 1000); } + + public static void WaitForIdeIdle (uint totalTimeoutInSecs = 100, uint idlePeriodInSecs = 10) + { + uint retriesLeft = (uint)Math.Ceiling ((double)totalTimeoutInSecs/(double)idlePeriodInSecs); + ManualResetEvent resetEvent = new ManualResetEvent (false); + + var timer = new System.Timers.Timer { + Interval = idlePeriodInSecs * 1000, + AutoReset = true + }; + + var initialStatusMessage = Workbench.GetStatusMessage (waitForNonEmpty: false); + timer.Elapsed += (sender, e) => { + if (retriesLeft == 0) + throw new TimeoutException ("Timeout waiting for IDE to be ready and idle"); + + var finalStatusMessage = Workbench.GetStatusMessage (waitForNonEmpty: false); + var isIdle = string.Equals (initialStatusMessage, finalStatusMessage); + + if (!isIdle) { + retriesLeft--; + initialStatusMessage = finalStatusMessage; + } + if (isIdle) { + resetEvent.Set (); + timer.Stop (); + timer.AutoReset = false; + timer.Dispose (); + } + }; + + timer.Start (); + resetEvent.WaitOne (); + } } } diff --git a/main/tests/UserInterfaceTests/TemplateTests/ASPNETTemplateTests.cs b/main/tests/UserInterfaceTests/TemplateTests/ASPNETTemplateTests.cs index c5d6c09c9d..f7f33b4266 100644 --- a/main/tests/UserInterfaceTests/TemplateTests/ASPNETTemplateTests.cs +++ b/main/tests/UserInterfaceTests/TemplateTests/ASPNETTemplateTests.cs @@ -35,22 +35,22 @@ namespace UserInterfaceTests { readonly string aspCategory = "ASP.NET"; - [Test, Timeout(60000)] - [TestCase ("Empty ASP.NET MVC Project", BeforeBuildAction.WaitForPackageUpdate, TestName = "TestEmptyASPMVCProject", + [Test, Timeout (90000)] + [TestCase ("Empty ASP.NET MVC Project", TestName = "TestEmptyASPMVCProject", Description = "Create and build Empty ASP.NET MVC Project")] - [TestCase ("Empty ASP.NET Project", BeforeBuildAction.None, TestName = "TestEmptyASPProject", + [TestCase ("Empty ASP.NET Project", TestName = "TestEmptyASPProject", Description = "Create and build Empty ASP.NET MVC Project")] - [TestCase ("ASP.NET MVC Project", BeforeBuildAction.WaitForPackageUpdate, TestName = "TestASPMVCProject", + [TestCase ("ASP.NET MVC Project", TestName = "TestASPMVCProject", Description = "Create and build ASP.NET MVC Project")] - [TestCase ("ASP.NET MVC Project with Unit Tests", BeforeBuildAction.WaitForPackageUpdate, TestName = "TestASPMVCProjectWithUnitTests", + [TestCase ("ASP.NET MVC Project with Unit Tests", TestName = "TestASPMVCProjectWithUnitTests", Description = "Create and build ASP.NET MVC Project with Unit Tests")] - [TestCase ("ASP.NET MVC Razor Project", BeforeBuildAction.WaitForPackageUpdate, TestName = "TestASPMVCMazorProject", + [TestCase ("ASP.NET MVC Razor Project", TestName = "TestASPMVCMazorProject", Description = "Create and build ASP.NET MVC Razor Project")] - [TestCase ("ASP.NET MVC Razor Project with Unit Tests", BeforeBuildAction.WaitForPackageUpdate, TestName = "TestASPMVCMazorProjectWithUnitTests", - Description = "Create and build \"ASP.NET MVC Razor Project with Unit Tests")] - [TestCase ("ASP.NET Project", BeforeBuildAction.None, TestName = "TestASPProject", + [TestCase ("ASP.NET MVC Razor Project with Unit Tests", TestName = "TestASPMVCMazorProjectWithUnitTests", + Description = "Create and build ASP.NET MVC Razor Project with Unit Tests")] + [TestCase ("ASP.NET Project", TestName = "TestASPProject", Description = "Create and build ASP.NET Project")] - public void RunASPTest (string templateName, BeforeBuildAction beforeBuild) + public void RunASPTest (string templateName) { var templateOptions = new TemplateSelectionOptions { CategoryRoot = OtherCategoryRoot, @@ -58,8 +58,8 @@ namespace UserInterfaceTests TemplateKindRoot = GeneralKindRoot, TemplateKind = templateName }; - CreateBuildProject (templateOptions, beforeBuild.GetAction ()); - IsTemplateSelected (templateOptions); + + CreateBuildProject (templateOptions, () => Ide.WaitForIdeIdle (totalTimeoutInSecs: 50)); } } } diff --git a/main/tests/UserInterfaceTests/TemplateTests/DotNetTemplatesTest.cs b/main/tests/UserInterfaceTests/TemplateTests/DotNetTemplatesTest.cs index ceb101e8ca..63c2a09a21 100644 --- a/main/tests/UserInterfaceTests/TemplateTests/DotNetTemplatesTest.cs +++ b/main/tests/UserInterfaceTests/TemplateTests/DotNetTemplatesTest.cs @@ -34,13 +34,13 @@ namespace UserInterfaceTests { readonly string dotNetCategory = ".NET"; - [Test, Timeout(60000)] - [TestCase ("Console Project", BeforeBuildAction.None, TestName = "TestCreateBuildConsoleProject", Description = "Create and build C# Console Project")] - [TestCase ("Gtk# 2.0 Project", BeforeBuildAction.None, TestName = "TestCreateBuildGtkSharp20Project", Description = "Create and build a GTK#2 Project")] - [TestCase ("Library", BeforeBuildAction.None, TestName = "TestCreateBuildLibrary", Description = "Create and build a Library Project")] - [TestCase ("NUnit Library Project", BeforeBuildAction.WaitForPackageUpdate, TestName = "TestCreateBuildNUnitLibraryProject", + [Test, Timeout (90000)] + [TestCase ("Console Project", 30, TestName = "TestCreateBuildConsoleProject", Description = "Create and build C# Console Project")] + [TestCase ("Gtk# 2.0 Project", 30, TestName = "TestCreateBuildGtkSharp20Project", Description = "Create and build a GTK#2 Project")] + [TestCase ("Library", 30, TestName = "TestCreateBuildLibrary", Description = "Create and build a Library Project")] + [TestCase ("NUnit Library Project", 50, TestName = "TestCreateBuildNUnitLibraryProject", Description = "Create and build NUnit Library Project")] - public void RunDotNetTests (string templateName, BeforeBuildAction beforeBuild) + public void RunDotNetTests (string templateName, int totalTimeoutInSecs) { var templateOptions = new TemplateSelectionOptions { CategoryRoot = OtherCategoryRoot, @@ -48,8 +48,7 @@ namespace UserInterfaceTests TemplateKindRoot = GeneralKindRoot, TemplateKind = templateName }; - CreateBuildProject (templateOptions, beforeBuild.GetAction ()); - IsTemplateSelected (templateOptions); + CreateBuildProject (templateOptions, () => Ide.WaitForIdeIdle ((uint)totalTimeoutInSecs)); } } } diff --git a/main/tests/UserInterfaceTests/TemplateTests/MiscTemplatesTest.cs b/main/tests/UserInterfaceTests/TemplateTests/MiscTemplatesTest.cs index cb10da6d65..8a041ac129 100644 --- a/main/tests/UserInterfaceTests/TemplateTests/MiscTemplatesTest.cs +++ b/main/tests/UserInterfaceTests/TemplateTests/MiscTemplatesTest.cs @@ -55,7 +55,7 @@ namespace UserInterfaceTests TemplateKindRoot = templateKind, TemplateKind = templateName }; - CreateBuildProject (templateOptions, EmptyAction); + CreateBuildProject (templateOptions, () => Ide.WaitForIdeIdle ()); IsTemplateSelected (templateOptions); } } diff --git a/main/tests/UserInterfaceTests/Workbench.cs b/main/tests/UserInterfaceTests/Workbench.cs index 89f2a65b5b..dcdeabdad9 100644 --- a/main/tests/UserInterfaceTests/Workbench.cs +++ b/main/tests/UserInterfaceTests/Workbench.cs @@ -40,20 +40,24 @@ namespace UserInterfaceTests static readonly Regex buildRegex = new Regex (@"Build: (?<errors>\d*) error\D*, (?<warnings>\d*) warning\D*", RegexOptions.Compiled); - public static string GetStatusMessage (int timeout = 20000) + public static string GetStatusMessage (int timeout = 20000, bool waitForNonEmpty = true) { if (Platform.IsMac) { + if (waitForNonEmpty) { + Ide.WaitUntil ( + () => Session.GetGlobalValue<string> ("MonoDevelop.Ide.IdeApp.Workbench.RootWindow.StatusBar.text") != string.Empty, + timeout + ); + } + return (string)Session.GetGlobalValue ("MonoDevelop.Ide.IdeApp.Workbench.RootWindow.StatusBar.text"); + } + + if (waitForNonEmpty) { Ide.WaitUntil ( - () => Session.GetGlobalValue<string> ("MonoDevelop.Ide.IdeApp.Workbench.RootWindow.StatusBar.text") != string.Empty, + () => Session.GetGlobalValue<int> ("MonoDevelop.Ide.IdeApp.Workbench.RootWindow.StatusBar.messageQueue.Count") == 0, timeout ); - return (string)Session.GetGlobalValue ("MonoDevelop.Ide.IdeApp.Workbench.RootWindow.StatusBar.text"); } - - Ide.WaitUntil ( - () => Session.GetGlobalValue<int> ("MonoDevelop.Ide.IdeApp.Workbench.RootWindow.StatusBar.messageQueue.Count") == 0, - timeout - ); return (string) Session.GetGlobalValue ("MonoDevelop.Ide.IdeApp.Workbench.RootWindow.StatusBar.renderArg.CurrentText"); } |