forked from dotnet/roslyn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port immediate window tests to the new framework
Closes dotnet#25814
- Loading branch information
Showing
10 changed files
with
197 additions
and
174 deletions.
There are no files selected for viewing
61 changes: 0 additions & 61 deletions
61
src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpImmediate.cs
This file was deleted.
Oops, something went wrong.
58 changes: 0 additions & 58 deletions
58
src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicImmediate.cs
This file was deleted.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
src/VisualStudio/IntegrationTest/New.IntegrationTests/CSharp/CSharpImmediate.cs
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,57 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Threading.Tasks; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.Shared.TestHooks; | ||
using Microsoft.VisualStudio.IntegrationTest.Utilities; | ||
using Roslyn.VisualStudio.IntegrationTests; | ||
using WindowsInput.Native; | ||
using Xunit; | ||
|
||
namespace Roslyn.VisualStudio.NewIntegrationTests.CSharp | ||
{ | ||
public class CSharpImmediate : AbstractEditorTest | ||
{ | ||
protected override string LanguageName => LanguageNames.CSharp; | ||
|
||
public CSharpImmediate() | ||
: base() | ||
{ | ||
} | ||
|
||
public override async Task InitializeAsync() | ||
{ | ||
await base.InitializeAsync(); | ||
|
||
await TestServices.SolutionExplorer.CreateSolutionAsync(nameof(CSharpImmediate), HangMitigatingCancellationToken); | ||
await TestServices.SolutionExplorer.AddProjectAsync("TestProj", WellKnownProjectTemplates.ConsoleApplication, LanguageNames.CSharp, HangMitigatingCancellationToken); | ||
} | ||
|
||
[IdeFact] | ||
public async Task DumpLocalVariableValue() | ||
{ | ||
await TestServices.Editor.SetTextAsync(@" | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
int n1Var = 42; | ||
int n2Var = 43; | ||
} | ||
} | ||
", HangMitigatingCancellationToken); | ||
|
||
await TestServices.Workspace.WaitForAsyncOperationsAsync(FeatureAttribute.Workspace, HangMitigatingCancellationToken); | ||
await TestServices.Debugger.SetBreakpointAsync("Program.cs", "}", HangMitigatingCancellationToken); | ||
await TestServices.Debugger.GoAsync(waitForBreakMode: true, HangMitigatingCancellationToken); | ||
await TestServices.ImmediateWindow.ShowAsync(HangMitigatingCancellationToken); | ||
await TestServices.ImmediateWindow.ClearAllAsync(HangMitigatingCancellationToken); | ||
await TestServices.Input.SendWithoutActivateAsync("?n", HangMitigatingCancellationToken); | ||
await TestServices.Workspace.WaitForAsyncOperationsAsync(FeatureAttribute.CompletionSet, HangMitigatingCancellationToken); | ||
await TestServices.Input.SendWithoutActivateAsync(["1", VirtualKeyCode.TAB, VirtualKeyCode.RETURN], HangMitigatingCancellationToken); | ||
Assert.Contains("?n1Var\r\n42", await TestServices.ImmediateWindow.GetTextAsync(HangMitigatingCancellationToken)); | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/DebuggerInProcess.cs
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,56 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.CodeAnalysis.Editor.Shared.Extensions; | ||
using Microsoft.VisualStudio.Extensibility.Testing; | ||
using Microsoft.VisualStudio.Shell.Interop; | ||
|
||
namespace Roslyn.VisualStudio.NewIntegrationTests.InProcess | ||
{ | ||
[TestService] | ||
internal partial class DebuggerInProcess | ||
{ | ||
private async Task<EnvDTE100.Debugger5> GetDebuggerAsync(CancellationToken cancellationToken) | ||
{ | ||
await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); | ||
|
||
var dte = await GetRequiredGlobalServiceAsync<SDTE, EnvDTE.DTE>(cancellationToken); | ||
return (EnvDTE100.Debugger5)dte.Debugger; | ||
} | ||
|
||
public Task SetBreakpointAsync(string fileName, string text, CancellationToken cancellationToken) | ||
=> SetBreakpointAsync(fileName, text, charsOffset: 0, cancellationToken); | ||
|
||
public async Task SetBreakpointAsync(string fileName, string text, int charsOffset, CancellationToken cancellationToken) | ||
{ | ||
await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); | ||
|
||
await TestServices.Editor.ActivateAsync(cancellationToken); | ||
await TestServices.Editor.SelectTextInCurrentDocumentAsync(text, cancellationToken); | ||
|
||
var caretPosition = await TestServices.Editor.GetCaretPositionAsync(cancellationToken); | ||
caretPosition.BufferPosition.GetLineAndCharacter(out var lineNumber, out var characterIndex); | ||
await SetBreakpointAsync(fileName, lineNumber, characterIndex + charsOffset, cancellationToken); | ||
} | ||
|
||
public async Task SetBreakpointAsync(string fileName, int lineNumber, int characterIndex, CancellationToken cancellationToken) | ||
{ | ||
await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); | ||
|
||
var debugger = await GetDebuggerAsync(cancellationToken); | ||
// Need to increment the line number because editor line numbers starts from 0 but the debugger ones starts from 1. | ||
debugger.Breakpoints.Add(File: fileName, Line: lineNumber + 1, Column: characterIndex); | ||
} | ||
|
||
public async Task GoAsync(bool waitForBreakMode, CancellationToken cancellationToken) | ||
{ | ||
await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); | ||
|
||
var debugger = await GetDebuggerAsync(cancellationToken); | ||
debugger.Go(waitForBreakMode); | ||
} | ||
} | ||
} |
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
55 changes: 55 additions & 0 deletions
55
src/VisualStudio/IntegrationTest/New.IntegrationTests/VisualBasic/BasicImmediate.cs
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,55 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Threading.Tasks; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.Shared.TestHooks; | ||
using Microsoft.VisualStudio.IntegrationTest.Utilities; | ||
using Roslyn.VisualStudio.IntegrationTests; | ||
using WindowsInput.Native; | ||
using Xunit; | ||
|
||
namespace Roslyn.VisualStudio.NewIntegrationTests.VisualBasic | ||
{ | ||
public class BasicImmediate : AbstractEditorTest | ||
{ | ||
protected override string LanguageName => LanguageNames.VisualBasic; | ||
|
||
public BasicImmediate() | ||
: base() | ||
{ | ||
} | ||
|
||
public override async Task InitializeAsync() | ||
{ | ||
await base.InitializeAsync(); | ||
|
||
await TestServices.SolutionExplorer.CreateSolutionAsync(nameof(BasicImmediate), HangMitigatingCancellationToken); | ||
await TestServices.SolutionExplorer.AddProjectAsync("TestProj", WellKnownProjectTemplates.ConsoleApplication, LanguageNames.VisualBasic, HangMitigatingCancellationToken); | ||
} | ||
|
||
[IdeFact] | ||
public async Task DumpLocalVariableValue() | ||
{ | ||
await TestServices.Editor.SetTextAsync(@" | ||
Module Module1 | ||
Sub Main() | ||
Dim n1Var As Integer = 42 | ||
Dim n2Var As Integer = 43 | ||
End Sub | ||
End Module | ||
", HangMitigatingCancellationToken); | ||
|
||
await TestServices.Workspace.WaitForAsyncOperationsAsync(FeatureAttribute.Workspace, HangMitigatingCancellationToken); | ||
await TestServices.Debugger.SetBreakpointAsync("Module1.vb", "End Sub", HangMitigatingCancellationToken); | ||
await TestServices.Debugger.GoAsync(waitForBreakMode: true, HangMitigatingCancellationToken); | ||
await TestServices.ImmediateWindow.ShowAsync(HangMitigatingCancellationToken); | ||
await TestServices.ImmediateWindow.ClearAllAsync(HangMitigatingCancellationToken); | ||
await TestServices.Input.SendWithoutActivateAsync("?", HangMitigatingCancellationToken); | ||
await TestServices.Workspace.WaitForAsyncOperationsAsync(FeatureAttribute.CompletionSet, HangMitigatingCancellationToken); | ||
await TestServices.Input.SendWithoutActivateAsync(["n1", VirtualKeyCode.TAB, VirtualKeyCode.RETURN], HangMitigatingCancellationToken); | ||
Assert.Contains("?n1Var\r\n42", await TestServices.ImmediateWindow.GetTextAsync(HangMitigatingCancellationToken)); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.