Exemplo n.º 1
0
 public void Dispose()
 {
     try
     {
         _synchronizationContext.RunAll();
     }
     finally
     {
         _synchronizationContext.Dispose();
     }
 }
Exemplo n.º 2
0
        private void EnterMode(SnapshotSpan span)
        {
            var characterSpan   = CharacterSpan.CreateForSpan(span);
            var visualSelection = VisualSelection.NewCharacter(characterSpan, true);

            CommonUtil.SelectAndUpdateCaret(_textView, visualSelection);
            Assert.IsFalse(_context.IsEmpty);
            _context.RunAll();
            Assert.IsTrue(_context.IsEmpty);
        }
Exemplo n.º 3
0
 public void CloseBeforePost()
 {
     RaiseTextViewCreated(_textView);
     RaiseVimBufferCreated(_vimBuffer);
     _textView.Close();
     TestableSynchronizationContext.RunAll();
 }
Exemplo n.º 4
0
        /// <summary>
        /// Run the given KeyInput against the Visual Studio simulation
        /// </summary>
        internal void Run(KeyInput keyInput)
        {
            _testableSynchronizationContext.Install();
            try
            {
                // Update the KeyModifiers while this is being processed by our key processor
                var keyModifiers = keyInput.KeyModifiers;

                // The KeyInput for an upper letter doesn't have a Shift modifier.  However the
                // keyboard state which produced the letter will likely have it (not sure about
                // caps lock).  Need to simulate that here
                if (Char.IsLetter(keyInput.Char) && Char.IsUpper(keyInput.Char))
                {
                    keyModifiers |= KeyModifiers.Shift;
                }

                _defaultKeyboardDevice.DownKeyModifiers = keyInput.KeyModifiers;

                if (!RunInOleCommandTarget(keyInput))
                {
                    RunInWpf(keyInput);
                }

                _testableSynchronizationContext.RunAll();
            }
            finally
            {
                _defaultKeyboardDevice.DownKeyModifiers = KeyModifiers.None;
                _testableSynchronizationContext.Uninstall();
            }
        }
Exemplo n.º 5
0
 public void Start5()
 {
     Create(VisualKind.Line, "foo", "bar");
     _context.RunAll();
     Assert.AreEqual(_view.TextBuffer.GetLineFromLineNumber(0).Start, _view.Selection.Start.Position);
     Assert.AreEqual(_view.TextBuffer.GetLineFromLineNumber(0).EndIncludingLineBreak, _view.Selection.End.Position);
 }
Exemplo n.º 6
0
        public void SelectionChanged3()
        {
            _buffer.SetupGet(x => x.IsProcessingInput).Returns(false).Verifiable();
            _buffer.SetupGet(x => x.ModeKind).Returns(ModeKind.Normal).Verifiable();
            _selection.SetupGet(x => x.IsEmpty).Returns(false).Verifiable();
            _selection.Raise(x => x.SelectionChanged += null, null, EventArgs.Empty);
            Assert.IsFalse(_context.IsEmpty);
            _factory.Verify();

            _buffer
            .Setup(x => x.SwitchMode(ModeKind.VisualCharacter, ModeArgument.None))
            .Returns(_factory.Create <IMode>().Object)
            .Verifiable();
            _context.RunAll();
            _factory.Verify();
        }
Exemplo n.º 7
0
 /// <summary>
 /// Run the given KeyInput against the Visual Studio simulation
 /// </summary>
 internal void Run(KeyInput keyInput)
 {
     using (var context = new TestableSynchronizationContext())
     {
         _vsKeyboardInputSimulation.Run(keyInput);
         context.RunAll();
     }
 }
Exemplo n.º 8
0
            public void TextViewOnlyNoVimRc()
            {
                VimRcState = VimRcState.LoadFailed;
                RaiseTextViewCreated(_textView);

                _synchronizer.Setup(x => x.StartSynchronizing(_vimBuffer, SettingSyncSource.Editor)).Verifiable();
                TestableSynchronizationContext.RunAll();
                Dispatcher.CurrentDispatcher.DoEvents();
                _synchronizer.Verify();
            }
Exemplo n.º 9
0
            public void TextViewOnlyWithVimRcAndEditorDefaults()
            {
                VimRcState = VimRcState.NewLoadSucceeded(new VimRcPath(VimRcKind.VimRc, "test"), new string[] { });
                _vimApplicationSettings.SetupGet(x => x.UseEditorDefaults).Returns(true);
                RaiseTextViewCreated(_textView);

                _synchronizer.Setup(x => x.StartSynchronizing(_vimBuffer, SettingSyncSource.Editor)).Verifiable();
                TestableSynchronizationContext.RunAll();
                Dispatcher.CurrentDispatcher.DoEvents();
                _synchronizer.Verify();
            }
Exemplo n.º 10
0
 private void EnterMode(SnapshotSpan span, TextSelectionMode mode = TextSelectionMode.Stream)
 {
     _textView.SelectAndUpdateCaret(span, mode);
     Assert.IsFalse(_context.IsEmpty);
     _context.RunAll();
     Assert.IsTrue(_context.IsEmpty);
 }
Exemplo n.º 11
0
            public void BothViewsUseEditor()
            {
                _vimApplicationSettings.SetupGet(x => x.UseEditorDefaults).Returns(true);
                SetupVsTextView();
                RaiseTextViewCreated(_textView);
                RaiseVimBufferCreated(_vimBuffer);

                _synchronizer.Setup(x => x.StartSynchronizing(_vimBuffer, SettingSyncSource.Editor)).Verifiable();
                RaiseVsTextViewCreated(_vsTextView.Object);
                _synchronizer.Verify();
                InvalidateSynchronizer();
                TestableSynchronizationContext.RunAll();
            }
Exemplo n.º 12
0
 /// <summary>
 /// Run the given KeyInput against the Visual Studio simulation
 /// </summary>
 internal void Run(KeyInput keyInput)
 {
     _testableSynchronizationContext.Install();
     try
     {
         _vsKeyProcessorSimulation.Run(keyInput);
         _testableSynchronizationContext.RunAll();
     }
     finally
     {
         _testableSynchronizationContext.Uninstall();
     }
 }
Exemplo n.º 13
0
            public void BothViewsWithVimRcAndEditorDefaults()
            {
                VimRcState = VimRcState.NewLoadSucceeded(new VimRcPath(VimRcKind.VimRc, "test"), new string[] { });
                _vimApplicationSettings.SetupGet(x => x.UseEditorDefaults).Returns(true);
                SetupVsTextView();
                RaiseTextViewCreated(_textView);
                RaiseVimBufferCreated(_vimBuffer);

                _synchronizer.Setup(x => x.StartSynchronizing(_vimBuffer, SettingSyncSource.Editor)).Verifiable();
                RaiseVsTextViewCreated(_vsTextView.Object);
                _synchronizer.Verify();
                InvalidateSynchronizer();
                TestableSynchronizationContext.RunAll();
            }
Exemplo n.º 14
0
        private List <ITagSpan <TextMarkerTag> > GetTagsFull(SnapshotSpan span, out bool wasAsync)
        {
            Assert.IsTrue(_asyncTagger.AsyncBackgroundRequest.IsNone());
            wasAsync = false;
            var tags = _asyncTagger.GetTags(new NormalizedSnapshotSpanCollection(span)).ToList();

            if (_asyncTagger.AsyncBackgroundRequest.IsSome())
            {
                _asyncTagger.AsyncBackgroundRequest.Value.Task.Wait();
                _synchronizationContext.RunAll();
                tags     = _asyncTagger.GetTags(new NormalizedSnapshotSpanCollection(span)).ToList();
                wasAsync = true;
            }

            return(tags);
        }
Exemplo n.º 15
0
        internal void RunExec(EditCommand editCommand)
        {
            var oleCommandData = OleCommandData.Empty;

            try
            {
                Assert.True(OleCommandUtil.TryConvert(editCommand, out oleCommandData));
                _target.Exec(oleCommandData);
            }
            finally
            {
                oleCommandData.Dispose();
            }

            TestableSynchronizationContext.RunAll();
        }
Exemplo n.º 16
0
 public void Dispose()
 {
     _synchronizationContext.RunAll();
     _synchronizationContext.Uninstall();
 }
Exemplo n.º 17
0
 public override void Dispose()
 {
     base.Dispose();
     _synchronizationContext.RunAll();
     _synchronizationContext.Uninstall();
 }