Skip to content

Commit 6ba2032

Browse files
committed
Yield UI thread between editor commands in tests
1 parent 9212bb7 commit 6ba2032

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

MonoDevelop.MSBuild.Tests.Editor/Completion/MSBuildCommitTests.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
// Copyright (c) Microsoft. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4-
using System;
54
using System.Threading.Tasks;
65

7-
using Microsoft.VisualStudio.Text.Editor.Commanding;
8-
using MonoDevelop.MSBuild.Editor.Completion;
9-
106
using MonoDevelop.Xml.Editor.Tests.Extensions;
117

128
using NUnit.Framework;
@@ -24,7 +20,7 @@ async Task TestTypeCommands (string filename, string before, string typeChars, s
2420
await this.TestCommands (
2521
before,
2622
after,
27-
[ (s) => s.Type (typeChars) ],
23+
EditorAction.Type (typeChars),
2824
filename: filename,
2925
initialize: (tv) => {
3026
tv.Options.SetOptionValue ("BraceCompletion/Enabled", true);

MonoDevelop.MSBuild.Tests.Editor/Refactorings/MSBuildEditorTestExtensions.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,13 @@ public static async Task TestCodeActionContext (
224224
// the refactoring may have left multiple selections sp the user can e.g. type a new name for an extracted property
225225
await test.Catalog.JoinableTaskContext.Factory.SwitchToMainThreadAsync (default);
226226
var commandService = test.Catalog.CommandServiceFactory.GetService (ctx.TextView);
227-
commandService.Type (typeText);
227+
228+
foreach(var editorAction in EditorAction.Type (typeText)) {
229+
editorAction (commandService);
230+
// yield to let things catch up
231+
// and so we don't block the UI thread between the commands
232+
await Task.Delay (20);
233+
}
228234

229235
Assert.That (
230236
ctx.TextBuffer.CurrentSnapshot.GetText (),

0 commit comments

Comments
 (0)