mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-09 17:52:34 -05:00
Merge from vscode 2cd495805cf99b31b6926f08ff4348124b2cf73d
This commit is contained in:
committed by
AzureDataStudio
parent
a8a7559229
commit
1388493cc1
85
src/vs/workbench/test/browser/api/extHostDecorations.test.ts
Normal file
85
src/vs/workbench/test/browser/api/extHostDecorations.test.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { MainThreadDecorationsShape } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { ExtHostDecorations } from 'vs/workbench/api/common/extHostDecorations';
|
||||
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
|
||||
import { nullExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
|
||||
|
||||
suite('ExtHostDecorations', function () {
|
||||
|
||||
let mainThreadShape: MainThreadDecorationsShape;
|
||||
let extHostDecorations: ExtHostDecorations;
|
||||
let providers = new Set<number>();
|
||||
|
||||
setup(function () {
|
||||
|
||||
providers.clear();
|
||||
|
||||
mainThreadShape = new class extends mock<MainThreadDecorationsShape>() {
|
||||
$registerDecorationProvider(handle: number) {
|
||||
providers.add(handle);
|
||||
}
|
||||
};
|
||||
|
||||
extHostDecorations = new ExtHostDecorations(
|
||||
new class extends mock<IExtHostRpcService>() {
|
||||
getProxy(): any {
|
||||
return mainThreadShape;
|
||||
}
|
||||
},
|
||||
new NullLogService()
|
||||
);
|
||||
});
|
||||
|
||||
test('SCM Decorations missing #100524', async function () {
|
||||
|
||||
let calledA = false;
|
||||
let calledB = false;
|
||||
|
||||
// never returns
|
||||
extHostDecorations.registerDecorationProvider({
|
||||
onDidChangeDecorations: Event.None,
|
||||
provideDecoration() {
|
||||
calledA = true;
|
||||
return new Promise(() => { });
|
||||
}
|
||||
}, nullExtensionDescription.identifier);
|
||||
|
||||
// always returns
|
||||
extHostDecorations.registerDecorationProvider({
|
||||
onDidChangeDecorations: Event.None,
|
||||
provideDecoration() {
|
||||
calledB = true;
|
||||
return new Promise(resolve => resolve({ letter: 'H', title: 'Hello' }));
|
||||
}
|
||||
}, nullExtensionDescription.identifier);
|
||||
|
||||
|
||||
const requests = [...providers.values()].map((handle, idx) => {
|
||||
return extHostDecorations.$provideDecorations(handle, [{ id: idx, uri: URI.parse('test:///file') }], CancellationToken.None);
|
||||
});
|
||||
|
||||
assert.equal(calledA, true);
|
||||
assert.equal(calledB, true);
|
||||
|
||||
assert.equal(requests.length, 2);
|
||||
const [first, second] = requests;
|
||||
|
||||
const firstResult = await Promise.race([first, timeout(30).then(() => false)]);
|
||||
assert.equal(typeof firstResult, 'boolean'); // never finishes...
|
||||
|
||||
const secondResult = await Promise.race([second, timeout(30).then(() => false)]);
|
||||
assert.equal(typeof secondResult, 'object');
|
||||
});
|
||||
|
||||
});
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -111,6 +111,41 @@ suite('NotebookConcatDocument', function () {
|
||||
assert.deepStrictEqual(actual, lines);
|
||||
}
|
||||
|
||||
test('contains', function () {
|
||||
|
||||
const cellUri1 = CellUri.generate(notebook.uri, 1);
|
||||
const cellUri2 = CellUri.generate(notebook.uri, 2);
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
versionId: notebook.versionId + 1,
|
||||
changes: [[0, 0, [{
|
||||
handle: 1,
|
||||
uri: cellUri1,
|
||||
source: ['Hello', 'World', 'Hello World!'],
|
||||
language: 'test',
|
||||
cellKind: CellKind.Code,
|
||||
outputs: [],
|
||||
}, {
|
||||
handle: 2,
|
||||
uri: cellUri2,
|
||||
source: ['Hallo', 'Welt', 'Hallo Welt!'],
|
||||
language: 'test',
|
||||
cellKind: CellKind.Code,
|
||||
outputs: [],
|
||||
}]]]
|
||||
});
|
||||
|
||||
|
||||
assert.equal(notebook.cells.length, 1 + 2); // markdown and code
|
||||
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook, undefined);
|
||||
|
||||
assert.equal(doc.contains(cellUri1), true);
|
||||
assert.equal(doc.contains(cellUri2), true);
|
||||
assert.equal(doc.contains(URI.parse('some://miss/path')), false);
|
||||
});
|
||||
|
||||
test('location, position mapping', function () {
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
@@ -454,4 +489,53 @@ suite('NotebookConcatDocument', function () {
|
||||
assert.equal(doc.getText(new Range(0, 0, 1, 0)), 'Hello\n');
|
||||
assert.equal(doc.getText(new Range(2, 0, 4, 0)), 'Hello World!\nHallo\n');
|
||||
});
|
||||
|
||||
test('validateRange/Position', function () {
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
versionId: notebook.versionId + 1,
|
||||
changes: [[0, 0, [{
|
||||
handle: 1,
|
||||
uri: CellUri.generate(notebook.uri, 1),
|
||||
source: ['Hello', 'World', 'Hello World!'],
|
||||
language: 'test',
|
||||
cellKind: CellKind.Code,
|
||||
outputs: [],
|
||||
}, {
|
||||
handle: 2,
|
||||
uri: CellUri.generate(notebook.uri, 2),
|
||||
source: ['Hallo', 'Welt', 'Hallo Welt!'],
|
||||
language: 'test',
|
||||
cellKind: CellKind.Code,
|
||||
outputs: [],
|
||||
}]]]
|
||||
});
|
||||
|
||||
assert.equal(notebook.cells.length, 1 + 2); // markdown and code
|
||||
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook, undefined);
|
||||
assertLines(doc, 'Hello', 'World', 'Hello World!', 'Hallo', 'Welt', 'Hallo Welt!');
|
||||
|
||||
|
||||
function assertPosition(actual: vscode.Position, expectedLine: number, expectedCh: number) {
|
||||
assert.equal(actual.line, expectedLine);
|
||||
assert.equal(actual.character, expectedCh);
|
||||
}
|
||||
|
||||
|
||||
// "fixed"
|
||||
assertPosition(doc.validatePosition(new Position(0, 1000)), 0, 5);
|
||||
assertPosition(doc.validatePosition(new Position(2, 1000)), 2, 12);
|
||||
assertPosition(doc.validatePosition(new Position(5, 1000)), 5, 11);
|
||||
assertPosition(doc.validatePosition(new Position(5000, 1000)), 5, 11);
|
||||
|
||||
// "good"
|
||||
assertPosition(doc.validatePosition(new Position(0, 1)), 0, 1);
|
||||
assertPosition(doc.validatePosition(new Position(0, 5)), 0, 5);
|
||||
assertPosition(doc.validatePosition(new Position(2, 8)), 2, 8);
|
||||
assertPosition(doc.validatePosition(new Position(2, 12)), 2, 12);
|
||||
assertPosition(doc.validatePosition(new Position(5, 11)), 5, 11);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -95,10 +95,6 @@ suite('MainThreadEditors', () => {
|
||||
services.set(IEditorGroupsService, new TestEditorGroupsService());
|
||||
services.set(ITextFileService, new class extends mock<ITextFileService>() {
|
||||
isDirty() { return false; }
|
||||
create(resource: URI) {
|
||||
createdResources.add(resource);
|
||||
return Promise.resolve(Object.create(null));
|
||||
}
|
||||
files = <any>{
|
||||
onDidSave: Event.None,
|
||||
onDidRevert: Event.None,
|
||||
@@ -107,16 +103,24 @@ suite('MainThreadEditors', () => {
|
||||
});
|
||||
services.set(IWorkingCopyFileService, new class extends mock<IWorkingCopyFileService>() {
|
||||
onDidRunWorkingCopyFileOperation = Event.None;
|
||||
move(source: URI, target: URI) {
|
||||
create(resource: URI) {
|
||||
createdResources.add(resource);
|
||||
return Promise.resolve(Object.create(null));
|
||||
}
|
||||
move(files: { source: URI, target: URI }[]) {
|
||||
const { source, target } = files[0];
|
||||
movedResources.set(source, target);
|
||||
return Promise.resolve(Object.create(null));
|
||||
}
|
||||
copy(source: URI, target: URI) {
|
||||
copy(files: { source: URI, target: URI }[]) {
|
||||
const { source, target } = files[0];
|
||||
copiedResources.set(source, target);
|
||||
return Promise.resolve(Object.create(null));
|
||||
}
|
||||
delete(resource: URI) {
|
||||
deletedResources.add(resource);
|
||||
delete(resources: URI[]) {
|
||||
for (const resource of resources) {
|
||||
deletedResources.add(resource);
|
||||
}
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -34,8 +34,8 @@ suite('Workbench editor', () => {
|
||||
const untitled = instantiationService.createInstance(UntitledTextEditorInput, service.create());
|
||||
|
||||
assert.equal(toResource(untitled)!.toString(), untitled.resource.toString());
|
||||
assert.equal(toResource(untitled, { supportSideBySide: SideBySideEditor.MASTER })!.toString(), untitled.resource.toString());
|
||||
assert.equal(toResource(untitled, { supportSideBySide: SideBySideEditor.DETAILS })!.toString(), untitled.resource.toString());
|
||||
assert.equal(toResource(untitled, { supportSideBySide: SideBySideEditor.PRIMARY })!.toString(), untitled.resource.toString());
|
||||
assert.equal(toResource(untitled, { supportSideBySide: SideBySideEditor.SECONDARY })!.toString(), untitled.resource.toString());
|
||||
assert.equal(toResource(untitled, { supportSideBySide: SideBySideEditor.BOTH })!.toString(), untitled.resource.toString());
|
||||
assert.equal(toResource(untitled, { filterByScheme: Schemas.untitled })!.toString(), untitled.resource.toString());
|
||||
assert.equal(toResource(untitled, { filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), untitled.resource.toString());
|
||||
@@ -44,8 +44,8 @@ suite('Workbench editor', () => {
|
||||
const file = new TestEditorInput(URI.file('/some/path.txt'), 'editorResourceFileTest');
|
||||
|
||||
assert.equal(toResource(file)!.toString(), file.resource.toString());
|
||||
assert.equal(toResource(file, { supportSideBySide: SideBySideEditor.MASTER })!.toString(), file.resource.toString());
|
||||
assert.equal(toResource(file, { supportSideBySide: SideBySideEditor.DETAILS })!.toString(), file.resource.toString());
|
||||
assert.equal(toResource(file, { supportSideBySide: SideBySideEditor.PRIMARY })!.toString(), file.resource.toString());
|
||||
assert.equal(toResource(file, { supportSideBySide: SideBySideEditor.SECONDARY })!.toString(), file.resource.toString());
|
||||
assert.equal(toResource(file, { supportSideBySide: SideBySideEditor.BOTH })!.toString(), file.resource.toString());
|
||||
assert.equal(toResource(file, { filterByScheme: Schemas.file })!.toString(), file.resource.toString());
|
||||
assert.equal(toResource(file, { filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), file.resource.toString());
|
||||
@@ -56,20 +56,20 @@ suite('Workbench editor', () => {
|
||||
assert.ok(!toResource(diffEditorInput));
|
||||
assert.ok(!toResource(diffEditorInput, { filterByScheme: Schemas.file }));
|
||||
|
||||
assert.equal(toResource(diffEditorInput, { supportSideBySide: SideBySideEditor.MASTER })!.toString(), file.resource.toString());
|
||||
assert.equal(toResource(diffEditorInput, { supportSideBySide: SideBySideEditor.MASTER, filterByScheme: Schemas.file })!.toString(), file.resource.toString());
|
||||
assert.equal(toResource(diffEditorInput, { supportSideBySide: SideBySideEditor.MASTER, filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), file.resource.toString());
|
||||
assert.equal(toResource(diffEditorInput, { supportSideBySide: SideBySideEditor.PRIMARY })!.toString(), file.resource.toString());
|
||||
assert.equal(toResource(diffEditorInput, { supportSideBySide: SideBySideEditor.PRIMARY, filterByScheme: Schemas.file })!.toString(), file.resource.toString());
|
||||
assert.equal(toResource(diffEditorInput, { supportSideBySide: SideBySideEditor.PRIMARY, filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), file.resource.toString());
|
||||
|
||||
assert.equal(toResource(diffEditorInput, { supportSideBySide: SideBySideEditor.DETAILS })!.toString(), untitled.resource.toString());
|
||||
assert.equal(toResource(diffEditorInput, { supportSideBySide: SideBySideEditor.DETAILS, filterByScheme: Schemas.untitled })!.toString(), untitled.resource.toString());
|
||||
assert.equal(toResource(diffEditorInput, { supportSideBySide: SideBySideEditor.DETAILS, filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), untitled.resource.toString());
|
||||
assert.equal(toResource(diffEditorInput, { supportSideBySide: SideBySideEditor.SECONDARY })!.toString(), untitled.resource.toString());
|
||||
assert.equal(toResource(diffEditorInput, { supportSideBySide: SideBySideEditor.SECONDARY, filterByScheme: Schemas.untitled })!.toString(), untitled.resource.toString());
|
||||
assert.equal(toResource(diffEditorInput, { supportSideBySide: SideBySideEditor.SECONDARY, filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), untitled.resource.toString());
|
||||
|
||||
assert.equal((toResource(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH }) as { master: URI, detail: URI }).master.toString(), file.resource.toString());
|
||||
assert.equal((toResource(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH, filterByScheme: Schemas.file }) as { master: URI, detail: URI }).master.toString(), file.resource.toString());
|
||||
assert.equal((toResource(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH, filterByScheme: [Schemas.file, Schemas.untitled] }) as { master: URI, detail: URI }).master.toString(), file.resource.toString());
|
||||
assert.equal((toResource(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH }) as { primary: URI, secondary: URI }).primary.toString(), file.resource.toString());
|
||||
assert.equal((toResource(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH, filterByScheme: Schemas.file }) as { primary: URI, secondary: URI }).primary.toString(), file.resource.toString());
|
||||
assert.equal((toResource(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH, filterByScheme: [Schemas.file, Schemas.untitled] }) as { primary: URI, secondary: URI }).primary.toString(), file.resource.toString());
|
||||
|
||||
assert.equal((toResource(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH }) as { master: URI, detail: URI }).detail.toString(), untitled.resource.toString());
|
||||
assert.equal((toResource(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH, filterByScheme: Schemas.untitled }) as { master: URI, detail: URI }).detail.toString(), untitled.resource.toString());
|
||||
assert.equal((toResource(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH, filterByScheme: [Schemas.file, Schemas.untitled] }) as { master: URI, detail: URI }).detail.toString(), untitled.resource.toString());
|
||||
assert.equal((toResource(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH }) as { primary: URI, secondary: URI }).secondary.toString(), untitled.resource.toString());
|
||||
assert.equal((toResource(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH, filterByScheme: Schemas.untitled }) as { primary: URI, secondary: URI }).secondary.toString(), untitled.resource.toString());
|
||||
assert.equal((toResource(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH, filterByScheme: [Schemas.file, Schemas.untitled] }) as { primary: URI, secondary: URI }).secondary.toString(), untitled.resource.toString());
|
||||
});
|
||||
});
|
||||
|
||||
@@ -150,6 +150,8 @@ class NonSerializableTestEditorInput extends EditorInput {
|
||||
|
||||
class TestFileEditorInput extends EditorInput implements IFileEditorInput {
|
||||
|
||||
readonly label = this.resource;
|
||||
|
||||
constructor(public id: string, public resource: URI) {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -835,6 +835,7 @@ export class TestFileService implements IFileService {
|
||||
getWriteEncoding(_resource: URI): IResourceEncoding { return { encoding: 'utf8', hasBOM: false }; }
|
||||
dispose(): void { }
|
||||
|
||||
async canCreateFile(source: URI, options?: ICreateFileOptions): Promise<Error | true> { return true; }
|
||||
async canMove(source: URI, target: URI, overwrite?: boolean | undefined): Promise<Error | true> { return true; }
|
||||
async canCopy(source: URI, target: URI, overwrite?: boolean | undefined): Promise<Error | true> { return true; }
|
||||
async canDelete(resource: URI, options?: { useTrash?: boolean | undefined; recursive?: boolean | undefined; } | undefined): Promise<Error | true> { return true; }
|
||||
@@ -1056,6 +1057,9 @@ export function registerTestEditor(id: string, inputs: SyncDescriptor<EditorInpu
|
||||
}
|
||||
|
||||
export class TestFileEditorInput extends EditorInput implements IFileEditorInput {
|
||||
|
||||
readonly label = this.resource;
|
||||
|
||||
gotDisposed = false;
|
||||
gotSaved = false;
|
||||
gotSavedAs = false;
|
||||
@@ -1151,7 +1155,7 @@ export class TestPathService implements IPathService {
|
||||
|
||||
get path() { return Promise.resolve(isWindows ? win32 : posix); }
|
||||
|
||||
get userHome() { return Promise.resolve(this.fallbackUserHome); }
|
||||
async userHome() { return this.fallbackUserHome; }
|
||||
get resolvedUserHome() { return this.fallbackUserHome; }
|
||||
|
||||
async fileURI(path: string): Promise<URI> {
|
||||
|
||||
Reference in New Issue
Block a user