Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan McGovern <alan@xamarin.com>2014-01-28 07:25:31 +0400
committerAlan McGovern <alan@xamarin.com>2014-01-28 07:25:31 +0400
commitc559dd8f6c1f822e23c16fd4c970ab7a7ff0c7a0 (patch)
treebfe0727dc282272f634b5e20b8093c51dab7c75c /main/tests
parent7f11ea4997eaa9169b847d2f389979c97705c9a7 (diff)
[Ide.Tests] Initialize all of xamarin studio!
This initializes nearly all of XS in the 'correct' way. We have a full IdeApp and all the misc stuff has been initialized too. This means we can write tests properly without having to worry about IdeApp.IsInitialized. This allows us to create Gtk# projects in our test runner... hurrah!
Diffstat (limited to 'main/tests')
-rw-r--r--main/tests/Ide.Tests/Ide.Tests.csproj1
-rw-r--r--main/tests/Ide.Tests/ProjectTemplateTests.cs10
-rw-r--r--main/tests/Ide.Tests/TestBase.cs70
3 files changed, 76 insertions, 5 deletions
diff --git a/main/tests/Ide.Tests/Ide.Tests.csproj b/main/tests/Ide.Tests/Ide.Tests.csproj
index 2cb4dd7585..a39988d63a 100644
--- a/main/tests/Ide.Tests/Ide.Tests.csproj
+++ b/main/tests/Ide.Tests/Ide.Tests.csproj
@@ -35,6 +35,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="ProjectTemplateTests.cs" />
+ <Compile Include="TestBase.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
diff --git a/main/tests/Ide.Tests/ProjectTemplateTests.cs b/main/tests/Ide.Tests/ProjectTemplateTests.cs
index 79f72e89d4..139057cca7 100644
--- a/main/tests/Ide.Tests/ProjectTemplateTests.cs
+++ b/main/tests/Ide.Tests/ProjectTemplateTests.cs
@@ -33,22 +33,22 @@ using System.Text;
namespace MonoDevelop.Ide
{
[TestFixture]
- public class ProjectTemplateTests
+ public class ProjectTemplateTests : TestBase
{
string TempDir {
get; set;
}
- [SetUp]
- public void Setup ()
+ public override void Setup ()
{
+ base.Setup ();
var currentDir = Path.GetDirectoryName (typeof(ProjectTemplateTests).Assembly.Location);
TempDir = Path.GetFullPath (Path.Combine (currentDir, "TempDirForTests"));
}
- [TearDown]
- public void Teardown ()
+ public override void Teardown ()
{
+ base.Teardown ();
try { Directory.Delete (TempDir, true); } catch { }
}
diff --git a/main/tests/Ide.Tests/TestBase.cs b/main/tests/Ide.Tests/TestBase.cs
new file mode 100644
index 0000000000..ee05b5d83e
--- /dev/null
+++ b/main/tests/Ide.Tests/TestBase.cs
@@ -0,0 +1,70 @@
+//
+// TestBase.cs
+//
+// Author:
+// Alan McGovern <alan@xamarin.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.Ide;
+using MonoDevelop.Ide.Gui;
+using MonoDevelop.Core.ProgressMonitoring;
+using NUnit.Framework;
+
+namespace MonoDevelop.Ide
+{
+ [TestFixture]
+ public abstract class TestBase
+ {
+ static bool Initialized {
+ get; set;
+ }
+
+ [SetUp]
+ public virtual void Setup ()
+ {
+ // All this initialization was copied/pasted from IdeApp.Run. Hopefully i copied enough of it.
+ if (!Initialized) {
+ Initialized = true;
+ //ensure native libs initialized before we hit anything that p/invokes
+ MonoDevelop.Core.Platform.Initialize ();
+ // Set a synchronization context for the main gtk thread
+ SynchronizationContext.SetSynchronizationContext (new GtkSynchronizationContext ());
+ IdeApp.Customizer = new MonoDevelop.Ide.Extensions.IdeCustomizer ();
+
+ DispatchService.Initialize ();
+ InternalLog.Initialize ();
+ DesktopService.Initialize ();
+ ImageService.Initialize ();
+ IdeApp.Initialize (new NullProgressMonitor ());
+ }
+ }
+
+ [TearDown]
+ public virtual void Teardown ()
+ {
+
+ }
+ }
+}
+