Merge from master

This commit is contained in:
Raj Musuku
2019-02-21 17:56:04 -08:00
parent 5a146e34fa
commit 666ae11639
11482 changed files with 119352 additions and 255574 deletions

View File

@@ -3,8 +3,6 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as assert from 'assert';
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { prepareActions } from 'vs/workbench/browser/actions';

View File

@@ -3,120 +3,120 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as assert from 'assert';
import { 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';
import { append, $, hide } from 'vs/base/browser/dom';
import { TestStorageService } from 'vs/workbench/test/workbenchTestServices';
import { StorageScope } from 'vs/platform/storage/common/storage';
class MyPart extends Part {
constructor(private expectedParent: HTMLElement) {
super('myPart', { hasTitle: true }, new TestThemeService());
super('myPart', { hasTitle: true }, new TestThemeService(), new TestStorageService());
}
public createTitleArea(parent: HTMLElement): HTMLElement {
createTitleArea(parent: HTMLElement): HTMLElement {
assert.strictEqual(parent, this.expectedParent);
return super.createTitleArea(parent);
}
public createContentArea(parent: HTMLElement): HTMLElement {
createContentArea(parent: HTMLElement): HTMLElement {
assert.strictEqual(parent, this.expectedParent);
return super.createContentArea(parent);
}
public getMemento(storageService: IStorageService): any {
return super.getMemento(storageService);
getMemento(scope: StorageScope) {
return super.getMemento(scope);
}
saveState(): void {
return super.saveState();
}
}
class MyPart2 extends Part {
constructor() {
super('myPart2', { hasTitle: true }, new TestThemeService());
super('myPart2', { hasTitle: true }, new TestThemeService(), new TestStorageService());
}
public createTitleArea(parent: HTMLElement): HTMLElement {
return $(parent).div(function (div) {
div.span({
id: 'myPart.title',
innerHtml: 'Title'
});
}).getHTMLElement();
createTitleArea(parent: HTMLElement): HTMLElement {
const titleContainer = append(parent, $('div'));
const titleLabel = append(titleContainer, $('span'));
titleLabel.id = 'myPart.title';
titleLabel.innerHTML = 'Title';
return titleContainer;
}
public createContentArea(parent: HTMLElement): HTMLElement {
return $(parent).div(function (div) {
div.span({
id: 'myPart.content',
innerHtml: 'Content'
});
}).getHTMLElement();
createContentArea(parent: HTMLElement): HTMLElement {
const contentContainer = append(parent, $('div'));
const contentSpan = append(contentContainer, $('span'));
contentSpan.id = 'myPart.content';
contentSpan.innerHTML = 'Content';
return contentContainer;
}
}
class MyPart3 extends Part {
constructor() {
super('myPart2', { hasTitle: false }, new TestThemeService());
super('myPart2', { hasTitle: false }, new TestThemeService(), new TestStorageService());
}
public createTitleArea(parent: HTMLElement): HTMLElement {
createTitleArea(parent: HTMLElement): HTMLElement {
return null;
}
public createContentArea(parent: HTMLElement): HTMLElement {
return $(parent).div(function (div) {
div.span({
id: 'myPart.content',
innerHtml: 'Content'
});
}).getHTMLElement();
createContentArea(parent: HTMLElement): HTMLElement {
const contentContainer = append(parent, $('div'));
const contentSpan = append(contentContainer, $('span'));
contentSpan.id = 'myPart.content';
contentSpan.innerHTML = 'Content';
return contentContainer;
}
}
suite('Workbench parts', () => {
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 = new Builder(document.getElementById(fixtureId));
b.div().hide();
test('Creation', () => {
let b = document.createElement('div');
document.getElementById(fixtureId).appendChild(b);
hide(b);
let part = new MyPart(b.getHTMLElement());
part.create(b.getHTMLElement());
let part = new MyPart(b);
part.create(b);
assert.strictEqual(part.getId(), 'myPart');
// Memento
let memento = part.getMemento(storage);
let memento = part.getMemento(StorageScope.GLOBAL) as any;
assert(memento);
memento.foo = 'bar';
memento.bar = [1, 2, 3];
part.shutdown();
part.saveState();
// Re-Create to assert memento contents
part = new MyPart(b.getHTMLElement());
part = new MyPart(b);
memento = part.getMemento(storage);
memento = part.getMemento(StorageScope.GLOBAL);
assert(memento);
assert.strictEqual(memento.foo, 'bar');
assert.strictEqual(memento.bar.length, 3);
@@ -125,30 +125,32 @@ suite('Workbench parts', () => {
delete memento.foo;
delete memento.bar;
part.shutdown();
part = new MyPart(b.getHTMLElement());
memento = part.getMemento(storage);
part.saveState();
part = new MyPart(b);
memento = part.getMemento(StorageScope.GLOBAL);
assert(memento);
assert.strictEqual(Types.isEmptyObject(memento), true);
});
test('Part Layout with Title and Content', function () {
let b = new Builder(document.getElementById(fixtureId));
b.div().hide();
let b = document.createElement('div');
document.getElementById(fixtureId).appendChild(b);
hide(b);
let part = new MyPart2();
part.create(b.getHTMLElement());
part.create(b);
assert(document.getElementById('myPart.title'));
assert(document.getElementById('myPart.content'));
});
test('Part Layout with Content only', function () {
let b = new Builder(document.getElementById(fixtureId));
b.div().hide();
let b = document.createElement('div');
document.getElementById(fixtureId).appendChild(b);
hide(b);
let part = new MyPart3();
part.create(b.getHTMLElement());
part.create(b);
assert(!document.getElementById('myPart.title'));
assert(document.getElementById('myPart.content'));

View File

@@ -3,8 +3,6 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as assert from 'assert';
import { BaseEditor, EditorMemento } from 'vs/workbench/browser/parts/editor/baseEditor';
import { EditorInput, EditorOptions, IEditorInputFactory, IEditorInputFactoryRegistry, Extensions as EditorExtensions } from 'vs/workbench/common/editor';
@@ -14,13 +12,12 @@ 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 { workbenchInstantiationService, TestEditorGroup, TestEditorGroupsService } from 'vs/workbench/test/workbenchTestServices';
import { workbenchInstantiationService, TestEditorGroup, TestEditorGroupsService, TestStorageService } from 'vs/workbench/test/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 { URI } from 'vs/base/common/uri';
import { IEditorRegistry, Extensions, EditorDescriptor } from 'vs/workbench/browser/editor';
import { CancellationToken } from 'vs/base/common/cancellation';
import { TPromise } from 'vs/base/common/winjs.base';
import { IEditorModel } from 'vs/platform/editor/common/editor';
const NullThemeService = new TestThemeService();
@@ -31,7 +28,7 @@ let EditorInputRegistry: IEditorInputFactoryRegistry = Platform.Registry.as(Edit
export class MyEditor extends BaseEditor {
constructor(@ITelemetryService telemetryService: ITelemetryService) {
super('MyEditor', NullTelemetryService, NullThemeService);
super('MyEditor', NullTelemetryService, NullThemeService, new TestStorageService());
}
getId(): string { return 'myEditor'; }
@@ -42,7 +39,7 @@ export class MyEditor extends BaseEditor {
export class MyOtherEditor extends BaseEditor {
constructor(@ITelemetryService telemetryService: ITelemetryService) {
super('myOtherEditor', NullTelemetryService, NullThemeService);
super('myOtherEditor', NullTelemetryService, NullThemeService, new TestStorageService());
}
getId(): string { return 'myOtherEditor'; }
@@ -118,7 +115,7 @@ suite('Workbench base editor', () => {
});
});
test('EditorDescriptor', function () {
test('EditorDescriptor', () => {
let d = new EditorDescriptor(MyEditor, 'id', 'name');
assert.strictEqual(d.getId(), 'id');
assert.strictEqual(d.getName(), 'name');
@@ -208,54 +205,54 @@ suite('Workbench base editor', () => {
const rawMemento = Object.create(null);
let memento = new EditorMemento<TestViewState>('id', 'key', rawMemento, 3, editorGroupService);
let res = memento.loadState(testGroup0, URI.file('/A'));
let res = memento.loadEditorState(testGroup0, URI.file('/A'));
assert.ok(!res);
memento.saveState(testGroup0, URI.file('/A'), { line: 3 });
res = memento.loadState(testGroup0, URI.file('/A'));
memento.saveEditorState(testGroup0, URI.file('/A'), { line: 3 });
res = memento.loadEditorState(testGroup0, URI.file('/A'));
assert.ok(res);
assert.equal(res.line, 3);
memento.saveState(testGroup1, URI.file('/A'), { line: 5 });
res = memento.loadState(testGroup1, URI.file('/A'));
memento.saveEditorState(testGroup1, URI.file('/A'), { line: 5 });
res = memento.loadEditorState(testGroup1, URI.file('/A'));
assert.ok(res);
assert.equal(res.line, 5);
// Ensure capped at 3 elements
memento.saveState(testGroup0, URI.file('/B'), { line: 1 });
memento.saveState(testGroup0, URI.file('/C'), { line: 1 });
memento.saveState(testGroup0, URI.file('/D'), { line: 1 });
memento.saveState(testGroup0, URI.file('/E'), { line: 1 });
memento.saveEditorState(testGroup0, URI.file('/B'), { line: 1 });
memento.saveEditorState(testGroup0, URI.file('/C'), { line: 1 });
memento.saveEditorState(testGroup0, URI.file('/D'), { line: 1 });
memento.saveEditorState(testGroup0, URI.file('/E'), { line: 1 });
assert.ok(!memento.loadState(testGroup0, URI.file('/A')));
assert.ok(!memento.loadState(testGroup0, URI.file('/B')));
assert.ok(memento.loadState(testGroup0, URI.file('/C')));
assert.ok(memento.loadState(testGroup0, URI.file('/D')));
assert.ok(memento.loadState(testGroup0, URI.file('/E')));
assert.ok(!memento.loadEditorState(testGroup0, URI.file('/A')));
assert.ok(!memento.loadEditorState(testGroup0, URI.file('/B')));
assert.ok(memento.loadEditorState(testGroup0, URI.file('/C')));
assert.ok(memento.loadEditorState(testGroup0, URI.file('/D')));
assert.ok(memento.loadEditorState(testGroup0, URI.file('/E')));
// Save at an unknown group
memento.saveState(testGroup4, URI.file('/E'), { line: 1 });
assert.ok(memento.loadState(testGroup4, URI.file('/E'))); // only gets removed when memento is saved
memento.saveState(testGroup4, URI.file('/C'), { line: 1 });
assert.ok(memento.loadState(testGroup4, URI.file('/C'))); // only gets removed when memento is saved
memento.saveEditorState(testGroup4, URI.file('/E'), { line: 1 });
assert.ok(memento.loadEditorState(testGroup4, URI.file('/E'))); // only gets removed when memento is saved
memento.saveEditorState(testGroup4, URI.file('/C'), { line: 1 });
assert.ok(memento.loadEditorState(testGroup4, URI.file('/C'))); // only gets removed when memento is saved
memento.shutdown();
memento.saveState();
memento = new EditorMemento('id', 'key', rawMemento, 3, editorGroupService);
assert.ok(memento.loadState(testGroup0, URI.file('/C')));
assert.ok(memento.loadState(testGroup0, URI.file('/D')));
assert.ok(memento.loadState(testGroup0, URI.file('/E')));
assert.ok(memento.loadEditorState(testGroup0, URI.file('/C')));
assert.ok(memento.loadEditorState(testGroup0, URI.file('/D')));
assert.ok(memento.loadEditorState(testGroup0, URI.file('/E')));
// Check on entries no longer there from invalid groups
assert.ok(!memento.loadState(testGroup4, URI.file('/E')));
assert.ok(!memento.loadState(testGroup4, URI.file('/C')));
assert.ok(!memento.loadEditorState(testGroup4, URI.file('/E')));
assert.ok(!memento.loadEditorState(testGroup4, URI.file('/C')));
memento.clearState(URI.file('/C'));
memento.clearState(URI.file('/E'));
memento.clearEditorState(URI.file('/C'), testGroup4);
memento.clearEditorState(URI.file('/E'));
assert.ok(!memento.loadState(testGroup0, URI.file('/C')));
assert.ok(memento.loadState(testGroup0, URI.file('/D')));
assert.ok(!memento.loadState(testGroup0, URI.file('/E')));
assert.ok(!memento.loadEditorState(testGroup4, URI.file('/C')));
assert.ok(memento.loadEditorState(testGroup0, URI.file('/D')));
assert.ok(!memento.loadEditorState(testGroup0, URI.file('/E')));
});
test('EditoMemento - use with editor input', function () {
@@ -270,7 +267,7 @@ suite('Workbench base editor', () => {
super();
}
public getTypeId() { return 'testEditorInput'; }
public resolve(): TPromise<IEditorModel> { return null; }
public resolve(): Thenable<IEditorModel> { return Promise.resolve(null); }
public matches(other: TestEditorInput): boolean {
return other && this.id === other.id && other instanceof TestEditorInput;
@@ -286,17 +283,17 @@ suite('Workbench base editor', () => {
const testInputA = new TestEditorInput(URI.file('/A'));
let res = memento.loadState(testGroup0, testInputA);
let res = memento.loadEditorState(testGroup0, testInputA);
assert.ok(!res);
memento.saveState(testGroup0, testInputA, { line: 3 });
res = memento.loadState(testGroup0, testInputA);
memento.saveEditorState(testGroup0, testInputA, { line: 3 });
res = memento.loadEditorState(testGroup0, testInputA);
assert.ok(res);
assert.equal(res.line, 3);
// State removed when input gets disposed
testInputA.dispose();
res = memento.loadState(testGroup0, testInputA);
res = memento.loadEditorState(testGroup0, testInputA);
assert.ok(!res);
});

View File

@@ -3,10 +3,8 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as assert from 'assert';
import URI from 'vs/base/common/uri';
import { URI } from 'vs/base/common/uri';
import { Workspace, WorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { EditorBreadcrumbsModel, FileElement } from 'vs/workbench/browser/parts/editor/breadcrumbsModel';
import { TestContextService } from 'vs/workbench/test/workbenchTestServices';
@@ -16,7 +14,7 @@ import { FileKind } from 'vs/platform/files/common/files';
suite('Breadcrumb Model', function () {
const workspaceService = new TestContextService(new Workspace('ffff', 'Test', [new WorkspaceFolder({ uri: URI.parse('foo:/bar/baz/ws'), name: 'ws', index: 0 })]));
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[]) {
if (args[0] === 'breadcrumbs.filePath') {

View File

@@ -5,7 +5,7 @@
import * as assert from 'assert';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import URI from 'vs/base/common/uri';
import { URI } from 'vs/base/common/uri';
import { workbenchInstantiationService, TestEditorService } from 'vs/workbench/test/workbenchTestServices';
import { IModelService } from 'vs/editor/common/services/modelService';
import { IModeService } from 'vs/editor/common/services/modeService';

View File

@@ -4,14 +4,15 @@
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { ContributableViewsModel } from 'vs/workbench/browser/parts/views/views';
import { ViewsRegistry, IViewDescriptor, IViewContainersRegistry, Extensions as ViewContainerExtensions } from 'vs/workbench/common/views';
import { ContextKeyService } from 'vs/platform/contextkey/browser/contextKeyService';
import { IContextKeyService, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { ContributableViewsModel, ViewsService } from 'vs/workbench/browser/parts/views/views';
import { ViewsRegistry, IViewDescriptor, IViewContainersRegistry, Extensions as ViewContainerExtensions, IViewsService } from 'vs/workbench/common/views';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { move } from 'vs/base/common/arrays';
import { Registry } from 'vs/platform/registry/common/platform';
import { workbenchInstantiationService } from 'vs/workbench/test/workbenchTestServices';
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { ContextKeyService } from 'vs/platform/contextkey/browser/contextKeyService';
const container = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry).registerViewContainer('test');
@@ -33,24 +34,28 @@ class ViewDescriptorSequence {
}
suite('ContributableViewsModel', () => {
let viewsService: IViewsService;
let contextKeyService: IContextKeyService;
setup(() => {
const configurationService = new TestConfigurationService();
contextKeyService = new ContextKeyService(configurationService);
const instantiationService: TestInstantiationService = <TestInstantiationService>workbenchInstantiationService();
contextKeyService = instantiationService.createInstance(ContextKeyService);
instantiationService.stub(IContextKeyService, contextKeyService);
viewsService = instantiationService.createInstance(ViewsService);
});
teardown(() => {
contextKeyService.dispose();
ViewsRegistry.deregisterViews(ViewsRegistry.getViews(container).map(({ id }) => id), container);
});
test('empty model', function () {
const model = new ContributableViewsModel(container, contextKeyService);
const model = new ContributableViewsModel(container, viewsService);
assert.equal(model.visibleViewDescriptors.length, 0);
});
test('register/unregister', function () {
const model = new ContributableViewsModel(container, contextKeyService);
test('register/unregister', () => {
const model = new ContributableViewsModel(container, viewsService);
const seq = new ViewDescriptorSequence(model);
assert.equal(model.visibleViewDescriptors.length, 0);
@@ -77,7 +82,7 @@ suite('ContributableViewsModel', () => {
});
test('when contexts', async function () {
const model = new ContributableViewsModel(container, contextKeyService);
const model = new ContributableViewsModel(container, viewsService);
const seq = new ViewDescriptorSequence(model);
assert.equal(model.visibleViewDescriptors.length, 0);
@@ -122,7 +127,7 @@ suite('ContributableViewsModel', () => {
});
test('when contexts - multiple', async function () {
const model = new ContributableViewsModel(container, contextKeyService);
const model = new ContributableViewsModel(container, viewsService);
const seq = new ViewDescriptorSequence(model);
const view1: IViewDescriptor = { id: 'view1', ctor: null, container, name: 'Test View 1' };
@@ -145,7 +150,7 @@ suite('ContributableViewsModel', () => {
});
test('when contexts - multiple 2', async function () {
const model = new ContributableViewsModel(container, contextKeyService);
const model = new ContributableViewsModel(container, viewsService);
const seq = new ViewDescriptorSequence(model);
const view1: IViewDescriptor = { id: 'view1', ctor: null, container, name: 'Test View 1', when: ContextKeyExpr.equals('showview1', true) };
@@ -167,8 +172,8 @@ suite('ContributableViewsModel', () => {
ViewsRegistry.deregisterViews([view1.id, view2.id], container);
});
test('setVisible', function () {
const model = new ContributableViewsModel(container, contextKeyService);
test('setVisible', () => {
const model = new ContributableViewsModel(container, viewsService);
const seq = new ViewDescriptorSequence(model);
const view1: IViewDescriptor = { id: 'view1', ctor: null, container, name: 'Test View 1', canToggleVisibility: true };
@@ -212,8 +217,8 @@ suite('ContributableViewsModel', () => {
assert.deepEqual(seq.elements, []);
});
test('move', function () {
const model = new ContributableViewsModel(container, contextKeyService);
test('move', () => {
const model = new ContributableViewsModel(container, viewsService);
const seq = new ViewDescriptorSequence(model);
const view1: IViewDescriptor = { id: 'view1', ctor: null, container, name: 'Test View 1' };

View File

@@ -3,11 +3,8 @@
* 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';
@@ -22,10 +19,6 @@ export class TestQuickOpenService implements IQuickOpenService {
this.callback = callback;
}
pick(arg: any, options?: any, token?: any): Promise {
return TPromise.as(null);
}
accept(): void {
}
@@ -35,12 +28,12 @@ export class TestQuickOpenService implements IQuickOpenService {
close(): void {
}
show(prefix?: string, options?: any): Promise {
show(prefix?: string, options?: any): Thenable<void> {
if (this.callback) {
this.callback(prefix);
}
return TPromise.as(true);
return Promise.resolve();
}
get onShow(): Event<void> {

View File

@@ -3,8 +3,6 @@
* 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, Viewlet, ViewletRegistry } from 'vs/workbench/browser/viewlet';
@@ -15,7 +13,7 @@ suite('Viewlets', () => {
class TestViewlet extends Viewlet {
constructor() {
super('id', null, null, null);
super('id', null, null, null, null, null);
}
public layout(dimension: any): void {
@@ -53,4 +51,4 @@ suite('Viewlets', () => {
assert(d === Platform.Registry.as<ViewletRegistry>(Extensions.Viewlets).getViewlet('reg-test-id'));
assert.equal(oldCount + 1, Platform.Registry.as<ViewletRegistry>(Extensions.Viewlets).getViewlets().length);
});
});
});