Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/debug/test/browser/rawDebugSession.test.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import assert from 'assert';
7
import { mock, mockObject } from '../../../../../base/test/common/mock.js';
8
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../../base/test/common/utils.js';
9
import { IExtensionHostDebugService } from '../../../../../platform/debug/common/extensionHostDebug.js';
10
import { IDialogService } from '../../../../../platform/dialogs/common/dialogs.js';
11
import { INotificationService } from '../../../../../platform/notification/common/notification.js';
12
import { IOpenerService } from '../../../../../platform/opener/common/opener.js';
13
import { RawDebugSession } from '../../browser/rawDebugSession.js';
14
import { IDebugger } from '../../common/debug.js';
15
import { MockDebugAdapter } from '../common/mockDebug.js';
16
17
suite('RawDebugSession', () => {
18
const disposables = ensureNoDisposablesAreLeakedInTestSuite();
19
20
function createTestObjects() {
21
const debugAdapter = new MockDebugAdapter();
22
const dbgr = mockObject<IDebugger>()({
23
type: 'mock-debug'
24
});
25
26
const session = new RawDebugSession(
27
debugAdapter,
28
dbgr as any as IDebugger,
29
'sessionId',
30
'name',
31
new (mock<IExtensionHostDebugService>()),
32
new (mock<IOpenerService>()),
33
new (mock<INotificationService>()),
34
new (mock<IDialogService>()));
35
disposables.add(session);
36
disposables.add(debugAdapter);
37
38
return { debugAdapter, dbgr };
39
}
40
41
test('handles startDebugging request success', async () => {
42
const { debugAdapter, dbgr } = createTestObjects();
43
dbgr.startDebugging.returns(Promise.resolve(true));
44
45
debugAdapter.sendRequestBody('startDebugging', {
46
request: 'launch',
47
configuration: {
48
type: 'some-other-type'
49
}
50
} as DebugProtocol.StartDebuggingRequestArguments);
51
const response = await debugAdapter.waitForResponseFromClient('startDebugging');
52
assert.strictEqual(response.command, 'startDebugging');
53
assert.strictEqual(response.success, true);
54
});
55
56
test('handles startDebugging request failure', async () => {
57
const { debugAdapter, dbgr } = createTestObjects();
58
dbgr.startDebugging.returns(Promise.resolve(false));
59
60
debugAdapter.sendRequestBody('startDebugging', {
61
request: 'launch',
62
configuration: {
63
type: 'some-other-type'
64
}
65
} as DebugProtocol.StartDebuggingRequestArguments);
66
const response = await debugAdapter.waitForResponseFromClient('startDebugging');
67
assert.strictEqual(response.command, 'startDebugging');
68
assert.strictEqual(response.success, false);
69
});
70
});
71
72