|
| 1 | +// // Copyright (c) Microsoft. All rights reserved. |
| 2 | +// // Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| 3 | + |
| 4 | +using System; |
| 5 | +using System.Collections.Generic; |
| 6 | +using System.IO; |
| 7 | +using System.Linq; |
| 8 | +using DebuggerTesting; |
| 9 | +using DebuggerTesting.Compilation; |
| 10 | +using DebuggerTesting.OpenDebug; |
| 11 | +using DebuggerTesting.OpenDebug.Commands; |
| 12 | +using DebuggerTesting.OpenDebug.CrossPlatCpp; |
| 13 | +using DebuggerTesting.OpenDebug.Events; |
| 14 | +using DebuggerTesting.OpenDebug.Extensions; |
| 15 | +using DebuggerTesting.Ordering; |
| 16 | +using DebuggerTesting.Settings; |
| 17 | +using DebuggerTesting.Utilities; |
| 18 | +using Xunit; |
| 19 | +using Xunit.Abstractions; |
| 20 | + |
| 21 | +namespace CppTests.Tests |
| 22 | +{ |
| 23 | + [TestCaseOrderer(DependencyTestOrderer.TypeName, DependencyTestOrderer.AssemblyName)] |
| 24 | + public class AutoCompleteTests : TestBase |
| 25 | + { |
| 26 | + #region Constructor |
| 27 | + |
| 28 | + public AutoCompleteTests(ITestOutputHelper outputHelper) : base(outputHelper) |
| 29 | + { |
| 30 | + } |
| 31 | + |
| 32 | + #endregion |
| 33 | + |
| 34 | + #region Methods |
| 35 | + |
| 36 | + private const string HelloName = "hello"; |
| 37 | + private const string HelloSourceName = "hello.cpp"; |
| 38 | + |
| 39 | + [Theory] |
| 40 | + [RequiresTestSettings] |
| 41 | + public void CompileHelloDebuggee(ITestSettings settings) |
| 42 | + { |
| 43 | + this.TestPurpose("Create and compile the 'hello' debuggee"); |
| 44 | + this.WriteSettings(settings); |
| 45 | + |
| 46 | + IDebuggee debuggee = Debuggee.Create(this, settings.CompilerSettings, HelloName, DebuggeeMonikers.HelloWorld.Sample); |
| 47 | + debuggee.AddSourceFiles(HelloSourceName); |
| 48 | + debuggee.Compile(); |
| 49 | + } |
| 50 | + |
| 51 | + [Theory] |
| 52 | + [DependsOnTest(nameof(CompileHelloDebuggee))] |
| 53 | + [RequiresTestSettings] |
| 54 | + [UnsupportedDebugger(SupportedDebugger.Lldb | SupportedDebugger.VsDbg, SupportedArchitecture.x64 | SupportedArchitecture.x86)] |
| 55 | + public void TestAutoComplete(ITestSettings settings) |
| 56 | + { |
| 57 | + this.TestPurpose("This test checks a bunch of commands and events."); |
| 58 | + this.WriteSettings(settings); |
| 59 | + |
| 60 | + IDebuggee debuggee = Debuggee.Open(this, settings.CompilerSettings, HelloName, DebuggeeMonikers.HelloWorld.Sample); |
| 61 | + |
| 62 | + using (IDebuggerRunner runner = CreateDebugAdapterRunner(settings)) |
| 63 | + { |
| 64 | + this.Comment("Launch the debuggee"); |
| 65 | + runner.Launch(settings.DebuggerSettings, debuggee); |
| 66 | + |
| 67 | + SourceBreakpoints callingBreakpoints = new SourceBreakpoints(debuggee, HelloSourceName); |
| 68 | + callingBreakpoints.Add(9); |
| 69 | + runner.SetBreakpoints(callingBreakpoints); |
| 70 | + |
| 71 | + runner.Expects.HitBreakpointEvent(HelloSourceName, 9) |
| 72 | + .AfterConfigurationDone(); |
| 73 | + |
| 74 | + // Test completion with -exec |
| 75 | + string[] completions = runner.CompletionsRequest("-exec break"); |
| 76 | + Assert.Collection(completions, |
| 77 | + elem1 => Assert.Equal("-exec break", elem1), |
| 78 | + elem2 => Assert.Equal("-exec break-range", elem2) |
| 79 | + ); |
| 80 | + |
| 81 | + // Test completion with ` |
| 82 | + completions = runner.CompletionsRequest("`pw"); |
| 83 | + Assert.Collection(completions, |
| 84 | + elem1 => Assert.Equal("`pwd", elem1) |
| 85 | + ); |
| 86 | + |
| 87 | + // Test completions without -exec or ` |
| 88 | + completions = runner.CompletionsRequest("pw"); |
| 89 | + Assert.Empty(completions); |
| 90 | + |
| 91 | + runner.Expects.ExitedEvent(0).TerminatedEvent().AfterContinue(); |
| 92 | + runner.DisconnectAndVerify(); |
| 93 | + } |
| 94 | + } |
| 95 | + |
| 96 | + #endregion |
| 97 | + } |
| 98 | +} |
0 commit comments