Skip to content

Commit

Permalink
SWT test configuration fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Vivek Singh committed Mar 25, 2011
1 parent 63999d9 commit ceee112
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 14 deletions.
28 changes: 23 additions & 5 deletions Components/Core/Source/Application.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using Bricks.Core;
using White.Core.Configuration;
using White.Core.Factory;
Expand All @@ -20,7 +22,9 @@ public class Application : IDisposable
private readonly ApplicationSession applicationSession;
private readonly WindowFactory windowFactory;

protected Application() {}
protected Application()
{
}

private Application(Process process)
{
Expand Down Expand Up @@ -48,8 +52,20 @@ public static Application Launch(string executable)
/// <returns></returns>
public static Application Launch(ProcessStartInfo processStartInfo)
{
WhiteLogger.Instance.DebugFormat("Launching process: {0} in working directory: {1}", processStartInfo.FileName, processStartInfo.WorkingDirectory);
return Attach(Process.Start(processStartInfo));
WhiteLogger.Instance.DebugFormat("[Launching process:{0}] [Working directory:{1}] [Process full path:{2}] [Current Directory:{3}]",
processStartInfo.FileName,
new DirectoryInfo(processStartInfo.WorkingDirectory).FullName,
new FileInfo(processStartInfo.FileName).FullName,
Environment.CurrentDirectory);
Process process = Process.Start(processStartInfo);
if (ConfigurationManager.AppSettings["CaptureAUTOutput"] != null && process != null)
{
string output = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();
WhiteLogger.Instance.DebugFormat("[TestProcessOutput:{0}]", output);
WhiteLogger.Instance.DebugFormat("[TestProcessError:{0}]", error);
}
return Attach(process);
}

/// <summary>
Expand Down Expand Up @@ -159,7 +175,9 @@ public virtual void Kill()
process.Kill();
process.WaitForExit();
}
catch {}
catch
{
}
}

/// <summary>
Expand Down Expand Up @@ -243,4 +261,4 @@ public virtual void KillAndSaveState()
ApplicationSession.Save();
}
}
}
}
4 changes: 4 additions & 0 deletions Components/Core/Source/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@
<Compile Include="UIItems\Scrolling\WinFormScrollBars.cs" />
<Compile Include="UIItems\WPFButton.cs" />
<Compile Include="UIItems\WPFUIItems\WPFUIItem.cs" />
<Compile Include="Utility\MonitorForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Utility\TestExecutionMonitor.cs" />
<Compile Include="WindowsAPI\WindowPlacement.cs" />
<Compile Include="InputDevices\WindowsConstants.cs" />
<Compile Include="Interceptors\CoreInterceptor.cs" />
Expand Down
18 changes: 18 additions & 0 deletions Components/Core/Source/Utility/MonitorForm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Drawing;
using System.Windows.Forms;

namespace White.Core.Utility
{
public class MonitorForm : Form
{
public MonitorForm()
{
Size = new Size(1, 1);
}

protected override bool ProcessKeyMessage(ref Message m)
{
return base.ProcessKeyMessage(ref m);
}
}
}
13 changes: 13 additions & 0 deletions Components/Core/Source/Utility/TestExecutionMonitor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Windows.Forms;

namespace White.Core.Utility
{
public class TestExecutionMonitor
{
public TestExecutionMonitor()
{
var form = new Form();
form.Show();
}
}
}
21 changes: 16 additions & 5 deletions Components/Core/Tests/UITests/TestConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
using System;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using White.Core.Factory;

namespace White.Core.UITests
{
public abstract class TestConfiguration
{
public static string WPFTestAppLocation = @"..\..\..\WPFTestApp\bin\debug\WindowsPresentationFramework.exe";
public static string WinFormsTestAppLocation = @"..\..\..\WinFormsTestApp\bin\debug\WinFormsTestApp.exe";
public static string WPFTestAppLocation = @"..\..\..\TestApplications\WPFTestApp\bin\debug\WindowsPresentationFramework.exe";
public static string WinFormsTestAppLocation = @"..\..\..\TestApplications\WinFormsTestApp\bin\debug\WinFormsTestApp.exe";

public static string SWTTestAppLocation = @"java";
public static string SWTTestAppLocation = @"java.exe";

private readonly string program;
protected string commandLineArguments;
Expand All @@ -30,7 +32,9 @@ public virtual Application Launch()
FileName = program,
Arguments = commandLineArguments.Trim(),
UseShellExecute = false,
CreateNoWindow = true
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true
};
return Application.Launch(processStartInfo);
}
Expand Down Expand Up @@ -60,10 +64,17 @@ public class SWTTestConfiguration : TestConfiguration
{
public SWTTestConfiguration(string commandLineArguments)
: base(
SWTTestAppLocation,
SWTAppFullPath(),
@" -classpath SampleSWTApp\bin;""%classpath%"";SampleSWTApp\org.eclipse.swt.win32.win32.x86_3.2.1.v3235.jar -Djava.library.path=SampleSWTApp Program " +
commandLineArguments) {}

private static string SWTAppFullPath()
{
string javaLocation = ConfigurationManager.AppSettings["JavaLocation"];
if (javaLocation == null) throw new ConfigurationErrorsException("JavaLocation key is not configured in appSettings");
return Path.Combine(javaLocation, SWTTestAppLocation);
}

protected override string WorkingDir
{
get { return @"..\..\..\TestApplications"; }
Expand Down
2 changes: 1 addition & 1 deletion Components/Core/Tests/UITests/log4net.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<root>
<level value="Debug" />
<level value="Info" />
<appender-ref ref="Console" />
<appender-ref ref="White" />
</root>
Expand Down
14 changes: 11 additions & 3 deletions build/core.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@
<component-compile/>
</target>

<target name="core.uitest" depends="core.compile">
<core-test excludes="WinForm,SWT" framework="WPF"/>
<core-test excludes="WPF,SWT,Normal" framework="WinForm"/>
<target name="core.uitest" depends="core.compile,core.wpf.uitest,core.winform.uitest,core.swt.uitest"/>

<target name="core.swt.uitest" depends="core.compile">
<core-test excludes="WPF,WinForm,Normal" framework="SWT"/>
</target>

<target name="core.winform.uitest" depends="core.compile">
<core-test excludes="WPF,SWT,Normal" framework="WinForm"/>
</target>

<target name="core.wpf.uitest" depends="core.compile">
<core-test excludes="WinForm,SWT" framework="WPF"/>
</target>

<target name="core.unittest" depends="core.compile">
<unit-test/>
</target>
Expand Down

0 comments on commit ceee112

Please sign in to comment.