SQL Operations Studio Public Preview 1 (0.23) release source code

This commit is contained in:
Karl Burtram
2017-11-09 14:30:27 -08:00
parent b88ecb8d93
commit 3cdac41339
8829 changed files with 759707 additions and 286 deletions

View File

@@ -0,0 +1,60 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as assert from 'assert';
import * as Platform from 'vs/platform/registry/common/platform';
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { Extensions, IWorkbenchActionRegistry } from 'vs/workbench/common/actionRegistry';
import { prepareActions } from 'vs/workbench/browser/actions';
import { Action } from 'vs/base/common/actions';
class MyClass extends Action {
constructor(id: string, label: string) {
super(id, label);
}
}
suite('Workbench Action Registry', () => {
test('Workbench Action Registration', function () {
let Registry = <IWorkbenchActionRegistry>Platform.Registry.as(Extensions.WorkbenchActions);
let d = new SyncActionDescriptor(MyClass, 'id', 'name');
let oldActions = Registry.getWorkbenchActions().slice(0);
let oldCount = Registry.getWorkbenchActions().length;
Registry.registerWorkbenchAction(d, 'My Alias', 'category');
Registry.registerWorkbenchAction(d, null);
assert.equal(Registry.getWorkbenchActions().length, 1 + oldCount);
assert.strictEqual(d, Registry.getWorkbenchAction('id'));
assert.deepEqual(Registry.getAlias(d.id), 'My Alias');
assert.equal(Registry.getCategory(d.id), 'category');
(<any>Registry).setWorkbenchActions(oldActions);
});
test('Workbench Action Bar prepareActions()', function () {
let a1 = new Separator();
let a2 = new Separator();
let a3 = new Action('a3');
let a4 = new Separator();
let a5 = new Separator();
let a6 = new Action('a6');
let a7 = new Separator();
let actions = prepareActions([a1, a2, a3, a4, a5, a6, a7]);
assert.strictEqual(actions.length, 3); // duplicate separators get removed
assert(actions[0] === a3);
assert(actions[1] === a5);
assert(actions[2] === a6);
});
});

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,157 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as assert from 'assert';
import { Build, Builder } from 'vs/base/browser/builder';
import { Part } from 'vs/workbench/browser/part';
import * as Types from 'vs/base/common/types';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { StorageService, InMemoryLocalStorage } from 'vs/platform/storage/common/storageService';
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
class MyPart extends Part {
constructor(private expectedParent: Builder) {
super('myPart', { hasTitle: true }, new TestThemeService());
}
public createTitleArea(parent: Builder): Builder {
assert.strictEqual(parent, this.expectedParent);
return super.createTitleArea(parent);
}
public createContentArea(parent: Builder): Builder {
assert.strictEqual(parent, this.expectedParent);
return super.createContentArea(parent);
}
public getMemento(storageService: IStorageService): any {
return super.getMemento(storageService);
}
}
class MyPart2 extends Part {
constructor() {
super('myPart2', { hasTitle: true }, new TestThemeService());
}
public createTitleArea(parent: Builder): Builder {
return parent.div(function (div) {
div.span({
id: 'myPart.title',
innerHtml: 'Title'
});
});
}
public createContentArea(parent: Builder): Builder {
return parent.div(function (div) {
div.span({
id: 'myPart.content',
innerHtml: 'Content'
});
});
}
}
class MyPart3 extends Part {
constructor() {
super('myPart2', { hasTitle: false }, new TestThemeService());
}
public createTitleArea(parent: Builder): Builder {
return null;
}
public createContentArea(parent: Builder): Builder {
return parent.div(function (div) {
div.span({
id: 'myPart.content',
innerHtml: 'Content'
});
});
}
}
suite('Workbench Part', () => {
let fixture: HTMLElement;
let fixtureId = 'workbench-part-fixture';
let storage: IStorageService;
setup(() => {
fixture = document.createElement('div');
fixture.id = fixtureId;
document.body.appendChild(fixture);
storage = new StorageService(new InMemoryLocalStorage(), null, TestWorkspace.id);
});
teardown(() => {
document.body.removeChild(fixture);
});
test('Creation', function () {
let b = Build.withElementById(fixtureId);
b.div().hide();
let part = new MyPart(b);
part.create(b);
assert.strictEqual(part.getId(), 'myPart');
assert.strictEqual(part.getContainer(), b);
// Memento
let memento = part.getMemento(storage);
assert(memento);
memento.foo = 'bar';
memento.bar = [1, 2, 3];
part.shutdown();
// Re-Create to assert memento contents
part = new MyPart(b);
memento = part.getMemento(storage);
assert(memento);
assert.strictEqual(memento.foo, 'bar');
assert.strictEqual(memento.bar.length, 3);
// Empty Memento stores empty object
delete memento.foo;
delete memento.bar;
part.shutdown();
part = new MyPart(b);
memento = part.getMemento(storage);
assert(memento);
assert.strictEqual(Types.isEmptyObject(memento), true);
});
test('Part Layout with Title and Content', function () {
let b = Build.withElementById(fixtureId);
b.div().hide();
let part = new MyPart2();
part.create(b);
assert(Build.withElementById('myPart.title'));
assert(Build.withElementById('myPart.content'));
});
test('Part Layout with Content only', function () {
let b = Build.withElementById(fixtureId);
b.div().hide();
let part = new MyPart3();
part.create(b);
assert(!Build.withElementById('myPart.title'));
assert(Build.withElementById('myPart.content'));
});
});

View File

@@ -0,0 +1,208 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as assert from 'assert';
import { BaseEditor, EditorDescriptor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { EditorInput, EditorOptions, Extensions, IEditorRegistry, IEditorInputFactory } from 'vs/workbench/common/editor';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import * as Platform 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 { PLAINTEXT_MODE_ID } from 'vs/editor/common/modes/modesRegistry';
import { workbenchInstantiationService } from 'vs/workbench/test/workbenchTestServices';
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
const NullThemeService = new TestThemeService();
let EditorRegistry: IEditorRegistry = Platform.Registry.as(Extensions.Editors);
export class MyEditor extends BaseEditor {
constructor(id: string, @ITelemetryService telemetryService: ITelemetryService) {
super(id, NullTelemetryService, NullThemeService);
}
getId(): string {
return 'myEditor';
}
public layout(): void {
}
public createEditor(): any {
}
}
export class MyOtherEditor extends BaseEditor {
constructor(id: string, @ITelemetryService telemetryService: ITelemetryService) {
super(id, NullTelemetryService, NullThemeService);
}
getId(): string {
return 'myOtherEditor';
}
public layout(): void {
}
public createEditor(): any {
}
}
class MyInputFactory implements IEditorInputFactory {
serialize(input: EditorInput): string {
return input.toString();
}
deserialize(instantiationService: IInstantiationService, raw: string): EditorInput {
return <EditorInput>{};
}
}
class MyInput extends EditorInput {
getPreferredEditorId(ids) {
return ids[1];
}
public getTypeId(): string {
return '';
}
public resolve(refresh?: boolean): any {
return null;
}
}
class MyOtherInput extends EditorInput {
public getTypeId(): string {
return '';
}
public resolve(refresh?: boolean): any {
return null;
}
}
class MyResourceInput extends ResourceEditorInput { }
suite('Workbench BaseEditor', () => {
test('BaseEditor API', function (done) {
let e = new MyEditor('id', NullTelemetryService);
let input = new MyOtherInput();
let options = new EditorOptions();
assert(!e.isVisible());
assert(!e.input);
assert(!e.options);
e.setInput(input, options).then(() => {
assert.strictEqual(input, e.input);
assert.strictEqual(options, e.options);
e.setVisible(true);
assert(e.isVisible());
input.onDispose(() => {
assert(false);
});
e.dispose();
e.clearInput();
e.setVisible(false);
assert(!e.isVisible());
assert(!e.input);
assert(!e.options);
assert(!e.getControl());
}).done(() => done());
});
test('EditorDescriptor', function () {
let d = new EditorDescriptor('id', 'name', 'vs/workbench/test/browser/parts/editor/baseEditor.test', 'MyClass');
assert.strictEqual(d.getId(), 'id');
assert.strictEqual(d.getName(), 'name');
});
test('Editor Registration', function () {
let d1 = new EditorDescriptor('id1', 'name', 'vs/workbench/test/browser/parts/editor/baseEditor.test', 'MyClass');
let d2 = new EditorDescriptor('id2', 'name', 'vs/workbench/test/browser/parts/editor/baseEditor.test', 'MyOtherClass');
let oldEditorsCnt = EditorRegistry.getEditors().length;
let oldInputCnt = (<any>EditorRegistry).getEditorInputs().length;
EditorRegistry.registerEditor(d1, new SyncDescriptor(MyInput));
EditorRegistry.registerEditor(d2, [new SyncDescriptor(MyInput), new SyncDescriptor(MyOtherInput)]);
assert.equal(EditorRegistry.getEditors().length, oldEditorsCnt + 2);
assert.equal((<any>EditorRegistry).getEditorInputs().length, oldInputCnt + 3);
assert.strictEqual(EditorRegistry.getEditor(new MyInput()), d2);
assert.strictEqual(EditorRegistry.getEditor(new MyOtherInput()), d2);
assert.strictEqual(EditorRegistry.getEditorById('id1'), d1);
assert.strictEqual(EditorRegistry.getEditorById('id2'), d2);
assert(!EditorRegistry.getEditorById('id3'));
});
test('Editor Lookup favors specific class over superclass (match on specific class)', function (done) {
let d1 = new EditorDescriptor('id1', 'name', 'vs/workbench/test/browser/parts/editor/baseEditor.test', 'MyEditor');
let d2 = new EditorDescriptor('id2', 'name', 'vs/workbench/test/browser/parts/editor/baseEditor.test', 'MyOtherEditor');
let oldEditors = EditorRegistry.getEditors();
(<any>EditorRegistry).setEditors([]);
EditorRegistry.registerEditor(d2, new SyncDescriptor(ResourceEditorInput));
EditorRegistry.registerEditor(d1, new SyncDescriptor(MyResourceInput));
let inst = new TestInstantiationService();
inst.createInstance(EditorRegistry.getEditor(inst.createInstance(MyResourceInput, 'fake', '', '', PLAINTEXT_MODE_ID, false)), 'id').then(editor => {
assert.strictEqual(editor.getId(), 'myEditor');
return inst.createInstance(EditorRegistry.getEditor(inst.createInstance(ResourceEditorInput, 'fake', '', '', PLAINTEXT_MODE_ID, false)), 'id').then(editor => {
assert.strictEqual(editor.getId(), 'myOtherEditor');
(<any>EditorRegistry).setEditors(oldEditors);
});
}).done(() => done());
});
test('Editor Lookup favors specific class over superclass (match on super class)', function (done) {
let d1 = new EditorDescriptor('id1', 'name', 'vs/workbench/test/browser/parts/editor/baseEditor.test', 'MyOtherEditor');
let oldEditors = EditorRegistry.getEditors();
(<any>EditorRegistry).setEditors([]);
EditorRegistry.registerEditor(d1, new SyncDescriptor(ResourceEditorInput));
let inst = new TestInstantiationService();
inst.createInstance(EditorRegistry.getEditor(inst.createInstance(MyResourceInput, 'fake', '', '', PLAINTEXT_MODE_ID, false)), 'id').then(editor => {
assert.strictEqual('myOtherEditor', editor.getId());
(<any>EditorRegistry).setEditors(oldEditors);
}).done(() => done());
});
test('Editor Input Factory', function () {
EditorRegistry.setInstantiationService(workbenchInstantiationService());
EditorRegistry.registerEditorInputFactory('myInputId', MyInputFactory);
let factory = EditorRegistry.getEditorInputFactory('myInputId');
assert(factory);
});
return {
MyEditor: MyEditor,
MyOtherEditor: MyOtherEditor
};
});

View File

@@ -0,0 +1,89 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as assert from 'assert';
import 'vs/workbench/browser/parts/editor/editor.contribution'; // make sure to load all contributed editor things into tests
import { Promise, TPromise } from 'vs/base/common/winjs.base';
import Event from 'vs/base/common/event';
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
import { Registry } from 'vs/platform/registry/common/platform';
import { QuickOpenHandlerDescriptor, IQuickOpenRegistry, Extensions as QuickOpenExtensions, QuickOpenAction } from 'vs/workbench/browser/quickopen';
export class TestQuickOpenService implements IQuickOpenService {
public _serviceBrand: any;
private callback: (prefix: string) => void;
constructor(callback?: (prefix: string) => void) {
this.callback = callback;
}
pick(arg: any, options?: any, token?: any): Promise {
return TPromise.as(null);
}
input(options?: any, token?: any): Promise {
return TPromise.as(null);
}
accept(): void {
}
focus(): void {
}
close(): void {
}
show(prefix?: string, options?: any): Promise {
if (this.callback) {
this.callback(prefix);
}
return TPromise.as(true);
}
get onShow(): Event<void> {
return null;
}
get onHide(): Event<void> {
return null;
}
public dispose() { }
public navigate(): void { }
}
suite('Workbench QuickOpen', () => {
test('QuickOpen Handler and Registry', () => {
let registry = (<IQuickOpenRegistry>Registry.as(QuickOpenExtensions.Quickopen));
let handler = new QuickOpenHandlerDescriptor(
'test',
'TestHandler',
',',
'Handler',
null
);
registry.registerQuickOpenHandler(handler);
assert(registry.getQuickOpenHandler(',') === handler);
let handlers = registry.getQuickOpenHandlers();
assert(handlers.some((handler: QuickOpenHandlerDescriptor) => handler.prefix === ','));
});
test('QuickOpen Action', () => {
let defaultAction = new QuickOpenAction('id', 'label', void 0, new TestQuickOpenService((prefix: string) => assert(!prefix)));
let prefixAction = new QuickOpenAction('id', 'label', ',', new TestQuickOpenService((prefix: string) => assert(!!prefix)));
defaultAction.run();
prefixAction.run();
});
});

View File

@@ -0,0 +1,45 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as assert from 'assert';
import * as Platform from 'vs/platform/registry/common/platform';
import { ViewletDescriptor, Extensions } from 'vs/workbench/browser/viewlet';
import * as Types from 'vs/base/common/types';
suite('Workbench Viewlet', () => {
test('ViewletDescriptor API', function () {
let d = new ViewletDescriptor('moduleId', 'ctorName', 'id', 'name', 'class', 5);
assert.strictEqual(d.id, 'id');
assert.strictEqual(d.name, 'name');
assert.strictEqual(d.cssClass, 'class');
assert.strictEqual(d.order, 5);
});
test('Editor Aware ViewletDescriptor API', function () {
let d = new ViewletDescriptor('moduleId', 'ctorName', 'id', 'name', 'class', 5);
assert.strictEqual(d.id, 'id');
assert.strictEqual(d.name, 'name');
d = new ViewletDescriptor('moduleId', 'ctorName', 'id', 'name', 'class', 5);
assert.strictEqual(d.id, 'id');
assert.strictEqual(d.name, 'name');
});
test('Viewlet extension point and registration', function () {
assert(Types.isFunction(Platform.Registry.as(Extensions.Viewlets).registerViewlet));
assert(Types.isFunction(Platform.Registry.as(Extensions.Viewlets).getViewlet));
assert(Types.isFunction(Platform.Registry.as(Extensions.Viewlets).getViewlets));
let oldCount = Platform.Registry.as(Extensions.Viewlets).getViewlets().length;
let d = new ViewletDescriptor('moduleId', 'ctorName', 'reg-test-id', 'name');
Platform.Registry.as(Extensions.Viewlets).registerViewlet(d);
assert(d === Platform.Registry.as(Extensions.Viewlets).getViewlet('reg-test-id'));
assert.equal(oldCount + 1, Platform.Registry.as(Extensions.Viewlets).getViewlets().length);
});
});