protected void Create(params string[] lines) { _vimBuffer = CreateVimBuffer(lines); _textView = _vimBuffer.TextView; _textBuffer = _vimBuffer.TextBuffer; _globalSettings = _vimBuffer.GlobalSettings; _globalSettings.SelectModeOptions = SelectModeOptions.Mouse | SelectModeOptions.Keyboard; _textSelection = _textView.Selection; _context = new TestableSynchronizationContext(); _context.Install(); }
public void Create(params string[] lines) { _context = new TestableSynchronizationContext(); SynchronizationContext.SetSynchronizationContext(_context); _textView = CreateTextView(lines); _textBuffer = _textView.TextBuffer; _vimBuffer = Vim.CreateVimBuffer(_textView); _vimBuffer.SwitchMode(ModeKind.Normal, ModeArgument.None); _vimTextBuffer = _vimBuffer.VimTextBuffer; _registerMap = _vimBuffer.RegisterMap; _globalSettings = _vimBuffer.LocalSettings.GlobalSettings; Assert.IsTrue(_context.IsEmpty); // Need to make sure it's focused so macro recording will work ((MockVimHost)_vimBuffer.Vim.VimHost).FocusedTextView = _textView; }
public void Setup() { _factory = new MockRepository(MockBehavior.Loose); _selection = _factory.Create<ITextSelection>(); _textView = MockObjectFactory.CreateTextView( selection: _selection.Object, factory: _factory); _vimBuffer = MockObjectFactory.CreateVimBuffer( textView: _textView.Object, factory: _factory); _selectionOverride = _factory.Create<IVisualModeSelectionOverride>(); _selectionOverride.Setup(x => x.IsInsertModePreferred(It.IsAny<ITextView>())).Returns(false); var selectionList = new List<IVisualModeSelectionOverride>(); selectionList.Add(_selectionOverride.Object); _context = new TestableSynchronizationContext(); _context.Install(); _tracker = new SelectionChangeTracker(_vimBuffer.Object, selectionList.ToFSharpList()); }
public void SetUp() { _before = SynchronizationContext.Current; _context = new TestableSynchronizationContext(); SynchronizationContext.SetSynchronizationContext(_context); }
public void Setup() { _factory = new MockRepository(MockBehavior.Loose); _selection = _factory.Create<ITextSelection>(); _textView = MockObjectFactory.CreateTextView( selection: _selection.Object, factory: _factory); _buffer = MockObjectFactory.CreateVimBuffer( textView: _textView.Object, factory: _factory); _context = new TestableSynchronizationContext(); SynchronizationContext.SetSynchronizationContext(_context); _tracker = new SelectionChangeTracker(_buffer.Object); }
internal VsSimulation(IVimBufferCoordinator bufferCoordinator, bool simulateResharper, bool simulateStandardKeyMappings, IEditorOperationsFactoryService editorOperationsFactoryService) { _wpfTextView = (IWpfTextView)bufferCoordinator.VimBuffer.TextView; _factory = new MockRepository(MockBehavior.Strict); _defaultKeyboardDevice = new DefaultKeyboardDevice(InputManager.Current); _testableSynchronizationContext = new TestableSynchronizationContext(); // Create the IVsAdapter and pick reasonable defaults here. Consumers can modify // this via an exposed property _vsAdapter = _factory.Create<IVsAdapter>(); _vsAdapter.SetupGet(x => x.InAutomationFunction).Returns(false); _vsAdapter.SetupGet(x => x.KeyboardDevice).Returns(_defaultKeyboardDevice); _vsAdapter.Setup(x => x.IsReadOnly(It.IsAny<ITextBuffer>())).Returns(false); _vsAdapter.Setup(x => x.IsIncrementalSearchActive(_wpfTextView)).Returns(false); _resharperUtil = _factory.Create<IResharperUtil>(); _resharperUtil.SetupGet(x => x.IsInstalled).Returns(simulateResharper); _displayWindowBroker = _factory.Create<IDisplayWindowBroker>(); _displayWindowBroker.SetupGet(x => x.IsCompletionActive).Returns(false); _displayWindowBroker.SetupGet(x => x.IsQuickInfoActive).Returns(false); _displayWindowBroker.SetupGet(x => x.IsSignatureHelpActive).Returns(false); _displayWindowBroker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false); _defaultCommandTarget = new DefaultCommandTarget( bufferCoordinator.VimBuffer.TextView, editorOperationsFactoryService.GetEditorOperations(bufferCoordinator.VimBuffer.TextView)); // Visual Studio hides the default IOleCommandTarget inside of the IWpfTextView property // bag. The default KeyProcessor implementation looks here for IOleCommandTarget to // process text input _wpfTextView.Properties[typeof(IOleCommandTarget)] = _defaultCommandTarget; // Create the VsCommandTarget. It's next is the final and default Visual Studio // command target var vsTextView = _factory.Create<IVsTextView>(); IOleCommandTarget nextCommandTarget = _defaultCommandTarget; vsTextView.Setup(x => x.AddCommandFilter(It.IsAny<IOleCommandTarget>(), out nextCommandTarget)).Returns(VSConstants.S_OK); var vsCommandTarget = VsCommandTarget.Create( bufferCoordinator, vsTextView.Object, _vsAdapter.Object, _displayWindowBroker.Object, _resharperUtil.Object).Value; // Time to setup the start command target. If we are simulating R# then put them ahead of VsVim // on the IOleCommandTarget chain. VsVim doesn't try to fight R# and prefers instead to be // behind them if (simulateResharper) { var resharperCommandTarget = new ResharperCommandTarget(_wpfTextView, vsCommandTarget); _commandTarget = resharperCommandTarget; } else { _commandTarget = vsCommandTarget; } // Create the input controller. Make sure that the VsVim one is ahead in the list // from the default Visual Studio one. We can guarantee this is true due to MEF // ordering of the components var keyProcessors = new List<Microsoft.VisualStudio.Text.Editor.KeyProcessor>(); keyProcessors.Add(new VsKeyProcessor(_vsAdapter.Object, bufferCoordinator)); keyProcessors.Add(new SimulationKeyProcessor(bufferCoordinator.VimBuffer.TextView)); _defaultInputController = new DefaultInputController(bufferCoordinator.VimBuffer.TextView, keyProcessors); }
public EditorHostTest() { _editorHost = GetOrCreateEditorHost(); _synchronizationContext = new TestableSynchronizationContext(); _synchronizationContext.Install(); }