mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-09 01:32:34 -05:00
Merge from vscode a348d103d1256a06a2c9b3f9b406298a9fef6898 (#15681)
* Merge from vscode a348d103d1256a06a2c9b3f9b406298a9fef6898 * Fixes and cleanup * Distro * Fix hygiene yarn * delete no yarn lock changes file * Fix hygiene * Fix layer check * Fix CI * Skip lib checks * Remove tests deleted in vs code * Fix tests * Distro * Fix tests and add removed extension point * Skip failing notebook tests for now * Disable broken tests and cleanup build folder * Update yarn.lock and fix smoke tests * Bump sqlite * fix contributed actions and file spacing * Fix user data path * Update yarn.locks Co-authored-by: ADS Merger <karlb@microsoft.com>
This commit is contained in:
@@ -11,11 +11,11 @@ import { isWindows } from 'vs/base/common/platform';
|
||||
suite('ExtHost API', function () {
|
||||
test('issue #51387: originalFSPath', function () {
|
||||
if (isWindows) {
|
||||
assert.equal(originalFSPath(URI.file('C:\\test')).charAt(0), 'C');
|
||||
assert.equal(originalFSPath(URI.file('c:\\test')).charAt(0), 'c');
|
||||
assert.strictEqual(originalFSPath(URI.file('C:\\test')).charAt(0), 'C');
|
||||
assert.strictEqual(originalFSPath(URI.file('c:\\test')).charAt(0), 'c');
|
||||
|
||||
assert.equal(originalFSPath(URI.revive(JSON.parse(JSON.stringify(URI.file('C:\\test'))))).charAt(0), 'C');
|
||||
assert.equal(originalFSPath(URI.revive(JSON.parse(JSON.stringify(URI.file('c:\\test'))))).charAt(0), 'c');
|
||||
assert.strictEqual(originalFSPath(URI.revive(JSON.parse(JSON.stringify(URI.file('C:\\test'))))).charAt(0), 'C');
|
||||
assert.strictEqual(originalFSPath(URI.revive(JSON.parse(JSON.stringify(URI.file('c:\\test'))))).charAt(0), 'c');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -90,14 +90,14 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
rpcProtocol = new TestRPCProtocol();
|
||||
const services = new ServiceCollection();
|
||||
services.set(IExtensionService, new class extends mock<IExtensionService>() {
|
||||
async activateByEvent() {
|
||||
override async activateByEvent() {
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
services.set(ICommandService, new SyncDescriptor(class extends mock<ICommandService>() {
|
||||
|
||||
executeCommand(id: string, ...args: any): any {
|
||||
override executeCommand(id: string, ...args: any): any {
|
||||
const command = CommandsRegistry.getCommands().get(id);
|
||||
if (!command) {
|
||||
return Promise.reject(new Error(id + ' NOT known'));
|
||||
@@ -108,17 +108,17 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
}));
|
||||
services.set(IMarkerService, new MarkerService());
|
||||
services.set(IModelService, new class extends mock<IModelService>() {
|
||||
getModel() { return model; }
|
||||
override getModel() { return model; }
|
||||
});
|
||||
services.set(ITextModelService, new class extends mock<ITextModelService>() {
|
||||
async createModelReference() {
|
||||
override async createModelReference() {
|
||||
return new ImmortalReference<IResolvedTextEditorModel>(new class extends mock<IResolvedTextEditorModel>() {
|
||||
textEditorModel = model;
|
||||
override textEditorModel = model;
|
||||
});
|
||||
}
|
||||
});
|
||||
services.set(IEditorWorkerService, new class extends mock<IEditorWorkerService>() {
|
||||
async computeMoreMinimalEdits(_uri: any, edits: any) {
|
||||
override async computeMoreMinimalEdits(_uri: any, edits: any) {
|
||||
return edits || undefined;
|
||||
}
|
||||
});
|
||||
@@ -280,15 +280,21 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
|
||||
disposables.push(extHost.registerDefinitionProvider(nullExtensionDescription, defaultSelector, <vscode.DefinitionProvider>{
|
||||
provideDefinition(doc: any): any {
|
||||
return new types.Location(doc.uri, new types.Range(0, 0, 0, 0));
|
||||
return new types.Location(doc.uri, new types.Range(1, 0, 0, 0));
|
||||
}
|
||||
}));
|
||||
disposables.push(extHost.registerDefinitionProvider(nullExtensionDescription, defaultSelector, <vscode.DefinitionProvider>{
|
||||
provideDefinition(doc: any): any {
|
||||
// duplicate result will get removed
|
||||
return new types.Location(doc.uri, new types.Range(1, 0, 0, 0));
|
||||
}
|
||||
}));
|
||||
disposables.push(extHost.registerDefinitionProvider(nullExtensionDescription, defaultSelector, <vscode.DefinitionProvider>{
|
||||
provideDefinition(doc: any): any {
|
||||
return [
|
||||
new types.Location(doc.uri, new types.Range(0, 0, 0, 0)),
|
||||
new types.Location(doc.uri, new types.Range(0, 0, 0, 0)),
|
||||
new types.Location(doc.uri, new types.Range(0, 0, 0, 0)),
|
||||
new types.Location(doc.uri, new types.Range(2, 0, 0, 0)),
|
||||
new types.Location(doc.uri, new types.Range(3, 0, 0, 0)),
|
||||
new types.Location(doc.uri, new types.Range(4, 0, 0, 0)),
|
||||
];
|
||||
}
|
||||
}));
|
||||
@@ -304,12 +310,48 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
test('Definition, back and forth (sorting & de-deduping)', function () {
|
||||
|
||||
disposables.push(extHost.registerDefinitionProvider(nullExtensionDescription, defaultSelector, <vscode.DefinitionProvider>{
|
||||
provideDefinition(doc: any): any {
|
||||
return new types.Location(URI.parse('file:///b'), new types.Range(1, 0, 0, 0));
|
||||
}
|
||||
}));
|
||||
disposables.push(extHost.registerDefinitionProvider(nullExtensionDescription, defaultSelector, <vscode.DefinitionProvider>{
|
||||
provideDefinition(doc: any): any {
|
||||
// duplicate result will get removed
|
||||
return new types.Location(URI.parse('file:///b'), new types.Range(1, 0, 0, 0));
|
||||
}
|
||||
}));
|
||||
disposables.push(extHost.registerDefinitionProvider(nullExtensionDescription, defaultSelector, <vscode.DefinitionProvider>{
|
||||
provideDefinition(doc: any): any {
|
||||
return [
|
||||
new types.Location(URI.parse('file:///a'), new types.Range(2, 0, 0, 0)),
|
||||
new types.Location(URI.parse('file:///c'), new types.Range(3, 0, 0, 0)),
|
||||
new types.Location(URI.parse('file:///d'), new types.Range(4, 0, 0, 0)),
|
||||
];
|
||||
}
|
||||
}));
|
||||
|
||||
return rpcProtocol.sync().then(() => {
|
||||
return commands.executeCommand<vscode.Location[]>('vscode.executeDefinitionProvider', model.uri, new types.Position(0, 0)).then(values => {
|
||||
assert.strictEqual(values.length, 4);
|
||||
|
||||
assert.strictEqual(values[0].uri.path, '/a');
|
||||
assert.strictEqual(values[1].uri.path, '/b');
|
||||
assert.strictEqual(values[2].uri.path, '/c');
|
||||
assert.strictEqual(values[3].uri.path, '/d');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('Definition Link', () => {
|
||||
disposables.push(extHost.registerDefinitionProvider(nullExtensionDescription, defaultSelector, <vscode.DefinitionProvider>{
|
||||
provideDefinition(doc: any): (vscode.Location | vscode.LocationLink)[] {
|
||||
return [
|
||||
new types.Location(doc.uri, new types.Range(0, 0, 0, 0)),
|
||||
{ targetUri: doc.uri, targetRange: new types.Range(0, 0, 0, 0), targetSelectionRange: new types.Range(1, 1, 1, 1), originSelectionRange: new types.Range(2, 2, 2, 2) }
|
||||
{ targetUri: doc.uri, targetRange: new types.Range(1, 0, 0, 0), targetSelectionRange: new types.Range(1, 1, 1, 1), originSelectionRange: new types.Range(2, 2, 2, 2) }
|
||||
];
|
||||
}
|
||||
}));
|
||||
@@ -338,15 +380,21 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
|
||||
disposables.push(extHost.registerDeclarationProvider(nullExtensionDescription, defaultSelector, <vscode.DeclarationProvider>{
|
||||
provideDeclaration(doc: any): any {
|
||||
return new types.Location(doc.uri, new types.Range(0, 0, 0, 0));
|
||||
return new types.Location(doc.uri, new types.Range(1, 0, 0, 0));
|
||||
}
|
||||
}));
|
||||
disposables.push(extHost.registerDeclarationProvider(nullExtensionDescription, defaultSelector, <vscode.DeclarationProvider>{
|
||||
provideDeclaration(doc: any): any {
|
||||
// duplicate result will get removed
|
||||
return new types.Location(doc.uri, new types.Range(1, 0, 0, 0));
|
||||
}
|
||||
}));
|
||||
disposables.push(extHost.registerDeclarationProvider(nullExtensionDescription, defaultSelector, <vscode.DeclarationProvider>{
|
||||
provideDeclaration(doc: any): any {
|
||||
return [
|
||||
new types.Location(doc.uri, new types.Range(0, 0, 0, 0)),
|
||||
new types.Location(doc.uri, new types.Range(0, 0, 0, 0)),
|
||||
new types.Location(doc.uri, new types.Range(0, 0, 0, 0)),
|
||||
new types.Location(doc.uri, new types.Range(2, 0, 0, 0)),
|
||||
new types.Location(doc.uri, new types.Range(3, 0, 0, 0)),
|
||||
new types.Location(doc.uri, new types.Range(4, 0, 0, 0)),
|
||||
];
|
||||
}
|
||||
}));
|
||||
@@ -367,7 +415,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
provideDeclaration(doc: any): (vscode.Location | vscode.LocationLink)[] {
|
||||
return [
|
||||
new types.Location(doc.uri, new types.Range(0, 0, 0, 0)),
|
||||
{ targetUri: doc.uri, targetRange: new types.Range(0, 0, 0, 0), targetSelectionRange: new types.Range(1, 1, 1, 1), originSelectionRange: new types.Range(2, 2, 2, 2) }
|
||||
{ targetUri: doc.uri, targetRange: new types.Range(1, 0, 0, 0), targetSelectionRange: new types.Range(1, 1, 1, 1), originSelectionRange: new types.Range(2, 2, 2, 2) }
|
||||
];
|
||||
}
|
||||
}));
|
||||
@@ -407,15 +455,21 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
|
||||
disposables.push(extHost.registerTypeDefinitionProvider(nullExtensionDescription, defaultSelector, <vscode.TypeDefinitionProvider>{
|
||||
provideTypeDefinition(doc: any): any {
|
||||
return new types.Location(doc.uri, new types.Range(0, 0, 0, 0));
|
||||
return new types.Location(doc.uri, new types.Range(1, 0, 0, 0));
|
||||
}
|
||||
}));
|
||||
disposables.push(extHost.registerTypeDefinitionProvider(nullExtensionDescription, defaultSelector, <vscode.TypeDefinitionProvider>{
|
||||
provideTypeDefinition(doc: any): any {
|
||||
// duplicate result will get removed
|
||||
return new types.Location(doc.uri, new types.Range(1, 0, 0, 0));
|
||||
}
|
||||
}));
|
||||
disposables.push(extHost.registerTypeDefinitionProvider(nullExtensionDescription, defaultSelector, <vscode.TypeDefinitionProvider>{
|
||||
provideTypeDefinition(doc: any): any {
|
||||
return [
|
||||
new types.Location(doc.uri, new types.Range(0, 0, 0, 0)),
|
||||
new types.Location(doc.uri, new types.Range(0, 0, 0, 0)),
|
||||
new types.Location(doc.uri, new types.Range(0, 0, 0, 0)),
|
||||
new types.Location(doc.uri, new types.Range(2, 0, 0, 0)),
|
||||
new types.Location(doc.uri, new types.Range(3, 0, 0, 0)),
|
||||
new types.Location(doc.uri, new types.Range(4, 0, 0, 0)),
|
||||
];
|
||||
}
|
||||
}));
|
||||
@@ -436,7 +490,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
provideTypeDefinition(doc: any): (vscode.Location | vscode.LocationLink)[] {
|
||||
return [
|
||||
new types.Location(doc.uri, new types.Range(0, 0, 0, 0)),
|
||||
{ targetUri: doc.uri, targetRange: new types.Range(0, 0, 0, 0), targetSelectionRange: new types.Range(1, 1, 1, 1), originSelectionRange: new types.Range(2, 2, 2, 2) }
|
||||
{ targetUri: doc.uri, targetRange: new types.Range(1, 0, 0, 0), targetSelectionRange: new types.Range(1, 1, 1, 1), originSelectionRange: new types.Range(2, 2, 2, 2) }
|
||||
];
|
||||
}
|
||||
}));
|
||||
@@ -476,15 +530,21 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
|
||||
disposables.push(extHost.registerImplementationProvider(nullExtensionDescription, defaultSelector, <vscode.ImplementationProvider>{
|
||||
provideImplementation(doc: any): any {
|
||||
return new types.Location(doc.uri, new types.Range(0, 0, 0, 0));
|
||||
return new types.Location(doc.uri, new types.Range(1, 0, 0, 0));
|
||||
}
|
||||
}));
|
||||
disposables.push(extHost.registerImplementationProvider(nullExtensionDescription, defaultSelector, <vscode.ImplementationProvider>{
|
||||
provideImplementation(doc: any): any {
|
||||
// duplicate result will get removed
|
||||
return new types.Location(doc.uri, new types.Range(1, 0, 0, 0));
|
||||
}
|
||||
}));
|
||||
disposables.push(extHost.registerImplementationProvider(nullExtensionDescription, defaultSelector, <vscode.ImplementationProvider>{
|
||||
provideImplementation(doc: any): any {
|
||||
return [
|
||||
new types.Location(doc.uri, new types.Range(0, 0, 0, 0)),
|
||||
new types.Location(doc.uri, new types.Range(0, 0, 0, 0)),
|
||||
new types.Location(doc.uri, new types.Range(0, 0, 0, 0)),
|
||||
new types.Location(doc.uri, new types.Range(2, 0, 0, 0)),
|
||||
new types.Location(doc.uri, new types.Range(3, 0, 0, 0)),
|
||||
new types.Location(doc.uri, new types.Range(4, 0, 0, 0)),
|
||||
];
|
||||
}
|
||||
}));
|
||||
@@ -505,7 +565,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
provideImplementation(doc: any): (vscode.Location | vscode.LocationLink)[] {
|
||||
return [
|
||||
new types.Location(doc.uri, new types.Range(0, 0, 0, 0)),
|
||||
{ targetUri: doc.uri, targetRange: new types.Range(0, 0, 0, 0), targetSelectionRange: new types.Range(1, 1, 1, 1), originSelectionRange: new types.Range(2, 2, 2, 2) }
|
||||
{ targetUri: doc.uri, targetRange: new types.Range(1, 0, 0, 0), targetSelectionRange: new types.Range(1, 1, 1, 1), originSelectionRange: new types.Range(2, 2, 2, 2) }
|
||||
];
|
||||
}
|
||||
}));
|
||||
@@ -1147,7 +1207,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
test('Inline Hints, back and forth', async function () {
|
||||
disposables.push(extHost.registerInlineHintsProvider(nullExtensionDescription, defaultSelector, <vscode.InlineHintsProvider>{
|
||||
provideInlineHints() {
|
||||
return [new types.InlineHint('Foo', new types.Range(0, 1, 2, 3), undefined, true, false)];
|
||||
return [new types.InlineHint('Foo', new types.Range(0, 1, 2, 3))];
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -1167,13 +1227,15 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
test('Inline Hints, merge', async function () {
|
||||
disposables.push(extHost.registerInlineHintsProvider(nullExtensionDescription, defaultSelector, <vscode.InlineHintsProvider>{
|
||||
provideInlineHints() {
|
||||
return [new types.InlineHint('Bar', new types.Range(10, 11, 12, 13), undefined, true, false)];
|
||||
return [new types.InlineHint('Bar', new types.Range(10, 11, 12, 13))];
|
||||
}
|
||||
}));
|
||||
|
||||
disposables.push(extHost.registerInlineHintsProvider(nullExtensionDescription, defaultSelector, <vscode.InlineHintsProvider>{
|
||||
provideInlineHints() {
|
||||
return [new types.InlineHint('Foo', new types.Range(0, 1, 2, 3), new types.MarkdownString('**Hello**'), true, false)];
|
||||
const hint = new types.InlineHint('Foo', new types.Range(0, 1, 2, 3), types.InlineHintKind.Parameter);
|
||||
hint.description = new types.MarkdownString('**Hello**');
|
||||
return [hint];
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -1201,7 +1263,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
test('Inline Hints, bad provider', async function () {
|
||||
disposables.push(extHost.registerInlineHintsProvider(nullExtensionDescription, defaultSelector, <vscode.InlineHintsProvider>{
|
||||
provideInlineHints() {
|
||||
return [new types.InlineHint('Foo', new types.Range(0, 1, 2, 3), undefined, true, false)];
|
||||
return [new types.InlineHint('Foo', new types.Range(0, 1, 2, 3))];
|
||||
}
|
||||
}));
|
||||
disposables.push(extHost.registerInlineHintsProvider(nullExtensionDescription, defaultSelector, <vscode.InlineHintsProvider>{
|
||||
|
||||
@@ -24,7 +24,7 @@ suite('ExtHostBulkEdits.applyWorkspaceEdit', () => {
|
||||
|
||||
let rpcProtocol = new TestRPCProtocol();
|
||||
rpcProtocol.set(MainContext.MainThreadBulkEdits, new class extends mock<MainThreadBulkEditsShape>() {
|
||||
$tryApplyWorkspaceEdit(_workspaceResourceEdits: IWorkspaceEditDto): Promise<boolean> {
|
||||
override $tryApplyWorkspaceEdit(_workspaceResourceEdits: IWorkspaceEditDto): Promise<boolean> {
|
||||
workspaceResourceEdits = _workspaceResourceEdits;
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
@@ -40,7 +40,7 @@ suite('ExtHostBulkEdits.applyWorkspaceEdit', () => {
|
||||
EOL: '\n',
|
||||
}]
|
||||
});
|
||||
bulkEdits = new ExtHostBulkEdits(rpcProtocol, documentsAndEditors, null!);
|
||||
bulkEdits = new ExtHostBulkEdits(rpcProtocol, documentsAndEditors);
|
||||
});
|
||||
|
||||
test('uses version id if document available', async () => {
|
||||
|
||||
@@ -18,10 +18,10 @@ suite('ExtHostCommands', function () {
|
||||
let lastUnregister: string;
|
||||
|
||||
const shape = new class extends mock<MainThreadCommandsShape>() {
|
||||
$registerCommand(id: string): void {
|
||||
override $registerCommand(id: string): void {
|
||||
//
|
||||
}
|
||||
$unregisterCommand(id: string): void {
|
||||
override $unregisterCommand(id: string): void {
|
||||
lastUnregister = id;
|
||||
}
|
||||
};
|
||||
@@ -41,10 +41,10 @@ suite('ExtHostCommands', function () {
|
||||
let unregisterCounter = 0;
|
||||
|
||||
const shape = new class extends mock<MainThreadCommandsShape>() {
|
||||
$registerCommand(id: string): void {
|
||||
override $registerCommand(id: string): void {
|
||||
//
|
||||
}
|
||||
$unregisterCommand(id: string): void {
|
||||
override $unregisterCommand(id: string): void {
|
||||
unregisterCounter += 1;
|
||||
}
|
||||
};
|
||||
@@ -65,10 +65,10 @@ suite('ExtHostCommands', function () {
|
||||
let count = 0;
|
||||
|
||||
const shape = new class extends mock<MainThreadCommandsShape>() {
|
||||
$registerCommand(id: string): void {
|
||||
override $registerCommand(id: string): void {
|
||||
//
|
||||
}
|
||||
async $executeCommand<T>(id: string, args: any[], retry: boolean): Promise<T | undefined> {
|
||||
override async $executeCommand<T>(id: string, args: any[], retry: boolean): Promise<T | undefined> {
|
||||
count++;
|
||||
assert.strictEqual(retry, count === 1);
|
||||
if (count === 1) {
|
||||
|
||||
@@ -23,14 +23,14 @@ suite('ExtHostConfiguration', function () {
|
||||
|
||||
class RecordingShape extends mock<MainThreadConfigurationShape>() {
|
||||
lastArgs!: [ConfigurationTarget, string, any];
|
||||
$updateConfigurationOption(target: ConfigurationTarget, key: string, value: any): Promise<void> {
|
||||
override $updateConfigurationOption(target: ConfigurationTarget, key: string, value: any): Promise<void> {
|
||||
this.lastArgs = [target, key, value];
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
function createExtHostWorkspace(): ExtHostWorkspace {
|
||||
return new ExtHostWorkspace(new TestRPCProtocol(), new class extends mock<IExtHostInitDataService>() { }, new class extends mock<IExtHostFileSystemInfo>() { getCapabilities() { return isLinux ? FileSystemProviderCapabilities.PathCaseSensitive : undefined; } }, new NullLogService());
|
||||
return new ExtHostWorkspace(new TestRPCProtocol(), new class extends mock<IExtHostInitDataService>() { }, new class extends mock<IExtHostFileSystemInfo>() { override getCapabilities() { return isLinux ? FileSystemProviderCapabilities.PathCaseSensitive : undefined; } }, new NullLogService());
|
||||
}
|
||||
|
||||
function createExtHostConfiguration(contents: any = Object.create(null), shape?: MainThreadConfigurationShape) {
|
||||
@@ -318,7 +318,7 @@ suite('ExtHostConfiguration', function () {
|
||||
'id': 'foo',
|
||||
'folders': [aWorkspaceFolder(URI.file('foo'), 0)],
|
||||
'name': 'foo'
|
||||
});
|
||||
}, true);
|
||||
const testObject = new ExtHostConfigProvider(
|
||||
new class extends mock<MainThreadConfigurationShape>() { },
|
||||
extHostWorkspace,
|
||||
@@ -394,7 +394,7 @@ suite('ExtHostConfiguration', function () {
|
||||
'id': 'foo',
|
||||
'folders': [aWorkspaceFolder(firstRoot, 0), aWorkspaceFolder(secondRoot, 1)],
|
||||
'name': 'foo'
|
||||
});
|
||||
}, true);
|
||||
const testObject = new ExtHostConfigProvider(
|
||||
new class extends mock<MainThreadConfigurationShape>() { },
|
||||
extHostWorkspace,
|
||||
@@ -497,7 +497,7 @@ suite('ExtHostConfiguration', function () {
|
||||
'id': 'foo',
|
||||
'folders': [aWorkspaceFolder(firstRoot, 0), aWorkspaceFolder(secondRoot, 1)],
|
||||
'name': 'foo'
|
||||
});
|
||||
}, true);
|
||||
const testObject = new ExtHostConfigProvider(
|
||||
new class extends mock<MainThreadConfigurationShape>() { },
|
||||
extHostWorkspace,
|
||||
@@ -656,7 +656,7 @@ suite('ExtHostConfiguration', function () {
|
||||
test('update/error-state not OK', function () {
|
||||
|
||||
const shape = new class extends mock<MainThreadConfigurationShape>() {
|
||||
$updateConfigurationOption(target: ConfigurationTarget, key: string, value: any): Promise<any> {
|
||||
override $updateConfigurationOption(target: ConfigurationTarget, key: string, value: any): Promise<any> {
|
||||
return Promise.reject(new Error('Unknown Key')); // something !== OK
|
||||
}
|
||||
};
|
||||
@@ -675,7 +675,7 @@ suite('ExtHostConfiguration', function () {
|
||||
'id': 'foo',
|
||||
'folders': [workspaceFolder],
|
||||
'name': 'foo'
|
||||
});
|
||||
}, true);
|
||||
const testObject = new ExtHostConfigProvider(
|
||||
new class extends mock<MainThreadConfigurationShape>() { },
|
||||
extHostWorkspace,
|
||||
@@ -731,7 +731,7 @@ suite('ExtHostConfiguration', function () {
|
||||
|
||||
function toConfigurationModel(obj: any): ConfigurationModel {
|
||||
const parser = new ConfigurationModelParser('test');
|
||||
parser.parseContent(JSON.stringify(obj));
|
||||
parser.parse(JSON.stringify(obj));
|
||||
return parser.configurationModel;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,14 +25,14 @@ suite('ExtHostDecorations', function () {
|
||||
providers.clear();
|
||||
|
||||
mainThreadShape = new class extends mock<MainThreadDecorationsShape>() {
|
||||
$registerDecorationProvider(handle: number) {
|
||||
override $registerDecorationProvider(handle: number) {
|
||||
providers.add(handle);
|
||||
}
|
||||
};
|
||||
|
||||
extHostDecorations = new ExtHostDecorations(
|
||||
new class extends mock<IExtHostRpcService>() {
|
||||
getProxy(): any {
|
||||
override getProxy(): any {
|
||||
return mainThreadShape;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -18,10 +18,10 @@ import { nullExtensionDescription } from 'vs/workbench/services/extensions/commo
|
||||
suite('ExtHostDiagnostics', () => {
|
||||
|
||||
class DiagnosticsShape extends mock<MainThreadDiagnosticsShape>() {
|
||||
$changeMany(owner: string, entries: [UriComponents, IMarkerData[]][]): void {
|
||||
override $changeMany(owner: string, entries: [UriComponents, IMarkerData[]][]): void {
|
||||
//
|
||||
}
|
||||
$clear(owner: string): void {
|
||||
override $clear(owner: string): void {
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -164,7 +164,7 @@ suite('ExtHostDiagnostics', () => {
|
||||
|
||||
let lastEntries!: [UriComponents, IMarkerData[]][];
|
||||
let collection = new DiagnosticCollection('test', 'test', 100, new class extends DiagnosticsShape {
|
||||
$changeMany(owner: string, entries: [UriComponents, IMarkerData[]][]): void {
|
||||
override $changeMany(owner: string, entries: [UriComponents, IMarkerData[]][]): void {
|
||||
lastEntries = entries;
|
||||
return super.$changeMany(owner, entries);
|
||||
}
|
||||
@@ -198,7 +198,7 @@ suite('ExtHostDiagnostics', () => {
|
||||
const emitter = new Emitter<any>();
|
||||
emitter.event(_ => eventCount += 1);
|
||||
const collection = new DiagnosticCollection('test', 'test', 100, new class extends DiagnosticsShape {
|
||||
$changeMany() {
|
||||
override $changeMany() {
|
||||
changeCount += 1;
|
||||
}
|
||||
}, emitter);
|
||||
@@ -263,7 +263,7 @@ suite('ExtHostDiagnostics', () => {
|
||||
|
||||
let lastEntries!: [UriComponents, IMarkerData[]][];
|
||||
let collection = new DiagnosticCollection('test', 'test', 250, new class extends DiagnosticsShape {
|
||||
$changeMany(owner: string, entries: [UriComponents, IMarkerData[]][]): void {
|
||||
override $changeMany(owner: string, entries: [UriComponents, IMarkerData[]][]): void {
|
||||
lastEntries = entries;
|
||||
return super.$changeMany(owner, entries);
|
||||
}
|
||||
@@ -350,7 +350,7 @@ suite('ExtHostDiagnostics', () => {
|
||||
test('diagnostics with related information', function (done) {
|
||||
|
||||
let collection = new DiagnosticCollection('ddd', 'test', 100, new class extends DiagnosticsShape {
|
||||
$changeMany(owner: string, entries: [UriComponents, IMarkerData[]][]) {
|
||||
override $changeMany(owner: string, entries: [UriComponents, IMarkerData[]][]) {
|
||||
|
||||
let [[, data]] = entries;
|
||||
assert.strictEqual(entries.length, 1);
|
||||
@@ -408,7 +408,7 @@ suite('ExtHostDiagnostics', () => {
|
||||
test('Error updating diagnostics from extension #60394', function () {
|
||||
let callCount = 0;
|
||||
let collection = new DiagnosticCollection('ddd', 'test', 100, new class extends DiagnosticsShape {
|
||||
$changeMany(owner: string, entries: [UriComponents, IMarkerData[]][]) {
|
||||
override $changeMany(owner: string, entries: [UriComponents, IMarkerData[]][]) {
|
||||
callCount += 1;
|
||||
}
|
||||
}, new Emitter<any>());
|
||||
|
||||
@@ -50,7 +50,7 @@ suite('ExtHostDocumentData', () => {
|
||||
test('save, when disposed', function () {
|
||||
let saved: URI;
|
||||
let data = new ExtHostDocumentData(new class extends mock<MainThreadDocumentsShape>() {
|
||||
$trySaveDocument(uri: URI) {
|
||||
override $trySaveDocument(uri: URI) {
|
||||
assert.ok(!saved);
|
||||
saved = uri;
|
||||
return Promise.resolve(true);
|
||||
@@ -365,16 +365,16 @@ suite('ExtHostDocumentData updates line mapping', () => {
|
||||
let line = 0, character = 0, previousIsCarriageReturn = false;
|
||||
for (let offset = 0; offset <= allText.length; offset++) {
|
||||
// The position coordinate system cannot express the position between \r and \n
|
||||
const position = new Position(line, character + (previousIsCarriageReturn ? -1 : 0));
|
||||
const position: Position = new Position(line, character + (previousIsCarriageReturn ? -1 : 0));
|
||||
|
||||
if (direction === AssertDocumentLineMappingDirection.OffsetToPosition) {
|
||||
let actualPosition = doc.document.positionAt(offset);
|
||||
assert.equal(positionToStr(actualPosition), positionToStr(position), 'positionAt mismatch for offset ' + offset);
|
||||
assert.strictEqual(positionToStr(actualPosition), positionToStr(position), 'positionAt mismatch for offset ' + offset);
|
||||
} else {
|
||||
// The position coordinate system cannot express the position between \r and \n
|
||||
let expectedOffset = offset + (previousIsCarriageReturn ? -1 : 0);
|
||||
let expectedOffset: number = offset + (previousIsCarriageReturn ? -1 : 0);
|
||||
let actualOffset = doc.document.offsetAt(position);
|
||||
assert.equal(actualOffset, expectedOffset, 'offsetAt mismatch for position ' + positionToStr(position));
|
||||
assert.strictEqual(actualOffset, expectedOffset, 'offsetAt mismatch for position ' + positionToStr(position));
|
||||
}
|
||||
|
||||
if (allText.charAt(offset) === '\n') {
|
||||
|
||||
@@ -379,7 +379,7 @@ suite('ExtHostDocumentSaveParticipant', () => {
|
||||
test('Log failing listener', function () {
|
||||
let didLogSomething = false;
|
||||
let participant = new ExtHostDocumentSaveParticipant(new class extends NullLogService {
|
||||
error(message: string | Error, ...args: any[]): void {
|
||||
override error(message: string | Error, ...args: any[]): void {
|
||||
didLogSomething = true;
|
||||
}
|
||||
}, documents, mainThreadBulkEdits);
|
||||
|
||||
@@ -259,7 +259,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
}));
|
||||
disposables.push(extHost.registerDefinitionProvider(defaultExtension, defaultSelector, new class implements vscode.DefinitionProvider {
|
||||
provideDefinition(): any {
|
||||
return new types.Location(model.uri, new types.Range(1, 1, 1, 1));
|
||||
return new types.Location(model.uri, new types.Range(2, 1, 1, 1));
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -591,7 +591,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
}));
|
||||
|
||||
await rpcProtocol.sync();
|
||||
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: modes.CodeActionTriggerType.Manual }, Progress.None, CancellationToken.None);
|
||||
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: modes.CodeActionTriggerType.Invoke }, Progress.None, CancellationToken.None);
|
||||
assert.strictEqual(actions.length, 2);
|
||||
const [first, second] = actions;
|
||||
assert.strictEqual(first.action.title, 'Testing1');
|
||||
@@ -615,7 +615,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
}));
|
||||
|
||||
await rpcProtocol.sync();
|
||||
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: modes.CodeActionTriggerType.Manual }, Progress.None, CancellationToken.None);
|
||||
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: modes.CodeActionTriggerType.Invoke }, Progress.None, CancellationToken.None);
|
||||
assert.strictEqual(actions.length, 1);
|
||||
const [first] = actions;
|
||||
assert.strictEqual(first.action.title, 'Testing1');
|
||||
@@ -638,7 +638,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
}));
|
||||
|
||||
await rpcProtocol.sync();
|
||||
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: modes.CodeActionTriggerType.Manual }, Progress.None, CancellationToken.None);
|
||||
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: modes.CodeActionTriggerType.Invoke }, Progress.None, CancellationToken.None);
|
||||
assert.strictEqual(actions.length, 1);
|
||||
});
|
||||
|
||||
@@ -656,7 +656,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
}));
|
||||
|
||||
await rpcProtocol.sync();
|
||||
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: modes.CodeActionTriggerType.Manual }, Progress.None, CancellationToken.None);
|
||||
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: modes.CodeActionTriggerType.Invoke }, Progress.None, CancellationToken.None);
|
||||
assert.strictEqual(actions.length, 1);
|
||||
});
|
||||
|
||||
@@ -966,7 +966,7 @@ suite('ExtHostLanguageFeatures', function () {
|
||||
// --- format
|
||||
|
||||
const NullWorkerService = new class extends mock<IEditorWorkerService>() {
|
||||
computeMoreMinimalEdits(resource: URI, edits: modes.TextEdit[] | null | undefined): Promise<modes.TextEdit[] | undefined> {
|
||||
override computeMoreMinimalEdits(resource: URI, edits: modes.TextEdit[] | null | undefined): Promise<modes.TextEdit[] | undefined> {
|
||||
return Promise.resolve(withNullAsUndefined(edits));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -11,6 +11,7 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
|
||||
const emptyDialogService = new class implements IDialogService {
|
||||
declare readonly _serviceBrand: undefined;
|
||||
@@ -42,6 +43,8 @@ const emptyCommandService: ICommandService = {
|
||||
|
||||
const emptyNotificationService = new class implements INotificationService {
|
||||
declare readonly _serviceBrand: undefined;
|
||||
onDidAddNotification: Event<INotification> = Event.None;
|
||||
onDidRemoveNotification: Event<INotification> = Event.None;
|
||||
notify(...args: any[]): never {
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
@@ -71,6 +74,8 @@ class EmptyNotificationService implements INotificationService {
|
||||
constructor(private withNotify: (notification: INotification) => void) {
|
||||
}
|
||||
|
||||
onDidAddNotification: Event<INotification> = Event.None;
|
||||
onDidRemoveNotification: Event<INotification> = Event.None;
|
||||
notify(notification: INotification): INotificationHandle {
|
||||
this.withNotify(notification);
|
||||
|
||||
@@ -112,7 +117,7 @@ suite('ExtHostMessageService', function () {
|
||||
suite('modal', () => {
|
||||
test('calls dialog service', async () => {
|
||||
const service = new MainThreadMessageService(null!, emptyNotificationService, emptyCommandService, new class extends mock<IDialogService>() {
|
||||
show(severity: Severity, message: string, buttons: string[]) {
|
||||
override show(severity: Severity, message: string, buttons: string[]) {
|
||||
assert.strictEqual(severity, 1);
|
||||
assert.strictEqual(message, 'h');
|
||||
assert.strictEqual(buttons.length, 2);
|
||||
@@ -127,7 +132,7 @@ suite('ExtHostMessageService', function () {
|
||||
|
||||
test('returns undefined when cancelled', async () => {
|
||||
const service = new MainThreadMessageService(null!, emptyNotificationService, emptyCommandService, new class extends mock<IDialogService>() {
|
||||
show() {
|
||||
override show() {
|
||||
return Promise.resolve({ choice: 1 });
|
||||
}
|
||||
} as IDialogService);
|
||||
@@ -138,7 +143,7 @@ suite('ExtHostMessageService', function () {
|
||||
|
||||
test('hides Cancel button when not needed', async () => {
|
||||
const service = new MainThreadMessageService(null!, emptyNotificationService, emptyCommandService, new class extends mock<IDialogService>() {
|
||||
show(severity: Severity, message: string, buttons: string[]) {
|
||||
override show(severity: Severity, message: string, buttons: string[]) {
|
||||
assert.strictEqual(buttons.length, 1);
|
||||
return Promise.resolve({ choice: 0 });
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import { mock } from 'vs/base/test/common/mock';
|
||||
import { IModelAddedData, MainContext, MainThreadCommandsShape, MainThreadNotebookShape } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { ExtHostNotebookController } from 'vs/workbench/api/common/extHostNotebook';
|
||||
import { ExtHostNotebookDocument } from 'vs/workbench/api/common/extHostNotebookDocument';
|
||||
import { CellKind, CellUri, NotebookCellsChangeType } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import { CellKind, CellUri, NotebookCellExecutionState, NotebookCellsChangeType } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ExtHostDocuments } from 'vs/workbench/api/common/extHostDocuments';
|
||||
import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
|
||||
@@ -21,6 +21,7 @@ import { nullExtensionDescription } from 'vs/workbench/services/extensions/commo
|
||||
import { isEqual } from 'vs/base/common/resources';
|
||||
import { IExtensionStoragePaths } from 'vs/workbench/api/common/extHostStoragePaths';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
|
||||
suite('NotebookCell#Document', function () {
|
||||
|
||||
@@ -33,25 +34,27 @@ suite('NotebookCell#Document', function () {
|
||||
const notebookUri = URI.parse('test:///notebook.file');
|
||||
const disposables = new DisposableStore();
|
||||
|
||||
setup(async function () {
|
||||
teardown(function () {
|
||||
disposables.clear();
|
||||
});
|
||||
|
||||
setup(async function () {
|
||||
rpcProtocol = new TestRPCProtocol();
|
||||
rpcProtocol.set(MainContext.MainThreadCommands, new class extends mock<MainThreadCommandsShape>() {
|
||||
$registerCommand() { }
|
||||
override $registerCommand() { }
|
||||
});
|
||||
rpcProtocol.set(MainContext.MainThreadNotebook, new class extends mock<MainThreadNotebookShape>() {
|
||||
async $registerNotebookProvider() { }
|
||||
async $unregisterNotebookProvider() { }
|
||||
override async $registerNotebookProvider() { }
|
||||
override async $unregisterNotebookProvider() { }
|
||||
});
|
||||
extHostDocumentsAndEditors = new ExtHostDocumentsAndEditors(rpcProtocol, new NullLogService());
|
||||
extHostDocuments = new ExtHostDocuments(rpcProtocol, extHostDocumentsAndEditors);
|
||||
const extHostStoragePaths = new class extends mock<IExtensionStoragePaths>() {
|
||||
workspaceValue() {
|
||||
override workspaceValue() {
|
||||
return URI.from({ scheme: 'test', path: generateUuid() });
|
||||
}
|
||||
};
|
||||
extHostNotebooks = new ExtHostNotebookController(rpcProtocol, new ExtHostCommands(rpcProtocol, new NullLogService()), extHostDocumentsAndEditors, { isExtensionDevelopmentDebug: false, webviewCspSource: '', webviewResourceRoot: '' }, new NullLogService(), extHostStoragePaths);
|
||||
extHostNotebooks = new ExtHostNotebookController(rpcProtocol, new ExtHostCommands(rpcProtocol, new NullLogService()), extHostDocumentsAndEditors, extHostDocuments, new NullLogService(), extHostStoragePaths);
|
||||
let reg = extHostNotebooks.registerNotebookContentProvider(nullExtensionDescription, 'test', new class extends mock<vscode.NotebookContentProvider>() {
|
||||
// async openNotebook() { }
|
||||
});
|
||||
@@ -77,12 +80,11 @@ suite('NotebookCell#Document', function () {
|
||||
cellKind: CellKind.Code,
|
||||
outputs: [],
|
||||
}],
|
||||
contentOptions: { transientMetadata: {}, transientOutputs: false }
|
||||
}],
|
||||
addedEditors: [{
|
||||
documentUri: notebookUri,
|
||||
id: '_notebook_editor_0',
|
||||
selections: [0],
|
||||
selections: [{ start: 0, end: 1 }],
|
||||
visibleRanges: []
|
||||
}]
|
||||
});
|
||||
@@ -98,28 +100,28 @@ suite('NotebookCell#Document', function () {
|
||||
|
||||
test('cell document is vscode.TextDocument', async function () {
|
||||
|
||||
assert.strictEqual(notebook.notebookDocument.cells.length, 2);
|
||||
assert.strictEqual(notebook.apiNotebook.cellCount, 2);
|
||||
|
||||
const [c1, c2] = notebook.notebookDocument.cells;
|
||||
const d1 = extHostDocuments.getDocument(c1.uri);
|
||||
const [c1, c2] = notebook.apiNotebook.getCells();
|
||||
const d1 = extHostDocuments.getDocument(c1.document.uri);
|
||||
|
||||
assert.ok(d1);
|
||||
assert.strictEqual(d1.languageId, c1.language);
|
||||
assert.strictEqual(d1.languageId, c1.document.languageId);
|
||||
assert.strictEqual(d1.version, 1);
|
||||
assert.ok(d1.notebook === notebook.notebookDocument);
|
||||
assert.ok(d1.notebook === notebook.apiNotebook);
|
||||
|
||||
const d2 = extHostDocuments.getDocument(c2.uri);
|
||||
const d2 = extHostDocuments.getDocument(c2.document.uri);
|
||||
assert.ok(d2);
|
||||
assert.strictEqual(d2.languageId, c2.language);
|
||||
assert.strictEqual(d2.languageId, c2.document.languageId);
|
||||
assert.strictEqual(d2.version, 1);
|
||||
assert.ok(d2.notebook === notebook.notebookDocument);
|
||||
assert.ok(d2.notebook === notebook.apiNotebook);
|
||||
});
|
||||
|
||||
test('cell document goes when notebook closes', async function () {
|
||||
const cellUris: string[] = [];
|
||||
for (let cell of notebook.notebookDocument.cells) {
|
||||
assert.ok(extHostDocuments.getDocument(cell.uri));
|
||||
cellUris.push(cell.uri.toString());
|
||||
for (let cell of notebook.apiNotebook.getCells()) {
|
||||
assert.ok(extHostDocuments.getDocument(cell.document.uri));
|
||||
cellUris.push(cell.document.uri.toString());
|
||||
}
|
||||
|
||||
const removedCellUris: string[] = [];
|
||||
@@ -144,11 +146,11 @@ suite('NotebookCell#Document', function () {
|
||||
|
||||
const [first, second] = e.changes[0].items;
|
||||
|
||||
const doc1 = extHostDocuments.getAllDocumentData().find(data => isEqual(data.document.uri, first.uri));
|
||||
const doc1 = extHostDocuments.getAllDocumentData().find(data => isEqual(data.document.uri, first.document.uri));
|
||||
assert.ok(doc1);
|
||||
assert.strictEqual(doc1?.document === first.document, true);
|
||||
|
||||
const doc2 = extHostDocuments.getAllDocumentData().find(data => isEqual(data.document.uri, second.uri));
|
||||
const doc2 = extHostDocuments.getAllDocumentData().find(data => isEqual(data.document.uri, second.document.uri));
|
||||
assert.ok(doc2);
|
||||
assert.strictEqual(doc2?.document === second.document, true);
|
||||
|
||||
@@ -161,7 +163,7 @@ suite('NotebookCell#Document', function () {
|
||||
});
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
versionId: notebook.apiNotebook.version + 1,
|
||||
rawEvents: [
|
||||
{
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
@@ -194,10 +196,10 @@ suite('NotebookCell#Document', function () {
|
||||
|
||||
const docs: vscode.TextDocument[] = [];
|
||||
const addData: IModelAddedData[] = [];
|
||||
for (let cell of notebook.notebookDocument.cells) {
|
||||
const doc = extHostDocuments.getDocument(cell.uri);
|
||||
for (let cell of notebook.apiNotebook.getCells()) {
|
||||
const doc = extHostDocuments.getDocument(cell.document.uri);
|
||||
assert.ok(doc);
|
||||
assert.strictEqual(extHostDocuments.getDocument(cell.uri).isClosed, false);
|
||||
assert.strictEqual(extHostDocuments.getDocument(cell.document.uri).isClosed, false);
|
||||
docs.push(doc);
|
||||
addData.push({
|
||||
EOL: '\n',
|
||||
@@ -216,15 +218,15 @@ suite('NotebookCell#Document', function () {
|
||||
extHostDocumentsAndEditors.$acceptDocumentsAndEditorsDelta({ removedDocuments: docs.map(d => d.uri) });
|
||||
|
||||
// notebook is still open -> cell documents stay open
|
||||
for (let cell of notebook.notebookDocument.cells) {
|
||||
assert.ok(extHostDocuments.getDocument(cell.uri));
|
||||
assert.strictEqual(extHostDocuments.getDocument(cell.uri).isClosed, false);
|
||||
for (let cell of notebook.apiNotebook.getCells()) {
|
||||
assert.ok(extHostDocuments.getDocument(cell.document.uri));
|
||||
assert.strictEqual(extHostDocuments.getDocument(cell.document.uri).isClosed, false);
|
||||
}
|
||||
|
||||
// close notebook -> docs are closed
|
||||
extHostNotebooks.$acceptDocumentAndEditorsDelta({ removedDocuments: [notebook.uri] });
|
||||
for (let cell of notebook.notebookDocument.cells) {
|
||||
assert.throws(() => extHostDocuments.getDocument(cell.uri));
|
||||
for (let cell of notebook.apiNotebook.getCells()) {
|
||||
assert.throws(() => extHostDocuments.getDocument(cell.document.uri));
|
||||
}
|
||||
for (let doc of docs) {
|
||||
assert.strictEqual(doc.isClosed, true);
|
||||
@@ -233,8 +235,8 @@ suite('NotebookCell#Document', function () {
|
||||
|
||||
test('cell document goes when cell is removed', async function () {
|
||||
|
||||
assert.strictEqual(notebook.notebookDocument.cells.length, 2);
|
||||
const [cell1, cell2] = notebook.notebookDocument.cells;
|
||||
assert.strictEqual(notebook.apiNotebook.cellCount, 2);
|
||||
const [cell1, cell2] = notebook.apiNotebook.getCells();
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebook.uri, {
|
||||
versionId: 2,
|
||||
@@ -246,40 +248,40 @@ suite('NotebookCell#Document', function () {
|
||||
]
|
||||
}, false);
|
||||
|
||||
assert.strictEqual(notebook.notebookDocument.cells.length, 1);
|
||||
assert.strictEqual(notebook.apiNotebook.cellCount, 1);
|
||||
assert.strictEqual(cell1.document.isClosed, true); // ref still alive!
|
||||
assert.strictEqual(cell2.document.isClosed, false);
|
||||
|
||||
assert.throws(() => extHostDocuments.getDocument(cell1.uri));
|
||||
assert.throws(() => extHostDocuments.getDocument(cell1.document.uri));
|
||||
});
|
||||
|
||||
test('cell document knows notebook', function () {
|
||||
for (let cells of notebook.notebookDocument.cells) {
|
||||
assert.strictEqual(cells.document.notebook === notebook.notebookDocument, true);
|
||||
for (let cells of notebook.apiNotebook.getCells()) {
|
||||
assert.strictEqual(cells.document.notebook === notebook.apiNotebook, true);
|
||||
}
|
||||
});
|
||||
|
||||
test('cell#index', function () {
|
||||
|
||||
assert.strictEqual(notebook.notebookDocument.cells.length, 2);
|
||||
const [first, second] = notebook.notebookDocument.cells;
|
||||
assert.strictEqual(notebook.apiNotebook.cellCount, 2);
|
||||
const [first, second] = notebook.apiNotebook.getCells();
|
||||
assert.strictEqual(first.index, 0);
|
||||
assert.strictEqual(second.index, 1);
|
||||
|
||||
// remove first cell
|
||||
extHostNotebooks.$acceptModelChanged(notebook.uri, {
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
versionId: notebook.apiNotebook.version + 1,
|
||||
rawEvents: [{
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
changes: [[0, 1, []]]
|
||||
}]
|
||||
}, false);
|
||||
|
||||
assert.strictEqual(notebook.notebookDocument.cells.length, 1);
|
||||
assert.strictEqual(notebook.apiNotebook.cellCount, 1);
|
||||
assert.strictEqual(second.index, 0);
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
versionId: notebook.apiNotebook.version + 1,
|
||||
rawEvents: [{
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
changes: [[0, 0, [{
|
||||
@@ -302,7 +304,138 @@ suite('NotebookCell#Document', function () {
|
||||
}]
|
||||
}, false);
|
||||
|
||||
assert.strictEqual(notebook.notebookDocument.cells.length, 3);
|
||||
assert.strictEqual(notebook.apiNotebook.cellCount, 3);
|
||||
assert.strictEqual(second.index, 2);
|
||||
});
|
||||
|
||||
test('ERR MISSING extHostDocument for notebook cell: #116711', async function () {
|
||||
|
||||
const p = Event.toPromise(extHostNotebooks.onDidChangeNotebookCells);
|
||||
|
||||
// DON'T call this, make sure the cell-documents have not been created yet
|
||||
// assert.strictEqual(notebook.notebookDocument.cellCount, 2);
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebook.uri, {
|
||||
versionId: 100,
|
||||
rawEvents: [{
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
changes: [[0, 2, [{
|
||||
handle: 3,
|
||||
uri: CellUri.generate(notebookUri, 3),
|
||||
source: ['### Heading'],
|
||||
eol: '\n',
|
||||
language: 'markdown',
|
||||
cellKind: CellKind.Markdown,
|
||||
outputs: [],
|
||||
}, {
|
||||
handle: 4,
|
||||
uri: CellUri.generate(notebookUri, 4),
|
||||
source: ['console.log("aaa")', 'console.log("bbb")'],
|
||||
eol: '\n',
|
||||
language: 'javascript',
|
||||
cellKind: CellKind.Code,
|
||||
outputs: [],
|
||||
}]]]
|
||||
}]
|
||||
}, false);
|
||||
|
||||
assert.strictEqual(notebook.apiNotebook.cellCount, 2);
|
||||
|
||||
const event = await p;
|
||||
|
||||
assert.strictEqual(event.document === notebook.apiNotebook, true);
|
||||
assert.strictEqual(event.changes.length, 1);
|
||||
assert.strictEqual(event.changes[0].deletedCount, 2);
|
||||
assert.strictEqual(event.changes[0].deletedItems[0].document.isClosed, true);
|
||||
assert.strictEqual(event.changes[0].deletedItems[1].document.isClosed, true);
|
||||
assert.strictEqual(event.changes[0].items.length, 2);
|
||||
assert.strictEqual(event.changes[0].items[0].document.isClosed, false);
|
||||
assert.strictEqual(event.changes[0].items[1].document.isClosed, false);
|
||||
});
|
||||
|
||||
|
||||
test('Opening a notebook results in VS Code firing the event onDidChangeActiveNotebookEditor twice #118470', function () {
|
||||
let count = 0;
|
||||
extHostNotebooks.onDidChangeActiveNotebookEditor(() => count += 1);
|
||||
|
||||
extHostNotebooks.$acceptDocumentAndEditorsDelta({
|
||||
addedEditors: [{
|
||||
documentUri: notebookUri,
|
||||
id: '_notebook_editor_2',
|
||||
selections: [{ start: 0, end: 1 }],
|
||||
visibleRanges: []
|
||||
}]
|
||||
});
|
||||
|
||||
extHostNotebooks.$acceptDocumentAndEditorsDelta({
|
||||
newActiveEditor: '_notebook_editor_2'
|
||||
});
|
||||
|
||||
assert.strictEqual(count, 1);
|
||||
});
|
||||
|
||||
test('unset active notebook editor', function () {
|
||||
|
||||
const editor = extHostNotebooks.activeNotebookEditor;
|
||||
assert.ok(editor !== undefined);
|
||||
|
||||
extHostNotebooks.$acceptDocumentAndEditorsDelta({ newActiveEditor: undefined });
|
||||
assert.ok(extHostNotebooks.activeNotebookEditor === editor);
|
||||
|
||||
extHostNotebooks.$acceptDocumentAndEditorsDelta({});
|
||||
assert.ok(extHostNotebooks.activeNotebookEditor === editor);
|
||||
|
||||
extHostNotebooks.$acceptDocumentAndEditorsDelta({ newActiveEditor: null });
|
||||
assert.ok(extHostNotebooks.activeNotebookEditor === undefined);
|
||||
});
|
||||
|
||||
test('change cell language triggers onDidChange events', async function () {
|
||||
|
||||
const first = notebook.apiNotebook.cellAt(0);
|
||||
|
||||
assert.strictEqual(first.document.languageId, 'markdown');
|
||||
|
||||
const removed = Event.toPromise(extHostDocuments.onDidRemoveDocument);
|
||||
const added = Event.toPromise(extHostDocuments.onDidAddDocument);
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebook.uri, {
|
||||
versionId: 12, rawEvents: [{
|
||||
kind: NotebookCellsChangeType.ChangeLanguage,
|
||||
index: 0,
|
||||
language: 'fooLang'
|
||||
}]
|
||||
}, false);
|
||||
|
||||
const removedDoc = await removed;
|
||||
const addedDoc = await added;
|
||||
|
||||
assert.strictEqual(first.document.languageId, 'fooLang');
|
||||
assert.ok(removedDoc === addedDoc);
|
||||
});
|
||||
|
||||
test('change cell execution state does not trigger onDidChangeMetadata event', async function () {
|
||||
let didFireOnDidChangeMetadata = false;
|
||||
let e = extHostNotebooks.onDidChangeCellMetadata(() => {
|
||||
didFireOnDidChangeMetadata = true;
|
||||
});
|
||||
|
||||
const changeExeState = Event.toPromise(extHostNotebooks.onDidChangeNotebookCellExecutionState);
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebook.uri, {
|
||||
versionId: 12, rawEvents: [{
|
||||
kind: NotebookCellsChangeType.ChangeCellMetadata,
|
||||
index: 0,
|
||||
metadata: {
|
||||
...notebook.getCellFromIndex(0)?.internalMetadata,
|
||||
...{
|
||||
runState: NotebookCellExecutionState.Executing
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, false);
|
||||
|
||||
await changeExeState;
|
||||
assert.strictEqual(didFireOnDidChangeMetadata, false);
|
||||
e.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -38,20 +38,20 @@ suite('NotebookConcatDocument', function () {
|
||||
|
||||
rpcProtocol = new TestRPCProtocol();
|
||||
rpcProtocol.set(MainContext.MainThreadCommands, new class extends mock<MainThreadCommandsShape>() {
|
||||
$registerCommand() { }
|
||||
override $registerCommand() { }
|
||||
});
|
||||
rpcProtocol.set(MainContext.MainThreadNotebook, new class extends mock<MainThreadNotebookShape>() {
|
||||
async $registerNotebookProvider() { }
|
||||
async $unregisterNotebookProvider() { }
|
||||
override async $registerNotebookProvider() { }
|
||||
override async $unregisterNotebookProvider() { }
|
||||
});
|
||||
extHostDocumentsAndEditors = new ExtHostDocumentsAndEditors(rpcProtocol, new NullLogService());
|
||||
extHostDocuments = new ExtHostDocuments(rpcProtocol, extHostDocumentsAndEditors);
|
||||
const extHostStoragePaths = new class extends mock<IExtensionStoragePaths>() {
|
||||
workspaceValue() {
|
||||
override workspaceValue() {
|
||||
return URI.from({ scheme: 'test', path: generateUuid() });
|
||||
}
|
||||
};
|
||||
extHostNotebooks = new ExtHostNotebookController(rpcProtocol, new ExtHostCommands(rpcProtocol, new NullLogService()), extHostDocumentsAndEditors, { isExtensionDevelopmentDebug: false, webviewCspSource: '', webviewResourceRoot: '' }, new NullLogService(), extHostStoragePaths);
|
||||
extHostNotebooks = new ExtHostNotebookController(rpcProtocol, new ExtHostCommands(rpcProtocol, new NullLogService()), extHostDocumentsAndEditors, extHostDocuments, new NullLogService(), extHostStoragePaths);
|
||||
let reg = extHostNotebooks.registerNotebookContentProvider(nullExtensionDescription, 'test', new class extends mock<vscode.NotebookContentProvider>() {
|
||||
// async openNotebook() { }
|
||||
});
|
||||
@@ -68,17 +68,14 @@ suite('NotebookConcatDocument', function () {
|
||||
cellKind: CellKind.Markdown,
|
||||
outputs: [],
|
||||
}],
|
||||
contentOptions: { transientOutputs: false, transientMetadata: {} },
|
||||
versionId: 0
|
||||
}],
|
||||
addedEditors: [
|
||||
{
|
||||
documentUri: notebookUri,
|
||||
id: '_notebook_editor_0',
|
||||
selections: [0],
|
||||
visibleRanges: []
|
||||
}
|
||||
]
|
||||
addedEditors: [{
|
||||
documentUri: notebookUri,
|
||||
id: '_notebook_editor_0',
|
||||
selections: [{ start: 0, end: 1 }],
|
||||
visibleRanges: []
|
||||
}]
|
||||
});
|
||||
extHostNotebooks.$acceptDocumentAndEditorsDelta({ newActiveEditor: '_notebook_editor_0' });
|
||||
|
||||
@@ -90,7 +87,7 @@ suite('NotebookConcatDocument', function () {
|
||||
});
|
||||
|
||||
test('empty', function () {
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.apiNotebook, undefined);
|
||||
assert.strictEqual(doc.getText(), '');
|
||||
assert.strictEqual(doc.version, 0);
|
||||
|
||||
@@ -126,7 +123,7 @@ suite('NotebookConcatDocument', function () {
|
||||
const cellUri2 = CellUri.generate(notebook.uri, 2);
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
versionId: notebook.apiNotebook.version + 1,
|
||||
rawEvents: [{
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
changes: [[0, 0, [{
|
||||
@@ -151,9 +148,9 @@ suite('NotebookConcatDocument', function () {
|
||||
}, false);
|
||||
|
||||
|
||||
assert.strictEqual(notebook.notebookDocument.cells.length, 1 + 2); // markdown and code
|
||||
assert.strictEqual(notebook.apiNotebook.cellCount, 1 + 2); // markdown and code
|
||||
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.apiNotebook, undefined);
|
||||
|
||||
assert.strictEqual(doc.contains(cellUri1), true);
|
||||
assert.strictEqual(doc.contains(cellUri2), true);
|
||||
@@ -163,7 +160,7 @@ suite('NotebookConcatDocument', function () {
|
||||
test('location, position mapping', function () {
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
versionId: notebook.apiNotebook.version + 1,
|
||||
rawEvents: [
|
||||
{
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
@@ -189,26 +186,26 @@ suite('NotebookConcatDocument', function () {
|
||||
}, false);
|
||||
|
||||
|
||||
assert.strictEqual(notebook.notebookDocument.cells.length, 1 + 2); // markdown and code
|
||||
assert.strictEqual(notebook.apiNotebook.cellCount, 1 + 2); // markdown and code
|
||||
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.apiNotebook, undefined);
|
||||
assertLines(doc, 'Hello', 'World', 'Hello World!', 'Hallo', 'Welt', 'Hallo Welt!');
|
||||
|
||||
assertLocation(doc, new Position(0, 0), new Location(notebook.notebookDocument.cells[0].uri, new Position(0, 0)));
|
||||
assertLocation(doc, new Position(4, 0), new Location(notebook.notebookDocument.cells[1].uri, new Position(1, 0)));
|
||||
assertLocation(doc, new Position(4, 3), new Location(notebook.notebookDocument.cells[1].uri, new Position(1, 3)));
|
||||
assertLocation(doc, new Position(5, 11), new Location(notebook.notebookDocument.cells[1].uri, new Position(2, 11)));
|
||||
assertLocation(doc, new Position(5, 12), new Location(notebook.notebookDocument.cells[1].uri, new Position(2, 11)), false); // don't check identity because position will be clamped
|
||||
assertLocation(doc, new Position(0, 0), new Location(notebook.apiNotebook.cellAt(0).document.uri, new Position(0, 0)));
|
||||
assertLocation(doc, new Position(4, 0), new Location(notebook.apiNotebook.cellAt(1).document.uri, new Position(1, 0)));
|
||||
assertLocation(doc, new Position(4, 3), new Location(notebook.apiNotebook.cellAt(1).document.uri, new Position(1, 3)));
|
||||
assertLocation(doc, new Position(5, 11), new Location(notebook.apiNotebook.cellAt(1).document.uri, new Position(2, 11)));
|
||||
assertLocation(doc, new Position(5, 12), new Location(notebook.apiNotebook.cellAt(1).document.uri, new Position(2, 11)), false); // don't check identity because position will be clamped
|
||||
});
|
||||
|
||||
|
||||
test('location, position mapping, cell changes', function () {
|
||||
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.apiNotebook, undefined);
|
||||
|
||||
// UPDATE 1
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
versionId: notebook.apiNotebook.version + 1,
|
||||
rawEvents: [
|
||||
{
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
@@ -224,18 +221,18 @@ suite('NotebookConcatDocument', function () {
|
||||
}
|
||||
]
|
||||
}, false);
|
||||
assert.strictEqual(notebook.notebookDocument.cells.length, 1 + 1);
|
||||
assert.strictEqual(notebook.apiNotebook.cellCount, 1 + 1);
|
||||
assert.strictEqual(doc.version, 1);
|
||||
assertLines(doc, 'Hello', 'World', 'Hello World!');
|
||||
|
||||
assertLocation(doc, new Position(0, 0), new Location(notebook.notebookDocument.cells[0].uri, new Position(0, 0)));
|
||||
assertLocation(doc, new Position(2, 2), new Location(notebook.notebookDocument.cells[0].uri, new Position(2, 2)));
|
||||
assertLocation(doc, new Position(4, 0), new Location(notebook.notebookDocument.cells[0].uri, new Position(2, 12)), false); // clamped
|
||||
assertLocation(doc, new Position(0, 0), new Location(notebook.apiNotebook.cellAt(0).document.uri, new Position(0, 0)));
|
||||
assertLocation(doc, new Position(2, 2), new Location(notebook.apiNotebook.cellAt(0).document.uri, new Position(2, 2)));
|
||||
assertLocation(doc, new Position(4, 0), new Location(notebook.apiNotebook.cellAt(0).document.uri, new Position(2, 12)), false); // clamped
|
||||
|
||||
|
||||
// UPDATE 2
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
versionId: notebook.apiNotebook.version + 1,
|
||||
rawEvents: [
|
||||
{
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
@@ -252,18 +249,18 @@ suite('NotebookConcatDocument', function () {
|
||||
]
|
||||
}, false);
|
||||
|
||||
assert.strictEqual(notebook.notebookDocument.cells.length, 1 + 2);
|
||||
assert.strictEqual(notebook.apiNotebook.cellCount, 1 + 2);
|
||||
assert.strictEqual(doc.version, 2);
|
||||
assertLines(doc, 'Hello', 'World', 'Hello World!', 'Hallo', 'Welt', 'Hallo Welt!');
|
||||
assertLocation(doc, new Position(0, 0), new Location(notebook.notebookDocument.cells[0].uri, new Position(0, 0)));
|
||||
assertLocation(doc, new Position(4, 0), new Location(notebook.notebookDocument.cells[1].uri, new Position(1, 0)));
|
||||
assertLocation(doc, new Position(4, 3), new Location(notebook.notebookDocument.cells[1].uri, new Position(1, 3)));
|
||||
assertLocation(doc, new Position(5, 11), new Location(notebook.notebookDocument.cells[1].uri, new Position(2, 11)));
|
||||
assertLocation(doc, new Position(5, 12), new Location(notebook.notebookDocument.cells[1].uri, new Position(2, 11)), false); // don't check identity because position will be clamped
|
||||
assertLocation(doc, new Position(0, 0), new Location(notebook.apiNotebook.cellAt(0).document.uri, new Position(0, 0)));
|
||||
assertLocation(doc, new Position(4, 0), new Location(notebook.apiNotebook.cellAt(1).document.uri, new Position(1, 0)));
|
||||
assertLocation(doc, new Position(4, 3), new Location(notebook.apiNotebook.cellAt(1).document.uri, new Position(1, 3)));
|
||||
assertLocation(doc, new Position(5, 11), new Location(notebook.apiNotebook.cellAt(1).document.uri, new Position(2, 11)));
|
||||
assertLocation(doc, new Position(5, 12), new Location(notebook.apiNotebook.cellAt(1).document.uri, new Position(2, 11)), false); // don't check identity because position will be clamped
|
||||
|
||||
// UPDATE 3 (remove cell #2 again)
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
versionId: notebook.apiNotebook.version + 1,
|
||||
rawEvents: [
|
||||
{
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
@@ -271,21 +268,21 @@ suite('NotebookConcatDocument', function () {
|
||||
}
|
||||
]
|
||||
}, false);
|
||||
assert.strictEqual(notebook.notebookDocument.cells.length, 1 + 1);
|
||||
assert.strictEqual(notebook.apiNotebook.cellCount, 1 + 1);
|
||||
assert.strictEqual(doc.version, 3);
|
||||
assertLines(doc, 'Hello', 'World', 'Hello World!');
|
||||
assertLocation(doc, new Position(0, 0), new Location(notebook.notebookDocument.cells[0].uri, new Position(0, 0)));
|
||||
assertLocation(doc, new Position(2, 2), new Location(notebook.notebookDocument.cells[0].uri, new Position(2, 2)));
|
||||
assertLocation(doc, new Position(4, 0), new Location(notebook.notebookDocument.cells[0].uri, new Position(2, 12)), false); // clamped
|
||||
assertLocation(doc, new Position(0, 0), new Location(notebook.apiNotebook.cellAt(0).document.uri, new Position(0, 0)));
|
||||
assertLocation(doc, new Position(2, 2), new Location(notebook.apiNotebook.cellAt(0).document.uri, new Position(2, 2)));
|
||||
assertLocation(doc, new Position(4, 0), new Location(notebook.apiNotebook.cellAt(0).document.uri, new Position(2, 12)), false); // clamped
|
||||
});
|
||||
|
||||
test('location, position mapping, cell-document changes', function () {
|
||||
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.apiNotebook, undefined);
|
||||
|
||||
// UPDATE 1
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
versionId: notebook.apiNotebook.version + 1,
|
||||
rawEvents: [
|
||||
{
|
||||
|
||||
@@ -310,21 +307,21 @@ suite('NotebookConcatDocument', function () {
|
||||
}
|
||||
]
|
||||
}, false);
|
||||
assert.strictEqual(notebook.notebookDocument.cells.length, 1 + 2);
|
||||
assert.strictEqual(notebook.apiNotebook.cellCount, 1 + 2);
|
||||
assert.strictEqual(doc.version, 1);
|
||||
|
||||
assertLines(doc, 'Hello', 'World', 'Hello World!', 'Hallo', 'Welt', 'Hallo Welt!');
|
||||
assertLocation(doc, new Position(0, 0), new Location(notebook.notebookDocument.cells[0].uri, new Position(0, 0)));
|
||||
assertLocation(doc, new Position(2, 2), new Location(notebook.notebookDocument.cells[0].uri, new Position(2, 2)));
|
||||
assertLocation(doc, new Position(2, 12), new Location(notebook.notebookDocument.cells[0].uri, new Position(2, 12)));
|
||||
assertLocation(doc, new Position(4, 0), new Location(notebook.notebookDocument.cells[1].uri, new Position(1, 0)));
|
||||
assertLocation(doc, new Position(4, 3), new Location(notebook.notebookDocument.cells[1].uri, new Position(1, 3)));
|
||||
assertLocation(doc, new Position(0, 0), new Location(notebook.apiNotebook.cellAt(0).document.uri, new Position(0, 0)));
|
||||
assertLocation(doc, new Position(2, 2), new Location(notebook.apiNotebook.cellAt(0).document.uri, new Position(2, 2)));
|
||||
assertLocation(doc, new Position(2, 12), new Location(notebook.apiNotebook.cellAt(0).document.uri, new Position(2, 12)));
|
||||
assertLocation(doc, new Position(4, 0), new Location(notebook.apiNotebook.cellAt(1).document.uri, new Position(1, 0)));
|
||||
assertLocation(doc, new Position(4, 3), new Location(notebook.apiNotebook.cellAt(1).document.uri, new Position(1, 3)));
|
||||
|
||||
// offset math
|
||||
let cell1End = doc.offsetAt(new Position(2, 12));
|
||||
assert.strictEqual(doc.positionAt(cell1End).isEqual(new Position(2, 12)), true);
|
||||
|
||||
extHostDocuments.$acceptModelChanged(notebook.notebookDocument.cells[0].uri, {
|
||||
extHostDocuments.$acceptModelChanged(notebook.apiNotebook.cellAt(0).document.uri, {
|
||||
versionId: 0,
|
||||
eol: '\n',
|
||||
changes: [{
|
||||
@@ -335,7 +332,7 @@ suite('NotebookConcatDocument', function () {
|
||||
}]
|
||||
}, false);
|
||||
assertLines(doc, 'Hello', 'World', 'Hi World!', 'Hallo', 'Welt', 'Hallo Welt!');
|
||||
assertLocation(doc, new Position(2, 12), new Location(notebook.notebookDocument.cells[0].uri, new Position(2, 9)), false);
|
||||
assertLocation(doc, new Position(2, 12), new Location(notebook.apiNotebook.cellAt(0).document.uri, new Position(2, 9)), false);
|
||||
|
||||
assert.strictEqual(doc.positionAt(cell1End).isEqual(new Position(3, 2)), true);
|
||||
|
||||
@@ -344,7 +341,7 @@ suite('NotebookConcatDocument', function () {
|
||||
test('selector', function () {
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
versionId: notebook.apiNotebook.version + 1,
|
||||
rawEvents: [
|
||||
{
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
@@ -369,16 +366,16 @@ suite('NotebookConcatDocument', function () {
|
||||
]
|
||||
}, false);
|
||||
|
||||
const mixedDoc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
|
||||
const fooLangDoc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, 'fooLang');
|
||||
const barLangDoc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, 'barLang');
|
||||
const mixedDoc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.apiNotebook, undefined);
|
||||
const fooLangDoc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.apiNotebook, 'fooLang');
|
||||
const barLangDoc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.apiNotebook, 'barLang');
|
||||
|
||||
assertLines(mixedDoc, 'fooLang-document', 'barLang-document');
|
||||
assertLines(fooLangDoc, 'fooLang-document');
|
||||
assertLines(barLangDoc, 'barLang-document');
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
versionId: notebook.apiNotebook.version + 1,
|
||||
rawEvents: [
|
||||
{
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
@@ -416,7 +413,7 @@ suite('NotebookConcatDocument', function () {
|
||||
test('offsetAt(position) <-> positionAt(offset)', function () {
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
versionId: notebook.apiNotebook.version + 1,
|
||||
rawEvents: [
|
||||
{
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
@@ -441,9 +438,9 @@ suite('NotebookConcatDocument', function () {
|
||||
]
|
||||
}, false);
|
||||
|
||||
assert.strictEqual(notebook.notebookDocument.cells.length, 1 + 2); // markdown and code
|
||||
assert.strictEqual(notebook.apiNotebook.cellCount, 1 + 2); // markdown and code
|
||||
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.apiNotebook, undefined);
|
||||
assertLines(doc, 'Hello', 'World', 'Hello World!', 'Hallo', 'Welt', 'Hallo Welt!');
|
||||
|
||||
assertOffsetAtPosition(doc, 0, { line: 0, character: 0 });
|
||||
@@ -473,7 +470,7 @@ suite('NotebookConcatDocument', function () {
|
||||
test('locationAt(position) <-> positionAt(location)', function () {
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
versionId: notebook.apiNotebook.version + 1,
|
||||
rawEvents: [
|
||||
{
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
@@ -498,23 +495,23 @@ suite('NotebookConcatDocument', function () {
|
||||
]
|
||||
}, false);
|
||||
|
||||
assert.strictEqual(notebook.notebookDocument.cells.length, 1 + 2); // markdown and code
|
||||
assert.strictEqual(notebook.apiNotebook.cellCount, 1 + 2); // markdown and code
|
||||
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.apiNotebook, undefined);
|
||||
assertLines(doc, 'Hello', 'World', 'Hello World!', 'Hallo', 'Welt', 'Hallo Welt!');
|
||||
|
||||
assertLocationAtPosition(doc, { line: 0, character: 0 }, { uri: notebook.notebookDocument.cells[0].uri, line: 0, character: 0 });
|
||||
assertLocationAtPosition(doc, { line: 2, character: 0 }, { uri: notebook.notebookDocument.cells[0].uri, line: 2, character: 0 });
|
||||
assertLocationAtPosition(doc, { line: 2, character: 12 }, { uri: notebook.notebookDocument.cells[0].uri, line: 2, character: 12 });
|
||||
assertLocationAtPosition(doc, { line: 3, character: 0 }, { uri: notebook.notebookDocument.cells[1].uri, line: 0, character: 0 });
|
||||
assertLocationAtPosition(doc, { line: 5, character: 0 }, { uri: notebook.notebookDocument.cells[1].uri, line: 2, character: 0 });
|
||||
assertLocationAtPosition(doc, { line: 5, character: 11 }, { uri: notebook.notebookDocument.cells[1].uri, line: 2, character: 11 });
|
||||
assertLocationAtPosition(doc, { line: 0, character: 0 }, { uri: notebook.apiNotebook.cellAt(0).document.uri, line: 0, character: 0 });
|
||||
assertLocationAtPosition(doc, { line: 2, character: 0 }, { uri: notebook.apiNotebook.cellAt(0).document.uri, line: 2, character: 0 });
|
||||
assertLocationAtPosition(doc, { line: 2, character: 12 }, { uri: notebook.apiNotebook.cellAt(0).document.uri, line: 2, character: 12 });
|
||||
assertLocationAtPosition(doc, { line: 3, character: 0 }, { uri: notebook.apiNotebook.cellAt(1).document.uri, line: 0, character: 0 });
|
||||
assertLocationAtPosition(doc, { line: 5, character: 0 }, { uri: notebook.apiNotebook.cellAt(1).document.uri, line: 2, character: 0 });
|
||||
assertLocationAtPosition(doc, { line: 5, character: 11 }, { uri: notebook.apiNotebook.cellAt(1).document.uri, line: 2, character: 11 });
|
||||
});
|
||||
|
||||
test('getText(range)', function () {
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
versionId: notebook.apiNotebook.version + 1,
|
||||
rawEvents: [
|
||||
{
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
@@ -539,9 +536,9 @@ suite('NotebookConcatDocument', function () {
|
||||
]
|
||||
}, false);
|
||||
|
||||
assert.strictEqual(notebook.notebookDocument.cells.length, 1 + 2); // markdown and code
|
||||
assert.strictEqual(notebook.apiNotebook.cellCount, 1 + 2); // markdown and code
|
||||
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.apiNotebook, undefined);
|
||||
assertLines(doc, 'Hello', 'World', 'Hello World!', 'Hallo', 'Welt', 'Hallo Welt!');
|
||||
|
||||
assert.strictEqual(doc.getText(new Range(0, 0, 0, 0)), '');
|
||||
@@ -552,7 +549,7 @@ suite('NotebookConcatDocument', function () {
|
||||
test('validateRange/Position', function () {
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
versionId: notebook.apiNotebook.version + 1,
|
||||
rawEvents: [
|
||||
{
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
@@ -577,9 +574,9 @@ suite('NotebookConcatDocument', function () {
|
||||
]
|
||||
}, false);
|
||||
|
||||
assert.strictEqual(notebook.notebookDocument.cells.length, 1 + 2); // markdown and code
|
||||
assert.strictEqual(notebook.apiNotebook.cellCount, 1 + 2); // markdown and code
|
||||
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.apiNotebook, undefined);
|
||||
assertLines(doc, 'Hello', 'World', 'Hello World!', 'Hallo', 'Welt', 'Hallo Welt!');
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { TestRPCProtocol } from 'vs/workbench/test/browser/api/testRPCProtocol';
|
||||
import { ExtHostNotebookController } from 'vs/workbench/api/common/extHostNotebook';
|
||||
import { nullExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { mock } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
import { INotebookKernelDto2, MainContext, MainThreadCommandsShape, MainThreadNotebookKernelsShape } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { ExtHostNotebookKernels } from 'vs/workbench/api/common/extHostNotebookKernels';
|
||||
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
|
||||
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService';
|
||||
|
||||
suite('NotebookKernel', function () {
|
||||
|
||||
let rpcProtocol: TestRPCProtocol;
|
||||
let extHostNotebookKernels: ExtHostNotebookKernels;
|
||||
|
||||
const kernelData = new Map<number, INotebookKernelDto2>();
|
||||
|
||||
setup(async function () {
|
||||
|
||||
kernelData.clear();
|
||||
|
||||
rpcProtocol = new TestRPCProtocol();
|
||||
rpcProtocol.set(MainContext.MainThreadCommands, new class extends mock<MainThreadCommandsShape>() {
|
||||
override $registerCommand() { }
|
||||
});
|
||||
rpcProtocol.set(MainContext.MainThreadNotebookKernels, new class extends mock<MainThreadNotebookKernelsShape>() {
|
||||
override async $addKernel(handle: number, data: INotebookKernelDto2): Promise<void> {
|
||||
kernelData.set(handle, data);
|
||||
}
|
||||
override $removeKernel(handle: number) {
|
||||
kernelData.delete(handle);
|
||||
}
|
||||
override $updateKernel(handle: number, data: Partial<INotebookKernelDto2>) {
|
||||
assert.strictEqual(kernelData.has(handle), true);
|
||||
kernelData.set(handle, { ...kernelData.get(handle)!, ...data, });
|
||||
}
|
||||
});
|
||||
|
||||
extHostNotebookKernels = new ExtHostNotebookKernels(
|
||||
rpcProtocol,
|
||||
new class extends mock<IExtHostInitDataService>() { },
|
||||
new class extends mock<ExtHostNotebookController>() { }
|
||||
);
|
||||
});
|
||||
|
||||
test('create/dispose kernel', async function () {
|
||||
|
||||
const kernel = extHostNotebookKernels.createNotebookController(nullExtensionDescription, 'foo', '*', 'Foo');
|
||||
|
||||
assert.throws(() => (<any>kernel).id = 'dd');
|
||||
assert.throws(() => (<any>kernel).viewType = 'dd');
|
||||
|
||||
assert.ok(kernel);
|
||||
assert.strictEqual(kernel.id, 'foo');
|
||||
assert.strictEqual(kernel.label, 'Foo');
|
||||
assert.strictEqual(kernel.viewType, '*');
|
||||
|
||||
await rpcProtocol.sync();
|
||||
assert.strictEqual(kernelData.size, 1);
|
||||
|
||||
let [first] = kernelData.values();
|
||||
assert.strictEqual(first.id, 'nullExtensionDescription/foo');
|
||||
assert.strictEqual(ExtensionIdentifier.equals(first.extensionId, nullExtensionDescription.identifier), true);
|
||||
assert.strictEqual(first.label, 'Foo');
|
||||
assert.strictEqual(first.viewType, '*');
|
||||
|
||||
kernel.dispose();
|
||||
await rpcProtocol.sync();
|
||||
assert.strictEqual(kernelData.size, 0);
|
||||
});
|
||||
|
||||
test('update kernel', async function () {
|
||||
|
||||
const kernel = extHostNotebookKernels.createNotebookController(nullExtensionDescription, 'foo', '*', 'Foo');
|
||||
|
||||
await rpcProtocol.sync();
|
||||
assert.ok(kernel);
|
||||
|
||||
let [first] = kernelData.values();
|
||||
assert.strictEqual(first.id, 'nullExtensionDescription/foo');
|
||||
assert.strictEqual(first.label, 'Foo');
|
||||
|
||||
kernel.label = 'Far';
|
||||
assert.strictEqual(kernel.label, 'Far');
|
||||
|
||||
await rpcProtocol.sync();
|
||||
[first] = kernelData.values();
|
||||
assert.strictEqual(first.id, 'nullExtensionDescription/foo');
|
||||
assert.strictEqual(first.label, 'Far');
|
||||
});
|
||||
});
|
||||
@@ -4,53 +4,58 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { MirroredTestCollection, TestItemFilteredWrapper } from 'vs/workbench/api/common/extHostTesting';
|
||||
import * as convert from 'vs/workbench/api/common/extHostTypeConverters';
|
||||
import { TestDiffOpType } from 'vs/workbench/contrib/testing/common/testCollection';
|
||||
import { stubTest, testStubs } from 'vs/workbench/contrib/testing/common/testStubs';
|
||||
import { TestOwnedTestCollection, TestSingleUseCollection } from 'vs/workbench/contrib/testing/test/common/ownedTestCollection';
|
||||
import { TestChangeEvent, TestItem, TextDocument } from 'vscode';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Location } from 'vs/editor/common/modes';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { createDefaultDocumentTestRoot, TestItemFilteredWrapper } from 'vs/workbench/api/common/extHostTesting';
|
||||
import * as convert from 'vs/workbench/api/common/extHostTypeConverters';
|
||||
import { TestDiffOpType, TestItemExpandState } from 'vs/workbench/contrib/testing/common/testCollection';
|
||||
import { stubTest, TestItemImpl, testStubs } from 'vs/workbench/contrib/testing/common/testStubs';
|
||||
import { TestOwnedTestCollection, TestSingleUseCollection } from 'vs/workbench/contrib/testing/test/common/ownedTestCollection';
|
||||
import { TestItem, TextDocument } from 'vscode';
|
||||
|
||||
const simplify = (item: TestItem) => {
|
||||
if ('toJSON' in item) {
|
||||
item = (item as any).toJSON();
|
||||
delete (item as any).id;
|
||||
delete (item as any).providerId;
|
||||
delete (item as any).testId;
|
||||
const simplify = (item: TestItem<unknown>) => ({
|
||||
id: item.id,
|
||||
label: item.label,
|
||||
uri: item.uri,
|
||||
range: item.range,
|
||||
runnable: item.runnable,
|
||||
debuggable: item.debuggable,
|
||||
});
|
||||
|
||||
const assertTreesEqual = (a: TestItem<unknown> | undefined, b: TestItem<unknown> | undefined) => {
|
||||
if (!a) {
|
||||
throw new assert.AssertionError({ message: 'Expected a to be defined', actual: a });
|
||||
}
|
||||
|
||||
return { ...item, children: undefined };
|
||||
};
|
||||
if (!b) {
|
||||
throw new assert.AssertionError({ message: 'Expected b to be defined', actual: b });
|
||||
}
|
||||
|
||||
const assertTreesEqual = (a: Readonly<TestItem>, b: Readonly<TestItem>) => {
|
||||
assert.deepStrictEqual(simplify(a), simplify(b));
|
||||
|
||||
const aChildren = (a.children ?? []).sort();
|
||||
const bChildren = (b.children ?? []).sort();
|
||||
const aChildren = [...a.children.keys()].slice().sort();
|
||||
const bChildren = [...b.children.keys()].slice().sort();
|
||||
assert.strictEqual(aChildren.length, bChildren.length, `expected ${a.label}.children.length == ${b.label}.children.length`);
|
||||
aChildren.forEach((_, i) => assertTreesEqual(aChildren[i], bChildren[i]));
|
||||
aChildren.forEach(key => assertTreesEqual(a.children.get(key), b.children.get(key)));
|
||||
};
|
||||
|
||||
const assertTreeListEqual = (a: ReadonlyArray<Readonly<TestItem>>, b: ReadonlyArray<Readonly<TestItem>>) => {
|
||||
assert.strictEqual(a.length, b.length, `expected a.length == n.length`);
|
||||
a.forEach((_, i) => assertTreesEqual(a[i], b[i]));
|
||||
};
|
||||
// const assertTreeListEqual = (a: ReadonlyArray<TestItem>, b: ReadonlyArray<TestItem>) => {
|
||||
// assert.strictEqual(a.length, b.length, `expected a.length == n.length`);
|
||||
// a.forEach((_, i) => assertTreesEqual(a[i], b[i]));
|
||||
// };
|
||||
|
||||
class TestMirroredCollection extends MirroredTestCollection {
|
||||
public changeEvent!: TestChangeEvent;
|
||||
// class TestMirroredCollection extends MirroredTestCollection {
|
||||
// public changeEvent!: TestChangeEvent;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.onDidChangeTests(evt => this.changeEvent = evt);
|
||||
}
|
||||
// constructor() {
|
||||
// super();
|
||||
// this.onDidChangeTests(evt => this.changeEvent = evt);
|
||||
// }
|
||||
|
||||
public get length() {
|
||||
return this.items.size;
|
||||
}
|
||||
}
|
||||
// public get length() {
|
||||
// return this.items.size;
|
||||
// }
|
||||
// }
|
||||
|
||||
suite('ExtHost Testing', () => {
|
||||
let single: TestSingleUseCollection;
|
||||
@@ -62,19 +67,47 @@ suite('ExtHost Testing', () => {
|
||||
|
||||
teardown(() => {
|
||||
single.dispose();
|
||||
assert.strictEqual(owned.idToInternal.size, 0, 'expected owned ids to be empty after dispose');
|
||||
assert.strictEqual(!owned.idToInternal?.size, true, 'expected owned ids to be empty after dispose');
|
||||
});
|
||||
|
||||
suite('OwnedTestCollection', () => {
|
||||
test('adds a root recursively', () => {
|
||||
const tests = testStubs.nested();
|
||||
single.addRoot(tests, 'pid');
|
||||
single.expand('id-root', Infinity);
|
||||
assert.deepStrictEqual(single.collectDiff(), [
|
||||
[TestDiffOpType.Add, { id: '0', providerId: 'pid', parent: null, item: convert.TestItem.from(stubTest('root')) }],
|
||||
[TestDiffOpType.Add, { id: '1', providerId: 'pid', parent: '0', item: convert.TestItem.from(stubTest('a'), 'root') }],
|
||||
[TestDiffOpType.Add, { id: '2', providerId: 'pid', parent: '1', item: convert.TestItem.from(stubTest('aa'), 'root\0a') }],
|
||||
[TestDiffOpType.Add, { id: '3', providerId: 'pid', parent: '1', item: convert.TestItem.from(stubTest('ab'), 'root\0a') }],
|
||||
[TestDiffOpType.Add, { id: '4', providerId: 'pid', parent: '0', item: convert.TestItem.from(stubTest('b'), 'root') }],
|
||||
[
|
||||
TestDiffOpType.Add,
|
||||
{ src: { tree: 0, controller: 'pid' }, parent: null, expand: TestItemExpandState.BusyExpanding, item: { ...convert.TestItem.from(stubTest('root')) } }
|
||||
],
|
||||
[
|
||||
TestDiffOpType.Add,
|
||||
{ src: { tree: 0, controller: 'pid' }, parent: 'id-root', expand: TestItemExpandState.Expandable, item: { ...convert.TestItem.from(stubTest('a')) } }
|
||||
],
|
||||
[
|
||||
TestDiffOpType.Add,
|
||||
{ src: { tree: 0, controller: 'pid' }, parent: 'id-root', expand: TestItemExpandState.NotExpandable, item: convert.TestItem.from(stubTest('b')) }
|
||||
],
|
||||
[
|
||||
TestDiffOpType.Update,
|
||||
{ extId: 'id-root', expand: TestItemExpandState.Expanded }
|
||||
],
|
||||
[
|
||||
TestDiffOpType.Update,
|
||||
{ extId: 'id-a', expand: TestItemExpandState.BusyExpanding }
|
||||
],
|
||||
[
|
||||
TestDiffOpType.Add,
|
||||
{ src: { tree: 0, controller: 'pid' }, parent: 'id-a', expand: TestItemExpandState.NotExpandable, item: convert.TestItem.from(stubTest('aa')) }
|
||||
],
|
||||
[
|
||||
TestDiffOpType.Add,
|
||||
{ src: { tree: 0, controller: 'pid' }, parent: 'id-a', expand: TestItemExpandState.NotExpandable, item: convert.TestItem.from(stubTest('ab')) }
|
||||
],
|
||||
[
|
||||
TestDiffOpType.Update,
|
||||
{ extId: 'id-a', expand: TestItemExpandState.Expanded }
|
||||
],
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -88,229 +121,223 @@ suite('ExtHost Testing', () => {
|
||||
test('watches property mutations', () => {
|
||||
const tests = testStubs.nested();
|
||||
single.addRoot(tests, 'pid');
|
||||
single.expand('id-root', Infinity);
|
||||
single.collectDiff();
|
||||
tests.children![0].description = 'Hello world'; /* item a */
|
||||
single.onItemChange(tests, 'pid');
|
||||
assert.deepStrictEqual(single.collectDiff(), [
|
||||
[TestDiffOpType.Update, { id: '1', parent: '0', providerId: 'pid', item: convert.TestItem.from({ ...stubTest('a'), description: 'Hello world' }, 'root') }],
|
||||
]);
|
||||
tests.children.get('id-a')!.description = 'Hello world'; /* item a */
|
||||
|
||||
single.onItemChange(tests, 'pid');
|
||||
assert.deepStrictEqual(single.collectDiff(), []);
|
||||
assert.deepStrictEqual(single.collectDiff(), [
|
||||
[
|
||||
TestDiffOpType.Update,
|
||||
{ extId: 'id-a', item: { description: 'Hello world' } }],
|
||||
]);
|
||||
});
|
||||
|
||||
test('removes children', () => {
|
||||
const tests = testStubs.nested();
|
||||
single.addRoot(tests, 'pid');
|
||||
single.expand('id-root', Infinity);
|
||||
single.collectDiff();
|
||||
tests.children!.splice(0, 1);
|
||||
single.onItemChange(tests, 'pid');
|
||||
tests.children.get('id-a')!.dispose();
|
||||
|
||||
assert.deepStrictEqual(single.collectDiff(), [
|
||||
[TestDiffOpType.Remove, '1'],
|
||||
[TestDiffOpType.Remove, 'id-a'],
|
||||
]);
|
||||
assert.deepStrictEqual([...owned.idToInternal.keys()].sort(), ['0', '4']);
|
||||
assert.deepStrictEqual([...owned.idToInternal].map(n => n.item.extId).sort(), ['id-b', 'id-root']);
|
||||
assert.strictEqual(single.itemToInternal.size, 2);
|
||||
});
|
||||
|
||||
test('adds new children', () => {
|
||||
const tests = testStubs.nested();
|
||||
single.addRoot(tests, 'pid');
|
||||
single.expand('id-root', Infinity);
|
||||
single.collectDiff();
|
||||
const child = stubTest('ac');
|
||||
tests.children![0].children!.push(child);
|
||||
single.onItemChange(tests, 'pid');
|
||||
tests.children.get('id-a')!.addChild(child);
|
||||
|
||||
assert.deepStrictEqual(single.collectDiff(), [
|
||||
[TestDiffOpType.Add, { id: '5', providerId: 'pid', parent: '1', item: convert.TestItem.from(child, 'root\0a') }],
|
||||
[TestDiffOpType.Add, {
|
||||
src: { tree: 0, controller: 'pid' },
|
||||
parent: 'id-a',
|
||||
expand: TestItemExpandState.NotExpandable,
|
||||
item: convert.TestItem.from(child),
|
||||
}],
|
||||
]);
|
||||
assert.deepStrictEqual([...owned.idToInternal.keys()].sort(), ['0', '1', '2', '3', '4', '5']);
|
||||
assert.deepStrictEqual(
|
||||
[...owned.idToInternal].map(n => n.item.extId).sort(),
|
||||
['id-a', 'id-aa', 'id-ab', 'id-ac', 'id-b', 'id-root'],
|
||||
);
|
||||
assert.strictEqual(single.itemToInternal.size, 6);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
suite('MirroredTestCollection', () => {
|
||||
let m: TestMirroredCollection;
|
||||
setup(() => m = new TestMirroredCollection());
|
||||
// todo@connor4312: re-renable when we figure out what observing looks like we async children
|
||||
// let m: TestMirroredCollection;
|
||||
// setup(() => m = new TestMirroredCollection());
|
||||
|
||||
test('mirrors creation of the root', () => {
|
||||
const tests = testStubs.nested();
|
||||
single.addRoot(tests, 'pid');
|
||||
m.apply(single.collectDiff());
|
||||
assertTreesEqual(m.rootTestItems[0], owned.getTestById('0')!.actual);
|
||||
assert.strictEqual(m.length, single.itemToInternal.size);
|
||||
});
|
||||
// test('mirrors creation of the root', () => {
|
||||
// const tests = testStubs.nested();
|
||||
// single.addRoot(tests, 'pid');
|
||||
// single.expand('id-root', Infinity);
|
||||
// m.apply(single.collectDiff());
|
||||
// assertTreesEqual(m.rootTestItems[0], owned.getTestById('id-root')![1].actual);
|
||||
// assert.strictEqual(m.length, single.itemToInternal.size);
|
||||
// });
|
||||
|
||||
test('mirrors node deletion', () => {
|
||||
const tests = testStubs.nested();
|
||||
single.addRoot(tests, 'pid');
|
||||
m.apply(single.collectDiff());
|
||||
tests.children!.splice(0, 1);
|
||||
single.onItemChange(tests, 'pid');
|
||||
m.apply(single.collectDiff());
|
||||
// test('mirrors node deletion', () => {
|
||||
// const tests = testStubs.nested();
|
||||
// single.addRoot(tests, 'pid');
|
||||
// m.apply(single.collectDiff());
|
||||
// single.expand('id-root', Infinity);
|
||||
// tests.children!.splice(0, 1);
|
||||
// single.onItemChange(tests, 'pid');
|
||||
// single.expand('id-root', Infinity);
|
||||
// m.apply(single.collectDiff());
|
||||
|
||||
assertTreesEqual(m.rootTestItems[0], owned.getTestById('0')!.actual);
|
||||
assert.strictEqual(m.length, single.itemToInternal.size);
|
||||
});
|
||||
// assertTreesEqual(m.rootTestItems[0], owned.getTestById('id-root')![1].actual);
|
||||
// assert.strictEqual(m.length, single.itemToInternal.size);
|
||||
// });
|
||||
|
||||
test('mirrors node addition', () => {
|
||||
const tests = testStubs.nested();
|
||||
single.addRoot(tests, 'pid');
|
||||
m.apply(single.collectDiff());
|
||||
tests.children![0].children!.push(stubTest('ac'));
|
||||
single.onItemChange(tests, 'pid');
|
||||
m.apply(single.collectDiff());
|
||||
// test('mirrors node addition', () => {
|
||||
// const tests = testStubs.nested();
|
||||
// single.addRoot(tests, 'pid');
|
||||
// m.apply(single.collectDiff());
|
||||
// tests.children![0].children!.push(stubTest('ac'));
|
||||
// single.onItemChange(tests, 'pid');
|
||||
// m.apply(single.collectDiff());
|
||||
|
||||
assertTreesEqual(m.rootTestItems[0], owned.getTestById('0')!.actual);
|
||||
assert.strictEqual(m.length, single.itemToInternal.size);
|
||||
});
|
||||
// assertTreesEqual(m.rootTestItems[0], owned.getTestById('id-root')![1].actual);
|
||||
// assert.strictEqual(m.length, single.itemToInternal.size);
|
||||
// });
|
||||
|
||||
test('mirrors node update', () => {
|
||||
const tests = testStubs.nested();
|
||||
single.addRoot(tests, 'pid');
|
||||
m.apply(single.collectDiff());
|
||||
tests.children![0].description = 'Hello world'; /* item a */
|
||||
single.onItemChange(tests, 'pid');
|
||||
m.apply(single.collectDiff());
|
||||
// test('mirrors node update', () => {
|
||||
// const tests = testStubs.nested();
|
||||
// single.addRoot(tests, 'pid');
|
||||
// m.apply(single.collectDiff());
|
||||
// tests.children![0].description = 'Hello world'; /* item a */
|
||||
// single.onItemChange(tests, 'pid');
|
||||
// m.apply(single.collectDiff());
|
||||
|
||||
assertTreesEqual(m.rootTestItems[0], owned.getTestById('0')!.actual);
|
||||
});
|
||||
// assertTreesEqual(m.rootTestItems[0], owned.getTestById('id-root')![1].actual);
|
||||
// });
|
||||
|
||||
suite('MirroredChangeCollector', () => {
|
||||
let tests = testStubs.nested();
|
||||
setup(() => {
|
||||
tests = testStubs.nested();
|
||||
single.addRoot(tests, 'pid');
|
||||
m.apply(single.collectDiff());
|
||||
});
|
||||
// suite('MirroredChangeCollector', () => {
|
||||
// let tests = testStubs.nested();
|
||||
// setup(() => {
|
||||
// tests = testStubs.nested();
|
||||
// single.addRoot(tests, 'pid');
|
||||
// m.apply(single.collectDiff());
|
||||
// });
|
||||
|
||||
test('creates change for root', () => {
|
||||
assert.deepStrictEqual(m.changeEvent.commonChangeAncestor, null);
|
||||
assertTreeListEqual(m.changeEvent.added, [
|
||||
tests,
|
||||
tests.children[0],
|
||||
tests.children![0].children![0],
|
||||
tests.children![0].children![1],
|
||||
tests.children[1],
|
||||
]);
|
||||
assertTreeListEqual(m.changeEvent.removed, []);
|
||||
assertTreeListEqual(m.changeEvent.updated, []);
|
||||
});
|
||||
// test('creates change for root', () => {
|
||||
// assertTreeListEqual(m.changeEvent.added, [
|
||||
// tests,
|
||||
// tests.children[0],
|
||||
// tests.children![0].children![0],
|
||||
// tests.children![0].children![1],
|
||||
// tests.children[1],
|
||||
// ]);
|
||||
// assertTreeListEqual(m.changeEvent.removed, []);
|
||||
// assertTreeListEqual(m.changeEvent.updated, []);
|
||||
// });
|
||||
|
||||
test('creates change for delete', () => {
|
||||
const rm = tests.children.shift()!;
|
||||
single.onItemChange(tests, 'pid');
|
||||
m.apply(single.collectDiff());
|
||||
// test('creates change for delete', () => {
|
||||
// const rm = tests.children.shift()!;
|
||||
// single.onItemChange(tests, 'pid');
|
||||
// m.apply(single.collectDiff());
|
||||
|
||||
assertTreesEqual(m.changeEvent.commonChangeAncestor!, tests);
|
||||
assertTreeListEqual(m.changeEvent.added, []);
|
||||
assertTreeListEqual(m.changeEvent.removed, [
|
||||
{ ...rm, children: [] },
|
||||
{ ...rm.children![0], children: [] },
|
||||
{ ...rm.children![1], children: [] },
|
||||
]);
|
||||
assertTreeListEqual(m.changeEvent.updated, []);
|
||||
});
|
||||
// assertTreeListEqual(m.changeEvent.added, []);
|
||||
// assertTreeListEqual(m.changeEvent.removed, [
|
||||
// { ...rm },
|
||||
// { ...rm.children![0] },
|
||||
// { ...rm.children![1] },
|
||||
// ]);
|
||||
// assertTreeListEqual(m.changeEvent.updated, []);
|
||||
// });
|
||||
|
||||
test('creates change for update', () => {
|
||||
tests.children[0].label = 'updated!';
|
||||
single.onItemChange(tests, 'pid');
|
||||
m.apply(single.collectDiff());
|
||||
// test('creates change for update', () => {
|
||||
// tests.children[0].label = 'updated!';
|
||||
// single.onItemChange(tests, 'pid');
|
||||
// m.apply(single.collectDiff());
|
||||
|
||||
assert.deepStrictEqual(m.changeEvent.commonChangeAncestor?.label, 'updated!');
|
||||
assertTreeListEqual(m.changeEvent.added, []);
|
||||
assertTreeListEqual(m.changeEvent.removed, []);
|
||||
assertTreeListEqual(m.changeEvent.updated, [tests.children[0]]);
|
||||
});
|
||||
// assertTreeListEqual(m.changeEvent.added, []);
|
||||
// assertTreeListEqual(m.changeEvent.removed, []);
|
||||
// assertTreeListEqual(m.changeEvent.updated, [tests.children[0]]);
|
||||
// });
|
||||
|
||||
test('is a no-op if a node is added and removed', () => {
|
||||
const nested = testStubs.nested();
|
||||
tests.children.push(nested);
|
||||
single.onItemChange(tests, 'pid');
|
||||
tests.children.pop();
|
||||
single.onItemChange(tests, 'pid');
|
||||
const previousEvent = m.changeEvent;
|
||||
m.apply(single.collectDiff());
|
||||
assert.strictEqual(m.changeEvent, previousEvent);
|
||||
});
|
||||
// test('is a no-op if a node is added and removed', () => {
|
||||
// const nested = testStubs.nested('id2-');
|
||||
// tests.children.push(nested);
|
||||
// single.onItemChange(tests, 'pid');
|
||||
// tests.children.pop();
|
||||
// single.onItemChange(tests, 'pid');
|
||||
// const previousEvent = m.changeEvent;
|
||||
// m.apply(single.collectDiff());
|
||||
// assert.strictEqual(m.changeEvent, previousEvent);
|
||||
// });
|
||||
|
||||
test('is a single-op if a node is added and changed', () => {
|
||||
const child = stubTest('c');
|
||||
tests.children.push(child);
|
||||
single.onItemChange(tests, 'pid');
|
||||
child.label = 'd';
|
||||
single.onItemChange(tests, 'pid');
|
||||
m.apply(single.collectDiff());
|
||||
// test('is a single-op if a node is added and changed', () => {
|
||||
// const child = stubTest('c');
|
||||
// tests.children.push(child);
|
||||
// single.onItemChange(tests, 'pid');
|
||||
// child.label = 'd';
|
||||
// single.onItemChange(tests, 'pid');
|
||||
// m.apply(single.collectDiff());
|
||||
|
||||
assert.strictEqual(m.changeEvent.commonChangeAncestor?.label, 'root');
|
||||
assertTreeListEqual(m.changeEvent.added, [child]);
|
||||
assertTreeListEqual(m.changeEvent.removed, []);
|
||||
assertTreeListEqual(m.changeEvent.updated, []);
|
||||
});
|
||||
// assertTreeListEqual(m.changeEvent.added, [child]);
|
||||
// assertTreeListEqual(m.changeEvent.removed, []);
|
||||
// assertTreeListEqual(m.changeEvent.updated, []);
|
||||
// });
|
||||
|
||||
test('gets the common ancestor (1)', () => {
|
||||
tests.children![0].children![0].label = 'za';
|
||||
tests.children![0].children![1].label = 'zb';
|
||||
single.onItemChange(tests, 'pid');
|
||||
m.apply(single.collectDiff());
|
||||
// test('gets the common ancestor (1)', () => {
|
||||
// tests.children![0].children![0].label = 'za';
|
||||
// tests.children![0].children![1].label = 'zb';
|
||||
// single.onItemChange(tests, 'pid');
|
||||
// m.apply(single.collectDiff());
|
||||
|
||||
assert.strictEqual(m.changeEvent.commonChangeAncestor?.label, 'a');
|
||||
});
|
||||
// });
|
||||
|
||||
test('gets the common ancestor (2)', () => {
|
||||
tests.children![0].children![0].label = 'za';
|
||||
tests.children![1].label = 'ab';
|
||||
single.onItemChange(tests, 'pid');
|
||||
m.apply(single.collectDiff());
|
||||
|
||||
assert.strictEqual(m.changeEvent.commonChangeAncestor?.label, 'root');
|
||||
});
|
||||
});
|
||||
// test('gets the common ancestor (2)', () => {
|
||||
// tests.children![0].children![0].label = 'za';
|
||||
// tests.children![1].label = 'ab';
|
||||
// single.onItemChange(tests, 'pid');
|
||||
// m.apply(single.collectDiff());
|
||||
// });
|
||||
// });
|
||||
|
||||
suite('TestItemFilteredWrapper', () => {
|
||||
const stubTestWithLocation = (label: string, location: Location): TestItem => {
|
||||
const t = stubTest(label);
|
||||
t.location = location as any;
|
||||
return t;
|
||||
};
|
||||
|
||||
const location1: Location = {
|
||||
range: new Range(0, 0, 0, 0),
|
||||
uri: URI.parse('file:///foo.ts')
|
||||
};
|
||||
|
||||
const location2: Location = {
|
||||
range: new Range(0, 0, 0, 0),
|
||||
uri: URI.parse('file:///bar.ts')
|
||||
};
|
||||
|
||||
const location3: Location = {
|
||||
range: new Range(0, 0, 0, 0),
|
||||
uri: URI.parse('file:///baz.ts')
|
||||
};
|
||||
|
||||
const textDocumentFilter = {
|
||||
uri: location1.uri
|
||||
uri: URI.parse('file:///foo.ts'),
|
||||
} as TextDocument;
|
||||
|
||||
let testsWithLocation: TestItem;
|
||||
setup(() => {
|
||||
testsWithLocation = {
|
||||
...stubTest('root'),
|
||||
children: [
|
||||
{
|
||||
...stubTestWithLocation('a', location1),
|
||||
children: [stubTestWithLocation('aa', location1), stubTestWithLocation('ab', location1)]
|
||||
},
|
||||
{
|
||||
...stubTestWithLocation('b', location2),
|
||||
children: [stubTestWithLocation('ba', location2), stubTestWithLocation('bb', location2)]
|
||||
},
|
||||
{
|
||||
...stubTestWithLocation('b', location3),
|
||||
let testsWithLocation: TestItemImpl;
|
||||
setup(async () => {
|
||||
testsWithLocation =
|
||||
stubTest('root', undefined, [
|
||||
stubTest('a', undefined, [
|
||||
stubTest('aa', undefined, undefined, URI.parse('file:///foo.ts')),
|
||||
stubTest('ab', undefined, undefined, URI.parse('file:///foo.ts'))
|
||||
], URI.parse('file:///foo.ts')),
|
||||
stubTest('b', undefined, [
|
||||
stubTest('ba', undefined, undefined, URI.parse('file:///bar.ts')),
|
||||
stubTest('bb', undefined, undefined, URI.parse('file:///bar.ts'))
|
||||
], URI.parse('file:///bar.ts')),
|
||||
stubTest('c', undefined, undefined, URI.parse('file:///baz.ts')),
|
||||
]);
|
||||
|
||||
// todo: this is not used, don't think it's needed anymore
|
||||
await createDefaultDocumentTestRoot<void>(
|
||||
{
|
||||
createWorkspaceTestRoot: () => testsWithLocation as TestItem<void>,
|
||||
runTests() {
|
||||
throw new Error('no implemented');
|
||||
}
|
||||
],
|
||||
};
|
||||
},
|
||||
textDocumentFilter,
|
||||
undefined,
|
||||
CancellationToken.None
|
||||
);
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
@@ -318,37 +345,41 @@ suite('ExtHost Testing', () => {
|
||||
});
|
||||
|
||||
test('gets all actual properties', () => {
|
||||
const testItem: TestItem = stubTest('test1');
|
||||
const wrapper: TestItemFilteredWrapper = TestItemFilteredWrapper.getWrapperForTestItem(testItem, textDocumentFilter);
|
||||
const testItem = stubTest('test1');
|
||||
const wrapper = TestItemFilteredWrapper.getWrapperForTestItem(testItem, textDocumentFilter);
|
||||
|
||||
assert.strictEqual(testItem.debuggable, wrapper.debuggable);
|
||||
assert.strictEqual(testItem.description, wrapper.description);
|
||||
assert.strictEqual(testItem.label, wrapper.label);
|
||||
assert.strictEqual(testItem.location, wrapper.location);
|
||||
assert.strictEqual(testItem.uri, wrapper.uri);
|
||||
assert.strictEqual(testItem.runnable, wrapper.runnable);
|
||||
assert.strictEqual(testItem.state, wrapper.state);
|
||||
});
|
||||
|
||||
test('gets no children if nothing matches Uri filter', () => {
|
||||
let tests: TestItem = testStubs.nested();
|
||||
const tests = testStubs.nested();
|
||||
const wrapper = TestItemFilteredWrapper.getWrapperForTestItem(tests, textDocumentFilter);
|
||||
assert.strictEqual(wrapper.children.length, 0);
|
||||
wrapper.resolveHandler?.(CancellationToken.None);
|
||||
assert.strictEqual(wrapper.children.size, 0);
|
||||
});
|
||||
|
||||
test('filter is applied to children', () => {
|
||||
const wrapper = TestItemFilteredWrapper.getWrapperForTestItem(testsWithLocation, textDocumentFilter);
|
||||
assert.strictEqual(wrapper.label, 'root');
|
||||
assert.strictEqual(wrapper.children.length, 1);
|
||||
assert.strictEqual(wrapper.children[0] instanceof TestItemFilteredWrapper, true);
|
||||
assert.strictEqual(wrapper.children[0].label, 'a');
|
||||
wrapper.resolveHandler?.(CancellationToken.None);
|
||||
|
||||
const children = [...wrapper.children.values()];
|
||||
assert.strictEqual(children.length, 1);
|
||||
assert.strictEqual(children[0] instanceof TestItemFilteredWrapper, true);
|
||||
assert.strictEqual(children[0].label, 'a');
|
||||
});
|
||||
|
||||
test('can get if node has matching filter', () => {
|
||||
const rootWrapper = TestItemFilteredWrapper.getWrapperForTestItem(testsWithLocation, textDocumentFilter);
|
||||
rootWrapper.resolveHandler?.(CancellationToken.None);
|
||||
|
||||
const invisible = testsWithLocation.children![1];
|
||||
const invisible = testsWithLocation.children.get('id-b')!;
|
||||
const invisibleWrapper = TestItemFilteredWrapper.getWrapperForTestItem(invisible, textDocumentFilter);
|
||||
const visible = testsWithLocation.children![0];
|
||||
const visible = testsWithLocation.children.get('id-a')!;
|
||||
const visibleWrapper = TestItemFilteredWrapper.getWrapperForTestItem(visible, textDocumentFilter);
|
||||
|
||||
// The root is always visible
|
||||
@@ -357,50 +388,39 @@ suite('ExtHost Testing', () => {
|
||||
assert.strictEqual(visibleWrapper.hasNodeMatchingFilter, true);
|
||||
});
|
||||
|
||||
test('can get visible parent', () => {
|
||||
const rootWrapper = TestItemFilteredWrapper.getWrapperForTestItem(testsWithLocation, textDocumentFilter);
|
||||
|
||||
const invisible = testsWithLocation.children![1];
|
||||
const invisibleWrapper = TestItemFilteredWrapper.getWrapperForTestItem(invisible, textDocumentFilter);
|
||||
const visible = testsWithLocation.children![0];
|
||||
const visibleWrapper = TestItemFilteredWrapper.getWrapperForTestItem(visible, textDocumentFilter);
|
||||
|
||||
// The root is always visible
|
||||
assert.strictEqual(rootWrapper.visibleParent, rootWrapper);
|
||||
assert.strictEqual(invisibleWrapper.visibleParent, rootWrapper);
|
||||
assert.strictEqual(visibleWrapper.visibleParent, visibleWrapper);
|
||||
});
|
||||
|
||||
test('can reset cached value of hasNodeMatchingFilter', () => {
|
||||
TestItemFilteredWrapper.getWrapperForTestItem(testsWithLocation, textDocumentFilter);
|
||||
const wrapper = TestItemFilteredWrapper.getWrapperForTestItem(testsWithLocation, textDocumentFilter);
|
||||
wrapper.resolveHandler?.(CancellationToken.None);
|
||||
|
||||
const invisible = testsWithLocation.children![1];
|
||||
const invisible = testsWithLocation.children.get('id-b')!;
|
||||
const invisibleWrapper = TestItemFilteredWrapper.getWrapperForTestItem(invisible, textDocumentFilter);
|
||||
|
||||
assert.strictEqual(wrapper.children.get('id-b'), undefined);
|
||||
assert.strictEqual(invisibleWrapper.hasNodeMatchingFilter, false);
|
||||
invisible.location = location1 as any;
|
||||
assert.strictEqual(invisibleWrapper.hasNodeMatchingFilter, false);
|
||||
invisibleWrapper.reset();
|
||||
|
||||
invisible.addChild(stubTest('bc', undefined, undefined, URI.parse('file:///foo.ts')));
|
||||
assert.strictEqual(invisibleWrapper.hasNodeMatchingFilter, true);
|
||||
assert.strictEqual(invisibleWrapper.children.size, 1);
|
||||
assert.strictEqual(wrapper.children.get('id-b'), invisibleWrapper);
|
||||
});
|
||||
|
||||
test('can reset cached value of hasNodeMatchingFilter of parents up to visible parent', () => {
|
||||
const rootWrapper = TestItemFilteredWrapper.getWrapperForTestItem(testsWithLocation, textDocumentFilter);
|
||||
// test('can reset cached value of hasNodeMatchingFilter of parents up to visible parent', () => {
|
||||
// const rootWrapper = TestItemFilteredWrapper.getWrapperForTestItem(testsWithLocation, textDocumentFilter);
|
||||
|
||||
const invisibleParent = testsWithLocation.children![1];
|
||||
const invisibleParentWrapper = TestItemFilteredWrapper.getWrapperForTestItem(invisibleParent, textDocumentFilter);
|
||||
const invisible = invisibleParent.children![1];
|
||||
const invisibleWrapper = TestItemFilteredWrapper.getWrapperForTestItem(invisible, textDocumentFilter);
|
||||
// const invisibleParent = testsWithLocation.children.get('id-b')!;
|
||||
// const invisibleParentWrapper = TestItemFilteredWrapper.getWrapperForTestItem(invisibleParent, textDocumentFilter);
|
||||
// const invisible = invisibleParent.children.get('id-bb')!;
|
||||
// const invisibleWrapper = TestItemFilteredWrapper.getWrapperForTestItem(invisible, textDocumentFilter);
|
||||
|
||||
assert.strictEqual(invisibleParentWrapper.hasNodeMatchingFilter, false);
|
||||
invisible.location = location1 as any;
|
||||
assert.strictEqual(invisibleParentWrapper.hasNodeMatchingFilter, false);
|
||||
invisibleWrapper.reset();
|
||||
assert.strictEqual(invisibleParentWrapper.hasNodeMatchingFilter, true);
|
||||
// assert.strictEqual(invisibleParentWrapper.hasNodeMatchingFilter, false);
|
||||
// invisible.location = location1 as any;
|
||||
// assert.strictEqual(invisibleParentWrapper.hasNodeMatchingFilter, false);
|
||||
// invisibleWrapper.reset();
|
||||
// assert.strictEqual(invisibleParentWrapper.hasNodeMatchingFilter, true);
|
||||
|
||||
// the root should be undefined due to the reset.
|
||||
assert.strictEqual((rootWrapper as any).matchesFilter, undefined);
|
||||
});
|
||||
// // the root should be undefined due to the reset.
|
||||
// assert.strictEqual((rootWrapper as any).matchesFilter, undefined);
|
||||
// });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -44,7 +44,7 @@ suite('ExtHostTextEditor', () => {
|
||||
let applyCount = 0;
|
||||
let editor = new ExtHostTextEditor('edt1',
|
||||
new class extends mock<MainThreadTextEditorsShape>() {
|
||||
$tryApplyEdits(): Promise<boolean> {
|
||||
override $tryApplyEdits(): Promise<boolean> {
|
||||
applyCount += 1;
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
@@ -26,16 +26,16 @@ suite.skip('ExtHostTreeView', function () {
|
||||
|
||||
onRefresh = new Emitter<{ [treeItemHandle: string]: ITreeItem }>();
|
||||
|
||||
$registerTreeViewDataProvider(treeViewId: string): void {
|
||||
override async $registerTreeViewDataProvider(treeViewId: string): Promise<void> {
|
||||
}
|
||||
|
||||
$refresh(viewId: string, itemsToRefresh: { [treeItemHandle: string]: ITreeItem }): Promise<void> {
|
||||
override $refresh(viewId: string, itemsToRefresh: { [treeItemHandle: string]: ITreeItem }): Promise<void> {
|
||||
return Promise.resolve(null).then(() => {
|
||||
this.onRefresh.fire(itemsToRefresh);
|
||||
});
|
||||
}
|
||||
|
||||
$reveal(): Promise<void> {
|
||||
override $reveal(): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
@@ -604,7 +604,7 @@ suite.skip('ExtHostTreeView', function () {
|
||||
const treeView = testObject.createTreeView('treeDataProvider', { treeDataProvider: aCompleteNodeTreeDataProvider() }, { enableProposedApi: true } as IExtensionDescription);
|
||||
return loadCompleteTree('treeDataProvider')
|
||||
.then(() => {
|
||||
runWithEventMerging((resolve) => {
|
||||
return runWithEventMerging((resolve) => {
|
||||
tree = {
|
||||
'a': {
|
||||
'aa': {},
|
||||
@@ -633,9 +633,9 @@ suite.skip('ExtHostTreeView', function () {
|
||||
.then(() => {
|
||||
assert.ok(revealTarget.calledOnce);
|
||||
assert.deepStrictEqual('treeDataProvider', revealTarget.args[0][0]);
|
||||
assert.deepStrictEqual({ handle: '0/0:b/0:bc', label: { label: 'bc' }, collapsibleState: TreeItemCollapsibleState.None, parentHandle: '0/0:b' }, removeUnsetKeys(revealTarget.args[0][1]));
|
||||
assert.deepStrictEqual([{ handle: '0/0:b', label: { label: 'b' }, collapsibleState: TreeItemCollapsibleState.Collapsed }], (<Array<any>>revealTarget.args[0][2]).map(arg => removeUnsetKeys(arg)));
|
||||
assert.deepStrictEqual({ select: true, focus: false, expand: false }, revealTarget.args[0][3]);
|
||||
assert.deepStrictEqual({ handle: '0/0:b/0:bc', label: { label: 'bc' }, collapsibleState: TreeItemCollapsibleState.None, parentHandle: '0/0:b' }, removeUnsetKeys(revealTarget.args[0][1].item));
|
||||
assert.deepStrictEqual([{ handle: '0/0:b', label: { label: 'b' }, collapsibleState: TreeItemCollapsibleState.Collapsed }], (<Array<any>>revealTarget.args[0][1].parentChain).map(arg => removeUnsetKeys(arg)));
|
||||
assert.deepStrictEqual({ select: true, focus: false, expand: false }, revealTarget.args[0][2]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,6 +8,7 @@ import { URI } from 'vs/base/common/uri';
|
||||
import * as types from 'vs/workbench/api/common/extHostTypes';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
import { assertType } from 'vs/base/common/types';
|
||||
import { notebookDocumentMetadataDefaults } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
|
||||
function assertToJSON(a: any, expected: any) {
|
||||
const raw = JSON.stringify(a);
|
||||
@@ -648,4 +649,57 @@ suite('ExtHostTypes', function () {
|
||||
assert.deepStrictEqual(md.value, '\n```html\n<img src=0 onerror="alert(1)">\n```\n');
|
||||
});
|
||||
|
||||
test('NotebookMetadata - defaults', function () {
|
||||
const obj = new types.NotebookDocumentMetadata();
|
||||
assert.strictEqual(obj.trusted, notebookDocumentMetadataDefaults.trusted);
|
||||
});
|
||||
|
||||
test('NotebookMetadata - with', function () {
|
||||
const obj = new types.NotebookDocumentMetadata();
|
||||
const newObj = obj.with({ trusted: false });
|
||||
assert.ok(obj !== newObj);
|
||||
const sameObj = newObj.with({ trusted: false });
|
||||
assert.ok(newObj === sameObj);
|
||||
assert.strictEqual(obj.trusted, true);
|
||||
assert.strictEqual(newObj.trusted, false);
|
||||
});
|
||||
|
||||
test('NotebookMetadata - with custom', function () {
|
||||
const obj = new types.NotebookDocumentMetadata();
|
||||
const newObj = obj.with({ trusted: false, mycustom: { display: 'hello' } });
|
||||
assert.ok(obj !== newObj);
|
||||
const sameObj = newObj.with({ trusted: false });
|
||||
assert.ok(newObj === sameObj);
|
||||
assert.strictEqual(obj.trusted, true);
|
||||
assert.strictEqual(newObj.trusted, false);
|
||||
assert.deepStrictEqual(newObj.mycustom, { display: 'hello' });
|
||||
});
|
||||
|
||||
test('NotebookCellMetadata - with', function () {
|
||||
const obj = new types.NotebookCellMetadata(true, true);
|
||||
|
||||
const newObj = obj.with({ inputCollapsed: false });
|
||||
assert.ok(obj !== newObj);
|
||||
assert.strictEqual(obj.inputCollapsed, true);
|
||||
assert.strictEqual(obj.custom, undefined);
|
||||
|
||||
assert.strictEqual(newObj.inputCollapsed, false);
|
||||
assert.strictEqual(newObj.custom, undefined);
|
||||
});
|
||||
|
||||
test('NotebookCellMetadata - with custom', function () {
|
||||
const obj = new types.NotebookCellMetadata(true, true);
|
||||
const newObj = obj.with({ inputCollapsed: false, custom: { display: 'hello' } });
|
||||
assert.ok(obj !== newObj);
|
||||
const sameObj = newObj.with({ inputCollapsed: false });
|
||||
assert.ok(newObj === sameObj);
|
||||
assert.strictEqual(obj.inputCollapsed, true);
|
||||
assert.strictEqual(newObj.inputCollapsed, false);
|
||||
assert.deepStrictEqual(newObj.custom, { display: 'hello' });
|
||||
|
||||
const newCustom = newObj.with({ anotherCustom: { display: 'hello2' } });
|
||||
assert.strictEqual(newCustom.inputCollapsed, false);
|
||||
assert.deepStrictEqual(newCustom.mycustom, undefined);
|
||||
assert.deepStrictEqual(newCustom.anotherCustom, { display: 'hello2' });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -53,7 +53,12 @@ suite('ExtHostWebview', () => {
|
||||
|
||||
const serializerARegistration = extHostWebviewPanels.registerWebviewPanelSerializer(extension, viewType, serializerA);
|
||||
|
||||
await extHostWebviewPanels.$deserializeWebviewPanel('x', viewType, 'title', {}, 0 as EditorGroupColumn, {});
|
||||
await extHostWebviewPanels.$deserializeWebviewPanel('x', viewType, {
|
||||
title: 'title',
|
||||
state: {},
|
||||
panelOptions: {},
|
||||
webviewOptions: {}
|
||||
}, 0 as EditorGroupColumn);
|
||||
assert.strictEqual(lastInvokedDeserializer, serializerA);
|
||||
|
||||
assert.throws(
|
||||
@@ -64,7 +69,12 @@ suite('ExtHostWebview', () => {
|
||||
|
||||
extHostWebviewPanels.registerWebviewPanelSerializer(extension, viewType, serializerB);
|
||||
|
||||
await extHostWebviewPanels.$deserializeWebviewPanel('x', viewType, 'title', {}, 0 as EditorGroupColumn, {});
|
||||
await extHostWebviewPanels.$deserializeWebviewPanel('x', viewType, {
|
||||
title: 'title',
|
||||
state: {},
|
||||
panelOptions: {},
|
||||
webviewOptions: {}
|
||||
}, 0 as EditorGroupColumn);
|
||||
assert.strictEqual(lastInvokedDeserializer, serializerB);
|
||||
});
|
||||
|
||||
|
||||
@@ -28,10 +28,10 @@ function createExtHostWorkspace(mainContext: IMainContext, data: IWorkspaceData,
|
||||
const result = new ExtHostWorkspace(
|
||||
new ExtHostRpcService(mainContext),
|
||||
new class extends mock<IExtHostInitDataService>() { workspace = data; },
|
||||
new class extends mock<IExtHostFileSystemInfo>() { getCapabilities() { return isLinux ? FileSystemProviderCapabilities.PathCaseSensitive : undefined; } },
|
||||
new class extends mock<IExtHostFileSystemInfo>() { override getCapabilities() { return isLinux ? FileSystemProviderCapabilities.PathCaseSensitive : undefined; } },
|
||||
logService,
|
||||
);
|
||||
result.$initializeWorkspace(data);
|
||||
result.$initializeWorkspace(data, true);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ suite('ExtHostWorkspace', function () {
|
||||
ws.$acceptWorkspaceData({ id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar3'), 0)] });
|
||||
ws.$acceptWorkspaceData({ id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar3'), 0), aWorkspaceFolderData(URI.parse('foo:bar'), 1)] });
|
||||
|
||||
assert.notEqual(firstFolder, ws.workspace!.folders[0]);
|
||||
assert.notStrictEqual(firstFolder, ws.workspace!.folders[0]);
|
||||
});
|
||||
|
||||
test('updateWorkspaceFolders - invalid arguments', function () {
|
||||
@@ -589,7 +589,7 @@ suite('ExtHostWorkspace', function () {
|
||||
|
||||
let mainThreadCalled = false;
|
||||
rpcProtocol.set(MainContext.MainThreadWorkspace, new class extends mock<MainThreadWorkspace>() {
|
||||
$startFileSearch(includePattern: string, _includeFolder: UriComponents | null, excludePatternOrDisregardExcludes: string | false, maxResults: number, token: CancellationToken): Promise<URI[] | null> {
|
||||
override $startFileSearch(includePattern: string, _includeFolder: UriComponents | null, excludePatternOrDisregardExcludes: string | false, maxResults: number, token: CancellationToken): Promise<URI[] | null> {
|
||||
mainThreadCalled = true;
|
||||
assert.strictEqual(includePattern, 'foo');
|
||||
assert.strictEqual(_includeFolder, null);
|
||||
@@ -611,7 +611,7 @@ suite('ExtHostWorkspace', function () {
|
||||
|
||||
let mainThreadCalled = false;
|
||||
rpcProtocol.set(MainContext.MainThreadWorkspace, new class extends mock<MainThreadWorkspace>() {
|
||||
$startFileSearch(includePattern: string, _includeFolder: UriComponents | null, excludePatternOrDisregardExcludes: string | false, maxResults: number, token: CancellationToken): Promise<URI[] | null> {
|
||||
override $startFileSearch(includePattern: string, _includeFolder: UriComponents | null, excludePatternOrDisregardExcludes: string | false, maxResults: number, token: CancellationToken): Promise<URI[] | null> {
|
||||
mainThreadCalled = true;
|
||||
assert.strictEqual(includePattern, 'glob/**');
|
||||
assert.deepStrictEqual(_includeFolder ? URI.from(_includeFolder).toJSON() : null, URI.file('/other/folder').toJSON());
|
||||
@@ -640,7 +640,7 @@ suite('ExtHostWorkspace', function () {
|
||||
|
||||
let mainThreadCalled = false;
|
||||
rpcProtocol.set(MainContext.MainThreadWorkspace, new class extends mock<MainThreadWorkspace>() {
|
||||
$startFileSearch(includePattern: string, _includeFolder: UriComponents | null, excludePatternOrDisregardExcludes: string | false, maxResults: number, token: CancellationToken): Promise<URI[] | null> {
|
||||
override $startFileSearch(includePattern: string, _includeFolder: UriComponents | null, excludePatternOrDisregardExcludes: string | false, maxResults: number, token: CancellationToken): Promise<URI[] | null> {
|
||||
mainThreadCalled = true;
|
||||
assert.strictEqual(includePattern, 'glob/**');
|
||||
assert.deepStrictEqual(_includeFolder, URI.file('/other/folder').toJSON());
|
||||
@@ -661,7 +661,7 @@ suite('ExtHostWorkspace', function () {
|
||||
|
||||
let mainThreadCalled = false;
|
||||
rpcProtocol.set(MainContext.MainThreadWorkspace, new class extends mock<MainThreadWorkspace>() {
|
||||
$startFileSearch(includePattern: string, _includeFolder: UriComponents | null, excludePatternOrDisregardExcludes: string | false, maxResults: number, token: CancellationToken): Promise<URI[] | null> {
|
||||
override $startFileSearch(includePattern: string, _includeFolder: UriComponents | null, excludePatternOrDisregardExcludes: string | false, maxResults: number, token: CancellationToken): Promise<URI[] | null> {
|
||||
mainThreadCalled = true;
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
@@ -681,7 +681,7 @@ suite('ExtHostWorkspace', function () {
|
||||
|
||||
let mainThreadCalled = false;
|
||||
rpcProtocol.set(MainContext.MainThreadWorkspace, new class extends mock<MainThreadWorkspace>() {
|
||||
$startFileSearch(includePattern: string, _includeFolder: UriComponents | null, excludePatternOrDisregardExcludes: string | false, maxResults: number, token: CancellationToken): Promise<URI[] | null> {
|
||||
override $startFileSearch(includePattern: string, _includeFolder: UriComponents | null, excludePatternOrDisregardExcludes: string | false, maxResults: number, token: CancellationToken): Promise<URI[] | null> {
|
||||
mainThreadCalled = true;
|
||||
assert(excludePatternOrDisregardExcludes, 'glob/**'); // Note that the base portion is ignored, see #52651
|
||||
return Promise.resolve(null);
|
||||
@@ -700,7 +700,7 @@ suite('ExtHostWorkspace', function () {
|
||||
|
||||
let mainThreadCalled = false;
|
||||
rpcProtocol.set(MainContext.MainThreadWorkspace, new class extends mock<MainThreadWorkspace>() {
|
||||
async $startTextSearch(query: IPatternInfo, folder: UriComponents | null, options: ITextQueryBuilderOptions, requestId: number, token: CancellationToken): Promise<ITextSearchComplete | null> {
|
||||
override async $startTextSearch(query: IPatternInfo, folder: UriComponents | null, options: ITextQueryBuilderOptions, requestId: number, token: CancellationToken): Promise<ITextSearchComplete | null> {
|
||||
mainThreadCalled = true;
|
||||
assert.strictEqual(query.pattern, 'foo');
|
||||
assert.strictEqual(folder, null);
|
||||
@@ -721,7 +721,7 @@ suite('ExtHostWorkspace', function () {
|
||||
|
||||
let mainThreadCalled = false;
|
||||
rpcProtocol.set(MainContext.MainThreadWorkspace, new class extends mock<MainThreadWorkspace>() {
|
||||
async $startTextSearch(query: IPatternInfo, folder: UriComponents | null, options: ITextQueryBuilderOptions, requestId: number, token: CancellationToken): Promise<ITextSearchComplete | null> {
|
||||
override async $startTextSearch(query: IPatternInfo, folder: UriComponents | null, options: ITextQueryBuilderOptions, requestId: number, token: CancellationToken): Promise<ITextSearchComplete | null> {
|
||||
mainThreadCalled = true;
|
||||
assert.strictEqual(query.pattern, 'foo');
|
||||
assert.strictEqual(folder, null);
|
||||
@@ -742,7 +742,7 @@ suite('ExtHostWorkspace', function () {
|
||||
|
||||
let mainThreadCalled = false;
|
||||
rpcProtocol.set(MainContext.MainThreadWorkspace, new class extends mock<MainThreadWorkspace>() {
|
||||
async $startTextSearch(query: IPatternInfo, folder: UriComponents | null, options: ITextQueryBuilderOptions, requestId: number, token: CancellationToken): Promise<ITextSearchComplete | null> {
|
||||
override async $startTextSearch(query: IPatternInfo, folder: UriComponents | null, options: ITextQueryBuilderOptions, requestId: number, token: CancellationToken): Promise<ITextSearchComplete | null> {
|
||||
mainThreadCalled = true;
|
||||
assert.strictEqual(query.pattern, 'foo');
|
||||
assert.deepStrictEqual(folder, URI.file('/other/folder').toJSON());
|
||||
@@ -763,7 +763,7 @@ suite('ExtHostWorkspace', function () {
|
||||
|
||||
let mainThreadCalled = false;
|
||||
rpcProtocol.set(MainContext.MainThreadWorkspace, new class extends mock<MainThreadWorkspace>() {
|
||||
async $startTextSearch(query: IPatternInfo, folder: UriComponents | null, options: ITextQueryBuilderOptions, requestId: number, token: CancellationToken): Promise<ITextSearchComplete | null> {
|
||||
override async $startTextSearch(query: IPatternInfo, folder: UriComponents | null, options: ITextQueryBuilderOptions, requestId: number, token: CancellationToken): Promise<ITextSearchComplete | null> {
|
||||
mainThreadCalled = true;
|
||||
return null;
|
||||
}
|
||||
@@ -781,7 +781,7 @@ suite('ExtHostWorkspace', function () {
|
||||
|
||||
let mainThreadCalled = false;
|
||||
rpcProtocol.set(MainContext.MainThreadWorkspace, new class extends mock<MainThreadWorkspace>() {
|
||||
async $startTextSearch(query: IPatternInfo, folder: UriComponents | null, options: ITextQueryBuilderOptions, requestId: number, token: CancellationToken): Promise<ITextSearchComplete | null> {
|
||||
override async $startTextSearch(query: IPatternInfo, folder: UriComponents | null, options: ITextQueryBuilderOptions, requestId: number, token: CancellationToken): Promise<ITextSearchComplete | null> {
|
||||
mainThreadCalled = true;
|
||||
assert.strictEqual(query.pattern, 'foo');
|
||||
assert.deepStrictEqual(folder, null);
|
||||
|
||||
@@ -51,13 +51,13 @@ suite('MainThreadCommands', function () {
|
||||
const commands = new MainThreadCommands(
|
||||
SingleProxyRPCProtocol(null),
|
||||
new class extends mock<ICommandService>() {
|
||||
executeCommand<T>(id: string): Promise<T | undefined> {
|
||||
override executeCommand<T>(id: string): Promise<T | undefined> {
|
||||
runs.push(id);
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
},
|
||||
new class extends mock<IExtensionService>() {
|
||||
activateByEvent(id: string) {
|
||||
override activateByEvent(id: string) {
|
||||
activations.push(id);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ suite('MainThreadDiagnostics', function () {
|
||||
},
|
||||
markerService,
|
||||
new class extends mock<IUriIdentityService>() {
|
||||
asCanonicalUri(uri: URI) { return uri; }
|
||||
override asCanonicalUri(uri: URI) { return uri; }
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -22,13 +22,13 @@ suite('MainThreadDocumentContentProviders', function () {
|
||||
|
||||
let providers = new MainThreadDocumentContentProviders(new TestRPCProtocol(), null!, null!,
|
||||
new class extends mock<IModelService>() {
|
||||
getModel(_uri: URI) {
|
||||
override getModel(_uri: URI) {
|
||||
assert.strictEqual(uri.toString(), _uri.toString());
|
||||
return model;
|
||||
}
|
||||
},
|
||||
new class extends mock<IEditorWorkerService>() {
|
||||
computeMoreMinimalEdits(_uri: URI, data: TextEdit[] | undefined) {
|
||||
override computeMoreMinimalEdits(_uri: URI, data: TextEdit[] | undefined) {
|
||||
assert.strictEqual(model.getValue(), '1');
|
||||
return Promise.resolve(data);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ suite('BoundModelReferenceCollection', () => {
|
||||
dispose() {
|
||||
disposed.push(0);
|
||||
}
|
||||
});
|
||||
}, 6);
|
||||
|
||||
col.add(
|
||||
URI.parse('test://boofar'),
|
||||
@@ -55,7 +55,7 @@ suite('BoundModelReferenceCollection', () => {
|
||||
dispose() {
|
||||
disposed.push(1);
|
||||
}
|
||||
});
|
||||
}, 6);
|
||||
|
||||
col.add(
|
||||
URI.parse('test://xxxxxxx'),
|
||||
@@ -64,7 +64,7 @@ suite('BoundModelReferenceCollection', () => {
|
||||
dispose() {
|
||||
disposed.push(2);
|
||||
}
|
||||
});
|
||||
}, 70);
|
||||
|
||||
assert.deepStrictEqual(disposed, [0, 1]);
|
||||
});
|
||||
|
||||
@@ -40,6 +40,7 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
function myCreateTestCodeEditor(model: ITextModel | undefined): ITestCodeEditor {
|
||||
return createTestCodeEditor({
|
||||
model: model,
|
||||
hasTextFocus: false,
|
||||
serviceCollection: new ServiceCollection(
|
||||
[ICodeEditorService, codeEditorService]
|
||||
)
|
||||
@@ -56,8 +57,8 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
modelService = new ModelServiceImpl(configService, new TestTextResourcePropertiesService(configService), new TestThemeService(), new NullLogService(), undoRedoService);
|
||||
codeEditorService = new TestCodeEditorService();
|
||||
textFileService = new class extends mock<ITextFileService>() {
|
||||
isDirty() { return false; }
|
||||
files = <any>{
|
||||
override isDirty() { return false; }
|
||||
override files = <any>{
|
||||
onDidSave: Event.None,
|
||||
onDidRevert: Event.None,
|
||||
onDidChangeDirty: Event.None
|
||||
@@ -67,14 +68,14 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
const editorGroupService = new TestEditorGroupsService();
|
||||
|
||||
const fileService = new class extends mock<IFileService>() {
|
||||
onDidRunOperation = Event.None;
|
||||
onDidChangeFileSystemProviderCapabilities = Event.None;
|
||||
onDidChangeFileSystemProviderRegistrations = Event.None;
|
||||
override onDidRunOperation = Event.None;
|
||||
override onDidChangeFileSystemProviderCapabilities = Event.None;
|
||||
override onDidChangeFileSystemProviderRegistrations = Event.None;
|
||||
};
|
||||
|
||||
new MainThreadDocumentsAndEditors(
|
||||
SingleProxyRPCProtocol(new class extends mock<ExtHostDocumentsAndEditorsShape>() {
|
||||
$acceptDocumentsAndEditorsDelta(delta: IDocumentsAndEditorsDelta) { deltas.push(delta); }
|
||||
override $acceptDocumentsAndEditorsDelta(delta: IDocumentsAndEditorsDelta) { deltas.push(delta); }
|
||||
}),
|
||||
modelService,
|
||||
textFileService,
|
||||
@@ -85,10 +86,9 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
editorGroupService,
|
||||
null!,
|
||||
new class extends mock<IPanelService>() implements IPanelService {
|
||||
declare readonly _serviceBrand: undefined;
|
||||
onDidPanelOpen = Event.None;
|
||||
onDidPanelClose = Event.None;
|
||||
getActivePanel() {
|
||||
override onDidPanelOpen = Event.None;
|
||||
override onDidPanelClose = Event.None;
|
||||
override getActivePanel() {
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
@@ -96,7 +96,7 @@ suite('MainThreadDocumentsAndEditors', () => {
|
||||
new TestWorkingCopyFileService(),
|
||||
new UriIdentityService(fileService),
|
||||
new class extends mock<IClipboardService>() {
|
||||
readText() {
|
||||
override readText() {
|
||||
return Promise.resolve('clipboard_contents');
|
||||
}
|
||||
},
|
||||
|
||||
@@ -51,8 +51,8 @@ import { TestTextResourcePropertiesService, TestContextService } from 'vs/workbe
|
||||
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
|
||||
import { extUri } from 'vs/base/common/resources';
|
||||
import { ITextSnapshot } from 'vs/editor/common/model';
|
||||
import { VSBuffer, VSBufferReadable } from 'vs/base/common/buffer';
|
||||
import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
|
||||
suite('MainThreadEditors', () => {
|
||||
|
||||
@@ -86,6 +86,7 @@ suite('MainThreadEditors', () => {
|
||||
services.set(ILabelService, new SyncDescriptor(LabelService));
|
||||
services.set(ILogService, new NullLogService());
|
||||
services.set(IWorkspaceContextService, new TestContextService());
|
||||
services.set(IEnvironmentService, TestEnvironmentService);
|
||||
services.set(IWorkbenchEnvironmentService, TestEnvironmentService);
|
||||
services.set(IConfigurationService, configService);
|
||||
services.set(IDialogService, dialogService);
|
||||
@@ -98,44 +99,44 @@ suite('MainThreadEditors', () => {
|
||||
services.set(ILifecycleService, new TestLifecycleService());
|
||||
services.set(IEditorGroupsService, new TestEditorGroupsService());
|
||||
services.set(ITextFileService, new class extends mock<ITextFileService>() {
|
||||
isDirty() { return false; }
|
||||
files = <any>{
|
||||
override isDirty() { return false; }
|
||||
override files = <any>{
|
||||
onDidSave: Event.None,
|
||||
onDidRevert: Event.None,
|
||||
onDidChangeDirty: Event.None
|
||||
};
|
||||
create(operations: { resource: URI }[]) {
|
||||
override create(operations: { resource: URI }[]) {
|
||||
for (const o of operations) {
|
||||
createdResources.add(o.resource);
|
||||
}
|
||||
return Promise.resolve(Object.create(null));
|
||||
}
|
||||
async getEncodedReadable(resource: URI, value?: string | ITextSnapshot): Promise<VSBuffer | VSBufferReadable | undefined> {
|
||||
override async getEncodedReadable(resource: URI, value?: string | ITextSnapshot): Promise<any> {
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
services.set(IWorkingCopyFileService, new class extends mock<IWorkingCopyFileService>() {
|
||||
onDidRunWorkingCopyFileOperation = Event.None;
|
||||
createFolder(operations: ICreateOperation[]): any {
|
||||
override onDidRunWorkingCopyFileOperation = Event.None;
|
||||
override createFolder(operations: ICreateOperation[]): any {
|
||||
this.create(operations);
|
||||
}
|
||||
create(operations: ICreateFileOperation[]) {
|
||||
override create(operations: ICreateFileOperation[]) {
|
||||
for (const operation of operations) {
|
||||
createdResources.add(operation.resource);
|
||||
}
|
||||
return Promise.resolve(Object.create(null));
|
||||
}
|
||||
move(operations: IMoveOperation[]) {
|
||||
override move(operations: IMoveOperation[]) {
|
||||
const { source, target } = operations[0].file;
|
||||
movedResources.set(source, target);
|
||||
return Promise.resolve(Object.create(null));
|
||||
}
|
||||
copy(operations: ICopyOperation[]) {
|
||||
override copy(operations: ICopyOperation[]) {
|
||||
const { source, target } = operations[0].file;
|
||||
copiedResources.set(source, target);
|
||||
return Promise.resolve(Object.create(null));
|
||||
}
|
||||
delete(operations: IDeleteOperation[]) {
|
||||
override delete(operations: IDeleteOperation[]) {
|
||||
for (const operation of operations) {
|
||||
deletedResources.add(operation.resource);
|
||||
}
|
||||
@@ -143,9 +144,9 @@ suite('MainThreadEditors', () => {
|
||||
}
|
||||
});
|
||||
services.set(ITextModelService, new class extends mock<ITextModelService>() {
|
||||
createModelReference(resource: URI): Promise<IReference<IResolvedTextEditorModel>> {
|
||||
override createModelReference(resource: URI): Promise<IReference<IResolvedTextEditorModel>> {
|
||||
const textEditorModel = new class extends mock<IResolvedTextEditorModel>() {
|
||||
textEditorModel = modelService.getModel(resource)!;
|
||||
override textEditorModel = modelService.getModel(resource)!;
|
||||
};
|
||||
textEditorModel.isReadonly = () => false;
|
||||
return Promise.resolve(new ImmortalReference(textEditorModel));
|
||||
@@ -155,26 +156,25 @@ suite('MainThreadEditors', () => {
|
||||
|
||||
});
|
||||
services.set(IPanelService, new class extends mock<IPanelService>() implements IPanelService {
|
||||
declare readonly _serviceBrand: undefined;
|
||||
onDidPanelOpen = Event.None;
|
||||
onDidPanelClose = Event.None;
|
||||
getActivePanel() {
|
||||
override onDidPanelOpen = Event.None;
|
||||
override onDidPanelClose = Event.None;
|
||||
override getActivePanel() {
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
services.set(IUriIdentityService, new class extends mock<IUriIdentityService>() {
|
||||
get extUri() { return extUri; }
|
||||
override get extUri() { return extUri; }
|
||||
});
|
||||
|
||||
const instaService = new InstantiationService(services);
|
||||
|
||||
const rpcProtocol = new TestRPCProtocol();
|
||||
rpcProtocol.set(ExtHostContext.ExtHostDocuments, new class extends mock<ExtHostDocumentsShape>() {
|
||||
$acceptModelChanged(): void {
|
||||
override $acceptModelChanged(): void {
|
||||
}
|
||||
});
|
||||
rpcProtocol.set(ExtHostContext.ExtHostDocumentsAndEditors, new class extends mock<ExtHostDocumentsAndEditorsShape>() {
|
||||
$acceptDocumentsAndEditorsDelta(): void {
|
||||
override $acceptDocumentsAndEditorsDelta(): void {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -29,15 +29,15 @@ suite('MainThreadHostTreeView', function () {
|
||||
}
|
||||
|
||||
class MockExtHostTreeViewsShape extends mock<ExtHostTreeViewsShape>() {
|
||||
async $getChildren(treeViewId: string, treeItemHandle?: string): Promise<ITreeItem[]> {
|
||||
override async $getChildren(treeViewId: string, treeItemHandle?: string): Promise<ITreeItem[]> {
|
||||
return [<CustomTreeItem>{ handle: 'testItem1', collapsibleState: TreeItemCollapsibleState.Expanded, customProp: customValue }];
|
||||
}
|
||||
|
||||
async $hasResolve(): Promise<boolean> {
|
||||
override async $hasResolve(): Promise<boolean> {
|
||||
return false;
|
||||
}
|
||||
|
||||
$setVisible(): void { }
|
||||
override $setVisible(): void { }
|
||||
}
|
||||
|
||||
let container: ViewContainer;
|
||||
|
||||
@@ -55,52 +55,52 @@ suite('Editor - Range decorations', () => {
|
||||
});
|
||||
|
||||
test('highlight range for the resource if it is an active editor', function () {
|
||||
let range: IRange = { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 };
|
||||
const range: IRange = new Range(1, 1, 1, 1);
|
||||
testObject.highlightRange({ resource: model.uri, range });
|
||||
|
||||
let actuals = rangeHighlightDecorations(model);
|
||||
const actuals = rangeHighlightDecorations(model);
|
||||
|
||||
assert.deepEqual([range], actuals);
|
||||
assert.deepStrictEqual(actuals, [range]);
|
||||
});
|
||||
|
||||
test('remove highlight range', function () {
|
||||
testObject.highlightRange({ resource: model.uri, range: { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 } });
|
||||
testObject.removeHighlightRange();
|
||||
|
||||
let actuals = rangeHighlightDecorations(model);
|
||||
const actuals = rangeHighlightDecorations(model);
|
||||
|
||||
assert.deepEqual([], actuals);
|
||||
assert.deepStrictEqual(actuals, []);
|
||||
});
|
||||
|
||||
test('highlight range for the resource removes previous highlight', function () {
|
||||
testObject.highlightRange({ resource: model.uri, range: { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 } });
|
||||
let range: IRange = { startLineNumber: 2, startColumn: 2, endLineNumber: 4, endColumn: 3 };
|
||||
const range: IRange = new Range(2, 2, 4, 3);
|
||||
testObject.highlightRange({ resource: model.uri, range });
|
||||
|
||||
let actuals = rangeHighlightDecorations(model);
|
||||
const actuals = rangeHighlightDecorations(model);
|
||||
|
||||
assert.deepEqual([range], actuals);
|
||||
assert.deepStrictEqual(actuals, [range]);
|
||||
});
|
||||
|
||||
test('highlight range for a new resource removes highlight of previous resource', function () {
|
||||
testObject.highlightRange({ resource: model.uri, range: { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 } });
|
||||
|
||||
let anotherModel = prepareActiveEditor('anotherModel');
|
||||
let range: IRange = { startLineNumber: 2, startColumn: 2, endLineNumber: 4, endColumn: 3 };
|
||||
const anotherModel = prepareActiveEditor('anotherModel');
|
||||
const range: IRange = new Range(2, 2, 4, 3);
|
||||
testObject.highlightRange({ resource: anotherModel.uri, range });
|
||||
|
||||
let actuals = rangeHighlightDecorations(model);
|
||||
assert.deepEqual([], actuals);
|
||||
assert.deepStrictEqual(actuals, []);
|
||||
actuals = rangeHighlightDecorations(anotherModel);
|
||||
assert.deepEqual([range], actuals);
|
||||
assert.deepStrictEqual(actuals, [range]);
|
||||
});
|
||||
|
||||
test('highlight is removed on model change', function () {
|
||||
testObject.highlightRange({ resource: model.uri, range: { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 } });
|
||||
prepareActiveEditor('anotherModel');
|
||||
|
||||
let actuals = rangeHighlightDecorations(model);
|
||||
assert.deepEqual([], actuals);
|
||||
const actuals = rangeHighlightDecorations(model);
|
||||
assert.deepStrictEqual(actuals, []);
|
||||
});
|
||||
|
||||
test('highlight is removed on cursor position change', function () {
|
||||
@@ -109,27 +109,27 @@ suite('Editor - Range decorations', () => {
|
||||
position: new Position(2, 1)
|
||||
});
|
||||
|
||||
let actuals = rangeHighlightDecorations(model);
|
||||
assert.deepEqual([], actuals);
|
||||
const actuals = rangeHighlightDecorations(model);
|
||||
assert.deepStrictEqual(actuals, []);
|
||||
});
|
||||
|
||||
test('range is not highlight if not active editor', function () {
|
||||
let model = aModel(URI.file('some model'));
|
||||
const model = aModel(URI.file('some model'));
|
||||
testObject.highlightRange({ resource: model.uri, range: { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 } });
|
||||
|
||||
let actuals = rangeHighlightDecorations(model);
|
||||
assert.deepEqual([], actuals);
|
||||
const actuals = rangeHighlightDecorations(model);
|
||||
assert.deepStrictEqual(actuals, []);
|
||||
});
|
||||
|
||||
test('previous highlight is not removed if not active editor', function () {
|
||||
let range: IRange = { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 };
|
||||
const range = new Range(1, 1, 1, 1);
|
||||
testObject.highlightRange({ resource: model.uri, range });
|
||||
|
||||
let model1 = aModel(URI.file('some model'));
|
||||
const model1 = aModel(URI.file('some model'));
|
||||
testObject.highlightRange({ resource: model1.uri, range: { startLineNumber: 2, startColumn: 1, endLineNumber: 2, endColumn: 1 } });
|
||||
|
||||
let actuals = rangeHighlightDecorations(model);
|
||||
assert.deepEqual([range], actuals);
|
||||
const actuals = rangeHighlightDecorations(model);
|
||||
assert.deepStrictEqual(actuals, [range]);
|
||||
});
|
||||
|
||||
function prepareActiveEditor(resource: string): TextModel {
|
||||
|
||||
@@ -21,7 +21,7 @@ suite('Workbench parts', () => {
|
||||
minimumHeight: number = 50;
|
||||
maximumHeight: number = 50;
|
||||
|
||||
layout(width: number, height: number): void {
|
||||
override layout(width: number, height: number): void {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
@@ -36,21 +36,21 @@ suite('Workbench parts', () => {
|
||||
super('myPart', { hasTitle: true }, new TestThemeService(), new TestStorageService(), new TestLayoutService());
|
||||
}
|
||||
|
||||
createTitleArea(parent: HTMLElement): HTMLElement {
|
||||
override createTitleArea(parent: HTMLElement): HTMLElement {
|
||||
assert.strictEqual(parent, this.expectedParent);
|
||||
return super.createTitleArea(parent)!;
|
||||
}
|
||||
|
||||
createContentArea(parent: HTMLElement): HTMLElement {
|
||||
override createContentArea(parent: HTMLElement): HTMLElement {
|
||||
assert.strictEqual(parent, this.expectedParent);
|
||||
return super.createContentArea(parent)!;
|
||||
}
|
||||
|
||||
getMemento(scope: StorageScope, target: StorageTarget) {
|
||||
override getMemento(scope: StorageScope, target: StorageTarget) {
|
||||
return super.getMemento(scope, target);
|
||||
}
|
||||
|
||||
saveState(): void {
|
||||
override saveState(): void {
|
||||
return super.saveState();
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ suite('Workbench parts', () => {
|
||||
super('myPart2', { hasTitle: true }, new TestThemeService(), new TestStorageService(), new TestLayoutService());
|
||||
}
|
||||
|
||||
createTitleArea(parent: HTMLElement): HTMLElement {
|
||||
override createTitleArea(parent: HTMLElement): HTMLElement {
|
||||
const titleContainer = append(parent, $('div'));
|
||||
const titleLabel = append(titleContainer, $('span'));
|
||||
titleLabel.id = 'myPart.title';
|
||||
@@ -70,7 +70,7 @@ suite('Workbench parts', () => {
|
||||
return titleContainer;
|
||||
}
|
||||
|
||||
createContentArea(parent: HTMLElement): HTMLElement {
|
||||
override createContentArea(parent: HTMLElement): HTMLElement {
|
||||
const contentContainer = append(parent, $('div'));
|
||||
const contentSpan = append(contentContainer, $('span'));
|
||||
contentSpan.id = 'myPart.content';
|
||||
@@ -86,11 +86,11 @@ suite('Workbench parts', () => {
|
||||
super('myPart2', { hasTitle: false }, new TestThemeService(), new TestStorageService(), new TestLayoutService());
|
||||
}
|
||||
|
||||
createTitleArea(parent: HTMLElement): HTMLElement {
|
||||
override createTitleArea(parent: HTMLElement): HTMLElement {
|
||||
return null!;
|
||||
}
|
||||
|
||||
createContentArea(parent: HTMLElement): HTMLElement {
|
||||
override createContentArea(parent: HTMLElement): HTMLElement {
|
||||
const contentContainer = append(parent, $('div'));
|
||||
const contentSpan = append(contentContainer, $('span'));
|
||||
contentSpan.id = 'myPart.content';
|
||||
|
||||
@@ -18,7 +18,7 @@ suite('Breadcrumb Model', function () {
|
||||
|
||||
const workspaceService = new TestContextService(new Workspace('ffff', [new WorkspaceFolder({ uri: URI.parse('foo:/bar/baz/ws'), name: 'ws', index: 0 })]));
|
||||
const configService = new class extends TestConfigurationService {
|
||||
getValue(...args: any[]) {
|
||||
override getValue(...args: any[]) {
|
||||
if (args[0] === 'breadcrumbs.filePath') {
|
||||
return 'on';
|
||||
}
|
||||
@@ -27,7 +27,7 @@ suite('Breadcrumb Model', function () {
|
||||
}
|
||||
return super.getValue(...args);
|
||||
}
|
||||
updateValue() {
|
||||
override updateValue() {
|
||||
return Promise.resolve();
|
||||
}
|
||||
};
|
||||
@@ -37,14 +37,14 @@ suite('Breadcrumb Model', function () {
|
||||
let model = new BreadcrumbsModel(URI.parse('foo:/bar/baz/ws/some/path/file.ts'), undefined, configService, workspaceService, new class extends mock<IOutlineService>() { });
|
||||
let elements = model.getElements();
|
||||
|
||||
assert.equal(elements.length, 3);
|
||||
assert.strictEqual(elements.length, 3);
|
||||
let [one, two, three] = elements as FileElement[];
|
||||
assert.equal(one.kind, FileKind.FOLDER);
|
||||
assert.equal(two.kind, FileKind.FOLDER);
|
||||
assert.equal(three.kind, FileKind.FILE);
|
||||
assert.equal(one.uri.toString(), 'foo:/bar/baz/ws/some');
|
||||
assert.equal(two.uri.toString(), 'foo:/bar/baz/ws/some/path');
|
||||
assert.equal(three.uri.toString(), 'foo:/bar/baz/ws/some/path/file.ts');
|
||||
assert.strictEqual(one.kind, FileKind.FOLDER);
|
||||
assert.strictEqual(two.kind, FileKind.FOLDER);
|
||||
assert.strictEqual(three.kind, FileKind.FILE);
|
||||
assert.strictEqual(one.uri.toString(), 'foo:/bar/baz/ws/some');
|
||||
assert.strictEqual(two.uri.toString(), 'foo:/bar/baz/ws/some/path');
|
||||
assert.strictEqual(three.uri.toString(), 'foo:/bar/baz/ws/some/path/file.ts');
|
||||
});
|
||||
|
||||
test('display uri matters for FileElement', function () {
|
||||
@@ -52,14 +52,14 @@ suite('Breadcrumb Model', function () {
|
||||
let model = new BreadcrumbsModel(URI.parse('foo:/bar/baz/ws/some/PATH/file.ts'), undefined, configService, workspaceService, new class extends mock<IOutlineService>() { });
|
||||
let elements = model.getElements();
|
||||
|
||||
assert.equal(elements.length, 3);
|
||||
assert.strictEqual(elements.length, 3);
|
||||
let [one, two, three] = elements as FileElement[];
|
||||
assert.equal(one.kind, FileKind.FOLDER);
|
||||
assert.equal(two.kind, FileKind.FOLDER);
|
||||
assert.equal(three.kind, FileKind.FILE);
|
||||
assert.equal(one.uri.toString(), 'foo:/bar/baz/ws/some');
|
||||
assert.equal(two.uri.toString(), 'foo:/bar/baz/ws/some/PATH');
|
||||
assert.equal(three.uri.toString(), 'foo:/bar/baz/ws/some/PATH/file.ts');
|
||||
assert.strictEqual(one.kind, FileKind.FOLDER);
|
||||
assert.strictEqual(two.kind, FileKind.FOLDER);
|
||||
assert.strictEqual(three.kind, FileKind.FILE);
|
||||
assert.strictEqual(one.uri.toString(), 'foo:/bar/baz/ws/some');
|
||||
assert.strictEqual(two.uri.toString(), 'foo:/bar/baz/ws/some/PATH');
|
||||
assert.strictEqual(three.uri.toString(), 'foo:/bar/baz/ws/some/PATH/file.ts');
|
||||
});
|
||||
|
||||
test('only uri, outside workspace', function () {
|
||||
@@ -67,11 +67,11 @@ suite('Breadcrumb Model', function () {
|
||||
let model = new BreadcrumbsModel(URI.parse('foo:/outside/file.ts'), undefined, configService, workspaceService, new class extends mock<IOutlineService>() { });
|
||||
let elements = model.getElements();
|
||||
|
||||
assert.equal(elements.length, 2);
|
||||
assert.strictEqual(elements.length, 2);
|
||||
let [one, two] = elements as FileElement[];
|
||||
assert.equal(one.kind, FileKind.FOLDER);
|
||||
assert.equal(two.kind, FileKind.FILE);
|
||||
assert.equal(one.uri.toString(), 'foo:/outside');
|
||||
assert.equal(two.uri.toString(), 'foo:/outside/file.ts');
|
||||
assert.strictEqual(one.kind, FileKind.FOLDER);
|
||||
assert.strictEqual(two.kind, FileKind.FILE);
|
||||
assert.strictEqual(one.uri.toString(), 'foo:/outside');
|
||||
assert.strictEqual(two.uri.toString(), 'foo:/outside/file.ts');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { EditorGroup, ISerializedEditorGroup, EditorCloseEvent } from 'vs/workbench/common/editor/editorGroup';
|
||||
import { Extensions as EditorExtensions, IEditorInputFactoryRegistry, EditorInput, IFileEditorInput, IEditorInputFactory, CloseDirection, EditorsOrder } from 'vs/workbench/common/editor';
|
||||
import { EditorGroupModel, ISerializedEditorGroupModel, EditorCloseEvent } from 'vs/workbench/common/editor/editorGroupModel';
|
||||
import { EditorExtensions, IEditorInputFactoryRegistry, EditorInput, IFileEditorInput, IEditorInputSerializer, CloseDirection, EditorsOrder } from 'vs/workbench/common/editor';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { TestLifecycleService, workbenchInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
@@ -23,7 +23,7 @@ import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { TestContextService, TestStorageService } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
|
||||
suite('Workbench editor groups', () => {
|
||||
suite('Workbench editor group model', () => {
|
||||
|
||||
function inst(): IInstantiationService {
|
||||
let inst = new TestInstantiationService();
|
||||
@@ -39,17 +39,17 @@ suite('Workbench editor groups', () => {
|
||||
return inst;
|
||||
}
|
||||
|
||||
function createGroup(serialized?: ISerializedEditorGroup): EditorGroup {
|
||||
return inst().createInstance(EditorGroup, serialized);
|
||||
function createEditorGroupModel(serialized?: ISerializedEditorGroupModel): EditorGroupModel {
|
||||
return inst().createInstance(EditorGroupModel, serialized);
|
||||
}
|
||||
|
||||
function closeAllEditors(group: EditorGroup): void {
|
||||
function closeAllEditors(group: EditorGroupModel): void {
|
||||
for (const editor of group.getEditors(EditorsOrder.SEQUENTIAL)) {
|
||||
group.closeEditor(editor, false);
|
||||
}
|
||||
}
|
||||
|
||||
function closeEditors(group: EditorGroup, except: EditorInput, direction?: CloseDirection): void {
|
||||
function closeEditors(group: EditorGroupModel, except: EditorInput, direction?: CloseDirection): void {
|
||||
const index = group.indexOf(except);
|
||||
if (index === -1) {
|
||||
return; // not found
|
||||
@@ -87,7 +87,7 @@ suite('Workbench editor groups', () => {
|
||||
disposed: EditorInput[];
|
||||
}
|
||||
|
||||
function groupListener(group: EditorGroup): GroupEvents {
|
||||
function groupListener(group: EditorGroupModel): GroupEvents {
|
||||
const groupEvents: GroupEvents = {
|
||||
opened: [],
|
||||
closed: [],
|
||||
@@ -106,7 +106,7 @@ suite('Workbench editor groups', () => {
|
||||
group.onDidChangeEditorPinned(e => group.isPinned(e) ? groupEvents.pinned.push(e) : groupEvents.unpinned.push(e));
|
||||
group.onDidChangeEditorSticky(e => group.isSticky(e) ? groupEvents.sticky.push(e) : groupEvents.unsticky.push(e));
|
||||
group.onDidMoveEditor(e => groupEvents.moved.push(e));
|
||||
group.onDidDisposeEditor(e => groupEvents.disposed.push(e));
|
||||
group.onWillDisposeEditor(e => groupEvents.disposed.push(e));
|
||||
|
||||
return groupEvents;
|
||||
}
|
||||
@@ -119,10 +119,10 @@ suite('Workbench editor groups', () => {
|
||||
constructor(public id: string) {
|
||||
super();
|
||||
}
|
||||
getTypeId() { return 'testEditorInputForGroups'; }
|
||||
async resolve(): Promise<IEditorModel> { return null!; }
|
||||
override get typeId() { return 'testEditorInputForGroups'; }
|
||||
override async resolve(): Promise<IEditorModel> { return null!; }
|
||||
|
||||
matches(other: TestEditorInput): boolean {
|
||||
override matches(other: TestEditorInput): boolean {
|
||||
return other && this.id === other.id && other instanceof TestEditorInput;
|
||||
}
|
||||
|
||||
@@ -142,10 +142,10 @@ suite('Workbench editor groups', () => {
|
||||
constructor(public id: string) {
|
||||
super();
|
||||
}
|
||||
getTypeId() { return 'testEditorInputForGroups-nonSerializable'; }
|
||||
async resolve(): Promise<IEditorModel | null> { return null; }
|
||||
override get typeId() { return 'testEditorInputForGroups-nonSerializable'; }
|
||||
override async resolve(): Promise<IEditorModel | null> { return null; }
|
||||
|
||||
matches(other: NonSerializableTestEditorInput): boolean {
|
||||
override matches(other: NonSerializableTestEditorInput): boolean {
|
||||
return other && this.id === other.id && other instanceof NonSerializableTestEditorInput;
|
||||
}
|
||||
}
|
||||
@@ -157,12 +157,12 @@ suite('Workbench editor groups', () => {
|
||||
constructor(public id: string, public resource: URI) {
|
||||
super();
|
||||
}
|
||||
getTypeId() { return 'testFileEditorInputForGroups'; }
|
||||
async resolve(): Promise<IEditorModel | null> { return null; }
|
||||
override get typeId() { return 'testFileEditorInputForGroups'; }
|
||||
override async resolve(): Promise<IEditorModel | null> { return null; }
|
||||
setPreferredName(name: string): void { }
|
||||
setPreferredDescription(description: string): void { }
|
||||
setPreferredResource(resource: URI): void { }
|
||||
setEncoding(encoding: string) { }
|
||||
async setEncoding(encoding: string) { }
|
||||
getEncoding() { return undefined; }
|
||||
setPreferredEncoding(encoding: string) { }
|
||||
setForceOpenAsBinary(): void { }
|
||||
@@ -170,7 +170,7 @@ suite('Workbench editor groups', () => {
|
||||
setPreferredMode(mode: string) { }
|
||||
isResolved(): boolean { return false; }
|
||||
|
||||
matches(other: TestFileEditorInput): boolean {
|
||||
override matches(other: TestFileEditorInput): boolean {
|
||||
return other && this.id === other.id && other instanceof TestFileEditorInput;
|
||||
}
|
||||
}
|
||||
@@ -187,7 +187,7 @@ suite('Workbench editor groups', () => {
|
||||
id: string;
|
||||
}
|
||||
|
||||
class TestEditorInputFactory implements IEditorInputFactory {
|
||||
class TestEditorInputSerializer implements IEditorInputSerializer {
|
||||
|
||||
static disableSerialize = false;
|
||||
static disableDeserialize = false;
|
||||
@@ -197,7 +197,7 @@ suite('Workbench editor groups', () => {
|
||||
}
|
||||
|
||||
serialize(editorInput: EditorInput): string | undefined {
|
||||
if (TestEditorInputFactory.disableSerialize) {
|
||||
if (TestEditorInputSerializer.disableSerialize) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ suite('Workbench editor groups', () => {
|
||||
}
|
||||
|
||||
deserialize(instantiationService: IInstantiationService, serializedEditorInput: string): EditorInput | undefined {
|
||||
if (TestEditorInputFactory.disableDeserialize) {
|
||||
if (TestEditorInputSerializer.disableDeserialize) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -223,10 +223,10 @@ suite('Workbench editor groups', () => {
|
||||
const disposables = new DisposableStore();
|
||||
|
||||
setup(() => {
|
||||
TestEditorInputFactory.disableSerialize = false;
|
||||
TestEditorInputFactory.disableDeserialize = false;
|
||||
TestEditorInputSerializer.disableSerialize = false;
|
||||
TestEditorInputSerializer.disableDeserialize = false;
|
||||
|
||||
disposables.add(Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).registerEditorInputFactory('testEditorInputForGroups', TestEditorInputFactory));
|
||||
disposables.add(Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).registerEditorInputSerializer('testEditorInputForGroups', TestEditorInputSerializer));
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
@@ -236,7 +236,7 @@ suite('Workbench editor groups', () => {
|
||||
});
|
||||
|
||||
test('Clone Group', function () {
|
||||
const group = createGroup();
|
||||
const group = createEditorGroupModel();
|
||||
|
||||
const input1 = input() as TestEditorInput;
|
||||
const input2 = input();
|
||||
@@ -276,7 +276,7 @@ suite('Workbench editor groups', () => {
|
||||
});
|
||||
|
||||
test('contains()', function () {
|
||||
const group = createGroup();
|
||||
const group = createEditorGroupModel();
|
||||
const instantiationService = workbenchInstantiationService();
|
||||
|
||||
const input1 = input();
|
||||
@@ -367,7 +367,7 @@ suite('Workbench editor groups', () => {
|
||||
|
||||
test('group serialization', function () {
|
||||
inst().invokeFunction(accessor => Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).start(accessor));
|
||||
const group = createGroup();
|
||||
const group = createEditorGroupModel();
|
||||
|
||||
const input1 = input();
|
||||
const input2 = input();
|
||||
@@ -379,7 +379,7 @@ suite('Workbench editor groups', () => {
|
||||
group.openEditor(input2, { pinned: true, active: true });
|
||||
group.openEditor(input3, { pinned: false, active: true });
|
||||
|
||||
let deserialized = createGroup(group.serialize());
|
||||
let deserialized = createEditorGroupModel(group.serialize());
|
||||
assert.strictEqual(group.id, deserialized.id);
|
||||
assert.strictEqual(deserialized.count, 3);
|
||||
assert.strictEqual(deserialized.getEditors(EditorsOrder.SEQUENTIAL).length, 3);
|
||||
@@ -390,19 +390,19 @@ suite('Workbench editor groups', () => {
|
||||
assert.strictEqual(deserialized.isActive(input3), true);
|
||||
|
||||
// Case 2: inputs cannot be serialized
|
||||
TestEditorInputFactory.disableSerialize = true;
|
||||
TestEditorInputSerializer.disableSerialize = true;
|
||||
|
||||
deserialized = createGroup(group.serialize());
|
||||
deserialized = createEditorGroupModel(group.serialize());
|
||||
assert.strictEqual(group.id, deserialized.id);
|
||||
assert.strictEqual(deserialized.count, 0);
|
||||
assert.strictEqual(deserialized.getEditors(EditorsOrder.SEQUENTIAL).length, 0);
|
||||
assert.strictEqual(deserialized.getEditors(EditorsOrder.MOST_RECENTLY_ACTIVE).length, 0);
|
||||
|
||||
// Case 3: inputs cannot be deserialized
|
||||
TestEditorInputFactory.disableSerialize = false;
|
||||
TestEditorInputFactory.disableDeserialize = true;
|
||||
TestEditorInputSerializer.disableSerialize = false;
|
||||
TestEditorInputSerializer.disableDeserialize = true;
|
||||
|
||||
deserialized = createGroup(group.serialize());
|
||||
deserialized = createEditorGroupModel(group.serialize());
|
||||
assert.strictEqual(group.id, deserialized.id);
|
||||
assert.strictEqual(deserialized.count, 0);
|
||||
assert.strictEqual(deserialized.getEditors(EditorsOrder.SEQUENTIAL).length, 0);
|
||||
@@ -411,7 +411,7 @@ suite('Workbench editor groups', () => {
|
||||
|
||||
test('group serialization (sticky editor)', function () {
|
||||
inst().invokeFunction(accessor => Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).start(accessor));
|
||||
const group = createGroup();
|
||||
const group = createEditorGroupModel();
|
||||
|
||||
const input1 = input();
|
||||
const input2 = input();
|
||||
@@ -426,7 +426,7 @@ suite('Workbench editor groups', () => {
|
||||
group.stick(input2);
|
||||
assert.ok(group.isSticky(input2));
|
||||
|
||||
let deserialized = createGroup(group.serialize());
|
||||
let deserialized = createEditorGroupModel(group.serialize());
|
||||
assert.strictEqual(group.id, deserialized.id);
|
||||
assert.strictEqual(deserialized.count, 3);
|
||||
|
||||
@@ -443,9 +443,9 @@ suite('Workbench editor groups', () => {
|
||||
assert.strictEqual(deserialized.isSticky(input3), false);
|
||||
|
||||
// Case 2: inputs cannot be serialized
|
||||
TestEditorInputFactory.disableSerialize = true;
|
||||
TestEditorInputSerializer.disableSerialize = true;
|
||||
|
||||
deserialized = createGroup(group.serialize());
|
||||
deserialized = createEditorGroupModel(group.serialize());
|
||||
assert.strictEqual(group.id, deserialized.id);
|
||||
assert.strictEqual(deserialized.count, 0);
|
||||
assert.strictEqual(deserialized.stickyCount, 0);
|
||||
@@ -453,10 +453,10 @@ suite('Workbench editor groups', () => {
|
||||
assert.strictEqual(deserialized.getEditors(EditorsOrder.MOST_RECENTLY_ACTIVE).length, 0);
|
||||
|
||||
// Case 3: inputs cannot be deserialized
|
||||
TestEditorInputFactory.disableSerialize = false;
|
||||
TestEditorInputFactory.disableDeserialize = true;
|
||||
TestEditorInputSerializer.disableSerialize = false;
|
||||
TestEditorInputSerializer.disableDeserialize = true;
|
||||
|
||||
deserialized = createGroup(group.serialize());
|
||||
deserialized = createEditorGroupModel(group.serialize());
|
||||
assert.strictEqual(group.id, deserialized.id);
|
||||
assert.strictEqual(deserialized.count, 0);
|
||||
assert.strictEqual(deserialized.stickyCount, 0);
|
||||
@@ -465,7 +465,7 @@ suite('Workbench editor groups', () => {
|
||||
});
|
||||
|
||||
test('One Editor', function () {
|
||||
const group = createGroup();
|
||||
const group = createEditorGroupModel();
|
||||
const events = groupListener(group);
|
||||
|
||||
assert.strictEqual(group.count, 0);
|
||||
@@ -576,7 +576,7 @@ suite('Workbench editor groups', () => {
|
||||
});
|
||||
|
||||
test('Multiple Editors - Pinned and Active', function () {
|
||||
const group = createGroup();
|
||||
const group = createEditorGroupModel();
|
||||
const events = groupListener(group);
|
||||
|
||||
const input1 = input('1');
|
||||
@@ -650,7 +650,7 @@ suite('Workbench editor groups', () => {
|
||||
});
|
||||
|
||||
test('Multiple Editors - Preview editor moves to the side of the active one', function () {
|
||||
const group = createGroup();
|
||||
const group = createEditorGroupModel();
|
||||
|
||||
const input1 = input();
|
||||
const input2 = input();
|
||||
@@ -679,7 +679,7 @@ suite('Workbench editor groups', () => {
|
||||
inst.stub(IConfigurationService, config);
|
||||
config.setUserConfiguration('workbench', { editor: { openPositioning: 'left' } });
|
||||
|
||||
const group: EditorGroup = inst.createInstance(EditorGroup, undefined);
|
||||
const group: EditorGroupModel = inst.createInstance(EditorGroupModel, undefined);
|
||||
|
||||
const events = groupListener(group);
|
||||
|
||||
@@ -703,7 +703,7 @@ suite('Workbench editor groups', () => {
|
||||
});
|
||||
|
||||
test('Multiple Editors - Pinned and Not Active', function () {
|
||||
const group = createGroup();
|
||||
const group = createEditorGroupModel();
|
||||
|
||||
const input1 = input();
|
||||
const input2 = input();
|
||||
@@ -735,7 +735,7 @@ suite('Workbench editor groups', () => {
|
||||
});
|
||||
|
||||
test('Multiple Editors - Preview gets overwritten', function () {
|
||||
const group = createGroup();
|
||||
const group = createEditorGroupModel();
|
||||
const events = groupListener(group);
|
||||
|
||||
const input1 = input();
|
||||
@@ -768,7 +768,7 @@ suite('Workbench editor groups', () => {
|
||||
});
|
||||
|
||||
test('Multiple Editors - set active', function () {
|
||||
const group = createGroup();
|
||||
const group = createEditorGroupModel();
|
||||
const events = groupListener(group);
|
||||
|
||||
const input1 = input();
|
||||
@@ -803,7 +803,7 @@ suite('Workbench editor groups', () => {
|
||||
});
|
||||
|
||||
test('Multiple Editors - pin and unpin', function () {
|
||||
const group = createGroup();
|
||||
const group = createEditorGroupModel();
|
||||
const events = groupListener(group);
|
||||
|
||||
const input1 = input();
|
||||
@@ -852,7 +852,7 @@ suite('Workbench editor groups', () => {
|
||||
});
|
||||
|
||||
test('Multiple Editors - closing picks next from MRU list', function () {
|
||||
const group = createGroup();
|
||||
const group = createEditorGroupModel();
|
||||
const events = groupListener(group);
|
||||
|
||||
const input1 = input();
|
||||
@@ -911,7 +911,7 @@ suite('Workbench editor groups', () => {
|
||||
config.setUserConfiguration('workbench', { editor: { focusRecentEditorAfterClose: false } });
|
||||
inst.stub(IConfigurationService, config);
|
||||
|
||||
const group = inst.createInstance(EditorGroup, undefined);
|
||||
const group = inst.createInstance(EditorGroupModel, undefined);
|
||||
const events = groupListener(group);
|
||||
|
||||
const input1 = input();
|
||||
@@ -959,7 +959,7 @@ suite('Workbench editor groups', () => {
|
||||
});
|
||||
|
||||
test('Multiple Editors - move editor', function () {
|
||||
const group = createGroup();
|
||||
const group = createEditorGroupModel();
|
||||
const events = groupListener(group);
|
||||
|
||||
const input1 = input();
|
||||
@@ -1021,8 +1021,8 @@ suite('Workbench editor groups', () => {
|
||||
});
|
||||
|
||||
test('Multiple Editors - move editor across groups', function () {
|
||||
const group1 = createGroup();
|
||||
const group2 = createGroup();
|
||||
const group1 = createEditorGroupModel();
|
||||
const group2 = createEditorGroupModel();
|
||||
|
||||
const g1_input1 = input();
|
||||
const g1_input2 = input();
|
||||
@@ -1043,8 +1043,8 @@ suite('Workbench editor groups', () => {
|
||||
});
|
||||
|
||||
test('Multiple Editors - move editor across groups (input already exists in group 1)', function () {
|
||||
const group1 = createGroup();
|
||||
const group2 = createGroup();
|
||||
const group1 = createEditorGroupModel();
|
||||
const group2 = createEditorGroupModel();
|
||||
|
||||
const g1_input1 = input();
|
||||
const g1_input2 = input();
|
||||
@@ -1067,7 +1067,7 @@ suite('Workbench editor groups', () => {
|
||||
});
|
||||
|
||||
test('Multiple Editors - Pinned & Non Active', function () {
|
||||
const group = createGroup();
|
||||
const group = createEditorGroupModel();
|
||||
|
||||
const input1 = input();
|
||||
group.openEditor(input1);
|
||||
@@ -1098,7 +1098,7 @@ suite('Workbench editor groups', () => {
|
||||
});
|
||||
|
||||
test('Multiple Editors - Close Others, Close Left, Close Right', function () {
|
||||
const group = createGroup();
|
||||
const group = createEditorGroupModel();
|
||||
|
||||
const input1 = input();
|
||||
const input2 = input();
|
||||
@@ -1153,7 +1153,7 @@ suite('Workbench editor groups', () => {
|
||||
});
|
||||
|
||||
test('Multiple Editors - real user example', function () {
|
||||
const group = createGroup();
|
||||
const group = createEditorGroupModel();
|
||||
|
||||
// [] -> /index.html/
|
||||
const indexHtml = input('index.html');
|
||||
@@ -1287,7 +1287,7 @@ suite('Workbench editor groups', () => {
|
||||
|
||||
inst.invokeFunction(accessor => Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).start(accessor));
|
||||
|
||||
let group = createGroup();
|
||||
let group = createEditorGroupModel();
|
||||
|
||||
const input1 = input();
|
||||
group.openEditor(input1);
|
||||
@@ -1298,7 +1298,7 @@ suite('Workbench editor groups', () => {
|
||||
assert.strictEqual(group.isActive(input1), true);
|
||||
|
||||
// Create model again - should load from storage
|
||||
group = inst.createInstance(EditorGroup, group.serialize());
|
||||
group = inst.createInstance(EditorGroupModel, group.serialize());
|
||||
|
||||
assert.strictEqual(group.count, 1);
|
||||
assert.strictEqual(group.activeEditor!.matches(input1), true);
|
||||
@@ -1321,7 +1321,7 @@ suite('Workbench editor groups', () => {
|
||||
|
||||
inst.invokeFunction(accessor => Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).start(accessor));
|
||||
|
||||
let group1 = createGroup();
|
||||
let group1 = createEditorGroupModel();
|
||||
|
||||
const g1_input1 = input();
|
||||
const g1_input2 = input();
|
||||
@@ -1331,7 +1331,7 @@ suite('Workbench editor groups', () => {
|
||||
group1.openEditor(g1_input2, { active: true, pinned: false });
|
||||
group1.openEditor(g1_input3, { active: false, pinned: true });
|
||||
|
||||
let group2 = createGroup();
|
||||
let group2 = createEditorGroupModel();
|
||||
|
||||
const g2_input1 = input();
|
||||
const g2_input2 = input();
|
||||
@@ -1357,8 +1357,8 @@ suite('Workbench editor groups', () => {
|
||||
assert.strictEqual(group2.getEditors(EditorsOrder.MOST_RECENTLY_ACTIVE)[2].matches(g2_input2), true);
|
||||
|
||||
// Create model again - should load from storage
|
||||
group1 = inst.createInstance(EditorGroup, group1.serialize());
|
||||
group2 = inst.createInstance(EditorGroup, group2.serialize());
|
||||
group1 = inst.createInstance(EditorGroupModel, group1.serialize());
|
||||
group2 = inst.createInstance(EditorGroupModel, group2.serialize());
|
||||
|
||||
assert.strictEqual(group1.count, 3);
|
||||
assert.strictEqual(group2.count, 3);
|
||||
@@ -1391,7 +1391,7 @@ suite('Workbench editor groups', () => {
|
||||
|
||||
inst.invokeFunction(accessor => Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).start(accessor));
|
||||
|
||||
let group = createGroup();
|
||||
let group = createEditorGroupModel();
|
||||
|
||||
const serializableInput1 = input();
|
||||
const nonSerializableInput2 = input('3', true);
|
||||
@@ -1410,7 +1410,7 @@ suite('Workbench editor groups', () => {
|
||||
assert.strictEqual(group.getEditors(EditorsOrder.MOST_RECENTLY_ACTIVE)[2].matches(serializableInput1), true);
|
||||
|
||||
// Create model again - should load from storage
|
||||
group = inst.createInstance(EditorGroup, group.serialize());
|
||||
group = inst.createInstance(EditorGroupModel, group.serialize());
|
||||
|
||||
assert.strictEqual(group.count, 2);
|
||||
assert.strictEqual(group.activeEditor!.matches(serializableInput2), true);
|
||||
@@ -1435,7 +1435,7 @@ suite('Workbench editor groups', () => {
|
||||
|
||||
inst.invokeFunction(accessor => Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).start(accessor));
|
||||
|
||||
let group = createGroup();
|
||||
let group = createEditorGroupModel();
|
||||
|
||||
const serializableInput1 = input();
|
||||
const nonSerializableInput2 = input('3', true);
|
||||
@@ -1449,7 +1449,7 @@ suite('Workbench editor groups', () => {
|
||||
assert.strictEqual(group.stickyCount, 1);
|
||||
|
||||
// Create model again - should load from storage
|
||||
group = inst.createInstance(EditorGroup, group.serialize());
|
||||
group = inst.createInstance(EditorGroupModel, group.serialize());
|
||||
|
||||
assert.strictEqual(group.count, 2);
|
||||
assert.strictEqual(group.stickyCount, 0);
|
||||
@@ -1470,8 +1470,8 @@ suite('Workbench editor groups', () => {
|
||||
|
||||
inst.invokeFunction(accessor => Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).start(accessor));
|
||||
|
||||
let group1 = createGroup();
|
||||
let group2 = createGroup();
|
||||
let group1 = createEditorGroupModel();
|
||||
let group2 = createEditorGroupModel();
|
||||
|
||||
const serializableInput1 = input();
|
||||
const serializableInput2 = input();
|
||||
@@ -1483,8 +1483,8 @@ suite('Workbench editor groups', () => {
|
||||
group2.openEditor(nonSerializableInput);
|
||||
|
||||
// Create model again - should load from storage
|
||||
group1 = inst.createInstance(EditorGroup, group1.serialize());
|
||||
group2 = inst.createInstance(EditorGroup, group2.serialize());
|
||||
group1 = inst.createInstance(EditorGroupModel, group1.serialize());
|
||||
group2 = inst.createInstance(EditorGroupModel, group2.serialize());
|
||||
|
||||
assert.strictEqual(group1.count, 2);
|
||||
assert.strictEqual(group1.getEditors(EditorsOrder.SEQUENTIAL)[0].matches(serializableInput1), true);
|
||||
@@ -1492,8 +1492,8 @@ suite('Workbench editor groups', () => {
|
||||
});
|
||||
|
||||
test('Multiple Editors - Editor Dispose', function () {
|
||||
const group1 = createGroup();
|
||||
const group2 = createGroup();
|
||||
const group1 = createEditorGroupModel();
|
||||
const group2 = createEditorGroupModel();
|
||||
|
||||
const group1Listener = groupListener(group1);
|
||||
const group2Listener = groupListener(group2);
|
||||
@@ -1523,7 +1523,7 @@ suite('Workbench editor groups', () => {
|
||||
});
|
||||
|
||||
test('Preview tab does not have a stable position (https://github.com/microsoft/vscode/issues/8245)', function () {
|
||||
const group1 = createGroup();
|
||||
const group1 = createEditorGroupModel();
|
||||
|
||||
const input1 = input();
|
||||
const input2 = input();
|
||||
@@ -1538,8 +1538,8 @@ suite('Workbench editor groups', () => {
|
||||
});
|
||||
|
||||
test('Multiple Editors - Editor Emits Dirty and Label Changed', function () {
|
||||
const group1 = createGroup();
|
||||
const group2 = createGroup();
|
||||
const group1 = createEditorGroupModel();
|
||||
const group2 = createEditorGroupModel();
|
||||
|
||||
const input1 = input();
|
||||
const input2 = input();
|
||||
@@ -1591,7 +1591,7 @@ suite('Workbench editor groups', () => {
|
||||
});
|
||||
|
||||
test('Sticky Editors', function () {
|
||||
const group = createGroup();
|
||||
const group = createEditorGroupModel();
|
||||
|
||||
const input1 = input();
|
||||
const input2 = input();
|
||||
@@ -13,8 +13,8 @@ suite('Workbench editor input', () => {
|
||||
class MyEditorInput extends EditorInput {
|
||||
readonly resource = undefined;
|
||||
|
||||
getTypeId(): string { return ''; }
|
||||
resolve(): any { return null; }
|
||||
override get typeId(): string { return 'myEditorInput'; }
|
||||
override resolve(): any { return null; }
|
||||
}
|
||||
|
||||
test('EditorInput', () => {
|
||||
@@ -27,7 +27,7 @@ suite('Workbench editor input', () => {
|
||||
assert(!input.matches(null));
|
||||
assert(input.getName());
|
||||
|
||||
input.onDispose(() => {
|
||||
input.onWillDispose(() => {
|
||||
assert(true);
|
||||
counter++;
|
||||
});
|
||||
@@ -41,13 +41,13 @@ suite('Workbench editor input', () => {
|
||||
|
||||
let counter = 0;
|
||||
let input = new MyEditorInput();
|
||||
input.onDispose(() => {
|
||||
input.onWillDispose(() => {
|
||||
assert(true);
|
||||
counter++;
|
||||
});
|
||||
|
||||
let otherInput = new MyEditorInput();
|
||||
otherInput.onDispose(() => {
|
||||
otherInput.onWillDispose(() => {
|
||||
assert(true);
|
||||
counter++;
|
||||
});
|
||||
@@ -72,7 +72,7 @@ suite('Workbench editor input', () => {
|
||||
let otherInput = new MyEditorInput();
|
||||
|
||||
let diffInput = instantiationService.createInstance(DiffEditorInput, 'name', 'description', input, otherInput, undefined);
|
||||
diffInput.onDispose(() => {
|
||||
diffInput.onWillDispose(() => {
|
||||
counter++;
|
||||
assert(true);
|
||||
});
|
||||
@@ -83,7 +83,7 @@ suite('Workbench editor input', () => {
|
||||
otherInput = new MyEditorInput();
|
||||
|
||||
let diffInput2 = instantiationService.createInstance(DiffEditorInput, 'name', 'description', input, otherInput, undefined);
|
||||
diffInput2.onDispose(() => {
|
||||
diffInput2.onWillDispose(() => {
|
||||
counter++;
|
||||
assert(true);
|
||||
});
|
||||
|
||||
@@ -31,11 +31,11 @@ suite('Workbench editor model', () => {
|
||||
|
||||
class MyEditorModel extends EditorModel { }
|
||||
class MyTextEditorModel extends BaseTextEditorModel {
|
||||
createTextEditorModel(value: ITextBufferFactory, resource?: URI, preferredMode?: string) {
|
||||
override createTextEditorModel(value: ITextBufferFactory, resource?: URI, preferredMode?: string) {
|
||||
return super.createTextEditorModel(value, resource, preferredMode);
|
||||
}
|
||||
|
||||
isReadonly(): boolean {
|
||||
override isReadonly(): boolean {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -67,28 +67,26 @@ suite('Workbench editor model', () => {
|
||||
|
||||
const model = new MyEditorModel();
|
||||
|
||||
model.onDispose(() => {
|
||||
model.onWillDispose(() => {
|
||||
assert(true);
|
||||
counter++;
|
||||
});
|
||||
|
||||
const resolvedModel = await model.load();
|
||||
assert(resolvedModel === model);
|
||||
assert.strictEqual(resolvedModel.isDisposed(), false);
|
||||
await model.resolve();
|
||||
assert.strictEqual(model.isDisposed(), false);
|
||||
assert.strictEqual(model.isResolved(), true);
|
||||
model.dispose();
|
||||
assert.strictEqual(counter, 1);
|
||||
assert.strictEqual(resolvedModel.isDisposed(), true);
|
||||
assert.strictEqual(model.isDisposed(), true);
|
||||
});
|
||||
|
||||
test('BaseTextEditorModel', async () => {
|
||||
let modelService = stubModelService(instantiationService);
|
||||
|
||||
const model = new MyTextEditorModel(modelService, modeService);
|
||||
const resolvedModel = await model.load() as MyTextEditorModel;
|
||||
await model.resolve();
|
||||
|
||||
assert(resolvedModel === model);
|
||||
resolvedModel.createTextEditorModel(createTextBufferFactory('foo'), null!, 'text/plain');
|
||||
model.createTextEditorModel(createTextBufferFactory('foo'), null!, 'text/plain');
|
||||
assert.strictEqual(model.isResolved(), true);
|
||||
model.dispose();
|
||||
});
|
||||
|
||||
@@ -5,17 +5,17 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { EditorPane, EditorMemento } from 'vs/workbench/browser/parts/editor/editorPane';
|
||||
import { EditorInput, EditorOptions, IEditorInputFactory, IEditorInputFactoryRegistry, Extensions as EditorExtensions } from 'vs/workbench/common/editor';
|
||||
import { EditorInput, EditorOptions, IEditorInputSerializer, IEditorInputFactoryRegistry, EditorExtensions } from 'vs/workbench/common/editor';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
|
||||
import { workbenchInstantiationService, TestEditorGroupView, TestEditorGroupsService, registerTestResourceEditor } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { workbenchInstantiationService, TestEditorGroupView, TestEditorGroupsService, registerTestResourceEditor, TestEditorInput } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
|
||||
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IEditorRegistry, Extensions, EditorDescriptor } from 'vs/workbench/browser/editor';
|
||||
import { IEditorRegistry, EditorDescriptor } from 'vs/workbench/browser/editor';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { IEditorModel } from 'vs/platform/editor/common/editor';
|
||||
import { DisposableStore, dispose } from 'vs/base/common/lifecycle';
|
||||
@@ -24,33 +24,33 @@ import { extUri } from 'vs/base/common/resources';
|
||||
|
||||
const NullThemeService = new TestThemeService();
|
||||
|
||||
let EditorRegistry: IEditorRegistry = Registry.as(Extensions.Editors);
|
||||
let EditorRegistry: IEditorRegistry = Registry.as(EditorExtensions.Editors);
|
||||
let EditorInputRegistry: IEditorInputFactoryRegistry = Registry.as(EditorExtensions.EditorInputFactories);
|
||||
|
||||
export class MyEditor extends EditorPane {
|
||||
class TestEditor extends EditorPane {
|
||||
|
||||
constructor(@ITelemetryService telemetryService: ITelemetryService) {
|
||||
super('MyEditor', NullTelemetryService, NullThemeService, new TestStorageService());
|
||||
super('TestEditor', NullTelemetryService, NullThemeService, new TestStorageService());
|
||||
}
|
||||
|
||||
getId(): string { return 'myEditor'; }
|
||||
override getId(): string { return 'testEditor'; }
|
||||
layout(): void { }
|
||||
createEditor(): any { }
|
||||
}
|
||||
|
||||
export class MyOtherEditor extends EditorPane {
|
||||
export class OtherTestEditor extends EditorPane {
|
||||
|
||||
constructor(@ITelemetryService telemetryService: ITelemetryService) {
|
||||
super('myOtherEditor', NullTelemetryService, NullThemeService, new TestStorageService());
|
||||
super('testOtherEditor', NullTelemetryService, NullThemeService, new TestStorageService());
|
||||
}
|
||||
|
||||
getId(): string { return 'myOtherEditor'; }
|
||||
override getId(): string { return 'testOtherEditor'; }
|
||||
|
||||
layout(): void { }
|
||||
createEditor(): any { }
|
||||
}
|
||||
|
||||
class MyInputFactory implements IEditorInputFactory {
|
||||
class TestInputSerializer implements IEditorInputSerializer {
|
||||
|
||||
canSerialize(editorInput: EditorInput): boolean {
|
||||
return true;
|
||||
@@ -65,42 +65,42 @@ class MyInputFactory implements IEditorInputFactory {
|
||||
}
|
||||
}
|
||||
|
||||
class MyInput extends EditorInput {
|
||||
class TestInput extends EditorInput {
|
||||
|
||||
readonly resource = undefined;
|
||||
|
||||
getPreferredEditorId(ids: string[]) {
|
||||
override getPreferredEditorId(ids: string[]) {
|
||||
return ids[1];
|
||||
}
|
||||
|
||||
getTypeId(): string {
|
||||
return '';
|
||||
override get typeId(): string {
|
||||
return 'testInput';
|
||||
}
|
||||
|
||||
resolve(): any {
|
||||
override resolve(): any {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class MyOtherInput extends EditorInput {
|
||||
class OtherTestInput extends EditorInput {
|
||||
|
||||
readonly resource = undefined;
|
||||
|
||||
getTypeId(): string {
|
||||
return '';
|
||||
override get typeId(): string {
|
||||
return 'otherTestInput';
|
||||
}
|
||||
|
||||
resolve(): any {
|
||||
override resolve(): any {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
class MyResourceEditorInput extends ResourceEditorInput { }
|
||||
class TestResourceEditorInput extends ResourceEditorInput { }
|
||||
|
||||
suite('Workbench EditorPane', () => {
|
||||
|
||||
test('EditorPane API', async () => {
|
||||
let e = new MyEditor(NullTelemetryService);
|
||||
let input = new MyOtherInput();
|
||||
let e = new TestEditor(NullTelemetryService);
|
||||
let input = new OtherTestInput();
|
||||
let options = new EditorOptions();
|
||||
|
||||
assert(!e.isVisible());
|
||||
@@ -112,7 +112,7 @@ suite('Workbench EditorPane', () => {
|
||||
e.setVisible(true, group);
|
||||
assert(e.isVisible());
|
||||
assert.strictEqual(e.group, group);
|
||||
input.onDispose(() => {
|
||||
input.onWillDispose(() => {
|
||||
assert(false);
|
||||
});
|
||||
e.dispose();
|
||||
@@ -124,26 +124,26 @@ suite('Workbench EditorPane', () => {
|
||||
});
|
||||
|
||||
test('EditorDescriptor', () => {
|
||||
let d = EditorDescriptor.create(MyEditor, 'id', 'name');
|
||||
let d = EditorDescriptor.create(TestEditor, 'id', 'name');
|
||||
assert.strictEqual(d.getId(), 'id');
|
||||
assert.strictEqual(d.getName(), 'name');
|
||||
});
|
||||
|
||||
test('Editor Registration', function () {
|
||||
let d1 = EditorDescriptor.create(MyEditor, 'id1', 'name');
|
||||
let d2 = EditorDescriptor.create(MyOtherEditor, 'id2', 'name');
|
||||
let d1 = EditorDescriptor.create(TestEditor, 'id1', 'name');
|
||||
let d2 = EditorDescriptor.create(OtherTestEditor, 'id2', 'name');
|
||||
|
||||
let oldEditorsCnt = EditorRegistry.getEditors().length;
|
||||
let oldInputCnt = (<any>EditorRegistry).getEditorInputs().length;
|
||||
|
||||
const dispose1 = EditorRegistry.registerEditor(d1, [new SyncDescriptor(MyInput)]);
|
||||
const dispose2 = EditorRegistry.registerEditor(d2, [new SyncDescriptor(MyInput), new SyncDescriptor(MyOtherInput)]);
|
||||
const dispose1 = EditorRegistry.registerEditor(d1, [new SyncDescriptor(TestInput)]);
|
||||
const dispose2 = EditorRegistry.registerEditor(d2, [new SyncDescriptor(TestInput), new SyncDescriptor(OtherTestInput)]);
|
||||
|
||||
assert.strictEqual(EditorRegistry.getEditors().length, oldEditorsCnt + 2);
|
||||
assert.strictEqual((<any>EditorRegistry).getEditorInputs().length, oldInputCnt + 3);
|
||||
|
||||
assert.strictEqual(EditorRegistry.getEditor(new MyInput()), d2);
|
||||
assert.strictEqual(EditorRegistry.getEditor(new MyOtherInput()), d2);
|
||||
assert.strictEqual(EditorRegistry.getEditor(new TestInput()), d2);
|
||||
assert.strictEqual(EditorRegistry.getEditor(new OtherTestInput()), d2);
|
||||
|
||||
assert.strictEqual(EditorRegistry.getEditorById('id1'), d1);
|
||||
assert.strictEqual(EditorRegistry.getEditorById('id2'), d2);
|
||||
@@ -153,17 +153,17 @@ suite('Workbench EditorPane', () => {
|
||||
});
|
||||
|
||||
test('Editor Lookup favors specific class over superclass (match on specific class)', function () {
|
||||
let d1 = EditorDescriptor.create(MyEditor, 'id1', 'name');
|
||||
let d1 = EditorDescriptor.create(TestEditor, 'id1', 'name');
|
||||
|
||||
const disposables = new DisposableStore();
|
||||
|
||||
disposables.add(registerTestResourceEditor());
|
||||
disposables.add(EditorRegistry.registerEditor(d1, [new SyncDescriptor(MyResourceEditorInput)]));
|
||||
disposables.add(EditorRegistry.registerEditor(d1, [new SyncDescriptor(TestResourceEditorInput)]));
|
||||
|
||||
let inst = workbenchInstantiationService();
|
||||
|
||||
const editor = EditorRegistry.getEditor(inst.createInstance(MyResourceEditorInput, URI.file('/fake'), 'fake', '', undefined))!.instantiate(inst);
|
||||
assert.strictEqual(editor.getId(), 'myEditor');
|
||||
const editor = EditorRegistry.getEditor(inst.createInstance(TestResourceEditorInput, URI.file('/fake'), 'fake', '', undefined))!.instantiate(inst);
|
||||
assert.strictEqual(editor.getId(), 'testEditor');
|
||||
|
||||
const otherEditor = EditorRegistry.getEditor(inst.createInstance(ResourceEditorInput, URI.file('/fake'), 'fake', '', undefined))!.instantiate(inst);
|
||||
assert.strictEqual(otherEditor.getId(), 'workbench.editors.textResourceEditor');
|
||||
@@ -177,20 +177,27 @@ suite('Workbench EditorPane', () => {
|
||||
const disposables = new DisposableStore();
|
||||
|
||||
disposables.add(registerTestResourceEditor());
|
||||
const editor = EditorRegistry.getEditor(inst.createInstance(MyResourceEditorInput, URI.file('/fake'), 'fake', '', undefined))!.instantiate(inst);
|
||||
const editor = EditorRegistry.getEditor(inst.createInstance(TestResourceEditorInput, URI.file('/fake'), 'fake', '', undefined))!.instantiate(inst);
|
||||
|
||||
assert.strictEqual('workbench.editors.textResourceEditor', editor.getId());
|
||||
|
||||
disposables.dispose();
|
||||
});
|
||||
|
||||
test('Editor Input Factory', function () {
|
||||
test('Editor Input Serializer', function () {
|
||||
const testInput = new TestEditorInput(URI.file('/fake'), 'testTypeId');
|
||||
workbenchInstantiationService().invokeFunction(accessor => EditorInputRegistry.start(accessor));
|
||||
const disposable = EditorInputRegistry.registerEditorInputFactory('myInputId', MyInputFactory);
|
||||
const disposable = EditorInputRegistry.registerEditorInputSerializer(testInput.typeId, TestInputSerializer);
|
||||
|
||||
let factory = EditorInputRegistry.getEditorInputFactory('myInputId');
|
||||
let factory = EditorInputRegistry.getEditorInputSerializer('testTypeId');
|
||||
assert(factory);
|
||||
|
||||
factory = EditorInputRegistry.getEditorInputSerializer(testInput);
|
||||
assert(factory);
|
||||
|
||||
// throws when registering serializer for same type
|
||||
assert.throws(() => EditorInputRegistry.registerEditorInputSerializer(testInput.typeId, TestInputSerializer));
|
||||
|
||||
disposable.dispose();
|
||||
});
|
||||
|
||||
@@ -260,9 +267,6 @@ suite('Workbench EditorPane', () => {
|
||||
assert.ok(!memento.loadEditorState(testGroup4, URI.file('/C')));
|
||||
assert.ok(memento.loadEditorState(testGroup0, URI.file('/D')));
|
||||
assert.ok(!memento.loadEditorState(testGroup0, URI.file('/E')));
|
||||
|
||||
// Use fallbackToOtherGroupState
|
||||
assert.ok(memento.loadEditorState(testGroup4, URI.file('/C'), true));
|
||||
});
|
||||
|
||||
test('EditorMemento - move', function () {
|
||||
@@ -307,10 +311,10 @@ suite('Workbench EditorPane', () => {
|
||||
constructor(public resource: URI, private id = 'testEditorInputForMementoTest') {
|
||||
super();
|
||||
}
|
||||
getTypeId() { return 'testEditorInputForMementoTest'; }
|
||||
async resolve(): Promise<IEditorModel | null> { return null; }
|
||||
override get typeId() { return 'testEditorInputForMementoTest'; }
|
||||
override async resolve(): Promise<IEditorModel | null> { return null; }
|
||||
|
||||
matches(other: TestEditorInput): boolean {
|
||||
override matches(other: TestEditorInput): boolean {
|
||||
return other && this.id === other.id && other instanceof TestEditorInput;
|
||||
}
|
||||
}
|
||||
@@ -345,10 +349,10 @@ suite('Workbench EditorPane', () => {
|
||||
constructor(public resource: URI, private id = 'testEditorInputForMementoTest') {
|
||||
super();
|
||||
}
|
||||
getTypeId() { return 'testEditorInputForMementoTest'; }
|
||||
async resolve(): Promise<IEditorModel | null> { return null; }
|
||||
override get typeId() { return 'testEditorInputForMementoTest'; }
|
||||
override async resolve(): Promise<IEditorModel | null> { return null; }
|
||||
|
||||
matches(other: TestEditorInput): boolean {
|
||||
override matches(other: TestEditorInput): boolean {
|
||||
return other && this.id === other.id && other instanceof TestEditorInput;
|
||||
}
|
||||
}
|
||||
@@ -389,9 +393,4 @@ suite('Workbench EditorPane', () => {
|
||||
res = memento.loadEditorState(testGroup0, testInputB);
|
||||
assert.ok(!res);
|
||||
});
|
||||
|
||||
return {
|
||||
MyEditor: MyEditor,
|
||||
MyOtherEditor: MyOtherEditor
|
||||
};
|
||||
});
|
||||
|
||||
@@ -46,9 +46,9 @@ suite('Resource text editors', () => {
|
||||
|
||||
const model = await input.resolve();
|
||||
assert.ok(model);
|
||||
assert.strictEqual(model.textEditorModel.getModeId(), 'resource-input-test');
|
||||
assert.strictEqual(model.textEditorModel?.getModeId(), 'resource-input-test');
|
||||
|
||||
input.setMode('text');
|
||||
assert.strictEqual(model.textEditorModel.getModeId(), PLAINTEXT_MODE_ID);
|
||||
assert.strictEqual(model.textEditorModel?.getModeId(), PLAINTEXT_MODE_ID);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,12 +13,14 @@ suite('Viewlets', () => {
|
||||
class TestViewlet extends Viewlet {
|
||||
|
||||
constructor() {
|
||||
super('id', null!, null!, null!, null!, null!, null!, null!, null!, null!, null!);
|
||||
super('id', null!, null!, null!, null!, null!, null!, null!, null!, null!);
|
||||
}
|
||||
|
||||
layout(dimension: any): void {
|
||||
override layout(dimension: any): void {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
createViewPaneContainer() { return null!; }
|
||||
}
|
||||
|
||||
test('ViewletDescriptor API', function () {
|
||||
|
||||
@@ -9,24 +9,24 @@ import { basename } from 'vs/base/common/resources';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
|
||||
import { IEditorInputWithOptions, IEditorIdentifier, IUntitledTextResourceEditorInput, IResourceDiffEditorInput, IEditorInput, IEditorPane, IEditorCloseEvent, IEditorPartOptions, IRevertOptions, GroupIdentifier, EditorInput, EditorOptions, EditorsOrder, IFileEditorInput, IEditorInputFactoryRegistry, IEditorInputFactory, Extensions as EditorExtensions, ISaveOptions, IMoveResult, ITextEditorPane, ITextDiffEditorPane, IVisibleEditorPane, IEditorOpenContext, SideBySideEditorInput } from 'vs/workbench/common/editor';
|
||||
import { IEditorOpeningEvent, EditorServiceImpl, IEditorGroupView, IEditorGroupsAccessor, IEditorGroupTitleDimensions } from 'vs/workbench/browser/parts/editor/editor';
|
||||
import { IEditorInputWithOptions, IEditorIdentifier, IUntitledTextResourceEditorInput, IResourceDiffEditorInput, IEditorInput, IEditorPane, IEditorCloseEvent, IEditorPartOptions, IRevertOptions, GroupIdentifier, EditorInput, EditorOptions, EditorsOrder, IFileEditorInput, IEditorInputFactoryRegistry, IEditorInputSerializer, EditorExtensions, ISaveOptions, IMoveResult, ITextEditorPane, ITextDiffEditorPane, IVisibleEditorPane, IEditorOpenContext, SideBySideEditorInput, IEditorMoveEvent, EditorExtensions as Extensions } from 'vs/workbench/common/editor';
|
||||
import { EditorServiceImpl, IEditorGroupView, IEditorGroupsAccessor, IEditorGroupTitleHeight } from 'vs/workbench/browser/parts/editor/editor';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
|
||||
import { IWorkingCopyBackupService } from 'vs/workbench/services/workingCopy/common/workingCopyBackup';
|
||||
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
|
||||
import { IWorkbenchLayoutService, Parts, Position as PartPosition } from 'vs/workbench/services/layout/browser/layoutService';
|
||||
import { TextModelResolverService } from 'vs/workbench/services/textmodelResolver/common/textModelResolverService';
|
||||
import { ITextModelService } from 'vs/editor/common/services/resolverService';
|
||||
import { IEditorOptions, IResourceEditorInput, IEditorModel, ITextEditorOptions } from 'vs/platform/editor/common/editor';
|
||||
import { IEditorOptions, IResourceEditorInput, IEditorModel, ITextEditorOptions, IResourceEditorInputIdentifier } from 'vs/platform/editor/common/editor';
|
||||
import { IUntitledTextEditorService, UntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { ILifecycleService, BeforeShutdownEvent, ShutdownReason, StartupKind, LifecyclePhase, WillShutdownEvent } from 'vs/workbench/services/lifecycle/common/lifecycle';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { FileOperationEvent, IFileService, IFileStat, IResolveFileResult, FileChangesEvent, IResolveFileOptions, ICreateFileOptions, IFileSystemProvider, FileSystemProviderCapabilities, IFileChange, IWatchOptions, IStat, FileType, FileDeleteOptions, FileOverwriteOptions, FileWriteOptions, FileOpenOptions, IFileStatWithMetadata, IResolveMetadataFileOptions, IWriteFileOptions, IReadFileOptions, IFileContent, IFileStreamContent, FileOperationError, IFileSystemProviderWithFileReadStreamCapability, FileReadStreamOptions } from 'vs/platform/files/common/files';
|
||||
import { FileOperationEvent, IFileService, IFileStat, IResolveFileResult, FileChangesEvent, IResolveFileOptions, ICreateFileOptions, IFileSystemProvider, FileSystemProviderCapabilities, IFileChange, IWatchOptions, IStat, FileType, FileDeleteOptions, FileOverwriteOptions, FileWriteOptions, FileOpenOptions, IFileStatWithMetadata, IResolveMetadataFileOptions, IWriteFileOptions, IReadFileOptions, IFileContent, IFileStreamContent, FileOperationError, IFileSystemProviderWithFileReadStreamCapability, FileReadStreamOptions, IReadFileStreamOptions } from 'vs/platform/files/common/files';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl';
|
||||
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
|
||||
import { IResourceEncoding, ITextFileService, IReadTextFileOptions, ITextFileStreamContent } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IResourceEncoding, ITextFileService, IReadTextFileOptions, ITextFileStreamContent, IWriteTextFileOptions, ITextFileEditorModel } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { IHistoryService } from 'vs/workbench/services/history/common/history';
|
||||
import { IInstantiationService, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
|
||||
@@ -50,11 +50,10 @@ import { IExtensionService } from 'vs/workbench/services/extensions/common/exten
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IDecorationsService, IResourceDecorationChangeEvent, IDecoration, IDecorationData, IDecorationsProvider } from 'vs/workbench/services/decorations/browser/decorations';
|
||||
import { IDisposable, toDisposable, Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { IEditorGroupsService, IEditorGroup, GroupsOrder, GroupsArrangement, GroupDirection, IAddGroupOptions, IMergeGroupOptions, IMoveEditorOptions, ICopyEditorOptions, IEditorReplacement, IGroupChangeEvent, IFindGroupScope, EditorGroupLayout, ICloseEditorOptions, GroupOrientation, ICloseAllEditorsOptions, ICloseEditorsFilter } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { IEditorService, IOpenEditorOverrideHandler, ISaveEditorsOptions, IRevertAllEditorsOptions, IResourceEditorInputType, SIDE_GROUP_TYPE, ACTIVE_GROUP_TYPE, IOpenEditorOverrideEntry, ICustomEditorViewTypesHandler } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IEditorGroupsService, IEditorGroup, GroupsOrder, GroupsArrangement, GroupDirection, IAddGroupOptions, IMergeGroupOptions, IEditorReplacement, IGroupChangeEvent, IFindGroupScope, EditorGroupLayout, ICloseEditorOptions, GroupOrientation, ICloseAllEditorsOptions, ICloseEditorsFilter } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { IEditorService, IOpenEditorOverrideHandler, ISaveEditorsOptions, IRevertAllEditorsOptions, IResourceEditorInputType, SIDE_GROUP_TYPE, ACTIVE_GROUP_TYPE, IOpenEditorOverrideEntry } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { IEditorRegistry, EditorDescriptor, Extensions } from 'vs/workbench/browser/editor';
|
||||
import { EditorGroup } from 'vs/workbench/common/editor/editorGroup';
|
||||
import { IEditorRegistry, EditorDescriptor } from 'vs/workbench/browser/editor';
|
||||
import { Dimension, IDimension } from 'vs/base/browser/dom';
|
||||
import { ILogService, NullLogService } from 'vs/platform/log/common/log';
|
||||
import { ILabelService } from 'vs/platform/label/common/label';
|
||||
@@ -63,18 +62,19 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
||||
import { ViewletDescriptor, Viewlet } from 'vs/workbench/browser/viewlet';
|
||||
import { IViewlet } from 'vs/workbench/common/viewlet';
|
||||
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
|
||||
import { isLinux, isWindows } from 'vs/base/common/platform';
|
||||
import { IProcessEnvironment, isLinux, isWindows, OperatingSystem } from 'vs/base/common/platform';
|
||||
import { LabelService } from 'vs/workbench/services/label/common/labelService';
|
||||
import { Part } from 'vs/workbench/browser/part';
|
||||
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
|
||||
import { IPanel } from 'vs/workbench/common/panel';
|
||||
import { IBadge } from 'vs/workbench/services/activity/common/activity';
|
||||
import { VSBuffer, VSBufferReadable } from 'vs/base/common/buffer';
|
||||
import { bufferToStream, VSBuffer, VSBufferReadable, VSBufferReadableStream } from 'vs/base/common/buffer';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
import { IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService';
|
||||
import { IWorkingCopyService, WorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService';
|
||||
import { IWorkingCopyIdentifier } from 'vs/workbench/services/workingCopy/common/workingCopy';
|
||||
import { IFilesConfigurationService, FilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
import { IAccessibilityService, AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
|
||||
import { BrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService';
|
||||
@@ -97,11 +97,11 @@ import { CodeEditorService } from 'vs/workbench/services/editor/browser/codeEdit
|
||||
import { EditorPart } from 'vs/workbench/browser/parts/editor/editorPart';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { IDiffEditor, IEditor } from 'vs/editor/common/editorCommon';
|
||||
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
|
||||
import { IInputBox, IInputOptions, IPickOptions, IQuickInputButton, IQuickInputService, IQuickNavigateConfiguration, IQuickPick, IQuickPickItem, QuickPickInput } from 'vs/platform/quickinput/common/quickInput';
|
||||
import { QuickInputService } from 'vs/workbench/services/quickinput/browser/quickInputService';
|
||||
import { IListService } from 'vs/platform/list/browser/listService';
|
||||
import { win32, posix } from 'vs/base/common/path';
|
||||
import { TestWorkingCopyService, TestContextService, TestStorageService, TestTextResourcePropertiesService, TestExtensionService } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
import { TestContextService, TestStorageService, TestTextResourcePropertiesService, TestExtensionService } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
import { IViewsService, IView, ViewContainer, ViewContainerLocation } from 'vs/workbench/common/views';
|
||||
import { IPaneComposite } from 'vs/workbench/common/panecomposite';
|
||||
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
|
||||
@@ -113,9 +113,8 @@ import { EncodingOracle, IEncodingOverride } from 'vs/workbench/services/textfil
|
||||
import { UTF16le, UTF16be, UTF8_with_bom } from 'vs/workbench/services/textfile/common/encoding';
|
||||
import { ColorScheme } from 'vs/platform/theme/common/theme';
|
||||
import { Iterable } from 'vs/base/common/iterator';
|
||||
import { InMemoryBackupFileService } from 'vs/workbench/services/backup/common/backupFileService';
|
||||
import { hash } from 'vs/base/common/hash';
|
||||
import { BrowserBackupFileService } from 'vs/workbench/services/backup/browser/backupFileService';
|
||||
import { InMemoryWorkingCopyBackupService } from 'vs/workbench/services/workingCopy/common/workingCopyBackupService';
|
||||
import { BrowserWorkingCopyBackupService } from 'vs/workbench/services/workingCopy/browser/workingCopyBackupService';
|
||||
import { FileService } from 'vs/platform/files/common/fileService';
|
||||
import { TextResourceEditor } from 'vs/workbench/browser/parts/editor/textResourceEditor';
|
||||
import { TestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
@@ -124,6 +123,19 @@ import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorIn
|
||||
import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput';
|
||||
import { SideBySideEditor } from 'vs/workbench/browser/parts/editor/sideBySideEditor';
|
||||
import { IEnterWorkspaceResult, IRecent, IRecentlyOpened, IWorkspaceFolderCreationData, IWorkspaceIdentifier, IWorkspacesService } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { IWorkspaceTrustManagementService } from 'vs/platform/workspace/common/workspaceTrust';
|
||||
import { TestWorkspaceTrustManagementService } from 'vs/workbench/services/workspaces/test/common/testWorkspaceTrustService';
|
||||
import { ILocalTerminalService, IShellLaunchConfig, ITerminalChildProcess, ITerminalsLayoutInfo, ITerminalsLayoutInfoById } from 'vs/platform/terminal/common/terminal';
|
||||
import { IProcessDetails, ISetTerminalLayoutInfoArgs } from 'vs/platform/terminal/common/terminalProcess';
|
||||
import { ITerminalInstanceService } from 'vs/workbench/contrib/terminal/browser/terminal';
|
||||
import { isArray } from 'vs/base/common/types';
|
||||
import { IShellLaunchConfigResolveOptions, ITerminalProfile, ITerminalProfileResolverService } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { EditorOverrideService } from 'vs/workbench/services/editor/browser/editorOverrideService';
|
||||
import { FILE_EDITOR_INPUT_ID } from 'vs/workbench/contrib/files/common/files';
|
||||
import { IEditorOverrideService } from 'vs/workbench/services/editor/common/editorOverrideService';
|
||||
import { IWorkingCopyEditorService, WorkingCopyEditorService } from 'vs/workbench/services/workingCopy/common/workingCopyEditorService';
|
||||
import { IElevatedFileService } from 'vs/workbench/services/files/common/elevatedFileService';
|
||||
import { BrowserElevatedFileService } from 'vs/workbench/services/files/browser/elevatedFileService';
|
||||
|
||||
export function createFileEditorInput(instantiationService: IInstantiationService, resource: URI): FileEditorInput {
|
||||
return instantiationService.createInstance(FileEditorInput, resource, undefined, undefined, undefined, undefined, undefined);
|
||||
@@ -131,6 +143,8 @@ export function createFileEditorInput(instantiationService: IInstantiationServic
|
||||
|
||||
Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).registerFileEditorInputFactory({
|
||||
|
||||
typeId: FILE_EDITOR_INPUT_ID,
|
||||
|
||||
createFileEditorInput: (resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredMode, instantiationService): IFileEditorInput => {
|
||||
return instantiationService.createInstance(FileEditorInput, resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredMode);
|
||||
},
|
||||
@@ -142,14 +156,14 @@ Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).
|
||||
|
||||
export class TestTextResourceEditor extends TextResourceEditor {
|
||||
|
||||
protected createEditorControl(parent: HTMLElement, configuration: any): IEditor {
|
||||
protected override createEditorControl(parent: HTMLElement, configuration: any): IEditor {
|
||||
return this.instantiationService.createInstance(TestCodeEditor, parent, configuration, {});
|
||||
}
|
||||
}
|
||||
|
||||
export class TestTextFileEditor extends TextFileEditor {
|
||||
|
||||
protected createEditorControl(parent: HTMLElement, configuration: any): IEditor {
|
||||
protected override createEditorControl(parent: HTMLElement, configuration: any): IEditor {
|
||||
return this.instantiationService.createInstance(TestCodeEditor, parent, configuration, {});
|
||||
}
|
||||
}
|
||||
@@ -169,8 +183,9 @@ export function workbenchInstantiationService(
|
||||
): ITestInstantiationService {
|
||||
const instantiationService = new TestInstantiationService(new ServiceCollection([ILifecycleService, new TestLifecycleService()]));
|
||||
|
||||
instantiationService.stub(IWorkingCopyService, disposables.add(new TestWorkingCopyService()));
|
||||
instantiationService.stub(IWorkingCopyService, disposables.add(new WorkingCopyService()));
|
||||
instantiationService.stub(IEnvironmentService, TestEnvironmentService);
|
||||
instantiationService.stub(IWorkbenchEnvironmentService, TestEnvironmentService);
|
||||
const contextKeyService = overrides?.contextKeyService ? overrides.contextKeyService(instantiationService) : instantiationService.createInstance(MockContextKeyService);
|
||||
instantiationService.stub(IContextKeyService, contextKeyService);
|
||||
instantiationService.stub(IProgressService, new TestProgressService());
|
||||
@@ -199,7 +214,7 @@ export function workbenchInstantiationService(
|
||||
const fileService = new TestFileService();
|
||||
instantiationService.stub(IFileService, fileService);
|
||||
instantiationService.stub(IUriIdentityService, new UriIdentityService(fileService));
|
||||
instantiationService.stub(IBackupFileService, new TestBackupFileService());
|
||||
instantiationService.stub(IWorkingCopyBackupService, new TestWorkingCopyBackupService());
|
||||
instantiationService.stub(ITelemetryService, NullTelemetryService);
|
||||
instantiationService.stub(INotificationService, new TestNotificationService());
|
||||
instantiationService.stub(IUntitledTextEditorService, disposables.add(instantiationService.createInstance(UntitledTextEditorService)));
|
||||
@@ -208,6 +223,7 @@ export function workbenchInstantiationService(
|
||||
instantiationService.stub(IKeybindingService, keybindingService);
|
||||
instantiationService.stub(IDecorationsService, new TestDecorationsService());
|
||||
instantiationService.stub(IExtensionService, new TestExtensionService());
|
||||
instantiationService.stub(IWorkingCopyEditorService, disposables.add(instantiationService.createInstance(WorkingCopyEditorService)));
|
||||
instantiationService.stub(IWorkingCopyFileService, disposables.add(instantiationService.createInstance(WorkingCopyFileService)));
|
||||
instantiationService.stub(ITextFileService, overrides?.textFileService ? overrides.textFileService(instantiationService) : disposables.add(<ITextFileService>instantiationService.createInstance(TestTextFileService)));
|
||||
instantiationService.stub(IHostService, <IHostService>instantiationService.createInstance(TestHostService));
|
||||
@@ -218,11 +234,16 @@ export function workbenchInstantiationService(
|
||||
instantiationService.stub(ILabelService, <ILabelService>disposables.add(instantiationService.createInstance(LabelService)));
|
||||
const editorService = overrides?.editorService ? overrides.editorService(instantiationService) : new TestEditorService(editorGroupService);
|
||||
instantiationService.stub(IEditorService, editorService);
|
||||
instantiationService.stub(IEditorOverrideService, disposables.add(instantiationService.createInstance(EditorOverrideService)));
|
||||
instantiationService.stub(ICodeEditorService, disposables.add(new CodeEditorService(editorService, themeService, configService)));
|
||||
instantiationService.stub(IViewletService, new TestViewletService());
|
||||
instantiationService.stub(IListService, new TestListService());
|
||||
instantiationService.stub(IQuickInputService, disposables.add(new QuickInputService(configService, instantiationService, keybindingService, contextKeyService, themeService, accessibilityService, layoutService)));
|
||||
instantiationService.stub(IWorkspacesService, new TestWorkspacesService());
|
||||
instantiationService.stub(IWorkspaceTrustManagementService, new TestWorkspaceTrustManagementService());
|
||||
instantiationService.stub(ITerminalInstanceService, new TestTerminalInstanceService());
|
||||
instantiationService.stub(ILocalTerminalService, new TestLocalTerminalService());
|
||||
instantiationService.stub(IElevatedFileService, new BrowserElevatedFileService());
|
||||
|
||||
return instantiationService;
|
||||
}
|
||||
@@ -244,17 +265,26 @@ export class TestServiceAccessor {
|
||||
@ITextModelService public textModelResolverService: ITextModelService,
|
||||
@IUntitledTextEditorService public untitledTextEditorService: UntitledTextEditorService,
|
||||
@IConfigurationService public testConfigurationService: TestConfigurationService,
|
||||
@IBackupFileService public backupFileService: TestBackupFileService,
|
||||
@IWorkingCopyBackupService public workingCopyBackupService: TestWorkingCopyBackupService,
|
||||
@IHostService public hostService: TestHostService,
|
||||
@IQuickInputService public quickInputService: IQuickInputService
|
||||
@IQuickInputService public quickInputService: IQuickInputService,
|
||||
@ILabelService public labelService: ILabelService,
|
||||
@ILogService public logService: ILogService,
|
||||
@IUriIdentityService public uriIdentityService: IUriIdentityService,
|
||||
@IInstantiationService public instantitionService: IInstantiationService,
|
||||
@INotificationService public notificationService: INotificationService,
|
||||
@IWorkingCopyEditorService public workingCopyEditorService: IWorkingCopyEditorService,
|
||||
@IInstantiationService public instantiationService: IInstantiationService,
|
||||
@IElevatedFileService public elevatedFileService: IElevatedFileService
|
||||
) { }
|
||||
}
|
||||
|
||||
export class TestTextFileService extends BrowserTextFileService {
|
||||
private resolveTextContentError!: FileOperationError | null;
|
||||
private readStreamError: FileOperationError | undefined = undefined;
|
||||
private writeError: FileOperationError | undefined = undefined;
|
||||
|
||||
constructor(
|
||||
@IFileService protected fileService: IFileService,
|
||||
@IFileService fileService: IFileService,
|
||||
@IUntitledTextEditorService untitledTextEditorService: IUntitledTextEditorService,
|
||||
@ILifecycleService lifecycleService: ILifecycleService,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@@ -271,7 +301,8 @@ export class TestTextFileService extends BrowserTextFileService {
|
||||
@IWorkingCopyFileService workingCopyFileService: IWorkingCopyFileService,
|
||||
@IUriIdentityService uriIdentityService: IUriIdentityService,
|
||||
@IModeService modeService: IModeService,
|
||||
@ILogService logService: ILogService
|
||||
@ILogService logService: ILogService,
|
||||
@IElevatedFileService elevatedFileService: IElevatedFileService
|
||||
) {
|
||||
super(
|
||||
fileService,
|
||||
@@ -290,18 +321,19 @@ export class TestTextFileService extends BrowserTextFileService {
|
||||
workingCopyFileService,
|
||||
uriIdentityService,
|
||||
modeService,
|
||||
logService
|
||||
logService,
|
||||
elevatedFileService
|
||||
);
|
||||
}
|
||||
|
||||
setResolveTextContentErrorOnce(error: FileOperationError): void {
|
||||
this.resolveTextContentError = error;
|
||||
setReadStreamErrorOnce(error: FileOperationError): void {
|
||||
this.readStreamError = error;
|
||||
}
|
||||
|
||||
async readStream(resource: URI, options?: IReadTextFileOptions): Promise<ITextFileStreamContent> {
|
||||
if (this.resolveTextContentError) {
|
||||
const error = this.resolveTextContentError;
|
||||
this.resolveTextContentError = null;
|
||||
override async readStream(resource: URI, options?: IReadTextFileOptions): Promise<ITextFileStreamContent> {
|
||||
if (this.readStreamError) {
|
||||
const error = this.readStreamError;
|
||||
this.readStreamError = undefined;
|
||||
|
||||
throw error;
|
||||
}
|
||||
@@ -318,12 +350,27 @@ export class TestTextFileService extends BrowserTextFileService {
|
||||
size: 10
|
||||
};
|
||||
}
|
||||
|
||||
setWriteErrorOnce(error: FileOperationError): void {
|
||||
this.writeError = error;
|
||||
}
|
||||
|
||||
override async write(resource: URI, value: string | ITextSnapshot, options?: IWriteTextFileOptions): Promise<IFileStatWithMetadata> {
|
||||
if (this.writeError) {
|
||||
const error = this.writeError;
|
||||
this.writeError = undefined;
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
return super.write(resource, value, options);
|
||||
}
|
||||
}
|
||||
|
||||
export class TestBrowserTextFileServiceWithEncodingOverrides extends BrowserTextFileService {
|
||||
|
||||
private _testEncoding: TestEncodingOracle | undefined;
|
||||
get encoding(): TestEncodingOracle {
|
||||
override get encoding(): TestEncodingOracle {
|
||||
if (!this._testEncoding) {
|
||||
this._testEncoding = this._register(this.instantiationService.createInstance(TestEncodingOracle));
|
||||
}
|
||||
@@ -334,7 +381,7 @@ export class TestBrowserTextFileServiceWithEncodingOverrides extends BrowserText
|
||||
|
||||
export class TestEncodingOracle extends EncodingOracle {
|
||||
|
||||
protected get encodingOverrides(): IEncodingOverride[] {
|
||||
protected override get encodingOverrides(): IEncodingOverride[] {
|
||||
return [
|
||||
{ extension: 'utf16le', encoding: UTF16le },
|
||||
{ extension: 'utf16be', encoding: UTF16be },
|
||||
@@ -342,7 +389,7 @@ export class TestEncodingOracle extends EncodingOracle {
|
||||
];
|
||||
}
|
||||
|
||||
protected set encodingOverrides(overrides: IEncodingOverride[]) { }
|
||||
protected override set encodingOverrides(overrides: IEncodingOverride[]) { }
|
||||
}
|
||||
|
||||
class TestEnvironmentServiceWithArgs extends BrowserWorkbenchEnvironmentService {
|
||||
@@ -414,7 +461,7 @@ export class TestHistoryService implements IHistoryService {
|
||||
removeFromHistory(_input: IEditorInput | IResourceEditorInput): void { }
|
||||
clear(): void { }
|
||||
clearRecentlyOpened(): void { }
|
||||
getHistory(): ReadonlyArray<IEditorInput | IResourceEditorInput> { return []; }
|
||||
getHistory(): readonly (IEditorInput | IResourceEditorInput)[] { return []; }
|
||||
openNextRecentlyUsedEditor(group?: GroupIdentifier): void { }
|
||||
openPreviouslyUsedEditor(group?: GroupIdentifier): void { }
|
||||
getLastActiveWorkspaceRoot(_schemeFilter: string): URI | undefined { return this.root; }
|
||||
@@ -460,19 +507,19 @@ export class TestLayoutService implements IWorkbenchLayoutService {
|
||||
|
||||
container: HTMLElement = window.document.body;
|
||||
|
||||
onZenModeChange: Event<boolean> = Event.None;
|
||||
onCenteredLayoutChange: Event<boolean> = Event.None;
|
||||
onFullscreenChange: Event<boolean> = Event.None;
|
||||
onMaximizeChange: Event<boolean> = Event.None;
|
||||
onPanelPositionChange: Event<string> = Event.None;
|
||||
onPartVisibilityChange: Event<void> = Event.None;
|
||||
onLayout = Event.None;
|
||||
|
||||
private readonly _onMenubarVisibilityChange = new Emitter<Dimension>();
|
||||
get onMenubarVisibilityChange(): Event<Dimension> { return this._onMenubarVisibilityChange.event; }
|
||||
onDidChangeZenMode: Event<boolean> = Event.None;
|
||||
onDidChangeCenteredLayout: Event<boolean> = Event.None;
|
||||
onDidChangeFullscreen: Event<boolean> = Event.None;
|
||||
onDidChangeWindowMaximized: Event<boolean> = Event.None;
|
||||
onDidChangePanelPosition: Event<string> = Event.None;
|
||||
onDidChangePartVisibility: Event<void> = Event.None;
|
||||
onDidLayout = Event.None;
|
||||
onDidChangeNotificationsVisibility = Event.None;
|
||||
|
||||
layout(): void { }
|
||||
isRestored(): boolean { return true; }
|
||||
whenReady: Promise<void> = Promise.resolve(undefined);
|
||||
whenRestored: Promise<void> = Promise.resolve(undefined);
|
||||
hasFocus(_part: Parts): boolean { return false; }
|
||||
focusPart(_part: Parts): void { }
|
||||
hasWindowBorder(): boolean { return false; }
|
||||
@@ -500,7 +547,6 @@ export class TestLayoutService implements IWorkbenchLayoutService {
|
||||
addClass(_clazz: string): void { }
|
||||
removeClass(_clazz: string): void { }
|
||||
getMaximumEditorDimensions(): Dimension { throw new Error('not implemented'); }
|
||||
getWorkbenchContainer(): HTMLElement { throw new Error('not implemented'); }
|
||||
toggleZenMode(): void { }
|
||||
isEditorLayoutCentered(): boolean { return false; }
|
||||
centerEditorLayout(_active: boolean): void { }
|
||||
@@ -572,6 +618,7 @@ export class TestViewsService implements IViewsService {
|
||||
onDidChangeViewVisibility = this.onDidChangeViewVisibilityEmitter.event;
|
||||
isViewVisible(id: string): boolean { return true; }
|
||||
getActiveViewWithId<T extends IView>(id: string): T | null { return null; }
|
||||
getViewWithId<T extends IView>(id: string): T | null { return null; }
|
||||
openView<T extends IView>(id: string, focus?: boolean | undefined): Promise<T | null> { return Promise.resolve(null); }
|
||||
closeView(id: string): void { }
|
||||
getViewProgressIndicator(id: string) { return null!; }
|
||||
@@ -584,25 +631,27 @@ export class TestEditorGroupsService implements IEditorGroupsService {
|
||||
|
||||
constructor(public groups: TestEditorGroupView[] = []) { }
|
||||
|
||||
onDidActiveGroupChange: Event<IEditorGroup> = Event.None;
|
||||
onDidChangeActiveGroup: Event<IEditorGroup> = Event.None;
|
||||
onDidActivateGroup: Event<IEditorGroup> = Event.None;
|
||||
onDidAddGroup: Event<IEditorGroup> = Event.None;
|
||||
onDidRemoveGroup: Event<IEditorGroup> = Event.None;
|
||||
onDidMoveGroup: Event<IEditorGroup> = Event.None;
|
||||
onDidGroupIndexChange: Event<IEditorGroup> = Event.None;
|
||||
onDidChangeGroupIndex: Event<IEditorGroup> = Event.None;
|
||||
onDidLayout: Event<IDimension> = Event.None;
|
||||
onDidEditorPartOptionsChange = Event.None;
|
||||
onDidChangeEditorPartOptions = Event.None;
|
||||
|
||||
orientation = GroupOrientation.HORIZONTAL;
|
||||
whenReady: Promise<void> = Promise.resolve(undefined);
|
||||
whenRestored: Promise<void> = Promise.resolve(undefined);
|
||||
willRestoreEditors = false;
|
||||
hasRestorableState = false;
|
||||
|
||||
contentDimension = { width: 800, height: 600 };
|
||||
|
||||
get activeGroup(): IEditorGroup { return this.groups[0]; }
|
||||
get count(): number { return this.groups.length; }
|
||||
|
||||
getGroups(_order?: GroupsOrder): ReadonlyArray<IEditorGroup> { return this.groups; }
|
||||
isRestored(): boolean { return true; }
|
||||
getGroups(_order?: GroupsOrder): readonly IEditorGroup[] { return this.groups; }
|
||||
getGroup(identifier: number): IEditorGroup | undefined { return this.groups.find(group => group.id === identifier); }
|
||||
getLabel(_identifier: number): string { return 'Group 1'; }
|
||||
findGroup(_scope: IFindGroupScope, _source?: number | IEditorGroup, _wrap?: boolean): IEditorGroup { throw new Error('not implemented'); }
|
||||
@@ -617,6 +666,7 @@ export class TestEditorGroupsService implements IEditorGroupsService {
|
||||
removeGroup(_group: number | IEditorGroup): void { }
|
||||
moveGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup { throw new Error('not implemented'); }
|
||||
mergeGroup(_group: number | IEditorGroup, _target: number | IEditorGroup, _options?: IMergeGroupOptions): IEditorGroup { throw new Error('not implemented'); }
|
||||
mergeAllGroups(): IEditorGroup { throw new Error('not implemented'); }
|
||||
copyGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup { throw new Error('not implemented'); }
|
||||
centerLayout(active: boolean): void { }
|
||||
isLayoutCentered(): boolean { return false; }
|
||||
@@ -629,14 +679,13 @@ export class TestEditorGroupView implements IEditorGroupView {
|
||||
|
||||
constructor(public id: number) { }
|
||||
|
||||
get group(): EditorGroup { throw new Error('not implemented'); }
|
||||
activeEditorPane!: IVisibleEditorPane;
|
||||
activeEditor!: IEditorInput;
|
||||
previewEditor!: IEditorInput;
|
||||
count!: number;
|
||||
stickyCount!: number;
|
||||
disposed!: boolean;
|
||||
editors: ReadonlyArray<IEditorInput> = [];
|
||||
editors: readonly IEditorInput[] = [];
|
||||
label!: string;
|
||||
ariaLabel!: string;
|
||||
index!: number;
|
||||
@@ -647,7 +696,7 @@ export class TestEditorGroupView implements IEditorGroupView {
|
||||
minimumHeight!: number;
|
||||
maximumHeight!: number;
|
||||
|
||||
titleDimensions!: IEditorGroupTitleDimensions;
|
||||
titleHeight!: IEditorGroupTitleHeight;
|
||||
|
||||
isEmpty = true;
|
||||
isMinimized = false;
|
||||
@@ -656,22 +705,23 @@ export class TestEditorGroupView implements IEditorGroupView {
|
||||
onDidGroupChange: Event<IGroupChangeEvent> = Event.None;
|
||||
onWillCloseEditor: Event<IEditorCloseEvent> = Event.None;
|
||||
onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
|
||||
onWillOpenEditor: Event<IEditorOpeningEvent> = Event.None;
|
||||
onDidOpenEditorFail: Event<IEditorInput> = Event.None;
|
||||
onDidFocus: Event<void> = Event.None;
|
||||
onDidChange: Event<{ width: number; height: number; }> = Event.None;
|
||||
onWillMoveEditor: Event<IEditorMoveEvent> = Event.None;
|
||||
|
||||
getEditors(_order?: EditorsOrder): ReadonlyArray<IEditorInput> { return []; }
|
||||
getEditors(_order?: EditorsOrder): readonly IEditorInput[] { return []; }
|
||||
findEditors(_resource: URI): readonly IEditorInput[] { return []; }
|
||||
getEditorByIndex(_index: number): IEditorInput { throw new Error('not implemented'); }
|
||||
getIndexOfEditor(_editor: IEditorInput): number { return -1; }
|
||||
openEditor(_editor: IEditorInput, _options?: IEditorOptions): Promise<IEditorPane> { throw new Error('not implemented'); }
|
||||
openEditors(_editors: IEditorInputWithOptions[]): Promise<IEditorPane> { throw new Error('not implemented'); }
|
||||
isOpened(_editor: IEditorInput | IResourceEditorInput): boolean { return false; }
|
||||
isPinned(_editor: IEditorInput): boolean { return false; }
|
||||
isSticky(_editor: IEditorInput): boolean { return false; }
|
||||
isActive(_editor: IEditorInput): boolean { return false; }
|
||||
moveEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: IMoveEditorOptions): void { }
|
||||
copyEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: ICopyEditorOptions): void { }
|
||||
contains(candidate: IEditorInput): boolean { return false; }
|
||||
moveEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: IEditorOptions | ITextEditorOptions): void { }
|
||||
copyEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: IEditorOptions | ITextEditorOptions): void { }
|
||||
async closeEditor(_editor?: IEditorInput, options?: ICloseEditorOptions): Promise<void> { }
|
||||
async closeEditors(_editors: IEditorInput[] | ICloseEditorsFilter, options?: ICloseEditorOptions): Promise<void> { }
|
||||
async closeAllEditors(options?: ICloseAllEditorsOptions): Promise<void> { }
|
||||
@@ -696,7 +746,7 @@ export class TestEditorGroupAccessor implements IEditorGroupsAccessor {
|
||||
|
||||
partOptions: IEditorPartOptions = {};
|
||||
|
||||
onDidEditorPartOptionsChange = Event.None;
|
||||
onDidChangeEditorPartOptions = Event.None;
|
||||
onDidVisibilityChange = Event.None;
|
||||
|
||||
getGroup(identifier: number): IEditorGroupView | undefined { throw new Error('Method not implemented.'); }
|
||||
@@ -732,21 +782,18 @@ export class TestEditorService implements EditorServiceImpl {
|
||||
public get activeEditor(): IEditorInput | undefined { return this._activeEditor; }
|
||||
public set activeEditor(value: IEditorInput | undefined) { this._activeEditor = value; }
|
||||
|
||||
editors: ReadonlyArray<IEditorInput> = [];
|
||||
mostRecentlyActiveEditors: ReadonlyArray<IEditorIdentifier> = [];
|
||||
visibleEditorPanes: ReadonlyArray<IVisibleEditorPane> = [];
|
||||
editors: readonly IEditorInput[] = [];
|
||||
mostRecentlyActiveEditors: readonly IEditorIdentifier[] = [];
|
||||
visibleEditorPanes: readonly IVisibleEditorPane[] = [];
|
||||
visibleTextEditorControls = [];
|
||||
visibleEditors: ReadonlyArray<IEditorInput> = [];
|
||||
visibleEditors: readonly IEditorInput[] = [];
|
||||
count = this.editors.length;
|
||||
|
||||
constructor(private editorGroupService?: IEditorGroupsService) { }
|
||||
getEditors() { return []; }
|
||||
findEditors() { return []; }
|
||||
findEditors() { return [] as any; }
|
||||
getEditorOverrides(resource: URI, options: IEditorOptions | undefined, group: IEditorGroup | undefined): [IOpenEditorOverrideHandler, IOpenEditorOverrideEntry][] { return []; }
|
||||
overrideOpenEditor(_handler: IOpenEditorOverrideHandler): IDisposable { return toDisposable(() => undefined); }
|
||||
registerCustomEditorViewTypesHandler(source: string, handler: ICustomEditorViewTypesHandler): IDisposable {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
openEditor(editor: IEditorInput, options?: IEditorOptions | ITextEditorOptions, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Promise<IEditorPane | undefined>;
|
||||
openEditor(editor: IResourceEditorInput | IUntitledTextResourceEditorInput, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Promise<ITextEditorPane | undefined>;
|
||||
openEditor(editor: IResourceDiffEditorInput, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Promise<ITextDiffEditorPane | undefined>;
|
||||
@@ -761,14 +808,13 @@ export class TestEditorService implements EditorServiceImpl {
|
||||
return [this.editorGroupService.activeGroup, editor as EditorInput, undefined];
|
||||
}
|
||||
openEditors(_editors: any, _group?: any): Promise<IEditorPane[]> { throw new Error('not implemented'); }
|
||||
isOpen(_editor: IEditorInput | IResourceEditorInput): boolean { return false; }
|
||||
isOpened(_editor: IResourceEditorInputIdentifier): boolean { return false; }
|
||||
replaceEditors(_editors: any, _group: any) { return Promise.resolve(undefined); }
|
||||
createEditorInput(_input: IResourceEditorInput | IUntitledTextResourceEditorInput | IResourceDiffEditorInput): EditorInput { throw new Error('not implemented'); }
|
||||
save(editors: IEditorIdentifier[], options?: ISaveEditorsOptions): Promise<boolean> { throw new Error('Method not implemented.'); }
|
||||
saveAll(options?: ISaveEditorsOptions): Promise<boolean> { throw new Error('Method not implemented.'); }
|
||||
revert(editors: IEditorIdentifier[], options?: IRevertOptions): Promise<boolean> { throw new Error('Method not implemented.'); }
|
||||
revertAll(options?: IRevertAllEditorsOptions): Promise<boolean> { throw new Error('Method not implemented.'); }
|
||||
whenClosed(editors: IResourceEditorInput[], options?: { waitForSaved: boolean; }): Promise<void> { throw new Error('Method not implemented.'); }
|
||||
}
|
||||
|
||||
export class TestFileService implements IFileService {
|
||||
@@ -814,9 +860,17 @@ export class TestFileService implements IFileService {
|
||||
return stats.map(stat => ({ stat, success: true }));
|
||||
}
|
||||
|
||||
async exists(_resource: URI): Promise<boolean> { return true; }
|
||||
readonly notExistsSet = new Set<URI>();
|
||||
|
||||
async exists(_resource: URI): Promise<boolean> { return !this.notExistsSet.has(_resource); }
|
||||
|
||||
readShouldThrowError: Error | undefined = undefined;
|
||||
|
||||
readFile(resource: URI, options?: IReadFileOptions | undefined): Promise<IFileContent> {
|
||||
if (this.readShouldThrowError) {
|
||||
throw this.readShouldThrowError;
|
||||
}
|
||||
|
||||
this.lastReadFileUri = resource;
|
||||
|
||||
return Promise.resolve({
|
||||
@@ -831,25 +885,16 @@ export class TestFileService implements IFileService {
|
||||
});
|
||||
}
|
||||
|
||||
readFileStream(resource: URI, options?: IReadFileOptions | undefined): Promise<IFileStreamContent> {
|
||||
readFileStream(resource: URI, options?: IReadFileStreamOptions | undefined): Promise<IFileStreamContent> {
|
||||
if (this.readShouldThrowError) {
|
||||
throw this.readShouldThrowError;
|
||||
}
|
||||
|
||||
this.lastReadFileUri = resource;
|
||||
|
||||
return Promise.resolve({
|
||||
resource,
|
||||
value: {
|
||||
on: (event: string, callback: Function): void => {
|
||||
if (event === 'data') {
|
||||
callback(this.content);
|
||||
}
|
||||
if (event === 'end') {
|
||||
callback();
|
||||
}
|
||||
},
|
||||
removeListener: () => { },
|
||||
resume: () => { },
|
||||
pause: () => { },
|
||||
destroy: () => { }
|
||||
},
|
||||
value: bufferToStream(VSBuffer.fromString(this.content)),
|
||||
etag: 'index.txt',
|
||||
encoding: 'utf8',
|
||||
mtime: Date.now(),
|
||||
@@ -896,6 +941,10 @@ export class TestFileService implements IFileService {
|
||||
return toDisposable(() => this.providers.delete(scheme));
|
||||
}
|
||||
|
||||
getProvider(scheme: string) {
|
||||
return this.providers.get(scheme);
|
||||
}
|
||||
|
||||
activateProvider(_scheme: string): Promise<void> { throw new Error('not implemented'); }
|
||||
canHandleResource(resource: URI): boolean { return resource.scheme === Schemas.file || this.providers.has(resource.scheme); }
|
||||
listCapabilities() {
|
||||
@@ -930,28 +979,37 @@ export class TestFileService implements IFileService {
|
||||
async canDelete(resource: URI, options?: { useTrash?: boolean | undefined; recursive?: boolean | undefined; } | undefined): Promise<Error | true> { return true; }
|
||||
}
|
||||
|
||||
export class TestBackupFileService extends InMemoryBackupFileService {
|
||||
export class TestWorkingCopyBackupService extends InMemoryWorkingCopyBackupService {
|
||||
|
||||
constructor() {
|
||||
super(resource => String(hash(resource.path)));
|
||||
super();
|
||||
}
|
||||
|
||||
parseBackupContent(textBufferFactory: ITextBufferFactory): string {
|
||||
const textBuffer = textBufferFactory.create(DefaultEndOfLine.LF).textBuffer;
|
||||
const lineCount = textBuffer.getLineCount();
|
||||
const range = new Range(1, 1, lineCount, textBuffer.getLineLength(lineCount) + 1);
|
||||
|
||||
return textBuffer.getValueInRange(range, EndOfLinePreference.TextDefined);
|
||||
}
|
||||
}
|
||||
|
||||
export class InMemoryTestBackupFileService extends BrowserBackupFileService {
|
||||
export function toUntypedWorkingCopyId(resource: URI): IWorkingCopyIdentifier {
|
||||
return toTypedWorkingCopyId(resource, '');
|
||||
}
|
||||
|
||||
readonly fileService: IFileService;
|
||||
export function toTypedWorkingCopyId(resource: URI, typeId = 'testBackupTypeId'): IWorkingCopyIdentifier {
|
||||
return { typeId, resource };
|
||||
}
|
||||
|
||||
export class InMemoryTestWorkingCopyBackupService extends BrowserWorkingCopyBackupService {
|
||||
|
||||
override readonly fileService: IFileService;
|
||||
|
||||
private backupResourceJoiners: Function[];
|
||||
private discardBackupJoiners: Function[];
|
||||
|
||||
discardedBackups: URI[];
|
||||
discardedBackups: IWorkingCopyIdentifier[];
|
||||
|
||||
constructor() {
|
||||
const environmentService = TestEnvironmentService;
|
||||
@@ -976,25 +1034,25 @@ export class InMemoryTestBackupFileService extends BrowserBackupFileService {
|
||||
return new Promise(resolve => this.discardBackupJoiners.push(resolve));
|
||||
}
|
||||
|
||||
async backup(resource: URI, content?: ITextSnapshot, versionId?: number, meta?: any, token?: CancellationToken): Promise<void> {
|
||||
await super.backup(resource, content, versionId, meta, token);
|
||||
override async backup(identifier: IWorkingCopyIdentifier, content?: VSBufferReadableStream | VSBufferReadable, versionId?: number, meta?: any, token?: CancellationToken): Promise<void> {
|
||||
await super.backup(identifier, content, versionId, meta, token);
|
||||
|
||||
while (this.backupResourceJoiners.length) {
|
||||
this.backupResourceJoiners.pop()!();
|
||||
}
|
||||
}
|
||||
|
||||
async discardBackup(resource: URI): Promise<void> {
|
||||
await super.discardBackup(resource);
|
||||
this.discardedBackups.push(resource);
|
||||
override async discardBackup(identifier: IWorkingCopyIdentifier): Promise<void> {
|
||||
await super.discardBackup(identifier);
|
||||
this.discardedBackups.push(identifier);
|
||||
|
||||
while (this.discardBackupJoiners.length) {
|
||||
this.discardBackupJoiners.pop()!();
|
||||
}
|
||||
}
|
||||
|
||||
async getBackupContents(resource: URI): Promise<string> {
|
||||
const backupResource = this.toBackupResource(resource);
|
||||
async getBackupContents(identifier: IWorkingCopyIdentifier): Promise<string> {
|
||||
const backupResource = this.toBackupResource(identifier);
|
||||
|
||||
const fileContents = await this.fileService.readFile(backupResource);
|
||||
|
||||
@@ -1016,24 +1074,52 @@ export class TestLifecycleService implements ILifecycleService {
|
||||
get onWillShutdown(): Event<WillShutdownEvent> { return this._onWillShutdown.event; }
|
||||
|
||||
private readonly _onShutdown = new Emitter<void>();
|
||||
get onShutdown(): Event<void> { return this._onShutdown.event; }
|
||||
get onDidShutdown(): Event<void> { return this._onShutdown.event; }
|
||||
|
||||
async when(): Promise<void> { }
|
||||
|
||||
shutdownJoiners: Promise<void>[] = [];
|
||||
|
||||
fireShutdown(reason = ShutdownReason.QUIT): void {
|
||||
this.shutdownJoiners = [];
|
||||
|
||||
this._onWillShutdown.fire({
|
||||
join: () => { },
|
||||
join: p => {
|
||||
this.shutdownJoiners.push(p);
|
||||
},
|
||||
reason
|
||||
});
|
||||
}
|
||||
|
||||
fireWillShutdown(event: BeforeShutdownEvent): void { this._onBeforeShutdown.fire(event); }
|
||||
fireBeforeShutdown(event: BeforeShutdownEvent): void { this._onBeforeShutdown.fire(event); }
|
||||
|
||||
fireWillShutdown(event: WillShutdownEvent): void { this._onWillShutdown.fire(event); }
|
||||
|
||||
shutdown(): void {
|
||||
this.fireShutdown();
|
||||
}
|
||||
}
|
||||
|
||||
export class TestBeforeShutdownEvent implements BeforeShutdownEvent {
|
||||
|
||||
value: boolean | Promise<boolean> | undefined;
|
||||
reason = ShutdownReason.CLOSE;
|
||||
|
||||
veto(value: boolean | Promise<boolean>): void {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
export class TestWillShutdownEvent implements WillShutdownEvent {
|
||||
|
||||
value: Promise<void>[] = [];
|
||||
reason = ShutdownReason.CLOSE;
|
||||
|
||||
join(promise: Promise<void>, id: string): void {
|
||||
this.value.push(promise);
|
||||
}
|
||||
}
|
||||
|
||||
export class TestTextResourceConfigurationService implements ITextResourceConfigurationService {
|
||||
|
||||
declare readonly _serviceBrand: undefined;
|
||||
@@ -1092,7 +1178,7 @@ export class RemoteFileSystemProvider implements IFileSystemProvider {
|
||||
}
|
||||
|
||||
export class TestInMemoryFileSystemProvider extends InMemoryFileSystemProvider implements IFileSystemProviderWithFileReadStreamCapability {
|
||||
readonly capabilities: FileSystemProviderCapabilities =
|
||||
override readonly capabilities: FileSystemProviderCapabilities =
|
||||
FileSystemProviderCapabilities.FileReadWrite
|
||||
| FileSystemProviderCapabilities.PathCaseSensitive
|
||||
| FileSystemProviderCapabilities.FileReadStream;
|
||||
@@ -1158,34 +1244,34 @@ export class TestHostService implements IHostService {
|
||||
|
||||
export class TestFilesConfigurationService extends FilesConfigurationService {
|
||||
|
||||
onFilesConfigurationChange(configuration: any): void {
|
||||
override onFilesConfigurationChange(configuration: any): void {
|
||||
super.onFilesConfigurationChange(configuration);
|
||||
}
|
||||
}
|
||||
|
||||
export class TestReadonlyTextFileEditorModel extends TextFileEditorModel {
|
||||
|
||||
isReadonly(): boolean {
|
||||
override isReadonly(): boolean {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export class TestEditorInput extends EditorInput {
|
||||
|
||||
constructor(public resource: URI, private typeId: string) {
|
||||
constructor(public resource: URI, private readonly _typeId: string) {
|
||||
super();
|
||||
}
|
||||
|
||||
getTypeId(): string {
|
||||
return this.typeId;
|
||||
override get typeId(): string {
|
||||
return this._typeId;
|
||||
}
|
||||
|
||||
resolve(): Promise<IEditorModel | null> {
|
||||
override resolve(): Promise<IEditorModel | null> {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
}
|
||||
|
||||
export function registerTestEditor(id: string, inputs: SyncDescriptor<EditorInput>[], factoryInputId?: string): IDisposable {
|
||||
export function registerTestEditor(id: string, inputs: SyncDescriptor<EditorInput>[], serializerInputId?: string): IDisposable {
|
||||
class TestEditor extends EditorPane {
|
||||
|
||||
private _scopedContextKeyService: IContextKeyService;
|
||||
@@ -1195,17 +1281,17 @@ export function registerTestEditor(id: string, inputs: SyncDescriptor<EditorInpu
|
||||
this._scopedContextKeyService = new MockContextKeyService();
|
||||
}
|
||||
|
||||
async setInput(input: EditorInput, options: EditorOptions | undefined, context: IEditorOpenContext, token: CancellationToken): Promise<void> {
|
||||
override async setInput(input: EditorInput, options: EditorOptions | undefined, context: IEditorOpenContext, token: CancellationToken): Promise<void> {
|
||||
super.setInput(input, options, context, token);
|
||||
|
||||
await input.resolve();
|
||||
}
|
||||
|
||||
getId(): string { return id; }
|
||||
override getId(): string { return id; }
|
||||
layout(): void { }
|
||||
createEditor(): void { }
|
||||
|
||||
get scopedContextKeyService() {
|
||||
override get scopedContextKeyService() {
|
||||
return this._scopedContextKeyService;
|
||||
}
|
||||
}
|
||||
@@ -1214,13 +1300,13 @@ export function registerTestEditor(id: string, inputs: SyncDescriptor<EditorInpu
|
||||
|
||||
disposables.add(Registry.as<IEditorRegistry>(Extensions.Editors).registerEditor(EditorDescriptor.create(TestEditor, id, 'Test Editor Control'), inputs));
|
||||
|
||||
if (factoryInputId) {
|
||||
if (serializerInputId) {
|
||||
|
||||
interface ISerializedTestInput {
|
||||
resource: string;
|
||||
}
|
||||
|
||||
class EditorsObserverTestEditorInputFactory implements IEditorInputFactory {
|
||||
class EditorsObserverTestEditorInputSerializer implements IEditorInputSerializer {
|
||||
|
||||
canSerialize(editorInput: EditorInput): boolean {
|
||||
return true;
|
||||
@@ -1238,11 +1324,11 @@ export function registerTestEditor(id: string, inputs: SyncDescriptor<EditorInpu
|
||||
deserialize(instantiationService: IInstantiationService, serializedEditorInput: string): EditorInput {
|
||||
let testInput: ISerializedTestInput = JSON.parse(serializedEditorInput);
|
||||
|
||||
return new TestFileEditorInput(URI.parse(testInput.resource), factoryInputId!);
|
||||
return new TestFileEditorInput(URI.parse(testInput.resource), serializerInputId!);
|
||||
}
|
||||
}
|
||||
|
||||
disposables.add(Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).registerEditorInputFactory(factoryInputId, EditorsObserverTestEditorInputFactory));
|
||||
disposables.add(Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).registerEditorInputSerializer(serializerInputId, EditorsObserverTestEditorInputSerializer));
|
||||
}
|
||||
|
||||
return disposables;
|
||||
@@ -1311,16 +1397,16 @@ export class TestFileEditorInput extends EditorInput implements IFileEditorInput
|
||||
|
||||
constructor(
|
||||
public resource: URI,
|
||||
private typeId: string
|
||||
private _typeId: string
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
getTypeId() { return this.typeId; }
|
||||
resolve(): Promise<IEditorModel | null> { return !this.fails ? Promise.resolve(null) : Promise.reject(new Error('fails')); }
|
||||
matches(other: EditorInput): boolean { return !!(other?.resource && this.resource.toString() === other.resource.toString() && other instanceof TestFileEditorInput && other.getTypeId() === this.typeId); }
|
||||
override get typeId() { return this._typeId; }
|
||||
override resolve(): Promise<IEditorModel | null> { return !this.fails ? Promise.resolve(null) : Promise.reject(new Error('fails')); }
|
||||
override matches(other: EditorInput): boolean { return !!(other?.resource && this.resource.toString() === other.resource.toString() && other instanceof TestFileEditorInput && other.typeId === this.typeId); }
|
||||
setPreferredResource(resource: URI): void { }
|
||||
setEncoding(encoding: string) { }
|
||||
async setEncoding(encoding: string) { }
|
||||
getEncoding() { return undefined; }
|
||||
setPreferredName(name: string): void { }
|
||||
setPreferredDescription(description: string): void { }
|
||||
@@ -1331,40 +1417,40 @@ export class TestFileEditorInput extends EditorInput implements IFileEditorInput
|
||||
setFailToOpen(): void {
|
||||
this.fails = true;
|
||||
}
|
||||
async save(groupId: GroupIdentifier, options?: ISaveOptions): Promise<IEditorInput | undefined> {
|
||||
override async save(groupId: GroupIdentifier, options?: ISaveOptions): Promise<IEditorInput | undefined> {
|
||||
this.gotSaved = true;
|
||||
this.dirty = false;
|
||||
return this;
|
||||
}
|
||||
async saveAs(groupId: GroupIdentifier, options?: ISaveOptions): Promise<IEditorInput | undefined> {
|
||||
override async saveAs(groupId: GroupIdentifier, options?: ISaveOptions): Promise<IEditorInput | undefined> {
|
||||
this.gotSavedAs = true;
|
||||
return this;
|
||||
}
|
||||
async revert(group: GroupIdentifier, options?: IRevertOptions): Promise<void> {
|
||||
override async revert(group: GroupIdentifier, options?: IRevertOptions): Promise<void> {
|
||||
this.gotReverted = true;
|
||||
this.gotSaved = false;
|
||||
this.gotSavedAs = false;
|
||||
this.dirty = false;
|
||||
}
|
||||
setDirty(): void { this.dirty = true; }
|
||||
isDirty(): boolean {
|
||||
override isDirty(): boolean {
|
||||
return this.dirty;
|
||||
}
|
||||
isReadonly(): boolean {
|
||||
override isReadonly(): boolean {
|
||||
return false;
|
||||
}
|
||||
isResolved(): boolean { return false; }
|
||||
dispose(): void {
|
||||
override dispose(): void {
|
||||
super.dispose();
|
||||
this.gotDisposed = true;
|
||||
}
|
||||
movedEditor: IMoveResult | undefined = undefined;
|
||||
rename(): IMoveResult | undefined { return this.movedEditor; }
|
||||
override rename(): IMoveResult | undefined { return this.movedEditor; }
|
||||
}
|
||||
|
||||
export class TestEditorPart extends EditorPart {
|
||||
|
||||
saveState(): void {
|
||||
override saveState(): void {
|
||||
return super.saveState();
|
||||
}
|
||||
|
||||
@@ -1381,6 +1467,16 @@ export class TestEditorPart extends EditorPart {
|
||||
}
|
||||
}
|
||||
|
||||
export async function createEditorPart(instantiationService: IInstantiationService, disposables: DisposableStore): Promise<TestEditorPart> {
|
||||
const part = disposables.add(instantiationService.createInstance(TestEditorPart));
|
||||
part.create(document.createElement('div'));
|
||||
part.layout(1080, 800);
|
||||
|
||||
await part.whenReady;
|
||||
|
||||
return part;
|
||||
}
|
||||
|
||||
export class TestListService implements IListService {
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
||||
@@ -1411,19 +1507,29 @@ export class TestPathService implements IPathService {
|
||||
|
||||
export class TestTextFileEditorModelManager extends TextFileEditorModelManager {
|
||||
|
||||
add(resource: URI, model: TextFileEditorModel): void {
|
||||
override add(resource: URI, model: TextFileEditorModel): void {
|
||||
return super.add(resource, model);
|
||||
}
|
||||
|
||||
remove(resource: URI): void {
|
||||
override remove(resource: URI): void {
|
||||
return super.remove(resource);
|
||||
}
|
||||
}
|
||||
|
||||
interface ITestTextFileEditorModel extends ITextFileEditorModel {
|
||||
readonly lastResolvedFileStat: IFileStatWithMetadata | undefined;
|
||||
}
|
||||
|
||||
export function getLastResolvedFileStat(model: unknown): IFileStatWithMetadata | undefined {
|
||||
const candidate = model as ITestTextFileEditorModel | undefined;
|
||||
|
||||
return candidate?.lastResolvedFileStat;
|
||||
}
|
||||
|
||||
export class TestWorkspacesService implements IWorkspacesService {
|
||||
_serviceBrand: undefined;
|
||||
|
||||
onRecentlyOpenedChange = Event.None;
|
||||
onDidChangeRecentlyOpened = Event.None;
|
||||
|
||||
async createUntitledWorkspace(folders?: IWorkspaceFolderCreationData[], remoteAuthority?: string): Promise<IWorkspaceIdentifier> { throw new Error('Method not implemented.'); }
|
||||
async deleteUntitledWorkspace(workspace: IWorkspaceIdentifier): Promise<void> { }
|
||||
@@ -1435,3 +1541,112 @@ export class TestWorkspacesService implements IWorkspacesService {
|
||||
async enterWorkspace(path: URI): Promise<IEnterWorkspaceResult | null> { throw new Error('Method not implemented.'); }
|
||||
async getWorkspaceIdentifier(workspacePath: URI): Promise<IWorkspaceIdentifier> { throw new Error('Method not implemented.'); }
|
||||
}
|
||||
|
||||
export class TestTerminalInstanceService implements ITerminalInstanceService {
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
||||
async getDefaultShellAndArgs(): Promise<{ shell: string, args: string[] | string | undefined }> {
|
||||
return {
|
||||
shell: 'bash',
|
||||
args: undefined
|
||||
};
|
||||
}
|
||||
async getMainProcessParentEnv(): Promise<IProcessEnvironment> {
|
||||
return {};
|
||||
}
|
||||
|
||||
async getXtermConstructor(): Promise<any> { throw new Error('Method not implemented.'); }
|
||||
async getXtermSearchConstructor(): Promise<any> { throw new Error('Method not implemented.'); }
|
||||
async getXtermUnicode11Constructor(): Promise<any> { throw new Error('Method not implemented.'); }
|
||||
async getXtermWebglConstructor(): Promise<any> { throw new Error('Method not implemented.'); }
|
||||
createWindowsShellHelper(shellProcessId: number, xterm: any): any { throw new Error('Method not implemented.'); }
|
||||
}
|
||||
|
||||
export class TestTerminalProfileResolverService implements ITerminalProfileResolverService {
|
||||
_serviceBrand: undefined;
|
||||
resolveIcon(shellLaunchConfig: IShellLaunchConfig): void { }
|
||||
async resolveShellLaunchConfig(shellLaunchConfig: IShellLaunchConfig, options: IShellLaunchConfigResolveOptions): Promise<void> { }
|
||||
async getDefaultProfile(options: IShellLaunchConfigResolveOptions): Promise<ITerminalProfile> { return { path: '/default', profileName: 'Default' }; }
|
||||
async getDefaultShell(options: IShellLaunchConfigResolveOptions): Promise<string> { return '/default'; }
|
||||
async getDefaultShellArgs(options: IShellLaunchConfigResolveOptions): Promise<string | string[]> { return []; }
|
||||
async getShellEnvironment(): Promise<IProcessEnvironment> { return process.env; }
|
||||
getSafeConfigValue(key: string, os: OperatingSystem): unknown | undefined { return undefined; }
|
||||
getSafeConfigValueFullKey(key: string): unknown | undefined { return undefined; }
|
||||
}
|
||||
|
||||
export class TestLocalTerminalService implements ILocalTerminalService {
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
||||
onPtyHostExit = Event.None;
|
||||
onPtyHostUnresponsive = Event.None;
|
||||
onPtyHostResponsive = Event.None;
|
||||
onPtyHostRestart = Event.None;
|
||||
|
||||
async createProcess(shellLaunchConfig: IShellLaunchConfig, cwd: string, cols: number, rows: number, env: IProcessEnvironment, windowsEnableConpty: boolean, shouldPersist: boolean): Promise<ITerminalChildProcess> {
|
||||
return new TestTerminalChildProcess(shouldPersist);
|
||||
}
|
||||
async attachToProcess(id: number): Promise<ITerminalChildProcess | undefined> { throw new Error('Method not implemented.'); }
|
||||
async listProcesses(): Promise<IProcessDetails[]> { throw new Error('Method not implemented.'); }
|
||||
getDefaultSystemShell(osOverride?: OperatingSystem): Promise<string> { throw new Error('Method not implemented.'); }
|
||||
getShellEnvironment(): Promise<IProcessEnvironment> { throw new Error('Method not implemented.'); }
|
||||
async setTerminalLayoutInfo(argsOrLayout?: ISetTerminalLayoutInfoArgs | ITerminalsLayoutInfoById) { throw new Error('Method not implemented.'); }
|
||||
async getTerminalLayoutInfo(): Promise<ITerminalsLayoutInfo | undefined> { throw new Error('Method not implemented.'); }
|
||||
async reduceConnectionGraceTime(): Promise<void> { throw new Error('Method not implemented.'); }
|
||||
processBinary(id: number, data: string): Promise<void> { throw new Error('Method not implemented.'); }
|
||||
}
|
||||
|
||||
class TestTerminalChildProcess implements ITerminalChildProcess {
|
||||
id: number = 0;
|
||||
|
||||
constructor(
|
||||
readonly shouldPersist: boolean
|
||||
) {
|
||||
}
|
||||
|
||||
onProcessData = Event.None;
|
||||
onProcessExit = Event.None;
|
||||
onProcessReady = Event.None;
|
||||
onProcessTitleChanged = Event.None;
|
||||
onProcessShellTypeChanged = Event.None;
|
||||
async start(): Promise<undefined> { return undefined; }
|
||||
shutdown(immediate: boolean): void { }
|
||||
input(data: string): void { }
|
||||
resize(cols: number, rows: number): void { }
|
||||
acknowledgeDataEvent(charCount: number): void { }
|
||||
async getInitialCwd(): Promise<string> { return ''; }
|
||||
async getCwd(): Promise<string> { return ''; }
|
||||
async getLatency(): Promise<number> { return 0; }
|
||||
async processBinary(data: string): Promise<void> { }
|
||||
}
|
||||
|
||||
export class TestQuickInputService implements IQuickInputService {
|
||||
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
||||
readonly onShow = Event.None;
|
||||
readonly onHide = Event.None;
|
||||
|
||||
readonly quickAccess = undefined!;
|
||||
backButton!: IQuickInputButton;
|
||||
|
||||
pick<T extends IQuickPickItem>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: IPickOptions<T> & { canPickMany: true }, token?: CancellationToken): Promise<T[]>;
|
||||
pick<T extends IQuickPickItem>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: IPickOptions<T> & { canPickMany: false }, token?: CancellationToken): Promise<T>;
|
||||
async pick<T extends IQuickPickItem>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: Omit<IPickOptions<T>, 'canPickMany'>, token?: CancellationToken): Promise<T | undefined> {
|
||||
if (isArray(picks)) {
|
||||
return <any>{ label: 'selectedPick', description: 'pick description', value: 'selectedPick' };
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async input(options?: IInputOptions, token?: CancellationToken): Promise<string> { return options ? 'resolved' + options.prompt : 'resolved'; }
|
||||
|
||||
createQuickPick<T extends IQuickPickItem>(): IQuickPick<T> { throw new Error('not implemented.'); }
|
||||
createInputBox(): IInputBox { throw new Error('not implemented.'); }
|
||||
focus(): void { throw new Error('not implemented.'); }
|
||||
toggle(): void { throw new Error('not implemented.'); }
|
||||
navigate(next: boolean, quickNavigate?: IQuickNavigateConfiguration): void { throw new Error('not implemented.'); }
|
||||
accept(): Promise<void> { throw new Error('not implemented.'); }
|
||||
back(): Promise<void> { throw new Error('not implemented.'); }
|
||||
cancel(): Promise<void> { throw new Error('not implemented.'); }
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@ import * as assert from 'assert';
|
||||
import { NotificationsModel, NotificationViewItem, INotificationChangeEvent, NotificationChangeType, NotificationViewItemContentChangeKind, IStatusMessageChangeEvent, StatusMessageChangeType } from 'vs/workbench/common/notifications';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import { INotification, Severity, NotificationsFilter } from 'vs/platform/notification/common/notification';
|
||||
import { createErrorWithActions } from 'vs/base/common/errorsWithActions';
|
||||
import { createErrorWithActions } from 'vs/base/common/errors';
|
||||
import { NotificationService } from 'vs/workbench/services/notification/common/notificationService';
|
||||
import { TestStorageService } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
|
||||
suite('Notifications', () => {
|
||||
|
||||
@@ -36,6 +38,12 @@ suite('Notifications', () => {
|
||||
assert.strictEqual(item1.equals(item4), false);
|
||||
assert.strictEqual(item1.equals(item5), false);
|
||||
|
||||
let itemId1 = NotificationViewItem.create({ id: 'same', message: 'Info Message', severity: Severity.Info })!;
|
||||
let itemId2 = NotificationViewItem.create({ id: 'same', message: 'Error Message', severity: Severity.Error })!;
|
||||
|
||||
assert.strictEqual(itemId1.equals(itemId2), true);
|
||||
assert.strictEqual(itemId1.equals(item3), false);
|
||||
|
||||
// Progress
|
||||
assert.strictEqual(item1.hasProgress, false);
|
||||
assert.strictEqual(item6.hasProgress, true);
|
||||
@@ -241,4 +249,41 @@ suite('Notifications', () => {
|
||||
disposable3.dispose();
|
||||
assert.ok(!model.statusMessage);
|
||||
});
|
||||
|
||||
test('Service', async () => {
|
||||
const service = new NotificationService(new TestStorageService());
|
||||
|
||||
let addNotificationCount = 0;
|
||||
let notification!: INotification;
|
||||
service.onDidAddNotification(n => {
|
||||
addNotificationCount++;
|
||||
notification = n;
|
||||
});
|
||||
service.info('hello there');
|
||||
assert.strictEqual(addNotificationCount, 1);
|
||||
assert.strictEqual(notification.message, 'hello there');
|
||||
assert.strictEqual(notification.silent, false);
|
||||
assert.strictEqual(notification.source, undefined);
|
||||
|
||||
let notificationHandle = service.notify({ message: 'important message', severity: Severity.Warning });
|
||||
assert.strictEqual(addNotificationCount, 2);
|
||||
assert.strictEqual(notification.message, 'important message');
|
||||
assert.strictEqual(notification.severity, Severity.Warning);
|
||||
|
||||
let removeNotificationCount = 0;
|
||||
service.onDidRemoveNotification(n => {
|
||||
removeNotificationCount++;
|
||||
notification = n;
|
||||
});
|
||||
notificationHandle.close();
|
||||
assert.strictEqual(removeNotificationCount, 1);
|
||||
assert.strictEqual(notification.message, 'important message');
|
||||
|
||||
notificationHandle = service.notify({ silent: true, message: 'test', severity: Severity.Ignore });
|
||||
assert.strictEqual(addNotificationCount, 3);
|
||||
assert.strictEqual(notification.message, 'test');
|
||||
assert.strictEqual(notification.silent, true);
|
||||
notificationHandle.close();
|
||||
assert.strictEqual(removeNotificationCount, 2);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,19 +8,20 @@ import { basename, isEqual, isEqualOrParent } from 'vs/base/common/resources';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IWorkspaceContextService, IWorkspace, WorkbenchState, IWorkspaceFolder, IWorkspaceFoldersChangeEvent, Workspace } from 'vs/platform/workspace/common/workspace';
|
||||
import { IWorkspaceContextService, IWorkspace, WorkbenchState, IWorkspaceFolder, IWorkspaceFoldersChangeEvent, Workspace, IWorkspaceFoldersWillChangeEvent } from 'vs/platform/workspace/common/workspace';
|
||||
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
|
||||
import { ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { ITextResourcePropertiesService } from 'vs/editor/common/services/textResourceConfigurationService';
|
||||
import { isLinux, isMacintosh } from 'vs/base/common/platform';
|
||||
import { InMemoryStorageService, WillSaveStateReason } from 'vs/platform/storage/common/storage';
|
||||
import { WorkingCopyService, IWorkingCopy, IWorkingCopyBackup, WorkingCopyCapabilities } from 'vs/workbench/services/workingCopy/common/workingCopyService';
|
||||
import { IWorkingCopy, IWorkingCopyBackup, WorkingCopyCapabilities } from 'vs/workbench/services/workingCopy/common/workingCopy';
|
||||
import { NullExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { IWorkingCopyFileService, IWorkingCopyFileOperationParticipant, WorkingCopyFileEvent, IDeleteOperation, ICopyOperation, IMoveOperation, IFileOperationUndoRedoInfo, ICreateFileOperation, ICreateOperation } from 'vs/workbench/services/workingCopy/common/workingCopyFileService';
|
||||
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IFileStatWithMetadata } from 'vs/platform/files/common/files';
|
||||
import { ISaveOptions, IRevertOptions } from 'vs/workbench/common/editor';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
|
||||
export class TestTextResourcePropertiesService implements ITextResourcePropertiesService {
|
||||
|
||||
@@ -50,6 +51,9 @@ export class TestContextService implements IWorkspaceContextService {
|
||||
private readonly _onDidChangeWorkspaceName: Emitter<void>;
|
||||
get onDidChangeWorkspaceName(): Event<void> { return this._onDidChangeWorkspaceName.event; }
|
||||
|
||||
private readonly _onWillChangeWorkspaceFolders: Emitter<IWorkspaceFoldersWillChangeEvent>;
|
||||
get onWillChangeWorkspaceFolders(): Event<IWorkspaceFoldersWillChangeEvent> { return this._onWillChangeWorkspaceFolders.event; }
|
||||
|
||||
private readonly _onDidChangeWorkspaceFolders: Emitter<IWorkspaceFoldersChangeEvent>;
|
||||
get onDidChangeWorkspaceFolders(): Event<IWorkspaceFoldersChangeEvent> { return this._onDidChangeWorkspaceFolders.event; }
|
||||
|
||||
@@ -60,6 +64,7 @@ export class TestContextService implements IWorkspaceContextService {
|
||||
this.workspace = workspace;
|
||||
this.options = options || Object.create(null);
|
||||
this._onDidChangeWorkspaceName = new Emitter<void>();
|
||||
this._onWillChangeWorkspaceFolders = new Emitter<IWorkspaceFoldersWillChangeEvent>();
|
||||
this._onDidChangeWorkspaceFolders = new Emitter<IWorkspaceFoldersChangeEvent>();
|
||||
this._onDidChangeWorkbenchState = new Emitter<WorkbenchState>();
|
||||
}
|
||||
@@ -121,13 +126,11 @@ export class TestContextService implements IWorkspaceContextService {
|
||||
|
||||
export class TestStorageService extends InMemoryStorageService {
|
||||
|
||||
emitWillSaveState(reason: WillSaveStateReason): void {
|
||||
override emitWillSaveState(reason: WillSaveStateReason): void {
|
||||
super.emitWillSaveState(reason);
|
||||
}
|
||||
}
|
||||
|
||||
export class TestWorkingCopyService extends WorkingCopyService { }
|
||||
|
||||
export class TestWorkingCopy extends Disposable implements IWorkingCopy {
|
||||
|
||||
private readonly _onDidChangeDirty = this._register(new Emitter<void>());
|
||||
@@ -136,16 +139,13 @@ export class TestWorkingCopy extends Disposable implements IWorkingCopy {
|
||||
private readonly _onDidChangeContent = this._register(new Emitter<void>());
|
||||
readonly onDidChangeContent = this._onDidChangeContent.event;
|
||||
|
||||
private readonly _onDispose = this._register(new Emitter<void>());
|
||||
readonly onDispose = this._onDispose.event;
|
||||
|
||||
readonly capabilities = WorkingCopyCapabilities.None;
|
||||
|
||||
readonly name = basename(this.resource);
|
||||
|
||||
private dirty = false;
|
||||
|
||||
constructor(public readonly resource: URI, isDirty = false) {
|
||||
constructor(public readonly resource: URI, isDirty = false, public readonly typeId = 'testWorkingCopyType') {
|
||||
super();
|
||||
|
||||
this.dirty = isDirty;
|
||||
@@ -177,12 +177,6 @@ export class TestWorkingCopy extends Disposable implements IWorkingCopy {
|
||||
async backup(token: CancellationToken): Promise<IWorkingCopyBackup> {
|
||||
return {};
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this._onDispose.fire();
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
export class TestWorkingCopyFileService implements IWorkingCopyFileService {
|
||||
@@ -195,18 +189,18 @@ export class TestWorkingCopyFileService implements IWorkingCopyFileService {
|
||||
|
||||
addFileOperationParticipant(participant: IWorkingCopyFileOperationParticipant): IDisposable { return Disposable.None; }
|
||||
|
||||
async delete(operations: IDeleteOperation[], undoInfo?: IFileOperationUndoRedoInfo, token?: CancellationToken): Promise<void> { }
|
||||
async delete(operations: IDeleteOperation[], token: CancellationToken, undoInfo?: IFileOperationUndoRedoInfo): Promise<void> { }
|
||||
|
||||
registerWorkingCopyProvider(provider: (resourceOrFolder: URI) => IWorkingCopy[]): IDisposable { return Disposable.None; }
|
||||
|
||||
getDirty(resource: URI): IWorkingCopy[] { return []; }
|
||||
|
||||
create(operations: ICreateFileOperation[], undoInfo?: IFileOperationUndoRedoInfo, token?: CancellationToken): Promise<IFileStatWithMetadata[]> { throw new Error('Method not implemented.'); }
|
||||
createFolder(operations: ICreateOperation[], undoInfo?: IFileOperationUndoRedoInfo, token?: CancellationToken): Promise<IFileStatWithMetadata[]> { throw new Error('Method not implemented.'); }
|
||||
create(operations: ICreateFileOperation[], token: CancellationToken, undoInfo?: IFileOperationUndoRedoInfo): Promise<IFileStatWithMetadata[]> { throw new Error('Method not implemented.'); }
|
||||
createFolder(operations: ICreateOperation[], token: CancellationToken, undoInfo?: IFileOperationUndoRedoInfo): Promise<IFileStatWithMetadata[]> { throw new Error('Method not implemented.'); }
|
||||
|
||||
move(operations: IMoveOperation[], undoInfo?: IFileOperationUndoRedoInfo): Promise<IFileStatWithMetadata[]> { throw new Error('Method not implemented.'); }
|
||||
move(operations: IMoveOperation[], token: CancellationToken, undoInfo?: IFileOperationUndoRedoInfo): Promise<IFileStatWithMetadata[]> { throw new Error('Method not implemented.'); }
|
||||
|
||||
copy(operations: ICopyOperation[], undoInfo?: IFileOperationUndoRedoInfo, token?: CancellationToken): Promise<IFileStatWithMetadata[]> { throw new Error('Method not implemented.'); }
|
||||
copy(operations: ICopyOperation[], token: CancellationToken, undoInfo?: IFileOperationUndoRedoInfo): Promise<IFileStatWithMetadata[]> { throw new Error('Method not implemented.'); }
|
||||
}
|
||||
|
||||
export function mock<T>(): Ctor<T> {
|
||||
@@ -218,3 +212,5 @@ export interface Ctor<T> {
|
||||
}
|
||||
|
||||
export class TestExtensionService extends NullExtensionService { }
|
||||
|
||||
export const TestProductService = { _serviceBrand: undefined, ...product };
|
||||
|
||||
@@ -23,6 +23,7 @@ import { mock } from 'vs/base/test/common/mock';
|
||||
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService';
|
||||
import { TextSearchManager } from 'vs/workbench/services/search/common/textSearchManager';
|
||||
import { NativeTextSearchManager } from 'vs/workbench/services/search/node/textSearchManager';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
|
||||
let rpcProtocol: TestRPCProtocol;
|
||||
let extHostSearch: NativeExtHostSearch;
|
||||
@@ -83,7 +84,7 @@ suite('ExtHostSearch', () => {
|
||||
const cancellation = new CancellationTokenSource();
|
||||
const p = extHostSearch.$provideFileSearchResults(mockMainThreadSearch.lastHandle, 0, query, cancellation.token);
|
||||
if (cancel) {
|
||||
await new Promise(resolve => process.nextTick(resolve));
|
||||
await timeout(0);
|
||||
cancellation.cancel();
|
||||
}
|
||||
|
||||
@@ -102,15 +103,11 @@ suite('ExtHostSearch', () => {
|
||||
};
|
||||
}
|
||||
|
||||
async function runTextSearch(query: ITextQuery, cancel = false): Promise<{ results: IFileMatch[], stats: ISearchCompleteStats }> {
|
||||
async function runTextSearch(query: ITextQuery): Promise<{ results: IFileMatch[], stats: ISearchCompleteStats }> {
|
||||
let stats: ISearchCompleteStats;
|
||||
try {
|
||||
const cancellation = new CancellationTokenSource();
|
||||
const p = extHostSearch.$provideTextSearchResults(mockMainThreadSearch.lastHandle, 0, query, cancellation.token);
|
||||
if (cancel) {
|
||||
await new Promise(resolve => process.nextTick(resolve));
|
||||
cancellation.cancel();
|
||||
}
|
||||
|
||||
stats = await p;
|
||||
} catch (err) {
|
||||
@@ -151,7 +148,7 @@ suite('ExtHostSearch', () => {
|
||||
this._pfs = mockPFS as any;
|
||||
}
|
||||
|
||||
protected createTextSearchManager(query: ITextQuery, provider: vscode.TextSearchProvider): TextSearchManager {
|
||||
protected override createTextSearchManager(query: ITextQuery, provider: vscode.TextSearchProvider): TextSearchManager {
|
||||
return new NativeTextSearchManager(query, provider, this._pfs);
|
||||
}
|
||||
};
|
||||
@@ -183,7 +180,7 @@ suite('ExtHostSearch', () => {
|
||||
function compareURIs(actual: URI[], expected: URI[]) {
|
||||
const sortAndStringify = (arr: URI[]) => arr.sort().map(u => u.toString());
|
||||
|
||||
assert.deepEqual(
|
||||
assert.deepStrictEqual(
|
||||
sortAndStringify(actual),
|
||||
sortAndStringify(expected));
|
||||
}
|
||||
@@ -215,7 +212,7 @@ suite('ExtHostSearch', () => {
|
||||
|
||||
const { results, stats } = await runFileSearch(getSimpleQuery());
|
||||
assert(!stats.limitHit);
|
||||
assert.equal(results.length, 3);
|
||||
assert.strictEqual(results.length, 3);
|
||||
compareURIs(results, reportedResults);
|
||||
});
|
||||
|
||||
@@ -223,12 +220,19 @@ suite('ExtHostSearch', () => {
|
||||
let cancelRequested = false;
|
||||
await registerTestFileSearchProvider({
|
||||
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Promise<URI[]> {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
token.onCancellationRequested(() => {
|
||||
function onCancel() {
|
||||
cancelRequested = true;
|
||||
|
||||
resolve([joinPath(options.folder, 'file1.ts')]); // or reject or nothing?
|
||||
});
|
||||
}
|
||||
|
||||
if (token.isCancellationRequested) {
|
||||
onCancel();
|
||||
} else {
|
||||
token.onCancellationRequested(() => onCancel());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -286,11 +290,11 @@ suite('ExtHostSearch', () => {
|
||||
await registerTestFileSearchProvider({
|
||||
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Promise<URI[]> {
|
||||
if (options.folder.toString() === rootFolderA.toString()) {
|
||||
assert.deepEqual(options.includes.sort(), ['*.ts', 'foo']);
|
||||
assert.deepEqual(options.excludes.sort(), ['*.js', 'bar']);
|
||||
assert.deepStrictEqual(options.includes.sort(), ['*.ts', 'foo']);
|
||||
assert.deepStrictEqual(options.excludes.sort(), ['*.js', 'bar']);
|
||||
} else {
|
||||
assert.deepEqual(options.includes.sort(), ['*.ts']);
|
||||
assert.deepEqual(options.excludes.sort(), ['*.js']);
|
||||
assert.deepStrictEqual(options.includes.sort(), ['*.ts']);
|
||||
assert.deepStrictEqual(options.excludes.sort(), ['*.js']);
|
||||
}
|
||||
|
||||
return Promise.resolve(null!);
|
||||
@@ -327,8 +331,8 @@ suite('ExtHostSearch', () => {
|
||||
test('include/excludes resolved correctly', async () => {
|
||||
await registerTestFileSearchProvider({
|
||||
provideFileSearchResults(query: vscode.FileSearchQuery, options: vscode.FileSearchOptions, token: vscode.CancellationToken): Promise<URI[]> {
|
||||
assert.deepEqual(options.includes.sort(), ['*.jsx', '*.ts']);
|
||||
assert.deepEqual(options.excludes.sort(), []);
|
||||
assert.deepStrictEqual(options.includes.sort(), ['*.jsx', '*.ts']);
|
||||
assert.deepStrictEqual(options.excludes.sort(), []);
|
||||
|
||||
return Promise.resolve(null!);
|
||||
}
|
||||
@@ -492,7 +496,7 @@ suite('ExtHostSearch', () => {
|
||||
|
||||
const { results, stats } = await runFileSearch(query);
|
||||
assert(stats.limitHit, 'Expected to return limitHit');
|
||||
assert.equal(results.length, 1);
|
||||
assert.strictEqual(results.length, 1);
|
||||
compareURIs(results, reportedResults.slice(0, 1));
|
||||
assert(wasCanceled, 'Expected to be canceled when hitting limit');
|
||||
});
|
||||
@@ -528,7 +532,7 @@ suite('ExtHostSearch', () => {
|
||||
|
||||
const { results, stats } = await runFileSearch(query);
|
||||
assert(stats.limitHit, 'Expected to return limitHit');
|
||||
assert.equal(results.length, 2);
|
||||
assert.strictEqual(results.length, 2);
|
||||
compareURIs(results, reportedResults.slice(0, 2));
|
||||
assert(wasCanceled, 'Expected to be canceled when hitting limit');
|
||||
});
|
||||
@@ -563,7 +567,7 @@ suite('ExtHostSearch', () => {
|
||||
|
||||
const { results, stats } = await runFileSearch(query);
|
||||
assert(!stats.limitHit, 'Expected not to return limitHit');
|
||||
assert.equal(results.length, 2);
|
||||
assert.strictEqual(results.length, 2);
|
||||
compareURIs(results, reportedResults);
|
||||
assert(!wasCanceled, 'Expected not to be canceled when just reaching limit');
|
||||
});
|
||||
@@ -601,8 +605,8 @@ suite('ExtHostSearch', () => {
|
||||
};
|
||||
|
||||
const { results } = await runFileSearch(query);
|
||||
assert.equal(results.length, 2); // Don't care which 2 we got
|
||||
assert.equal(cancels, 2, 'Expected all invocations to be canceled when hitting limit');
|
||||
assert.strictEqual(results.length, 2); // Don't care which 2 we got
|
||||
assert.strictEqual(cancels, 2, 'Expected all invocations to be canceled when hitting limit');
|
||||
});
|
||||
|
||||
test('works with non-file schemes', async () => {
|
||||
@@ -713,12 +717,12 @@ suite('ExtHostSearch', () => {
|
||||
match: null // Don't care about this right now
|
||||
}
|
||||
} : {
|
||||
uri: r.uri.toString(),
|
||||
text: r.text,
|
||||
lineNumber: r.lineNumber
|
||||
});
|
||||
uri: r.uri.toString(),
|
||||
text: r.text,
|
||||
lineNumber: r.lineNumber
|
||||
});
|
||||
|
||||
return assert.deepEqual(
|
||||
return assert.deepStrictEqual(
|
||||
makeComparable(actualTextSearchResults),
|
||||
makeComparable(expected));
|
||||
}
|
||||
@@ -756,8 +760,8 @@ suite('ExtHostSearch', () => {
|
||||
test('all provider calls get global include/excludes', async () => {
|
||||
await registerTestTextSearchProvider({
|
||||
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Promise<vscode.TextSearchComplete> {
|
||||
assert.equal(options.includes.length, 1);
|
||||
assert.equal(options.excludes.length, 1);
|
||||
assert.strictEqual(options.includes.length, 1);
|
||||
assert.strictEqual(options.excludes.length, 1);
|
||||
return Promise.resolve(null!);
|
||||
}
|
||||
});
|
||||
@@ -787,11 +791,11 @@ suite('ExtHostSearch', () => {
|
||||
await registerTestTextSearchProvider({
|
||||
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Promise<vscode.TextSearchComplete> {
|
||||
if (options.folder.toString() === rootFolderA.toString()) {
|
||||
assert.deepEqual(options.includes.sort(), ['*.ts', 'foo']);
|
||||
assert.deepEqual(options.excludes.sort(), ['*.js', 'bar']);
|
||||
assert.deepStrictEqual(options.includes.sort(), ['*.ts', 'foo']);
|
||||
assert.deepStrictEqual(options.excludes.sort(), ['*.js', 'bar']);
|
||||
} else {
|
||||
assert.deepEqual(options.includes.sort(), ['*.ts']);
|
||||
assert.deepEqual(options.excludes.sort(), ['*.js']);
|
||||
assert.deepStrictEqual(options.includes.sort(), ['*.ts']);
|
||||
assert.deepStrictEqual(options.excludes.sort(), ['*.js']);
|
||||
}
|
||||
|
||||
return Promise.resolve(null!);
|
||||
@@ -828,8 +832,8 @@ suite('ExtHostSearch', () => {
|
||||
test('include/excludes resolved correctly', async () => {
|
||||
await registerTestTextSearchProvider({
|
||||
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Promise<vscode.TextSearchComplete> {
|
||||
assert.deepEqual(options.includes.sort(), ['*.jsx', '*.ts']);
|
||||
assert.deepEqual(options.excludes.sort(), []);
|
||||
assert.deepStrictEqual(options.includes.sort(), ['*.jsx', '*.ts']);
|
||||
assert.deepStrictEqual(options.excludes.sort(), []);
|
||||
|
||||
return Promise.resolve(null!);
|
||||
}
|
||||
@@ -1184,8 +1188,8 @@ suite('ExtHostSearch', () => {
|
||||
};
|
||||
|
||||
const { results } = await runTextSearch(query);
|
||||
assert.equal(results.length, 2);
|
||||
assert.equal(cancels, 2);
|
||||
assert.strictEqual(results.length, 2);
|
||||
assert.strictEqual(cancels, 2);
|
||||
});
|
||||
|
||||
test('works with non-file schemes', async () => {
|
||||
|
||||
@@ -28,13 +28,13 @@ suite('MainThreadWorkspace', () => {
|
||||
test('simple', () => {
|
||||
instantiationService.stub(ISearchService, {
|
||||
fileSearch(query: IFileQuery) {
|
||||
assert.equal(query.folderQueries.length, 1);
|
||||
assert.equal(query.folderQueries[0].disregardIgnoreFiles, true);
|
||||
assert.strictEqual(query.folderQueries.length, 1);
|
||||
assert.strictEqual(query.folderQueries[0].disregardIgnoreFiles, true);
|
||||
|
||||
assert.deepEqual(query.includePattern, { 'foo': true });
|
||||
assert.equal(query.maxResults, 10);
|
||||
assert.strictEqual(query.maxResults, 10);
|
||||
|
||||
return Promise.resolve({ results: [] });
|
||||
return Promise.resolve({ results: [], messages: [] });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -52,11 +52,11 @@ suite('MainThreadWorkspace', () => {
|
||||
|
||||
instantiationService.stub(ISearchService, {
|
||||
fileSearch(query: IFileQuery) {
|
||||
assert.equal(query.folderQueries.length, 1);
|
||||
assert.equal(query.folderQueries[0].disregardIgnoreFiles, true);
|
||||
assert.deepEqual(query.folderQueries[0].excludePattern, { 'filesExclude': true });
|
||||
assert.strictEqual(query.folderQueries.length, 1);
|
||||
assert.strictEqual(query.folderQueries[0].disregardIgnoreFiles, true);
|
||||
assert.deepStrictEqual(query.folderQueries[0].excludePattern, { 'filesExclude': true });
|
||||
|
||||
return Promise.resolve({ results: [] });
|
||||
return Promise.resolve({ results: [], messages: [] });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -74,10 +74,10 @@ suite('MainThreadWorkspace', () => {
|
||||
|
||||
instantiationService.stub(ISearchService, {
|
||||
fileSearch(query: IFileQuery) {
|
||||
assert.equal(query.folderQueries[0].excludePattern, undefined);
|
||||
assert.deepEqual(query.excludePattern, undefined);
|
||||
assert.strictEqual(query.folderQueries[0].excludePattern, undefined);
|
||||
assert.deepStrictEqual(query.excludePattern, undefined);
|
||||
|
||||
return Promise.resolve({ results: [] });
|
||||
return Promise.resolve({ results: [], messages: [] });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -88,10 +88,10 @@ suite('MainThreadWorkspace', () => {
|
||||
test('exclude string', () => {
|
||||
instantiationService.stub(ISearchService, {
|
||||
fileSearch(query: IFileQuery) {
|
||||
assert.equal(query.folderQueries[0].excludePattern, undefined);
|
||||
assert.strictEqual(query.folderQueries[0].excludePattern, undefined);
|
||||
assert.deepEqual(query.excludePattern, { 'exclude/**': true });
|
||||
|
||||
return Promise.resolve({ results: [] });
|
||||
return Promise.resolve({ results: [], messages: [] });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -10,12 +10,13 @@ import * as fs from 'fs';
|
||||
import * as pfs from 'vs/base/node/pfs';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import * as assert from 'assert';
|
||||
import { getPathFromAmdModule } from 'vs/base/common/amd';
|
||||
import { getPathFromAmdModule } from 'vs/base/test/node/testUtils';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { RequestService } from 'vs/platform/request/node/requestService';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import 'vs/workbench/workbench.desktop.main';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { TestEnvironmentService } from 'vs/workbench/test/electron-browser/workbenchTestServices';
|
||||
|
||||
interface ColorInfo {
|
||||
description: string;
|
||||
@@ -33,7 +34,7 @@ export const experimental: string[] = []; // 'settings.modifiedItemForeground',
|
||||
suite('Color Registry', function () {
|
||||
|
||||
test('all colors documented in theme-color.md', async function () {
|
||||
const reqContext = await new RequestService(new TestConfigurationService(), new NullLogService()).request({ url: 'https://raw.githubusercontent.com/microsoft/vscode-docs/vnext/api/references/theme-color.md' }, CancellationToken.None);
|
||||
const reqContext = await new RequestService(new TestConfigurationService(), TestEnvironmentService, new NullLogService()).request({ url: 'https://raw.githubusercontent.com/microsoft/vscode-docs/vnext/api/references/theme-color.md' }, CancellationToken.None);
|
||||
const content = (await asText(reqContext))!;
|
||||
|
||||
const expression = /\-\s*\`([\w\.]+)\`: (.*)/g;
|
||||
@@ -83,10 +84,10 @@ suite('Color Registry', function () {
|
||||
}
|
||||
|
||||
let undocumentedKeys = Object.keys(missing).map(k => `\`${k}\`: ${missing[k]}`);
|
||||
assert.deepEqual(undocumentedKeys, [], 'Undocumented colors ids');
|
||||
assert.deepStrictEqual(undocumentedKeys, [], 'Undocumented colors ids');
|
||||
|
||||
let superfluousKeys = Object.keys(colorsInDoc);
|
||||
assert.deepEqual(superfluousKeys, [], 'Colors ids in doc that do not exist');
|
||||
assert.deepStrictEqual(superfluousKeys, [], 'Colors ids in doc that do not exist');
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,46 +3,46 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import 'vs/workbench/contrib/search/browser/search.contribution'; // load contributions
|
||||
import * as assert from 'assert';
|
||||
import * as fs from 'fs';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { createSyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { ISearchService } from 'vs/workbench/services/search/common/search';
|
||||
import { ITelemetryService, ITelemetryInfo } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IUntitledTextEditorService, UntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import * as minimist from 'minimist';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import { LocalSearchService } from 'vs/workbench/services/search/electron-browser/searchService';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { TestEditorService, TestEditorGroupsService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { TestEnvironmentService } from 'vs/workbench/test/electron-browser/workbenchTestServices';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
|
||||
import { SearchModel } from 'vs/workbench/contrib/search/common/searchModel';
|
||||
import { QueryBuilder, ITextQueryBuilderOptions } from 'vs/workbench/contrib/search/common/queryBuilder';
|
||||
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { testWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
|
||||
import { NullLogService, ILogService } from 'vs/platform/log/common/log';
|
||||
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
|
||||
import { ITextResourcePropertiesService } from 'vs/editor/common/services/textResourceConfigurationService';
|
||||
import { ClassifiedEvent, StrictPropertyCheck, GDPRClassification } from 'vs/platform/telemetry/common/gdprTypings';
|
||||
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
|
||||
import { UndoRedoService } from 'vs/platform/undoRedo/common/undoRedoService';
|
||||
import { TestDialogService } from 'vs/platform/dialogs/test/common/testDialogService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo';
|
||||
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
|
||||
import { TestDialogService } from 'vs/platform/dialogs/test/common/testDialogService';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { ILogService, NullLogService } from 'vs/platform/log/common/log';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { TestTextResourcePropertiesService, TestContextService } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
|
||||
import { ClassifiedEvent, GDPRClassification, StrictPropertyCheck } from 'vs/platform/telemetry/common/gdprTypings';
|
||||
import { ITelemetryInfo, ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
|
||||
import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo';
|
||||
import { UndoRedoService } from 'vs/platform/undoRedo/common/undoRedoService';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { testWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
|
||||
import 'vs/workbench/contrib/search/browser/search.contribution'; // load contributions
|
||||
import { ITextQueryBuilderOptions, QueryBuilder } from 'vs/workbench/contrib/search/common/queryBuilder';
|
||||
import { SearchModel } from 'vs/workbench/contrib/search/common/searchModel';
|
||||
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { ISearchService } from 'vs/workbench/services/search/common/search';
|
||||
import { LocalSearchService } from 'vs/workbench/services/search/electron-browser/searchService';
|
||||
import { IUntitledTextEditorService, UntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
|
||||
import { TestEditorGroupsService, TestEditorService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { TestContextService, TestTextResourcePropertiesService } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
import { TestEnvironmentService } from 'vs/workbench/test/electron-browser/workbenchTestServices';
|
||||
|
||||
|
||||
|
||||
// declare var __dirname: string;
|
||||
|
||||
@@ -84,8 +84,8 @@ suite.skip('TextSearch performance (integration)', () => {
|
||||
[IEditorService, new TestEditorService()],
|
||||
[IEditorGroupsService, new TestEditorGroupsService()],
|
||||
[IEnvironmentService, TestEnvironmentService],
|
||||
[IUntitledTextEditorService, createSyncDescriptor(UntitledTextEditorService)],
|
||||
[ISearchService, createSyncDescriptor(LocalSearchService)],
|
||||
[IUntitledTextEditorService, new SyncDescriptor(UntitledTextEditorService)],
|
||||
[ISearchService, new SyncDescriptor(LocalSearchService)],
|
||||
[ILogService, logService]
|
||||
));
|
||||
|
||||
@@ -105,12 +105,12 @@ suite.skip('TextSearch performance (integration)', () => {
|
||||
function onComplete(): void {
|
||||
try {
|
||||
const allEvents = telemetryService.events.map(e => JSON.stringify(e)).join('\n');
|
||||
assert.equal(telemetryService.events.length, 3, 'Expected 3 telemetry events, got:\n' + allEvents);
|
||||
assert.strictEqual(telemetryService.events.length, 3, 'Expected 3 telemetry events, got:\n' + allEvents);
|
||||
|
||||
const [firstRenderEvent, resultsShownEvent, resultsFinishedEvent] = telemetryService.events;
|
||||
assert.equal(firstRenderEvent.name, 'searchResultsFirstRender');
|
||||
assert.equal(resultsShownEvent.name, 'searchResultsShown');
|
||||
assert.equal(resultsFinishedEvent.name, 'searchResultsFinished');
|
||||
assert.strictEqual(firstRenderEvent.name, 'searchResultsFirstRender');
|
||||
assert.strictEqual(resultsShownEvent.name, 'searchResultsShown');
|
||||
assert.strictEqual(resultsFinishedEvent.name, 'searchResultsFinished');
|
||||
|
||||
telemetryService.events = [];
|
||||
|
||||
@@ -202,7 +202,8 @@ class TestTelemetryService implements ITelemetryService {
|
||||
return Promise.resolve({
|
||||
instanceId: 'someValue.instanceId',
|
||||
sessionId: 'someValue.sessionId',
|
||||
machineId: 'someValue.machineId'
|
||||
machineId: 'someValue.machineId',
|
||||
firstSessionDate: 'someValue.firstSessionDate'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,16 +5,15 @@
|
||||
|
||||
import { workbenchInstantiationService as browserWorkbenchInstantiationService, ITestInstantiationService, TestLifecycleService, TestFilesConfigurationService, TestFileService, TestFileDialogService, TestPathService, TestEncodingOracle, TestProductService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
|
||||
import { NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
|
||||
import { NativeTextFileService, } from 'vs/workbench/services/textfile/electron-browser/nativeTextFileService';
|
||||
import { ISharedProcessService } from 'vs/platform/ipc/electron-sandbox/services';
|
||||
import { NativeTextFileService, } from 'vs/workbench/services/textfile/electron-sandbox/nativeTextFileService';
|
||||
import { INativeHostService } from 'vs/platform/native/electron-sandbox/native';
|
||||
import { FileOperationError, IFileService } from 'vs/platform/files/common/files';
|
||||
import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
|
||||
import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { INativeWorkbenchConfiguration, INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService';
|
||||
import { INativeWorkbenchConfiguration, INativeWorkbenchEnvironmentService, NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService';
|
||||
import { IDialogService, IFileDialogService, INativeOpenDialogOptions } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { ITextResourceConfigurationService } from 'vs/editor/common/services/textResourceConfigurationService';
|
||||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
@@ -31,8 +30,8 @@ import { IPathService } from 'vs/workbench/services/path/common/pathService';
|
||||
import { IWorkingCopyFileService } from 'vs/workbench/services/workingCopy/common/workingCopyFileService';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
|
||||
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
|
||||
import { NodeTestBackupFileService } from 'vs/workbench/services/backup/test/electron-browser/backupFileService.test';
|
||||
import { IWorkingCopyBackupService } from 'vs/workbench/services/workingCopy/common/workingCopyBackup';
|
||||
import { NodeTestWorkingCopyBackupService } from 'vs/workbench/services/workingCopy/test/electron-browser/workingCopyBackupService.test';
|
||||
import { IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { TestContextService } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
@@ -40,12 +39,18 @@ import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/ur
|
||||
import { MouseInputEvent } from 'vs/base/parts/sandbox/common/electronTypes';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { IOSProperties, IOSStatistics } from 'vs/platform/native/common/native';
|
||||
import { homedir, release } from 'os';
|
||||
import { homedir, release, tmpdir, hostname } from 'os';
|
||||
import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { getUserDataPath } from 'vs/platform/environment/node/userDataPath';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
import { IElevatedFileService } from 'vs/workbench/services/files/common/elevatedFileService';
|
||||
|
||||
const args = parseArgs(process.argv, OPTIONS);
|
||||
|
||||
export const TestWorkbenchConfiguration: INativeWorkbenchConfiguration = {
|
||||
windowId: 0,
|
||||
machineId: 'testMachineId',
|
||||
sessionId: 'testSessionId',
|
||||
logLevel: LogLevel.Error,
|
||||
mainPid: 0,
|
||||
partsSplashPath: '',
|
||||
@@ -54,8 +59,12 @@ export const TestWorkbenchConfiguration: INativeWorkbenchConfiguration = {
|
||||
execPath: process.execPath,
|
||||
perfMarks: [],
|
||||
colorScheme: { dark: true, highContrast: false },
|
||||
os: { release: release() },
|
||||
...parseArgs(process.argv, OPTIONS)
|
||||
os: { release: release(), hostname: hostname() },
|
||||
product,
|
||||
homeDir: homedir(),
|
||||
tmpDir: tmpdir(),
|
||||
userDataDir: getUserDataPath(args),
|
||||
...args
|
||||
};
|
||||
|
||||
export const TestEnvironmentService = new NativeWorkbenchEnvironmentService(TestWorkbenchConfiguration, TestProductService);
|
||||
@@ -64,7 +73,7 @@ export class TestTextFileService extends NativeTextFileService {
|
||||
private resolveTextContentError!: FileOperationError | null;
|
||||
|
||||
constructor(
|
||||
@IFileService protected fileService: IFileService,
|
||||
@IFileService fileService: IFileService,
|
||||
@IUntitledTextEditorService untitledTextEditorService: IUntitledTextEditorService,
|
||||
@ILifecycleService lifecycleService: ILifecycleService,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@@ -82,7 +91,7 @@ export class TestTextFileService extends NativeTextFileService {
|
||||
@ILogService logService: ILogService,
|
||||
@IUriIdentityService uriIdentityService: IUriIdentityService,
|
||||
@IModeService modeService: IModeService,
|
||||
@INativeHostService nativeHostService: INativeHostService
|
||||
@IElevatedFileService elevatedFileService: IElevatedFileService
|
||||
) {
|
||||
super(
|
||||
fileService,
|
||||
@@ -101,7 +110,7 @@ export class TestTextFileService extends NativeTextFileService {
|
||||
workingCopyFileService,
|
||||
uriIdentityService,
|
||||
modeService,
|
||||
nativeHostService,
|
||||
elevatedFileService,
|
||||
logService
|
||||
);
|
||||
}
|
||||
@@ -110,7 +119,7 @@ export class TestTextFileService extends NativeTextFileService {
|
||||
this.resolveTextContentError = error;
|
||||
}
|
||||
|
||||
async readStream(resource: URI, options?: IReadTextFileOptions): Promise<ITextFileStreamContent> {
|
||||
override async readStream(resource: URI, options?: IReadTextFileOptions): Promise<ITextFileStreamContent> {
|
||||
if (this.resolveTextContentError) {
|
||||
const error = this.resolveTextContentError;
|
||||
this.resolveTextContentError = null;
|
||||
@@ -135,7 +144,7 @@ export class TestTextFileService extends NativeTextFileService {
|
||||
export class TestNativeTextFileServiceWithEncodingOverrides extends NativeTextFileService {
|
||||
|
||||
private _testEncoding: TestEncodingOracle | undefined;
|
||||
get encoding(): TestEncodingOracle {
|
||||
override get encoding(): TestEncodingOracle {
|
||||
if (!this._testEncoding) {
|
||||
this._testEncoding = this._register(this.instantiationService.createInstance(TestEncodingOracle));
|
||||
}
|
||||
@@ -167,6 +176,7 @@ export class TestNativeHostService implements INativeHostService {
|
||||
onDidResumeOS: Event<unknown> = Event.None;
|
||||
onDidChangeColorScheme = Event.None;
|
||||
onDidChangePassword = Event.None;
|
||||
onDidChangeDisplay = Event.None;
|
||||
|
||||
windowCount = Promise.resolve(1);
|
||||
getWindowCount(): Promise<number> { return this.windowCount; }
|
||||
@@ -198,7 +208,7 @@ export class TestNativeHostService implements INativeHostService {
|
||||
async showItemInFolder(path: string): Promise<void> { }
|
||||
async setRepresentedFilename(path: string): Promise<void> { }
|
||||
async isAdmin(): Promise<boolean> { return false; }
|
||||
async writeElevated(source: URI, target: URI, options?: { overwriteReadonly?: boolean | undefined; }): Promise<void> { }
|
||||
async writeElevated(source: URI, target: URI): Promise<void> { }
|
||||
async getOSProperties(): Promise<IOSProperties> { return Object.create(null); }
|
||||
async getOSStatistics(): Promise<IOSStatistics> { return Object.create(null); }
|
||||
async getOSVirtualMachineHint(): Promise<number> { return 0; }
|
||||
@@ -248,6 +258,9 @@ export function workbenchInstantiationService(): ITestInstantiationService {
|
||||
});
|
||||
|
||||
instantiationService.stub(INativeHostService, new TestNativeHostService());
|
||||
instantiationService.stub(IEnvironmentService, TestEnvironmentService);
|
||||
instantiationService.stub(INativeEnvironmentService, TestEnvironmentService);
|
||||
instantiationService.stub(IWorkbenchEnvironmentService, TestEnvironmentService);
|
||||
instantiationService.stub(INativeWorkbenchEnvironmentService, TestEnvironmentService);
|
||||
|
||||
return instantiationService;
|
||||
@@ -263,7 +276,7 @@ export class TestServiceAccessor {
|
||||
@IFileService public fileService: TestFileService,
|
||||
@INativeHostService public nativeHostService: TestNativeHostService,
|
||||
@IFileDialogService public fileDialogService: TestFileDialogService,
|
||||
@IBackupFileService public backupFileService: NodeTestBackupFileService,
|
||||
@IWorkingCopyBackupService public workingCopyBackupService: NodeTestWorkingCopyBackupService,
|
||||
@IWorkingCopyService public workingCopyService: IWorkingCopyService,
|
||||
@IEditorService public editorService: IEditorService
|
||||
) {
|
||||
@@ -272,8 +285,6 @@ export class TestServiceAccessor {
|
||||
|
||||
export class TestNativePathService extends TestPathService {
|
||||
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
||||
constructor() {
|
||||
super(URI.file(homedir()));
|
||||
}
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { findPorts, getSockets, loadConnectionTable, loadListeningPorts } from 'vs/workbench/api/node/extHostTunnelService';
|
||||
import { findPorts, getRootProcesses, getSockets, loadConnectionTable, loadListeningPorts, tryFindRootPorts } from 'vs/workbench/api/node/extHostTunnelService';
|
||||
|
||||
const tcp =
|
||||
` sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
|
||||
@@ -215,52 +214,68 @@ const processes: { pid: number, cwd: string, cmd: string }[] = [
|
||||
}
|
||||
];
|
||||
|
||||
if (platform.isLinux) {
|
||||
suite('ExtHostTunnelService', () => {
|
||||
test('getSockets', function () {
|
||||
const result = getSockets(procSockets);
|
||||
assert.equal(result.length, 78);
|
||||
// 4412 is the pid fo the http-server in the test data
|
||||
assert.notEqual(result.find(value => value.pid === 4412), undefined);
|
||||
});
|
||||
const psStdOut =
|
||||
`4 S root 1 0 0 80 0 - 596 - 1440 2 14:41 ? 00:00:00 /bin/sh -c echo Container started ; trap "exit 0" 15; while sleep 1 & wait $!; do :; done
|
||||
4 S root 14 0 0 80 0 - 596 - 764 4 14:41 ? 00:00:00 /bin/sh
|
||||
4 S root 40 0 0 80 0 - 596 - 700 4 14:41 ? 00:00:00 /bin/sh
|
||||
4 S root 513 380 0 80 0 - 2476 - 3404 1 14:41 pts/1 00:00:00 sudo npx http-server -p 5000
|
||||
4 S root 514 513 0 80 0 - 165439 - 41380 5 14:41 pts/1 00:00:00 http-server
|
||||
0 S root 1052 1 0 80 0 - 573 - 752 5 14:43 ? 00:00:00 sleep 1
|
||||
0 S node 1056 329 0 80 0 - 596 do_wai 764 10 14:43 ? 00:00:00 /bin/sh -c ps -F -A -l | grep root
|
||||
0 S node 1058 1056 0 80 0 - 770 pipe_w 888 9 14:43 ? 00:00:00 grep root`;
|
||||
|
||||
test('loadConnectionTable', function () {
|
||||
const result = loadConnectionTable(tcp);
|
||||
assert.equal(result.length, 6);
|
||||
assert.deepEqual(result[0], {
|
||||
10: '1',
|
||||
11: '0000000010173312',
|
||||
12: '100',
|
||||
13: '0',
|
||||
14: '0',
|
||||
15: '10',
|
||||
16: '0',
|
||||
inode: '2335214',
|
||||
local_address: '00000000:0BBA',
|
||||
rem_address: '00000000:0000',
|
||||
retrnsmt: '00000000',
|
||||
sl: '0:',
|
||||
st: '0A',
|
||||
timeout: '0',
|
||||
tr: '00:00000000',
|
||||
tx_queue: '00000000:00000000',
|
||||
uid: '1000'
|
||||
});
|
||||
});
|
||||
suite('ExtHostTunnelService', () => {
|
||||
test('getSockets', function () {
|
||||
const result = getSockets(procSockets);
|
||||
assert.strictEqual(Object.keys(result).length, 75);
|
||||
// 4412 is the pid of the http-server in the test data
|
||||
assert.notStrictEqual(Object.keys(result).find(key => result[key].pid === 4412), undefined);
|
||||
});
|
||||
|
||||
test('loadListeningPorts', function () {
|
||||
const result = loadListeningPorts(tcp, tcp6);
|
||||
// There should be 7 based on the input data. One of them should be 3002.
|
||||
assert.equal(result.length, 7);
|
||||
assert.notEqual(result.find(value => value.port === 3002), undefined);
|
||||
});
|
||||
|
||||
test('findPorts', async function () {
|
||||
const result = await findPorts(tcp, tcp6, procSockets, processes);
|
||||
assert.equal(result.length, 1);
|
||||
assert.equal(result[0].host, '0.0.0.0');
|
||||
assert.equal(result[0].port, 3002);
|
||||
assert.equal(result[0].detail, 'http-server');
|
||||
test('loadConnectionTable', function () {
|
||||
const result = loadConnectionTable(tcp);
|
||||
assert.strictEqual(result.length, 6);
|
||||
assert.deepStrictEqual(result[0], {
|
||||
10: '1',
|
||||
11: '0000000010173312',
|
||||
12: '100',
|
||||
13: '0',
|
||||
14: '0',
|
||||
15: '10',
|
||||
16: '0',
|
||||
inode: '2335214',
|
||||
local_address: '00000000:0BBA',
|
||||
rem_address: '00000000:0000',
|
||||
retrnsmt: '00000000',
|
||||
sl: '0:',
|
||||
st: '0A',
|
||||
timeout: '0',
|
||||
tr: '00:00000000',
|
||||
tx_queue: '00000000:00000000',
|
||||
uid: '1000'
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
test('loadListeningPorts', function () {
|
||||
const result = loadListeningPorts(tcp, tcp6);
|
||||
// There should be 7 based on the input data. One of them should be 3002.
|
||||
assert.strictEqual(result.length, 7);
|
||||
assert.notStrictEqual(result.find(value => value.port === 3002), undefined);
|
||||
});
|
||||
|
||||
test('tryFindRootPorts', function () {
|
||||
const rootProcesses = getRootProcesses(psStdOut);
|
||||
assert.strictEqual(rootProcesses.length, 6);
|
||||
const result = tryFindRootPorts([{ socket: 1000, ip: '127.0.0.1', port: 5000 }], psStdOut, new Map());
|
||||
assert.strictEqual(result.size, 1);
|
||||
assert.strictEqual(result.get(5000)?.pid, 514);
|
||||
});
|
||||
|
||||
test('findPorts', async function () {
|
||||
const result = await findPorts(loadListeningPorts(tcp, tcp6), getSockets(procSockets), processes);
|
||||
assert.strictEqual(result.length, 1);
|
||||
assert.strictEqual(result[0].host, '0.0.0.0');
|
||||
assert.strictEqual(result[0].port, 3002);
|
||||
assert.strictEqual(result[0].detail, 'http-server');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user