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

github.com/mono/guiunit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/framework/GuiUnit/TestRunner.cs3
-rw-r--r--src/framework/GuiUnit/XwtMainLoopIntegration.cs117
-rw-r--r--src/framework/GuiUnit_MT.csproj69
-rw-r--r--[-rwxr-xr-x]src/framework/Internal/TestExecutionContext.cs8
4 files changed, 192 insertions, 5 deletions
diff --git a/src/framework/GuiUnit/TestRunner.cs b/src/framework/GuiUnit/TestRunner.cs
index 996bc42..4ffd57b 100644
--- a/src/framework/GuiUnit/TestRunner.cs
+++ b/src/framework/GuiUnit/TestRunner.cs
@@ -46,7 +46,7 @@ namespace GuiUnit
static TestRunner ()
{
LoadFileMethod = typeof(Assembly).GetMethods ().FirstOrDefault (m => {
- return m.Name == "LoadFile" && m.GetParameters ().Length == 1 && m.GetParameters () [0].ParameterType == typeof(string);
+ return m.Name == "LoadFrom" && m.GetParameters ().Length == 1 && m.GetParameters () [0].ParameterType == typeof(string);
});
}
@@ -59,6 +59,7 @@ namespace GuiUnit
try { mainLoop = mainLoop ?? new XwtMainLoopIntegration (); } catch { }
try { mainLoop = mainLoop ?? new MonoMacMainLoopIntegration (); } catch { }
try { mainLoop = mainLoop ?? new GtkMainLoopIntegration (); } catch { }
+ mainLoop = mainLoop ?? new ConsoleMainLoop ();
return mainLoop;
} set {
mainLoop = value;
diff --git a/src/framework/GuiUnit/XwtMainLoopIntegration.cs b/src/framework/GuiUnit/XwtMainLoopIntegration.cs
index ff6d598..485cdfb 100644
--- a/src/framework/GuiUnit/XwtMainLoopIntegration.cs
+++ b/src/framework/GuiUnit/XwtMainLoopIntegration.cs
@@ -76,5 +76,122 @@ namespace GuiUnit
Application.GetMethod("Exit").Invoke(null, null);
}
}
+
+ class ConsoleMainLoop : System.Threading.SynchronizationContext, IMainLoopIntegration
+ {
+ System.Collections.Generic.Queue<InvokerHelper> work =
+ new System.Collections.Generic.Queue<InvokerHelper>();
+
+ System.Collections.Generic.Queue<Tuple<System.Threading.SendOrPostCallback, object>> contextWork =
+ new System.Collections.Generic.Queue<Tuple<System.Threading.SendOrPostCallback, object>>();
+
+ bool endLoop;
+
+ public void InitializeToolkit()
+ {
+ var runtime = Type.GetType("MonoDevelop.Core.Runtime, MonoDevelop.Core");
+ if (runtime == null)
+ return;
+
+ var property = runtime.GetProperty ("MainSynchronizationContext", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
+ if (property == null)
+ return;
+
+ System.Threading.SynchronizationContext.SetSynchronizationContext(this);
+ property.SetValue (null, System.Threading.SynchronizationContext.Current);
+ }
+
+ public void InvokeOnMainLoop (InvokerHelper helper)
+ {
+ lock (work)
+ {
+ work.Enqueue (helper);
+ System.Threading.Monitor.Pulse (work);
+ }
+ }
+
+ public void RunMainLoop ()
+ {
+ do
+ {
+ InvokerHelper next = null;
+ Tuple<System.Threading.SendOrPostCallback, object> nextContext = null;
+ lock (work)
+ {
+ if (work.Count > 0 && !endLoop)
+ next = work.Dequeue ();
+ else if (contextWork.Count > 0 && !endLoop)
+ nextContext = contextWork.Dequeue ();
+ else if (!endLoop)
+ System.Threading.Monitor.Wait (work);
+ }
+ if (next != null)
+ {
+ try
+ {
+ next.Invoke ();
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine (ex);
+ }
+ }
+ if (nextContext != null)
+ {
+ try
+ {
+ nextContext.Item1(nextContext.Item2);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex);
+ }
+ }
+ } while (!endLoop);
+ }
+
+ public void Shutdown ()
+ {
+ lock (work)
+ {
+ endLoop = true;
+ System.Threading.Monitor.Pulse (work);
+ }
+ }
+
+ public override void Post (System.Threading.SendOrPostCallback d, object state)
+ {
+ lock (work)
+ {
+ contextWork.Enqueue (new Tuple<System.Threading.SendOrPostCallback, object>(d, state));
+ System.Threading.Monitor.Pulse (work);
+ }
+ }
+
+ public override void Send (System.Threading.SendOrPostCallback d, object state)
+ {
+ var evt = new System.Threading.ManualResetEventSlim (false);
+ Exception exception = null;
+ Post (s =>
+ {
+ try
+ {
+ d.Invoke (state);
+ }
+ catch (Exception ex)
+ {
+ exception = ex;
+ }
+ finally
+ {
+ System.Threading.Thread.MemoryBarrier ();
+ evt.Set ();
+ }
+ }, null);
+ evt.Wait ();
+ if (exception != null)
+ throw exception;
+ }
+ }
}
diff --git a/src/framework/GuiUnit_MT.csproj b/src/framework/GuiUnit_MT.csproj
new file mode 100644
index 0000000..3d0f533
--- /dev/null
+++ b/src/framework/GuiUnit_MT.csproj
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project Sdk="Microsoft.NET.Sdk">
+ <PropertyGroup>
+ <ProjectGuid>{3D6A3EA9-6116-4E6C-9FD4-2F3259B6EAFD}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>NUnitLite</RootNamespace>
+ <AssemblyName>GuiUnit</AssemblyName>
+ <PublishUrl>publish\</PublishUrl>
+ <Install>true</Install>
+ <InstallFrom>Disk</InstallFrom>
+ <UpdateEnabled>false</UpdateEnabled>
+ <UpdateMode>Foreground</UpdateMode>
+ <UpdateInterval>7</UpdateInterval>
+ <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+ <UpdatePeriodically>false</UpdatePeriodically>
+ <UpdateRequired>false</UpdateRequired>
+ <MapFileExtensions>true</MapFileExtensions>
+ <ApplicationRevision>0</ApplicationRevision>
+ <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+ <IsWebBootstrapper>false</IsWebBootstrapper>
+ <UseApplicationTrust>false</UseApplicationTrust>
+ <BootstrapperEnabled>true</BootstrapperEnabled>
+ <TargetFrameworkProfile />
+ <SignAssembly>true</SignAssembly>
+ <TargetFrameworks>net472;net6.0</TargetFrameworks>
+ <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
+ <OutputPath>..\..\bin</OutputPath>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
+ <NoWarn>1574;1591</NoWarn>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <DefineConstants>TRACE;DEBUG;NET_4_5; CLR_4_0,NUNITLITE</DefineConstants>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <DefineConstants>TRACE;NET_4_5, CLR_4_0,NUNITLITE</DefineConstants>
+ </PropertyGroup>
+ <PropertyGroup>
+ <AssemblyOriginatorKeyFile>guiunit.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Remove="Runner\Silverlight\**" />
+ </ItemGroup>
+ <ItemGroup>
+ <PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" />
+ </ItemGroup>
+ <ItemGroup>
+ <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5 SP1</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
+ <Visible>False</Visible>
+ <ProductName>Windows Installer 3.1</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ </ItemGroup>
+</Project>
diff --git a/src/framework/Internal/TestExecutionContext.cs b/src/framework/Internal/TestExecutionContext.cs
index d7e7bb6..cdaa43d 100755..100644
--- a/src/framework/Internal/TestExecutionContext.cs
+++ b/src/framework/Internal/TestExecutionContext.cs
@@ -34,7 +34,7 @@ using System.Security.Principal;
#endif
using NUnit.Framework.Api;
-#if !NETCF
+#if !NETCF && !NETCOREAPP
using System.Runtime.Remoting.Messaging;
#endif
@@ -52,11 +52,11 @@ namespace NUnit.Framework.Internal
/// Static methods for each setting forward to the internal
/// object on the top of the stack.
/// </summary>
- public class TestExecutionContext
-#if !SILVERLIGHT && !NETCF
+ public class TestExecutionContext
+#if !SILVERLIGHT && !NETCF && !NETCOREAPP
//: ILogicalThreadAffinative
#endif
- {
+ {
#region Instance Fields
/// <summary>