mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode 1ec43773e37997841c5af42b33ddb180e9735bf2
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { prepareActions } from 'vs/workbench/browser/actions';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
|
||||
suite('Workbench action registry', () => {
|
||||
|
||||
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);
|
||||
});
|
||||
});
|
||||
@@ -41,10 +41,10 @@ import 'vs/editor/contrib/codelens/codelens';
|
||||
import 'vs/editor/contrib/colorPicker/color';
|
||||
import 'vs/editor/contrib/format/format';
|
||||
import 'vs/editor/contrib/gotoSymbol/goToCommands';
|
||||
import 'vs/editor/contrib/gotoSymbol/documentSymbols';
|
||||
import 'vs/editor/contrib/hover/getHover';
|
||||
import 'vs/editor/contrib/links/getLinks';
|
||||
import 'vs/editor/contrib/parameterHints/provideSignatureHelp';
|
||||
import 'vs/editor/contrib/quickOpen/quickOpen';
|
||||
import 'vs/editor/contrib/smartSelect/smartSelect';
|
||||
import 'vs/editor/contrib/suggest/suggest';
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
|
||||
import { MainThreadCommands } from 'vs/workbench/api/browser/mainThreadCommands';
|
||||
import { ExtHostDocuments } from 'vs/workbench/api/common/extHostDocuments';
|
||||
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors';
|
||||
import { getDocumentSymbols } from 'vs/editor/contrib/quickOpen/quickOpen';
|
||||
import { getDocumentSymbols } from 'vs/editor/contrib/gotoSymbol/documentSymbols';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import { getCodeLensData } from 'vs/editor/contrib/codelens/codelens';
|
||||
import { getDefinitionsAtPosition, getImplementationsAtPosition, getTypeDefinitionsAtPosition, getDeclarationsAtPosition, getReferencesAtPosition } from 'vs/editor/contrib/gotoSymbol/goToSymbol';
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 'vs/workbench/browser/parts/editor/editor.contribution'; // make sure to load all contributed editor things into tests
|
||||
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, QuickOpenHandler } from 'vs/workbench/browser/quickopen';
|
||||
|
||||
export class TestQuickOpenService implements IQuickOpenService {
|
||||
|
||||
_serviceBrand: undefined;
|
||||
|
||||
private callback?: (prefix?: string) => void;
|
||||
|
||||
constructor(callback?: (prefix?: string) => void) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
accept(): void {
|
||||
}
|
||||
|
||||
focus(): void {
|
||||
}
|
||||
|
||||
close(): void {
|
||||
}
|
||||
|
||||
show(prefix?: string, options?: any): Promise<void> {
|
||||
if (this.callback) {
|
||||
this.callback(prefix);
|
||||
}
|
||||
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
get onShow(): Event<void> {
|
||||
return null!;
|
||||
}
|
||||
|
||||
get onHide(): Event<void> {
|
||||
return null!;
|
||||
}
|
||||
|
||||
dispose() { }
|
||||
navigate(): void { }
|
||||
}
|
||||
|
||||
suite('QuickOpen', () => {
|
||||
|
||||
class TestHandler extends QuickOpenHandler { }
|
||||
|
||||
test('QuickOpen Handler and Registry', () => {
|
||||
let registry = (Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen));
|
||||
let handler = QuickOpenHandlerDescriptor.create(
|
||||
TestHandler,
|
||||
'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', (undefined)!, new TestQuickOpenService(prefix => assert(!prefix)));
|
||||
let prefixAction = new QuickOpenAction('id', 'label', ',', new TestQuickOpenService(prefix => assert(!!prefix)));
|
||||
|
||||
defaultAction.run();
|
||||
prefixAction.run();
|
||||
});
|
||||
});
|
||||
@@ -47,7 +47,7 @@ import { Range } from 'vs/editor/common/core/range';
|
||||
import { IDialogService, IPickAndOpenOptions, ISaveDialogOptions, IOpenDialogOptions, IFileDialogService, ConfirmResult } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
|
||||
import { IExtensionService, NullExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
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';
|
||||
@@ -103,7 +103,7 @@ import { IQuickInputService } 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 } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
import { TestWorkingCopyService, TestContextService, TestStorageService, TestTextResourcePropertiesService, TestExtensionService } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
import { IViewsService, IView } from 'vs/workbench/common/views';
|
||||
import { IStorageKeysSyncRegistryService, StorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys';
|
||||
|
||||
@@ -298,8 +298,6 @@ export class TestDecorationsService implements IDecorationsService {
|
||||
getDecoration(_uri: URI, _includeChildren: boolean, _overwrite?: IDecorationData): IDecoration | undefined { return undefined; }
|
||||
}
|
||||
|
||||
export class TestExtensionService extends NullExtensionService { }
|
||||
|
||||
export class TestMenuService implements IMenuService {
|
||||
|
||||
_serviceBrand: undefined;
|
||||
@@ -811,6 +809,7 @@ export class TestBackupFileService implements IBackupFileService {
|
||||
getBackups(): Promise<URI[]> { return Promise.resolve([]); }
|
||||
resolve<T extends object>(_backup: URI): Promise<IResolvedBackup<T> | undefined> { return Promise.resolve(undefined); }
|
||||
discardBackup(_resource: URI): Promise<void> { return Promise.resolve(); }
|
||||
discardBackups(): Promise<void> { return Promise.resolve(); }
|
||||
parseBackupContent(textBufferFactory: ITextBufferFactory): string {
|
||||
const textBuffer = textBufferFactory.create(DefaultEndOfLine.LF);
|
||||
const lineCount = textBuffer.getLineCount();
|
||||
|
||||
@@ -15,6 +15,7 @@ import { ITextResourcePropertiesService } from 'vs/editor/common/services/textRe
|
||||
import { isLinux, isMacintosh } from 'vs/base/common/platform';
|
||||
import { InMemoryStorageService, IWillSaveStateEvent } from 'vs/platform/storage/common/storage';
|
||||
import { WorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService';
|
||||
import { NullExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
|
||||
export class TestTextResourcePropertiesService implements ITextResourcePropertiesService {
|
||||
|
||||
@@ -127,3 +128,5 @@ export function mock<T>(): Ctor<T> {
|
||||
export interface Ctor<T> {
|
||||
new(): T;
|
||||
}
|
||||
|
||||
export class TestExtensionService extends NullExtensionService { }
|
||||
|
||||
@@ -1,203 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 * as minimist from 'vscode-minimist';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
|
||||
import { ITextResourcePropertiesService } from 'vs/editor/common/services/textResourceConfigurationService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { createSyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { ISearchService } from 'vs/workbench/services/search/common/search';
|
||||
import { ITelemetryInfo, ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { testWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
|
||||
import { Extensions, IQuickOpenRegistry } from 'vs/workbench/browser/quickopen';
|
||||
import 'vs/workbench/contrib/search/browser/search.contribution'; // load contributions
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { LocalSearchService } from 'vs/workbench/services/search/node/searchService';
|
||||
import { IUntitledTextEditorService, UntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
|
||||
import { TestEditorGroupsService, TestEditorService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { TestEnvironmentService } from 'vs/workbench/test/electron-browser/workbenchTestServices';
|
||||
import { ClassifiedEvent, StrictPropertyCheck, GDPRClassification } from 'vs/platform/telemetry/common/gdprTypings';
|
||||
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { UndoRedoService } from 'vs/platform/undoRedo/common/undoRedoService';
|
||||
import { TestDialogService } from 'vs/platform/dialogs/test/common/testDialogService';
|
||||
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 { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { TestContextService, TestTextResourcePropertiesService } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
|
||||
namespace Timer {
|
||||
export interface ITimerEvent {
|
||||
id: number;
|
||||
topic: string;
|
||||
name: string;
|
||||
description: string;
|
||||
data: any;
|
||||
|
||||
startTime: Date;
|
||||
stopTime: Date;
|
||||
|
||||
stop(stopTime?: Date): void;
|
||||
timeTaken(): number;
|
||||
}
|
||||
}
|
||||
|
||||
// declare var __dirname: string;
|
||||
|
||||
// Checkout sources to run against:
|
||||
// git clone --separate-git-dir=testGit --no-checkout --single-branch https://chromium.googlesource.com/chromium/src testWorkspace
|
||||
// cd testWorkspace; git checkout 39a7f93d67f7
|
||||
// Run from repository root folder with (test.bat on Windows): ./scripts/test.sh --grep QuickOpen.performance --timeout 180000 --testWorkspace <path>
|
||||
suite.skip('QuickOpen performance (integration)', () => {
|
||||
|
||||
test('Measure', () => {
|
||||
if (process.env['VSCODE_PID']) {
|
||||
return undefined; // TODO@Christoph find out why test fails when run from within VS Code
|
||||
}
|
||||
|
||||
const n = 3;
|
||||
const argv = minimist(process.argv);
|
||||
const testWorkspaceArg = argv['testWorkspace'];
|
||||
const verboseResults = argv['verboseResults'];
|
||||
const testWorkspacePath = testWorkspaceArg ? path.resolve(testWorkspaceArg) : __dirname;
|
||||
|
||||
const telemetryService = new TestTelemetryService();
|
||||
const configurationService = new TestConfigurationService();
|
||||
const textResourcePropertiesService = new TestTextResourcePropertiesService(configurationService);
|
||||
const dialogService = new TestDialogService();
|
||||
const notificationService = new TestNotificationService();
|
||||
const undoRedoService = new UndoRedoService(dialogService, notificationService);
|
||||
const instantiationService = new InstantiationService(new ServiceCollection(
|
||||
[ITelemetryService, telemetryService],
|
||||
[IConfigurationService, configurationService],
|
||||
[ITextResourcePropertiesService, textResourcePropertiesService],
|
||||
[IDialogService, dialogService],
|
||||
[INotificationService, notificationService],
|
||||
[IUndoRedoService, undoRedoService],
|
||||
[IModelService, new ModelServiceImpl(configurationService, textResourcePropertiesService, new TestThemeService(), new NullLogService(), undoRedoService, dialogService)],
|
||||
[IWorkspaceContextService, new TestContextService(testWorkspace(URI.file(testWorkspacePath)))],
|
||||
[IEditorService, new TestEditorService()],
|
||||
[IEditorGroupsService, new TestEditorGroupsService()],
|
||||
[IEnvironmentService, TestEnvironmentService],
|
||||
[IUntitledTextEditorService, createSyncDescriptor(UntitledTextEditorService)],
|
||||
[ISearchService, createSyncDescriptor(LocalSearchService)]
|
||||
));
|
||||
|
||||
const registry = Registry.as<IQuickOpenRegistry>(Extensions.Quickopen);
|
||||
const descriptor = registry.getDefaultQuickOpenHandler();
|
||||
assert.ok(descriptor);
|
||||
|
||||
function measure() {
|
||||
const handler = descriptor.instantiate(instantiationService);
|
||||
handler.onOpen();
|
||||
return handler.getResults('a', CancellationToken.None).then(result => {
|
||||
const uncachedEvent = popEvent();
|
||||
assert.strictEqual(uncachedEvent.data.symbols.fromCache, false, 'symbols.fromCache');
|
||||
assert.strictEqual(uncachedEvent.data.files.fromCache, true, 'files.fromCache');
|
||||
if (testWorkspaceArg) {
|
||||
assert.ok(!!uncachedEvent.data.files.joined, 'files.joined');
|
||||
}
|
||||
return uncachedEvent;
|
||||
}).then(uncachedEvent => {
|
||||
return handler.getResults('ab', CancellationToken.None).then(result => {
|
||||
const cachedEvent = popEvent();
|
||||
assert.strictEqual(uncachedEvent.data.symbols.fromCache, false, 'symbols.fromCache');
|
||||
assert.ok(cachedEvent.data.files.fromCache, 'filesFromCache');
|
||||
handler.onClose(false);
|
||||
return [uncachedEvent, cachedEvent];
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function popEvent() {
|
||||
const events = telemetryService.events
|
||||
.filter(event => event.name === 'openAnything');
|
||||
assert.strictEqual(events.length, 1);
|
||||
const event = events[0];
|
||||
telemetryService.events.length = 0;
|
||||
return event;
|
||||
}
|
||||
|
||||
function printResult(data: any) {
|
||||
if (verboseResults) {
|
||||
console.log(JSON.stringify(data, null, ' ') + ',');
|
||||
} else {
|
||||
console.log(JSON.stringify({
|
||||
filesfromCacheNotJoined: data.files.fromCache && !data.files.joined,
|
||||
searchLength: data.searchLength,
|
||||
sortedResultDuration: data.sortedResultDuration,
|
||||
filesResultCount: data.files.resultCount,
|
||||
errorCount: data.files.errors && data.files.errors.length || undefined
|
||||
}) + ',');
|
||||
}
|
||||
}
|
||||
|
||||
return measure() // Warm-up first
|
||||
.then(() => {
|
||||
if (testWorkspaceArg || verboseResults) { // Don't measure by default
|
||||
const cachedEvents: Timer.ITimerEvent[] = [];
|
||||
let i = n;
|
||||
return (function iterate(): Promise<Timer.ITimerEvent> {
|
||||
if (!i--) {
|
||||
return undefined!;
|
||||
}
|
||||
return measure()
|
||||
.then(([uncachedEvent, cachedEvent]) => {
|
||||
printResult(uncachedEvent.data);
|
||||
cachedEvents.push(cachedEvent);
|
||||
return iterate();
|
||||
});
|
||||
})().then(() => {
|
||||
console.log();
|
||||
cachedEvents.forEach(cachedEvent => {
|
||||
printResult(cachedEvent.data);
|
||||
});
|
||||
});
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
class TestTelemetryService implements ITelemetryService {
|
||||
|
||||
public _serviceBrand: undefined;
|
||||
public isOptedIn = true;
|
||||
|
||||
public events: any[] = [];
|
||||
|
||||
public setEnabled(value: boolean): void {
|
||||
}
|
||||
|
||||
public publicLog(eventName: string, data?: any): Promise<void> {
|
||||
this.events.push({ name: eventName, data: data });
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
public publicLog2<E extends ClassifiedEvent<T> = never, T extends GDPRClassification<T> = never>(eventName: string, data?: StrictPropertyCheck<T, E>) {
|
||||
return this.publicLog(eventName, data as any);
|
||||
}
|
||||
|
||||
public getTelemetryInfo(): Promise<ITelemetryInfo> {
|
||||
return Promise.resolve({
|
||||
instanceId: 'someValue.instanceId',
|
||||
sessionId: 'someValue.sessionId',
|
||||
machineId: 'someValue.machineId'
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user