提交 129df995 编写于 作者: T Tanner Gooding

Responding to PR feedback.

上级 a7dc3b60
......@@ -52,7 +52,7 @@ public async Task BracesInsertionAndTabCompleting()
Assert.Equal(" if (true) { ", _editorWindow.CurrentLineTextBeforeCursor);
Assert.Equal("}", _editorWindow.CurrentLineTextAfterCursor);
await _editorWindow.TypeTextAsync("\t");
await _editorWindow.TypeTextAsync($"{EditorWindow.TAB}");
Assert.Equal(" if (true) { }", _editorWindow.CurrentLineTextBeforeCursor);
Assert.Equal(string.Empty, _editorWindow.CurrentLineTextAfterCursor);
......@@ -88,7 +88,8 @@ public async Task BracesOnReturnNoFormattingOnlyIndentationBeforeCloseBrace()
_editorWindow.PlaceCursor("// Marker");
await _editorWindow.TypeTextAsync("if (true) {");
await _editorWindow.TypeTextAsync("\nvar a = 1;");
await _editorWindow.TypeTextAsync($"{EditorWindow.ENTER}");
await _editorWindow.TypeTextAsync("var a = 1;");
Assert.Equal(" var a = 1;", _editorWindow.CurrentLineTextBeforeCursor);
Assert.Equal(string.Empty, _editorWindow.CurrentLineTextAfterCursor);
......@@ -106,7 +107,8 @@ public async Task BracesOnReturnOvertypingTheClosingBrace()
_editorWindow.PlaceCursor("// Marker");
await _editorWindow.TypeTextAsync("if (true) {");
await _editorWindow.TypeTextAsync("\nvar a = 1;}");
await _editorWindow.TypeTextAsync($"{EditorWindow.ENTER}");
await _editorWindow.TypeTextAsync("var a = 1;}");
Assert.Equal(" }", _editorWindow.CurrentLineTextBeforeCursor);
Assert.Equal(string.Empty, _editorWindow.CurrentLineTextAfterCursor);
......@@ -123,7 +125,9 @@ public async Task BracesOnReturnOvertypingTheClosingBrace()
public async Task BracesOnReturnWithNonWhitespaceSpanInside()
{
_editorWindow.Text = string.Empty;
await _editorWindow.TypeTextAsync("class A { int i;\n");
await _editorWindow.TypeTextAsync("class A { int i;");
await _editorWindow.TypeTextAsync($"{EditorWindow.ENTER}");
Assert.Equal(string.Empty, _editorWindow.CurrentLineTextBeforeCursor);
Assert.Equal("}", _editorWindow.CurrentLineTextAfterCursor);
......@@ -146,7 +150,8 @@ public async Task ParenInsertionAndTabCompleting()
Assert.Equal(" void Foo(", _editorWindow.CurrentLineTextBeforeCursor);
Assert.Equal(")", _editorWindow.CurrentLineTextAfterCursor);
await _editorWindow.TypeTextAsync("int x\t");
await _editorWindow.TypeTextAsync("int x");
await _editorWindow.TypeTextAsync($"{EditorWindow.TAB}");
Assert.Equal(" void Foo(int x)", _editorWindow.CurrentLineTextBeforeCursor);
Assert.Equal(string.Empty, _editorWindow.CurrentLineTextAfterCursor);
......@@ -162,7 +167,7 @@ public async Task ParenOvertyping()
_editorWindow.PlaceCursor("// Marker");
await _editorWindow.TypeTextAsync("void Foo(");
await _editorWindow.TypeTextAsync("\u001B"); // ESC
await _editorWindow.TypeTextAsync($"{EditorWindow.ESC}");
await _editorWindow.TypeTextAsync(")");
Assert.Equal(" void Foo()", _editorWindow.CurrentLineTextBeforeCursor);
......
......@@ -44,7 +44,7 @@ public static bool BlockInput()
{
var hresult = Marshal.GetHRForLastWin32Error();
if (hresult == -2147024891) // E_ACCESS_DENIED
if (hresult == VSConstants.E_ACCESSDENIED)
{
Debug.WriteLine("Input cannot be blocked because the system requires Administrative privileges.");
}
......@@ -140,7 +140,7 @@ public static object GetRegistryKeyValue(RegistryKey baseKey, string subKeyName,
{
if (registryKey == null)
{
throw new Exception($"The specified registry key could not be found. Registry Key: '{registryKey}'");
throw new Exception($@"The specified registry key could not be found. Registry Key: '{baseKey}\{subKeyName}'");
}
return registryKey.GetValue(valueName);
......
......@@ -7,7 +7,6 @@ namespace Roslyn.VisualStudio.Test.Utilities.Interop
internal static class Kernel32
{
[DllImport("Kernel32.dll", CallingConvention = CallingConvention.Winapi, EntryPoint = "GetCurrentThreadId", PreserveSig = true, SetLastError = false)]
public static extern uint GetCurrentThreadId(
);
public static extern uint GetCurrentThreadId();
}
}
......@@ -12,6 +12,52 @@ namespace Roslyn.VisualStudio.Test.Utilities
/// <summary>Provides a means of interacting with the active editor window in the Visual Studio host.</summary>
public class EditorWindow
{
public const char ENTER = '\u000D';
public const char TAB = '\u0009';
public const char ESC = '\u001B';
public const char ESCAPE = '\u001B';
public const char HOME = '\u0024';
public const char END = '\u0023';
public const char LEFT = '\u0025';
public const char RIGHT = '\u0027';
public const char UP = '\u0026';
public const char DOWN = '\u0028';
public const char PGUP = '\u0021';
public const char PGDN = '\u0022';
public const char NUMLOCK = '\u0090';
public const char SCROLLLOCK = '\u0091';
public const char PRTSC = '\u002C';
public const char BREAK = '\u0003';
public const char BACKSPACE = '\u0008';
public const char BKSP = '\u0008';
public const char BS = '\u0008';
public const char CLEAR = '\u000C';
public const char CAPSLOCK = '\u0014';
public const char INSERT = '\u002D';
public const char DEL = '\u002E';
public const char DELETE = '\u002E';
public const char HELP = '\u002F';
public const char F1 = '\u0070';
public const char F2 = '\u0071';
public const char F3 = '\u0072';
public const char F4 = '\u0073';
public const char F5 = '\u0074';
public const char F6 = '\u0075';
public const char F7 = '\u0076';
public const char F8 = '\u0077';
public const char F9 = '\u0078';
public const char F10 = '\u0079';
public const char F11 = '\u007A';
public const char F12 = '\u007B';
public const char F13 = '\u007C';
public const char F14 = '\u007D';
public const char F15 = '\u007E';
public const char F16 = '\u007F';
public const char MULTIPLY = '\u006A';
public const char ADD = '\u006B';
public const char SUBTRACT = '\u006D';
public const char DIVIDE = '\u006F';
private readonly VisualStudioInstance _visualStudioInstance;
private readonly EditorWindowWrapper _editorWindowWrapper;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册