Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/test/browser/viewlet.test.ts
4778 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 { Registry } from '../../../platform/registry/common/platform.js';
8
import { PaneCompositeDescriptor, Extensions, PaneCompositeRegistry, PaneComposite } from '../../browser/panecomposite.js';
9
import { isFunction } from '../../../base/common/types.js';
10
import { IBoundarySashes } from '../../../base/browser/ui/sash/sash.js';
11
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../base/test/common/utils.js';
12
13
suite('Viewlets', () => {
14
15
class TestViewlet extends PaneComposite {
16
17
constructor() {
18
super('id', null!, null!, null!, null!, null!, null!, null!);
19
}
20
21
override layout(dimension: any): void {
22
throw new Error('Method not implemented.');
23
}
24
25
override setBoundarySashes(sashes: IBoundarySashes): void {
26
throw new Error('Method not implemented.');
27
}
28
29
protected override createViewPaneContainer() { return null!; }
30
}
31
32
test('ViewletDescriptor API', function () {
33
const d = PaneCompositeDescriptor.create(TestViewlet, 'id', 'name', 'class', 5);
34
assert.strictEqual(d.id, 'id');
35
assert.strictEqual(d.name, 'name');
36
assert.strictEqual(d.cssClass, 'class');
37
assert.strictEqual(d.order, 5);
38
});
39
40
test('Editor Aware ViewletDescriptor API', function () {
41
let d = PaneCompositeDescriptor.create(TestViewlet, 'id', 'name', 'class', 5);
42
assert.strictEqual(d.id, 'id');
43
assert.strictEqual(d.name, 'name');
44
45
d = PaneCompositeDescriptor.create(TestViewlet, 'id', 'name', 'class', 5);
46
assert.strictEqual(d.id, 'id');
47
assert.strictEqual(d.name, 'name');
48
});
49
50
test('Viewlet extension point and registration', function () {
51
assert(isFunction(Registry.as<PaneCompositeRegistry>(Extensions.Viewlets).registerPaneComposite));
52
assert(isFunction(Registry.as<PaneCompositeRegistry>(Extensions.Viewlets).getPaneComposite));
53
assert(isFunction(Registry.as<PaneCompositeRegistry>(Extensions.Viewlets).getPaneComposites));
54
55
const oldCount = Registry.as<PaneCompositeRegistry>(Extensions.Viewlets).getPaneComposites().length;
56
const d = PaneCompositeDescriptor.create(TestViewlet, 'reg-test-id', 'name');
57
Registry.as<PaneCompositeRegistry>(Extensions.Viewlets).registerPaneComposite(d);
58
59
assert(d === Registry.as<PaneCompositeRegistry>(Extensions.Viewlets).getPaneComposite('reg-test-id'));
60
assert.strictEqual(oldCount + 1, Registry.as<PaneCompositeRegistry>(Extensions.Viewlets).getPaneComposites().length);
61
});
62
63
ensureNoDisposablesAreLeakedInTestSuite();
64
});
65
66