diff options
author | Lluis Sanchez <lluis@xamarin.com> | 2014-03-03 13:02:33 +0400 |
---|---|---|
committer | Lluis Sanchez <lluis@xamarin.com> | 2014-03-03 13:02:33 +0400 |
commit | a41e429b4cd5dc717a037b2086db03df06aa2740 (patch) | |
tree | 765c29072a3661c056cfbcc14e15493cae92be73 /main/tests | |
parent | f2c2840ac9f3f29a01e4a7457e261a07f4ac1162 (diff) | |
parent | 017cecfc1febb5580b94b21362f35bc0d963cc88 (diff) |
Merge remote-tracking branch 'origin/master' into retina
Conflicts:
main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.QuickTasks/QuickTaskOverviewMode.cs
main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/SplashScreen.cs
version-checks
Diffstat (limited to 'main/tests')
-rw-r--r-- | main/tests/Ide.Tests/Ide.Tests.csproj | 2 | ||||
-rw-r--r-- | main/tests/MacPlatform.Tests/MacPlatform.Tests.csproj | 2 | ||||
-rw-r--r-- | main/tests/TestRunner/TestRunner.csproj | 2 | ||||
-rw-r--r-- | main/tests/UserInterfaceTests/Gui.cs | 58 | ||||
-rw-r--r-- | main/tests/UserInterfaceTests/Ide.cs | 140 | ||||
-rw-r--r-- | main/tests/UserInterfaceTests/IdeApi.cs | 78 | ||||
-rw-r--r-- | main/tests/UserInterfaceTests/SimpleTest.cs | 26 | ||||
-rw-r--r-- | main/tests/UserInterfaceTests/TestService.cs | 1 | ||||
-rw-r--r-- | main/tests/UserInterfaceTests/UserInterfaceTests.csproj | 3 |
9 files changed, 225 insertions, 87 deletions
diff --git a/main/tests/Ide.Tests/Ide.Tests.csproj b/main/tests/Ide.Tests/Ide.Tests.csproj index a39988d63a..a38f63715f 100644 --- a/main/tests/Ide.Tests/Ide.Tests.csproj +++ b/main/tests/Ide.Tests/Ide.Tests.csproj @@ -3,7 +3,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>10.0.0</ProductVersion> + <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{73D4CC8B-BAB9-4A29-841B-F25C6311F067}</ProjectGuid> <OutputType>Library</OutputType> diff --git a/main/tests/MacPlatform.Tests/MacPlatform.Tests.csproj b/main/tests/MacPlatform.Tests/MacPlatform.Tests.csproj index 91c509ffbe..c8cda725f7 100644 --- a/main/tests/MacPlatform.Tests/MacPlatform.Tests.csproj +++ b/main/tests/MacPlatform.Tests/MacPlatform.Tests.csproj @@ -3,7 +3,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>10.0.0</ProductVersion> + <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{C05AAB7A-523F-4109-966B-6675BE0975BA}</ProjectGuid> <OutputType>Library</OutputType> diff --git a/main/tests/TestRunner/TestRunner.csproj b/main/tests/TestRunner/TestRunner.csproj index 2101e9a64a..0b7d4810bb 100644 --- a/main/tests/TestRunner/TestRunner.csproj +++ b/main/tests/TestRunner/TestRunner.csproj @@ -3,7 +3,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>12.0.0</ProductVersion> + <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{EBFC7F90-C2E5-4A4C-A327-E35021BEC181}</ProjectGuid> <OutputType>Library</OutputType> diff --git a/main/tests/UserInterfaceTests/Gui.cs b/main/tests/UserInterfaceTests/Gui.cs new file mode 100644 index 0000000000..48a0b7cd72 --- /dev/null +++ b/main/tests/UserInterfaceTests/Gui.cs @@ -0,0 +1,58 @@ +// +// Gui.cs +// +// Author: +// Michael Hutchinson <m.j.hutchinson@gmail.com> +// +// Copyright (c) 2014 Xamarin Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Threading; +using MonoDevelop.Core; +using MonoDevelop.Core.Instrumentation; +using MonoDevelop.Ide.Commands; +using NUnit.Framework; +using MonoDevelop.Components.AutoTest; + +namespace UserInterfaceTests +{ + + static class Gui + { + static AutoTestClientSession Session { + get { return TestService.Session; } + } + + public static void PressButton (string buttonName) + { + Assert.IsTrue (Session.SelectWidget (buttonName)); + Session.Invoke ("Activate"); + } + + public static void EnterText (string widgetName, string text, bool replace = true) + { + Assert.IsTrue (Session.SelectWidget (widgetName)); + if (replace) + Session.ExecuteCommand (EditCommands.SelectAll); + Session.TypeText (text); + } + } +} diff --git a/main/tests/UserInterfaceTests/Ide.cs b/main/tests/UserInterfaceTests/Ide.cs new file mode 100644 index 0000000000..36f0d03b45 --- /dev/null +++ b/main/tests/UserInterfaceTests/Ide.cs @@ -0,0 +1,140 @@ +// +// IdeApi.cs +// +// Author: +// Lluis Sanchez Gual <lluis@novell.com> +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Threading; +using MonoDevelop.Core; +using MonoDevelop.Core.Instrumentation; +using MonoDevelop.Ide.Commands; +using NUnit.Framework; +using MonoDevelop.Components.AutoTest; +using System.Linq; + +namespace UserInterfaceTests +{ + public static class Ide + { + static AutoTestClientSession Session { + get { return TestService.Session; } + } + + public static void OpenFile (FilePath file) + { + Session.GlobalInvoke ("MonoDevelop.Ide.IdeApp.Workbench.OpenDocument", (FilePath) file, true); + Assert.AreEqual (file, Ide.GetActiveDocumentFilename ()); + } + + public static FilePath OpenTestSolution (string solution) + { + FilePath path = Util.GetSampleProject (solution); + + RunAndWaitForTimer ( + () => Session.GlobalInvoke ("MonoDevelop.Ide.IdeApp.Workspace.OpenWorkspaceItem", (string)path), + "MonoDevelop.Ide.Counters.OpenWorkspaceItemTimer" + ); + + return path; + } + + public static void CloseAll () + { + Session.ExecuteCommand (FileCommands.CloseWorkspace); + Session.ExecuteCommand (FileCommands.CloseAllFiles); + } + + public static FilePath GetActiveDocumentFilename () + { + return Session.GetGlobalValue<FilePath> ("MonoDevelop.Ide.IdeApp.Workbench.ActiveDocument.FileName"); + } + + public static void BuildSolution () + { + RunAndWaitForTimer ( + () => Session.ExecuteCommand (ProjectCommands.BuildSolution), + "MonoDevelop.Ide.Counters.BuildItemTimer" + ); + + var status = GetStatusMessage (); + Assert.AreEqual (status, "Build successful."); + } + + static void WaitUntil (Func<bool> done, int timeout = 20000, int pollStep = 200) + { + do { + if (done ()) + return; + timeout -= pollStep; + Thread.Sleep (pollStep); + } while (timeout > 0); + + throw new Exception ("Timed out waiting for event"); + } + + //no saner way to do this + public static string GetStatusMessage (int timeout = 20000) + { + //wait for any queued messages to pop + WaitUntil ( + () => Session.GetGlobalValue<int> ("MonoDevelop.Ide.IdeApp.Workbench.Toolbar.statusArea.messageQueue.Count") == 0, + timeout + ); + return (string) Session.GetGlobalValue ("MonoDevelop.Ide.IdeApp.Workbench.Toolbar.statusArea.renderArg.CurrentText"); + } + + public static void RunAndWaitForTimer (Action action, string counter, int timeout = 20000) + { + var c = Session.GetGlobalValue<TimerCounter> (counter); + var tt = c.TotalTime; + + action (); + + WaitUntil (() => c.TotalTime > tt, timeout); + } + + public static void CreateProject (string name, string category, string kind, FilePath directory) + { + Session.ExecuteCommand (FileCommands.NewProject); + Session.WaitForWindow ("MonoDevelop.Ide.Projects.NewProjectDialog"); + + Session.SelectWidget ("lst_template_types"); + Session.SelectTreeviewItem (category); + + Session.SelectWidget ("boxTemplates"); + var cells = Session.GetTreeviewCells (); + var cellName = cells.First (c => c!= null && c.StartsWith (kind + "\n", StringComparison.Ordinal)); + Session.SelectTreeviewItem (cellName); + + Gui.EnterText ("txt_name", name); + Gui.EnterText ("entry_location", directory); + + RunAndWaitForTimer ( + () => Gui.PressButton ("btn_new"), + "MonoDevelop.Ide.Counters.OpenDocumentTimer" + ); + } + } + +} diff --git a/main/tests/UserInterfaceTests/IdeApi.cs b/main/tests/UserInterfaceTests/IdeApi.cs deleted file mode 100644 index c62053f7b3..0000000000 --- a/main/tests/UserInterfaceTests/IdeApi.cs +++ /dev/null @@ -1,78 +0,0 @@ -// -// IdeApi.cs -// -// Author: -// Lluis Sanchez Gual <lluis@novell.com> -// -// Copyright (c) 2010 Novell, Inc (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -using MonoDevelop.Components.AutoTest; -using MonoDevelop.Core; -using MonoDevelop.Ide.Commands; -using NUnit.Framework; - -namespace UserInterfaceTests -{ - public static class IdeApi - { - public static void OpenFile (FilePath file) - { - TestService.Session.GlobalInvoke ("MonoDevelop.Ide.IdeApp.Workbench.OpenDocument", (FilePath) file, true); - Assert.AreEqual (file, IdeApi.GetActiveDocumentFilename ()); - } - - public static FilePath OpenTestSolution (string solution) - { - FilePath path = Util.GetSampleProject (solution); - - var op = TestService.Session.GlobalInvoke<AutoTestOperation> ( - "MonoDevelop.Ide.IdeApp.Workspace.OpenWorkspaceItem", (string) path - ); - - op.WaitForCompleted (); - Assert.IsTrue (op.Success); - - return path; - } - - public static void CloseAll () - { - TestService.Session.ExecuteCommand (FileCommands.CloseWorkspace); - TestService.Session.ExecuteCommand (FileCommands.CloseAllFiles); - } - - public static FilePath GetActiveDocumentFilename () - { - return TestService.Session.GetGlobalValue<FilePath> ("MonoDevelop.Ide.IdeApp.Workbench.ActiveDocument.FileName"); - } - - public static void BuildSolution (bool expectedResult = true) - { - TestService.Session.ExecuteCommand (ProjectCommands.BuildSolution); - - var buildOp = TestService.Session.GetGlobalValue<AutoTestOperation> ( - "MonoDevelop.Ide.IdeApp.ProjectOperations.CurrentBuildOperation" - ); - buildOp.WaitForCompleted (); - Assert.AreEqual (buildOp.Success, expectedResult); - } - } -} diff --git a/main/tests/UserInterfaceTests/SimpleTest.cs b/main/tests/UserInterfaceTests/SimpleTest.cs index 161ed3da21..2b0b2c1b76 100644 --- a/main/tests/UserInterfaceTests/SimpleTest.cs +++ b/main/tests/UserInterfaceTests/SimpleTest.cs @@ -38,15 +38,15 @@ namespace UserInterfaceTests [Test] public void OpenEditCompile () { - var slnFile = IdeApi.OpenTestSolution ("ConsoleApp-VS2010/ConsoleApplication.sln"); + var slnFile = Ide.OpenTestSolution ("ConsoleApp-VS2010/ConsoleApplication.sln"); var slnDir = slnFile.ParentDirectory; var exe = slnDir.Combine ("bin", "Debug", "ConsoleApplication.exe"); Assert.IsFalse (File.Exists (exe)); - IdeApi.OpenFile (slnFile.ParentDirectory.Combine ("Program.cs")); + Ide.OpenFile (slnFile.ParentDirectory.Combine ("Program.cs")); - IdeApi.BuildSolution (); + Ide.BuildSolution (); AssertExeHasOutput (exe, ""); //select text editor, move down 10 lines, and insert a statement @@ -56,10 +56,10 @@ namespace UserInterfaceTests Session.ExecuteCommand (TextEditorCommands.LineEnd); Session.TypeText ("\nConsole.WriteLine (\"Hello World!\");"); - IdeApi.BuildSolution (); + Ide.BuildSolution (); AssertExeHasOutput (exe, "Hello World!"); - IdeApi.CloseAll (); + Ide.CloseAll (); } void AssertExeHasOutput (string exe, string expectedOutput) @@ -71,5 +71,21 @@ namespace UserInterfaceTests Assert.AreEqual (expectedOutput, output.Trim ()); } + + [Test] + public void CreateBuildProject () + { + string projectName = "TestFoo"; + string projectCategory = "C#"; + string projectKind = "Console Project"; + + var projectDirectory = Util.CreateTmpDir (projectName); + + Ide.CreateProject (projectName, projectCategory, projectKind, projectDirectory); + + Ide.BuildSolution (); + + Ide.CloseAll (); + } } } diff --git a/main/tests/UserInterfaceTests/TestService.cs b/main/tests/UserInterfaceTests/TestService.cs index 8043a080a2..193a96c35a 100644 --- a/main/tests/UserInterfaceTests/TestService.cs +++ b/main/tests/UserInterfaceTests/TestService.cs @@ -46,6 +46,7 @@ namespace UserInterfaceTests { "MONODEVELOP_TEST_PROFILE", Util.CreateTmpDir ("profile") } }); + Session.SetGlobalValue ("MonoDevelop.Core.Instrumentation.InstrumentationService.Enabled", true); Session.GlobalInvoke ("MonoDevelop.Ide.IdeApp.Workbench.GrabDesktopFocus"); } diff --git a/main/tests/UserInterfaceTests/UserInterfaceTests.csproj b/main/tests/UserInterfaceTests/UserInterfaceTests.csproj index ab7091bcca..f320e12bd8 100644 --- a/main/tests/UserInterfaceTests/UserInterfaceTests.csproj +++ b/main/tests/UserInterfaceTests/UserInterfaceTests.csproj @@ -40,12 +40,13 @@ </Reference> </ItemGroup> <ItemGroup> - <Compile Include="IdeApi.cs" /> <Compile Include="UITestBase.cs" /> <Compile Include="TestService.cs" /> <Compile Include="Util.cs" /> <Compile Include="SimpleTest.cs" /> <Compile Include="ProcessUtils.cs" /> + <Compile Include="Gui.cs" /> + <Compile Include="Ide.cs" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <ItemGroup> |