Browse Source

Added 'Stop tests' toolbar button and context menus to the MbUnit pad. Go to definition context menu command is not currently working.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@499 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 20 years ago
parent
commit
befee650b3
  1. 90
      src/AddIns/Misc/MbUnitPad/Project/MbUnitPad.addin
  2. 1
      src/AddIns/Misc/MbUnitPad/Project/MbUnitPad.csproj
  3. 88
      src/AddIns/Misc/MbUnitPad/Project/Src/MbUnitCommands.cs
  4. 38
      src/AddIns/Misc/MbUnitPad/Project/Src/MbUnitPad.cs
  5. 27
      src/AddIns/Misc/MbUnitPad/Project/Src/MbUnitRunningTestsCondition.cs
  6. 153
      src/AddIns/Misc/MbUnitPad/Project/Src/TestTreeView.cs

90
src/AddIns/Misc/MbUnitPad/Project/MbUnitPad.addin

@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
<Import assembly = "../../../../bin/Tools/MbUnit/MbUnit.GUI.exe"/>
<Import assembly = "MbUnitPad.dll">
<ConditionEvaluator name = "MbUnitTestable" class = "ICSharpCode.MbUnitPad.MbUnitTestableCondition"/>
<ConditionEvaluator name = "MbUnitRunningTests" class = "ICSharpCode.MbUnitPad.MbUnitRunningTestsCondition"/>
</Import>
</Runtime>
@ -80,13 +81,94 @@ @@ -80,13 +81,94 @@
tooltip = "${res:NUnitPad.NUnitPadContent.ReferenceItem}"
class = "ICSharpCode.MbUnitPad.AddNUnitReferenceCommand"/>
<ToolbarItem id = "Separator2" type = "Separator"/>
<ToolbarItem id = "Run"
icon = "Icons.16x16.RunProgramIcon"
tooltip = "${res:NUnitPad.NUnitPadContent.RunItem}"
class = "ICSharpCode.MbUnitPad.RunTestsCommand"/>
</Condition>
<ComplexCondition action="Disable">
<And>
<Condition name="CombineOpen" iscombineopen="True"/>
<Not>
<Condition name="MbUnitRunningTests"/>
</Not>
</And>
<ToolbarItem id = "Run"
icon = "Icons.16x16.RunProgramIcon"
tooltip = "${res:NUnitPad.NUnitPadContent.RunItem}"
class = "ICSharpCode.MbUnitPad.RunTestsCommand"/>
</ComplexCondition>
<ComplexCondition action="Disable">
<And>
<Condition name="CombineOpen" iscombineopen="True"/>
<Condition name="MbUnitRunningTests"/>
</And>
<ToolbarItem id = "Stop"
icon = "Icons.16x16.Debug.StopProcess"
tooltip = "Stop tests"
class = "ICSharpCode.MbUnitPad.StopTestsCommand"/>
</ComplexCondition>
</Path>
<Path name = "/SharpDevelop/Pads/MbUnitPad/ContextMenu">
<ComplexCondition action="Disable">
<And>
<Condition name="Ownerstate" ownerstate="TestItemSelected"/>
<Not>
<Condition name="MbUnitRunningTests"/>
</Not>
</And>
<MenuItem id = "Run"
icon = "Icons.16x16.RunProgramIcon"
label = "${res:NUnitPad.NUnitPadContent.RunTestsContextMenuLabel}"
class = "ICSharpCode.MbUnitPad.RunTestsCommand"/>
</ComplexCondition>
<ComplexCondition action="Disable">
<And>
<Condition name="Ownerstate" ownerstate="TestItemSelected"/>
<Condition name="MbUnitRunningTests"/>
</And>
<MenuItem id = "Stop"
icon = "Icons.16x16.Debug.StopProcess"
label = "Stop tests"
class = "ICSharpCode.MbUnitPad.StopTestsCommand"/>
</ComplexCondition>
<Condition name="Ownerstate" ownerstate="SourceCodeItemSelected" action="Disable">
<MenuItem id = "GotoDefinition"
label = "${res:NUnitPad.NUnitPadContent.GotoDefinitionContextMenuLabel}"
class = "ICSharpCode.MbUnitPad.GotoDefinitionCommand"/>
</Condition>
<MenuItem id="Tree"
label="Tree"
type="Menu">
<MenuItem id = "ExpandAll"
label = "Expand all"
class = "ICSharpCode.MbUnitPad.ExpandAllCommand"/>
<MenuItem id = "CollapseAll"
label = "Collapse all"
class = "ICSharpCode.MbUnitPad.CollapseAllCommand"/>
<MenuItem id="Separator1" type = "Separator"/>
<MenuItem id = "ExpandCurrent"
label = "Expand current"
class = "ICSharpCode.MbUnitPad.ExpandCurrentCommand"/>
<MenuItem id = "CollapseCurrent"
label = "Collapse current"
class = "ICSharpCode.MbUnitPad.CollapseCurrentCommand"/>
<MenuItem id="Separator2" type = "Separator"/>
<MenuItem id = "ExpandAllFailures"
label = "Expand all failures"
class = "ICSharpCode.MbUnitPad.ExpandAllFailuresCommand"/>
<MenuItem id = "ExpandCurrentFailures"
label = "Expand current failures"
class = "ICSharpCode.MbUnitPad.ExpandCurrentFailuresCommand"/>
<MenuItem id="Separator3" type = "Separator"/>
<MenuItem id = "ExpandAllIgnored"
label = "Expand all ignored"
class = "ICSharpCode.MbUnitPad.ExpandAllIgnoredCommand"/>
<MenuItem id = "ExpandCurrentIgnored"
label = "Expand current ignored"
class = "ICSharpCode.MbUnitPad.ExpandCurrentIgnoredCommand"/>
<MenuItem id="Separator4" type = "Separator"/>
<MenuItem id = "ClearResults"
label = "Clear results"
class = "ICSharpCode.MbUnitPad.ClearResultsCommand"/>
</MenuItem>
</Path>
</AddIn>

1
src/AddIns/Misc/MbUnitPad/Project/MbUnitPad.csproj

@ -46,6 +46,7 @@ @@ -46,6 +46,7 @@
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Src\MbUnitTestableCondition.cs" />
<Compile Include="Src\MbUnitRunningTestsCondition.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">

88
src/AddIns/Misc/MbUnitPad/Project/Src/MbUnitCommands.cs

@ -41,6 +41,14 @@ namespace ICSharpCode.MbUnitPad @@ -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 @@ -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();
}
}
}

38
src/AddIns/Misc/MbUnitPad/Project/Src/MbUnitPad.cs

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
// </file>
using System;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
using ICSharpCode.Core;
@ -33,6 +34,7 @@ namespace ICSharpCode.MbUnitPad @@ -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 @@ -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 @@ -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 @@ -147,7 +175,11 @@ namespace ICSharpCode.MbUnitPad
/// </summary>
public override void RedrawContent()
{
}
void UpdateToolbar()
{
ToolbarService.UpdateToolbar(toolStrip);
}
}
}

27
src/AddIns/Misc/MbUnitPad/Project/Src/MbUnitRunningTestsCondition.cs

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.Core;
using System;
namespace ICSharpCode.MbUnitPad
{
/// <summary>
/// Determines whether #develop is currently running MbUnit tests.
/// </summary>
public class MbUnitRunningTestsCondition : IConditionEvaluator
{
public bool IsValid(object caller, Condition condition)
{
MbUnitPadContent pad = caller as MbUnitPadContent;
if (pad != null) {
return pad.IsRunningTests;
}
return false;
}
}
}

153
src/AddIns/Misc/MbUnitPad/Project/Src/TestTreeView.cs

@ -14,19 +14,37 @@ using ICSharpCode.Core; @@ -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 @@ -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 @@ -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;
// }
}
}

Loading…
Cancel
Save