diff --git a/src/AddIns/Misc/MbUnitPad/Project/MbUnitPad.addin b/src/AddIns/Misc/MbUnitPad/Project/MbUnitPad.addin
index 52945b2fce..bb6f77c483 100644
--- a/src/AddIns/Misc/MbUnitPad/Project/MbUnitPad.addin
+++ b/src/AddIns/Misc/MbUnitPad/Project/MbUnitPad.addin
@@ -10,6 +10,7 @@
+
@@ -80,13 +81,94 @@
tooltip = "${res:NUnitPad.NUnitPadContent.ReferenceItem}"
class = "ICSharpCode.MbUnitPad.AddNUnitReferenceCommand"/>
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/AddIns/Misc/MbUnitPad/Project/MbUnitPad.csproj b/src/AddIns/Misc/MbUnitPad/Project/MbUnitPad.csproj
index 78e34f8425..a3e3b7b522 100644
--- a/src/AddIns/Misc/MbUnitPad/Project/MbUnitPad.csproj
+++ b/src/AddIns/Misc/MbUnitPad/Project/MbUnitPad.csproj
@@ -46,6 +46,7 @@
UserControl
+
diff --git a/src/AddIns/Misc/MbUnitPad/Project/Src/MbUnitCommands.cs b/src/AddIns/Misc/MbUnitPad/Project/Src/MbUnitCommands.cs
index 23e3713283..f82fbefe76 100644
--- a/src/AddIns/Misc/MbUnitPad/Project/Src/MbUnitCommands.cs
+++ b/src/AddIns/Misc/MbUnitPad/Project/Src/MbUnitCommands.cs
@@ -41,6 +41,14 @@ namespace ICSharpCode.MbUnitPad
}
}
+ public class StopTestsCommand : AbstractMenuCommand
+ {
+ public override void Run()
+ {
+ MbUnitPadContent.Instance.StopTests();
+ }
+ }
+
public class AddNUnitReferenceCommand : AbstractMenuCommand
{
public override void Run()
@@ -104,4 +112,84 @@ namespace ICSharpCode.MbUnitPad
DebuggerService.CurrentDebugger.Start(startInfo);
}
}
+
+ public class GotoDefinitionCommand : AbstractMenuCommand
+ {
+ public override void Run()
+ {
+ MbUnitPadContent.Instance.TreeView.GotoDefinition();
+ }
+ }
+
+ public class ExpandAllCommand : AbstractMenuCommand
+ {
+ public override void Run()
+ {
+ MbUnitPadContent.Instance.TreeView.ExpandAll();
+ }
+ }
+
+ public class CollapseAllCommand : AbstractMenuCommand
+ {
+ public override void Run()
+ {
+ MbUnitPadContent.Instance.TreeView.CollapseAll();
+ }
+ }
+
+ public class ExpandCurrentCommand : AbstractMenuCommand
+ {
+ public override void Run()
+ {
+ MbUnitPadContent.Instance.TreeView.ExpandChildNode(MbUnitPadContent.Instance.TreeView.SelectedNode);
+ }
+ }
+
+ public class CollapseCurrentCommand : AbstractMenuCommand
+ {
+ public override void Run()
+ {
+ MbUnitPadContent.Instance.TreeView.CollapseChildNode(MbUnitPadContent.Instance.TreeView.SelectedNode);
+ }
+ }
+
+ public class ExpandAllFailuresCommand : AbstractMenuCommand
+ {
+ public override void Run()
+ {
+ MbUnitPadContent.Instance.TreeView.ExpandAllFailures();
+ }
+ }
+
+ public class ExpandCurrentFailuresCommand : AbstractMenuCommand
+ {
+ public override void Run()
+ {
+ MbUnitPadContent.Instance.TreeView.ExpandCurrentFailures();
+ }
+ }
+
+ public class ExpandAllIgnoredCommand : AbstractMenuCommand
+ {
+ public override void Run()
+ {
+ MbUnitPadContent.Instance.TreeView.ExpandAllIgnored();
+ }
+ }
+
+ public class ExpandCurrentIgnoredCommand : AbstractMenuCommand
+ {
+ public override void Run()
+ {
+ MbUnitPadContent.Instance.TreeView.ExpandCurrentIgnored();
+ }
+ }
+
+ public class ClearResultsCommand : AbstractMenuCommand
+ {
+ public override void Run()
+ {
+ MbUnitPadContent.Instance.TreeView.ClearAllResults();
+ }
+ }
}
diff --git a/src/AddIns/Misc/MbUnitPad/Project/Src/MbUnitPad.cs b/src/AddIns/Misc/MbUnitPad/Project/Src/MbUnitPad.cs
index 13ab89e77b..772cf7e389 100644
--- a/src/AddIns/Misc/MbUnitPad/Project/Src/MbUnitPad.cs
+++ b/src/AddIns/Misc/MbUnitPad/Project/Src/MbUnitPad.cs
@@ -6,6 +6,7 @@
//
using System;
+using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
using ICSharpCode.Core;
@@ -33,6 +34,7 @@ namespace ICSharpCode.MbUnitPad
TestTreeView treeView;
ToolStrip toolStrip;
Control ctl;
+ bool runningTests;
public TestTreeView TreeView {
get {
@@ -68,14 +70,20 @@ namespace ICSharpCode.MbUnitPad
ctl.Dispose();
}
+ public bool IsRunningTests {
+ get {
+ return runningTests;
+ }
+ }
+
void OnSolutionLoaded(object sender, EventArgs e)
{
- ToolbarService.UpdateToolbar(toolStrip);
+ UpdateToolbar();
}
void OnSolutionClosed(object sender, EventArgs e)
{
- ToolbarService.UpdateToolbar(toolStrip);
+ UpdateToolbar();
treeView.NewConfig();
}
@@ -83,17 +91,37 @@ namespace ICSharpCode.MbUnitPad
{
if (treeView.TypeTree.Nodes.Count == 0) {
treeView.TreePopulated += StartTestsAfterTreePopulation;
+ treeView.FinishTests += FinishTests;
ReloadAssemblyList();
} else {
+ treeView.FinishTests += FinishTests;
treeView.ThreadedRunTests();
+ runningTests = true;
+ UpdateToolbar();
}
}
+ public void StopTests()
+ {
+ treeView.AbortWorkerThread();
+ runningTests = false;
+ UpdateToolbar();
+ }
+
+ void FinishTests(object sender, EventArgs e)
+ {
+ treeView.FinishTests -= FinishTests;
+ runningTests = false;
+ WorkbenchSingleton.SafeThreadAsyncCall(this, "UpdateToolbar");
+ }
+
void StartTestsAfterTreePopulation(object sender, EventArgs e)
{
treeView.TreePopulated -= StartTestsAfterTreePopulation;
// we cannot run the tests on this thread because we have to wait for the worker thread to exit
WorkbenchSingleton.SafeThreadAsyncCall(treeView, "ThreadedRunTests");
+ runningTests = true;
+ WorkbenchSingleton.SafeThreadAsyncCall(this, "UpdateToolbar");
}
public void ReloadAssemblyList()
@@ -147,7 +175,11 @@ namespace ICSharpCode.MbUnitPad
///
public override void RedrawContent()
{
-
+ }
+
+ void UpdateToolbar()
+ {
+ ToolbarService.UpdateToolbar(toolStrip);
}
}
}
diff --git a/src/AddIns/Misc/MbUnitPad/Project/Src/MbUnitRunningTestsCondition.cs b/src/AddIns/Misc/MbUnitPad/Project/Src/MbUnitRunningTestsCondition.cs
new file mode 100644
index 0000000000..8ba0b0d3a3
--- /dev/null
+++ b/src/AddIns/Misc/MbUnitPad/Project/Src/MbUnitRunningTestsCondition.cs
@@ -0,0 +1,27 @@
+//
+// 2002-2005 AlphaSierraPapa
+// GNU General Public License
+//
+// $Revision$
+//
+
+using ICSharpCode.Core;
+using System;
+
+namespace ICSharpCode.MbUnitPad
+{
+ ///
+ /// Determines whether #develop is currently running MbUnit tests.
+ ///
+ public class MbUnitRunningTestsCondition : IConditionEvaluator
+ {
+ public bool IsValid(object caller, Condition condition)
+ {
+ MbUnitPadContent pad = caller as MbUnitPadContent;
+ if (pad != null) {
+ return pad.IsRunningTests;
+ }
+ return false;
+ }
+ }
+}
diff --git a/src/AddIns/Misc/MbUnitPad/Project/Src/TestTreeView.cs b/src/AddIns/Misc/MbUnitPad/Project/Src/TestTreeView.cs
index 20c830a22f..6de34924b0 100644
--- a/src/AddIns/Misc/MbUnitPad/Project/Src/TestTreeView.cs
+++ b/src/AddIns/Misc/MbUnitPad/Project/Src/TestTreeView.cs
@@ -14,19 +14,37 @@ using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
using MbUnit.Forms;
using MbUnit.Core;
+using MbUnit.Core.Graph;
using MbUnit.Core.Remoting;
using MbUnit.Core.Reports.Serialization;
namespace ICSharpCode.MbUnitPad
{
- public class TestTreeView : ReflectorTreeView
+ public class TestTreeView : ReflectorTreeView, IOwnerState
{
Hashtable pipeNodes;
+ [Flags]
+ public enum TestTreeViewState {
+ Nothing = 0,
+ SourceCodeItemSelected = 1,
+ TestItemSelected = 2
+ }
+
+ protected TestTreeViewState internalState = TestTreeViewState.Nothing;
+
+ public System.Enum InternalState {
+ get {
+ return internalState;
+ }
+ }
+
public TestTreeView()
{
+ TypeTree.HideSelection = false;
TypeTree.ContextMenu = null;
TypeTree.ContextMenuStrip = MenuService.CreateContextMenu(this, "/SharpDevelop/Pads/MbUnitPad/ContextMenu");
+ TypeTree.MouseDown += TreeViewMouseDown;
this.StartTests += OnTestsStarted;
this.FinishTests += delegate { BeginInvoke(new MethodInvoker(ExpandAllFailures)); };
this.Facade.Updated += OnFacadeUpdated;
@@ -34,6 +52,82 @@ namespace ICSharpCode.MbUnitPad
pipeNodes = (Hashtable)typeof(TestTreeNodeFacade).InvokeMember("pipeNodes", BindingFlags.GetField | BindingFlags.Instance | BindingFlags.NonPublic, null, Facade, null);
}
+ public TreeNode SelectedNode {
+ get {
+ return TypeTree.SelectedNode;
+ }
+ }
+
+ public void ExpandChildNode(TreeNode node)
+ {
+ TypeTree.BeginUpdate();
+ if (node != null) {
+ node.Expand();
+ foreach(TreeNode child in node.Nodes) {
+ ExpandChildNode(child);
+ }
+ }
+ TypeTree.EndUpdate();
+ }
+
+ public void CollapseChildNode(TreeNode node)
+ {
+ TypeTree.BeginUpdate();
+ if (node != null) {
+ node.Collapse();
+ foreach(TreeNode child in node.Nodes) {
+ CollapseChildNode(child);
+ }
+ }
+ TypeTree.EndUpdate();
+ }
+
+ public void ExpandAll()
+ {
+ TypeTree.ExpandAll();
+ }
+
+ public void CollapseAll()
+ {
+ TypeTree.CollapseAll();
+ }
+
+ public void GotoDefinition()
+ {
+ MessageBox.Show("Not implemented.");
+// UnitTreeNode node = SelectedNode as UnitTreeNode;
+// if (node != null) {
+// string fullMemberName = null;
+// Fixture fixture = null;
+// switch (node.TestNodeType) {
+// case TestNodeType.Test:
+// fixture = FindFixture(node.DomainIdentifier, node.Parent.Text);
+// if (fixture != null)
+// fullMemberName = String.Concat(fixture.Type.FullName, ".", node.Text);
+// break;
+//
+// case TestNodeType.Fixture:
+// fixture = FindFixture(node.DomainIdentifier, node.Text);
+// if (fixture != null)
+// fullMemberName = fixture.Type.FullName;
+// break;
+// }
+//
+// LoggingService.Debug("MemberName=" + fullMemberName);
+// if (fullMemberName != null) {
+// foreach (IProjectContent projectContent in ParserService.AllProjectContents) {
+// LoggingService.Debug("Checking project content...");
+// Position pos = projectContent.GetPosition(fullMemberName);
+// if (pos != null && pos.Cu != null) {
+// LoggingService.Debug("Pos=" + pos.Line + ", " + pos.Column);
+// FileService.JumpToFilePosition(pos.Cu.FileName, Math.Max(0, pos.Line - 1), Math.Max(0, pos.Column - 1));
+// break;
+// }
+// }
+// }
+// }
+ }
+
static MessageViewCategory testRunnerCategory;
void OnTestsStarted(object sender, EventArgs e)
@@ -123,5 +217,62 @@ namespace ICSharpCode.MbUnitPad
StatusBarService.SetMessage("MbUnit: " + msg);
}
}
+
+ void TreeViewMouseDown(object sender, MouseEventArgs e)
+ {
+ TreeNode node = TypeTree.GetNodeAt(e.X, e.Y);
+
+ TypeTree.SelectedNode = node;
+
+ internalState = TestTreeViewState.Nothing;
+ if (IsSourceCodeItemSelected) {
+ internalState |= TestTreeViewState.SourceCodeItemSelected;
+ }
+
+ if (IsTestItemSelected) {
+ internalState |= TestTreeViewState.TestItemSelected;
+ }
+ }
+
+ bool IsSourceCodeItemSelected {
+ get {
+ UnitTreeNode node = TypeTree.SelectedNode as UnitTreeNode;
+ if (node != null) {
+ return (node.TestNodeType == TestNodeType.Test) || (node.TestNodeType == TestNodeType.Fixture);
+ }
+ return false;
+ }
+ }
+
+ bool IsTestItemSelected {
+ get {
+ UnitTreeNode node = TypeTree.SelectedNode as UnitTreeNode;
+ return node != null;
+ }
+ }
+
+// TreeTestDomain FindTestDomain(Guid id)
+// {
+// foreach (TreeTestDomain d in TestDomains) {
+// if (d.Identifier == id) {
+// return d;
+// }
+// }
+// return null;
+// }
+//
+// Fixture FindFixture(Guid testDomainId, string name)
+// {
+// TestDomain testDomain = FindTestDomain(testDomainId);
+// if (testDomain != null) {
+// FixtureDependencyGraph graph = testDomain.TestEngine.Explorer.FixtureGraph;
+// foreach (Fixture fixture in graph.Fixtures) {
+// if (fixture.Name == name) {
+// return fixture;
+// }
+// }
+// }
+// return null;
+// }
}
}