mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 03:29:00 +01:00
Add more ext host editor tabs tests
This commit is contained in:
@@ -4,9 +4,10 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import assert = require('assert');
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
import { IEditorTabDto, MainThreadEditorTabsShape, TabKind } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { ExtHostEditorTabs } from 'vs/workbench/api/common/extHostEditorTabs';
|
||||
import { ExtHostEditorTabs, IEditorTabGroup } from 'vs/workbench/api/common/extHostEditorTabs';
|
||||
import { SingleProxyRPCProtocol } from 'vs/workbench/api/test/common/testRPCProtocol';
|
||||
|
||||
suite('ExtHostEditorTabs', function () {
|
||||
@@ -88,4 +89,65 @@ suite('ExtHostEditorTabs', function () {
|
||||
assert.strictEqual(first.activeTab, undefined);
|
||||
assert.strictEqual(first.tabs.length, 0);
|
||||
});
|
||||
|
||||
test('Ensure tabGroup change events fires', function () {
|
||||
const extHostEditorTabs = new ExtHostEditorTabs(
|
||||
SingleProxyRPCProtocol(new class extends mock<MainThreadEditorTabsShape>() {
|
||||
// override/implement $moveTab or $closeTab
|
||||
})
|
||||
);
|
||||
|
||||
let count = 0;
|
||||
extHostEditorTabs.onDidChangeTabGroup(() => count++);
|
||||
|
||||
|
||||
assert.strictEqual(extHostEditorTabs.tabGroups.all.length, 0);
|
||||
assert.strictEqual(extHostEditorTabs.tabGroups.activeTabGroup, undefined);
|
||||
assert.strictEqual(count, 0);
|
||||
extHostEditorTabs.$acceptEditorTabModel([{
|
||||
isActive: true,
|
||||
viewColumn: 0,
|
||||
groupId: 12,
|
||||
tabs: [],
|
||||
activeTab: undefined
|
||||
}]);
|
||||
assert.ok(extHostEditorTabs.tabGroups.activeTabGroup);
|
||||
const activeTabGroup: IEditorTabGroup = extHostEditorTabs.tabGroups.activeTabGroup;
|
||||
assert.strictEqual(extHostEditorTabs.tabGroups.all.length, 1);
|
||||
assert.strictEqual(activeTabGroup.tabs.length, 0);
|
||||
assert.strictEqual(count, 1);
|
||||
});
|
||||
|
||||
test('Ensure reference equality for activeTab and activeGroup', function () {
|
||||
const extHostEditorTabs = new ExtHostEditorTabs(
|
||||
SingleProxyRPCProtocol(new class extends mock<MainThreadEditorTabsShape>() {
|
||||
// override/implement $moveTab or $closeTab
|
||||
})
|
||||
);
|
||||
const tab: IEditorTabDto = {
|
||||
isActive: true,
|
||||
isDirty: true,
|
||||
isPinned: true,
|
||||
label: 'label1',
|
||||
resource: URI.parse('file://abc/def.txt'),
|
||||
editorId: 'default',
|
||||
viewColumn: 0,
|
||||
additionalResourcesAndViewIds: [],
|
||||
kind: TabKind.Singular
|
||||
};
|
||||
|
||||
extHostEditorTabs.$acceptEditorTabModel([{
|
||||
isActive: true,
|
||||
viewColumn: 0,
|
||||
groupId: 12,
|
||||
tabs: [tab],
|
||||
activeTab: { ...tab }
|
||||
}]);
|
||||
assert.strictEqual(extHostEditorTabs.tabGroups.all.length, 1);
|
||||
const [first] = extHostEditorTabs.tabGroups.all;
|
||||
assert.ok(first.activeTab);
|
||||
assert.strictEqual(first.tabs.indexOf(first.activeTab), 0);
|
||||
assert.strictEqual(first.activeTab, first.tabs[0]);
|
||||
assert.strictEqual(extHostEditorTabs.tabGroups.activeTabGroup, first);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user