Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed the bug where VsVim interferred with user automation functions
- Loading branch information
Showing
4 changed files
with
88 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using NUnit.Framework; | ||
using Vim; | ||
using Moq; | ||
using Microsoft.VisualStudio.TextManager.Interop; | ||
using Microsoft.VisualStudio; | ||
using VsVim; | ||
using EnvDTE; | ||
|
||
namespace VsVimTest | ||
{ | ||
[TestFixture] | ||
public class VsCommandFilterTest | ||
{ | ||
private Mock<IVimBuffer> _buffer; | ||
private Mock<IVsTextView> _textView; | ||
private Mock<IServiceProvider> _serviceProvider; | ||
private Mock<IVsExtensibility> _vsExt; | ||
private VsCommandFilter _filter; | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
_buffer = new Mock<IVimBuffer>(); | ||
_textView = new Mock<IVsTextView>(); | ||
_vsExt = new Mock<IVsExtensibility>(MockBehavior.Strict); | ||
_vsExt.Setup(x => x.IsInAutomationFunction()).Returns(0); | ||
_serviceProvider = MockObjectFactory.CreateServiceProvider(Tuple.Create(typeof(IVsExtensibility), (object)_vsExt.Object)); | ||
_filter = new VsCommandFilter(_buffer.Object, _textView.Object, _serviceProvider.Object); | ||
} | ||
|
||
private void AssertCannotConvert2K(VSConstants.VSStd2KCmdID id) | ||
{ | ||
KeyInput ki; | ||
Assert.IsFalse(_filter.TryConvert(VSConstants.VSStd2K, (uint)id, IntPtr.Zero, out ki)); | ||
} | ||
|
||
private void AssertCanConvert2K(VSConstants.VSStd2KCmdID id, KeyInput expected) | ||
{ | ||
KeyInput ki; | ||
Assert.IsTrue(_filter.TryConvert(VSConstants.VSStd2K, (uint)id, IntPtr.Zero, out ki)); | ||
Assert.AreEqual(expected,ki); | ||
} | ||
|
||
[Test] | ||
public void TryConvert1() | ||
{ | ||
_buffer.Setup(x => x.CanProcessInput(It.IsAny<KeyInput>())).Returns(true); | ||
AssertCanConvert2K(VSConstants.VSStd2KCmdID.TAB, InputUtil.VimKeyToKeyInput(VimKey.TabKey)); | ||
} | ||
|
||
[Test] | ||
public void TryConvert2() | ||
{ | ||
_buffer.Setup(x => x.CanProcessInput(It.IsAny<KeyInput>())).Returns(false); | ||
AssertCannotConvert2K(VSConstants.VSStd2KCmdID.TAB); | ||
} | ||
|
||
[Test, Description("Don't convert keys when in automation")] | ||
public void TryConvert3() | ||
{ | ||
_vsExt.Setup(x => x.IsInAutomationFunction()).Returns(1); | ||
_buffer.Setup(x => x.CanProcessInput(It.IsAny<KeyInput>())).Returns(true); | ||
AssertCannotConvert2K(VSConstants.VSStd2KCmdID.TAB); | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters