Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.1@2312 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
5 changed files with 104 additions and 4 deletions
@ -0,0 +1,54 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Windows.Forms; |
||||||
|
using ICSharpCode.SharpDevelop.Gui; |
||||||
|
using ICSharpCode.UnitTesting; |
||||||
|
using NUnit.Framework; |
||||||
|
using UnitTesting.Tests.Utils; |
||||||
|
|
||||||
|
namespace UnitTesting.Tests.Tree |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Tests that the TestTreeNode's ContextMenuStrip is set so
|
||||||
|
/// that if the user uses the shortcut Shift+F10 the menu appears
|
||||||
|
/// at the node rather than in the middle of the Unit Tests window.
|
||||||
|
/// </summary>
|
||||||
|
[TestFixture] |
||||||
|
public class TreeNodeContextMenuTestFixture |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Tests that the context menu strip for the tree node is
|
||||||
|
/// the same as that used with the tree view.
|
||||||
|
/// </summary>
|
||||||
|
[Test] |
||||||
|
public void TreeNodeContextMenuMatches() |
||||||
|
{ |
||||||
|
using (DerivedTestTreeView treeView = new DerivedTestTreeView()) { |
||||||
|
ContextMenuStrip menuStrip = new ContextMenuStrip(); |
||||||
|
treeView.ContextMenuStrip = menuStrip; |
||||||
|
|
||||||
|
// Add a root node to the tree.
|
||||||
|
TestProject project = new TestProject(new MockCSharpProject(), new MockProjectContent()); |
||||||
|
TestProjectTreeNode node = new TestProjectTreeNode(project); |
||||||
|
node.AddTo(treeView); |
||||||
|
|
||||||
|
// Select the tree node.
|
||||||
|
treeView.SelectedNode = node; |
||||||
|
|
||||||
|
// Call the treeView's OnBeforeSelect so the context menu
|
||||||
|
// is connected to the tree node.
|
||||||
|
treeView.CallOnBeforeSelect(new TreeViewCancelEventArgs(node, false, TreeViewAction.ByMouse)); |
||||||
|
|
||||||
|
// Context menu strip on tree node should match
|
||||||
|
// the tree view's context menu strip.
|
||||||
|
Assert.IsTrue(Object.ReferenceEquals(menuStrip, node.ContextMenuStrip)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,28 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Windows.Forms; |
||||||
|
using ICSharpCode.UnitTesting; |
||||||
|
|
||||||
|
namespace UnitTesting.Tests.Utils |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Derives from the TestTreeView class and allows us to directly
|
||||||
|
/// call the OnBeforeSelect method.
|
||||||
|
/// </summary>
|
||||||
|
public class DerivedTestTreeView : TestTreeView |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Calls the base class's OnBeforeSelect method.
|
||||||
|
/// </summary>
|
||||||
|
public void CallOnBeforeSelect(TreeViewCancelEventArgs e) |
||||||
|
{ |
||||||
|
base.OnBeforeSelect(e); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue