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
5240 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
// eslint-disable-next-line local/code-no-any-casts
29
dbgr as any as IDebugger,
30
'sessionId',
31
'name',
32
new (mock<IExtensionHostDebugService>()),
33
new (mock<IOpenerService>()),
34
new (mock<INotificationService>()),
35
new (mock<IDialogService>()));
36
disposables.add(session);
37
disposables.add(debugAdapter);
38
39
return { debugAdapter, dbgr };
40
}
41
42
test('handles startDebugging request success', async () => {
43
const { debugAdapter, dbgr } = createTestObjects();
44
dbgr.startDebugging.returns(Promise.resolve(true));
45
46
debugAdapter.sendRequestBody('startDebugging', {
47
request: 'launch',
48
configuration: {
49
type: 'some-other-type'
50
}
51
} as DebugProtocol.StartDebuggingRequestArguments);
52
const response = await debugAdapter.waitForResponseFromClient('startDebugging');
53
assert.strictEqual(response.command, 'startDebugging');
54
assert.strictEqual(response.success, true);
55
});
56
57
test('handles startDebugging request failure', async () => {
58
const { debugAdapter, dbgr } = createTestObjects();
59
dbgr.startDebugging.returns(Promise.resolve(false));
60
61
debugAdapter.sendRequestBody('startDebugging', {
62
request: 'launch',
63
configuration: {
64
type: 'some-other-type'
65
}
66
} as DebugProtocol.StartDebuggingRequestArguments);
67
const response = await debugAdapter.waitForResponseFromClient('startDebugging');
68
assert.strictEqual(response.command, 'startDebugging');
69
assert.strictEqual(response.success, false);
70
});
71
});
72
73