[Monodevelop-patches-list] r2366 - in trunk/MonoDevelop/Extras/NUnit: . Commands Gui Services
John Luke <jluke@cfl.rr.com>
jluke at mono-cvs.ximian.com
Wed Mar 16 21:54:53 EST 2005
Author: jluke
Date: 2005-03-16 21:54:53 -0500 (Wed, 16 Mar 2005)
New Revision: 2366
Modified:
trunk/MonoDevelop/Extras/NUnit/Commands/NUnitCommands.cs
trunk/MonoDevelop/Extras/NUnit/Gui/TestPad.cs
trunk/MonoDevelop/Extras/NUnit/Services/NUnitService.cs
trunk/MonoDevelop/Extras/NUnit/TODO
Log:
add context menu
Modified: trunk/MonoDevelop/Extras/NUnit/Commands/NUnitCommands.cs
===================================================================
--- trunk/MonoDevelop/Extras/NUnit/Commands/NUnitCommands.cs 2005-03-17 02:02:37 UTC (rev 2365)
+++ trunk/MonoDevelop/Extras/NUnit/Commands/NUnitCommands.cs 2005-03-17 02:54:53 UTC (rev 2366)
@@ -11,10 +11,10 @@
{
public class NUnitLoadAssembly : AbstractMenuCommand
{
+ NUnitService nunitService = (NUnitService) ServiceManager.GetService (typeof (NUnitService));
+
public override void Run ()
{
- NUnitService nunitService = (NUnitService) ServiceManager.GetService (typeof (NUnitService));
-
using (FileSelector fs = new FileSelector ("Load test assembly")) {
//fs.DefaultPath = Path.Combine (Environment.GetEnvironmentVariable ("HOME"), "Projects");
@@ -30,9 +30,11 @@
public class NUnitRunTests : AbstractMenuCommand
{
+ NUnitService nunitService = (NUnitService) ServiceManager.GetService (typeof (NUnitService));
+
public override void Run ()
{
- Console.WriteLine ("Not implemented");
+ nunitService.RunTests ();
}
}
}
Modified: trunk/MonoDevelop/Extras/NUnit/Gui/TestPad.cs
===================================================================
--- trunk/MonoDevelop/Extras/NUnit/Gui/TestPad.cs 2005-03-17 02:02:37 UTC (rev 2365)
+++ trunk/MonoDevelop/Extras/NUnit/Gui/TestPad.cs 2005-03-17 02:54:53 UTC (rev 2366)
@@ -6,6 +6,7 @@
using MonoDevelop.Core.Services;
using MonoDevelop.Services;
using MonoDevelop.Gui;
+using MonoDevelop.Commands;
using NUnit.Framework;
using NUnit.Core;
@@ -24,7 +25,8 @@
IStatusBarService statusBarService;
NUnitService nunitService;
- int currentTest, totalTests;
+ int currentTest, totalTests, finishedTests;
+ int ignoredTests, errorTests;
event FixtureAddedEventHandler FixtureAddedEvent;
@@ -45,6 +47,7 @@
// register events
this.FixtureAddedEvent += OnFixtureAdded;
nunitService.AssemblyLoaded += OnAssemblyLoaded;
+ nunitService.TestStartedEvent += OnTestStarted;
nunitService.TestFinishedEvent += OnTestFinished;
}
@@ -67,6 +70,8 @@
view.AppendColumn (column);
view.RowActivated += OnRowActivated;
+ view.PopupMenu += OnPopup;
+ view.ButtonReleaseEvent += OnButtonReleased;
}
TreeIter AddFixture (TreeIter parent, string fullname)
@@ -104,7 +109,7 @@
if (t.IsSuite)
AddTestSuite (next, (TestSuite) t);
else if (FixtureAddedEvent != null)
- FixtureAddedEvent (this, new FixtureAddedEventArgs (++ currentTest, totalTests));
+ FixtureAddedEvent (this, new FixtureAddedEventArgs (++currentTest, totalTests));
}
}
@@ -113,12 +118,21 @@
GLib.Idle.Add (new GLib.IdleHandler (Populate));
}
+ void OnButtonReleased (object sender, ButtonReleaseEventArgs a)
+ {
+ if (a.Event.Button == 3)
+ ShowPopup ();
+ }
+
void OnFinishedLoad (object sender, EventArgs a)
{
string msg = String.Format (GettextCatalog.GetString ("{0} tests loaded."), totalTests);
statusBarService.SetProgressFraction (0.0);
statusBarService.SetMessage (msg);
// FIXME: set run menu items sensitive
+ TreeIter first;
+ if (store.GetIterFirst (out first))
+ view.Selection.SelectIter (first);
}
void OnFinishedRunning (object sender, EventArgs a)
@@ -133,16 +147,59 @@
statusBarService.SetMessage (msg);
}
+ void OnLoadActivated (object sender, EventArgs a)
+ {
+ new NUnitLoadAssembly ().Run ();
+ }
+
+ void OnPopup (object sender, EventArgs a)
+ {
+ ShowPopup ();
+ }
+
+ void ShowPopup ()
+ {
+ Menu menu = new Menu ();
+
+ MenuItem load = new MenuItem ("Load test assembly");
+ load.Activated += OnLoadActivated;
+ menu.Append (load);
+
+ MenuItem run = new MenuItem ("Run tests");
+ run.Activated += OnRunActivated;
+ menu.Append (run);
+
+ //MenuItem save = new MenuItem ("Save Results");
+
+ menu.ShowAll ();
+ menu.Popup ();
+ }
+
void OnRowActivated (object sender, RowActivatedArgs a)
{
- RunTestAtPath (a.Path);
+ if (!nunitService.Running) {
+ finishedTests = 0;
+ RunTestAtPath (a.Path);
+ }
}
+ void OnRunActivated (object sender, EventArgs a)
+ {
+ new NUnitRunTests ().Run ();
+ }
+
void OnTestFinished (object sender, TestEventArgs a)
{
SetIconFromResult (a.Result);
+ statusBarService.SetMessage ("");
}
+ void OnTestStarted (object sender, TestEventArgs a)
+ {
+ statusBarService.SetProgressFraction (++finishedTests / totalTests);
+ statusBarService.SetMessage ("Test: " + a.Test.FullName);
+ }
+
bool Populate ()
{
Assembly test = nunitService.TestAssembly;
@@ -165,7 +222,9 @@
void RunTestAtPath (TreePath path)
{
- nunitService.RunTest (GetTestFromPath (path.ToString (), null));
+ Test test = GetTestFromPath (path.ToString (), null);
+ totalTests = test.CountTestCases ();
+ nunitService.RunTest (test);
}
Test GetTestFromPath (string path, Test t)
Modified: trunk/MonoDevelop/Extras/NUnit/Services/NUnitService.cs
===================================================================
--- trunk/MonoDevelop/Extras/NUnit/Services/NUnitService.cs 2005-03-17 02:02:37 UTC (rev 2365)
+++ trunk/MonoDevelop/Extras/NUnit/Services/NUnitService.cs 2005-03-17 02:54:53 UTC (rev 2366)
@@ -12,6 +12,7 @@
{
Assembly asm;
bool running = false;
+ TestSuite rootTestSuite;
public event EventHandler AssemblyLoaded;
public event FixtureLoadedErrorEventHandler FixtureLoadError;
@@ -24,6 +25,10 @@
{
}
+ public bool Running {
+ get { return running; }
+ }
+
public Assembly TestAssembly {
get { return asm; }
}
@@ -44,6 +49,7 @@
finally {
AppDomain.CurrentDomain.AssemblyResolve -= reh;
}
+ rootTestSuite = suite;
return suite;
}
@@ -82,6 +88,12 @@
running = false;
}
+ public void RunTests ()
+ {
+ if (rootTestSuite != null)
+ RunTest (rootTestSuite);
+ }
+
public void SuiteFinished (TestSuiteResult result)
{
if (SuiteFinishedEvent != null)
Modified: trunk/MonoDevelop/Extras/NUnit/TODO
===================================================================
--- trunk/MonoDevelop/Extras/NUnit/TODO 2005-03-17 02:02:37 UTC (rev 2365)
+++ trunk/MonoDevelop/Extras/NUnit/TODO 2005-03-17 02:54:53 UTC (rev 2366)
@@ -1,4 +1,5 @@
load assembly/run context menus
+proper threading
viewing results
save the results to xml
More information about the Monodevelop-patches-list
mailing list