提交 4cb12d10 编写于 作者: S Sandeep Somavarapu

fix test failures

上级 95be625a
...@@ -14,8 +14,8 @@ export class GlobalExtensionEnablementService extends Disposable implements IGlo ...@@ -14,8 +14,8 @@ export class GlobalExtensionEnablementService extends Disposable implements IGlo
_serviceBrand: undefined; _serviceBrand: undefined;
private _onDidChangeEnablement = new Emitter<readonly IExtensionIdentifier[]>(); private _onDidChangeEnablement = new Emitter<{ readonly extensions: IExtensionIdentifier[], readonly source?: string }>();
readonly onDidChangeEnablement: Event<readonly IExtensionIdentifier[]> = this._onDidChangeEnablement.event; readonly onDidChangeEnablement: Event<{ readonly extensions: IExtensionIdentifier[], readonly source?: string }> = this._onDidChangeEnablement.event;
private readonly storageManger: StorageManager; private readonly storageManger: StorageManager;
constructor( constructor(
...@@ -23,20 +23,20 @@ export class GlobalExtensionEnablementService extends Disposable implements IGlo ...@@ -23,20 +23,20 @@ export class GlobalExtensionEnablementService extends Disposable implements IGlo
) { ) {
super(); super();
this.storageManger = this._register(new StorageManager(storageService)); this.storageManger = this._register(new StorageManager(storageService));
this._register(this.storageManger.onDidChange(extensions => this._onDidChangeEnablement.fire(extensions))); this._register(this.storageManger.onDidChange(extensions => this._onDidChangeEnablement.fire({ extensions, source: 'storage' })));
} }
async enableExtension(extension: IExtensionIdentifier): Promise<boolean> { async enableExtension(extension: IExtensionIdentifier, source?: string): Promise<boolean> {
if (this._removeFromDisabledExtensions(extension)) { if (this._removeFromDisabledExtensions(extension)) {
this._onDidChangeEnablement.fire([extension]); this._onDidChangeEnablement.fire({ extensions: [extension], source });
return true; return true;
} }
return false; return false;
} }
async disableExtension(extension: IExtensionIdentifier): Promise<boolean> { async disableExtension(extension: IExtensionIdentifier, source?: string): Promise<boolean> {
if (this._addToDisabledExtensions(extension)) { if (this._addToDisabledExtensions(extension)) {
this._onDidChangeEnablement.fire([extension]); this._onDidChangeEnablement.fire({ extensions: [extension], source });
return true; return true;
} }
return false; return false;
......
...@@ -213,11 +213,11 @@ export const IGlobalExtensionEnablementService = createDecorator<IGlobalExtensio ...@@ -213,11 +213,11 @@ export const IGlobalExtensionEnablementService = createDecorator<IGlobalExtensio
export interface IGlobalExtensionEnablementService { export interface IGlobalExtensionEnablementService {
_serviceBrand: undefined; _serviceBrand: undefined;
readonly onDidChangeEnablement: Event<readonly IExtensionIdentifier[]>; readonly onDidChangeEnablement: Event<{ readonly extensions: IExtensionIdentifier[], readonly source?: string }>;
getDisabledExtensions(): IExtensionIdentifier[]; getDisabledExtensions(): IExtensionIdentifier[];
enableExtension(extension: IExtensionIdentifier): Promise<boolean>; enableExtension(extension: IExtensionIdentifier, source?: string): Promise<boolean>;
disableExtension(extension: IExtensionIdentifier): Promise<boolean>; disableExtension(extension: IExtensionIdentifier, source?: string): Promise<boolean>;
// Async method until storage service is available in shared process // Async method until storage service is available in shared process
getDisabledExtensionsAsync(): Promise<IExtensionIdentifier[]>; getDisabledExtensionsAsync(): Promise<IExtensionIdentifier[]>;
......
...@@ -156,7 +156,7 @@ export class GlobalExtensionEnablementServiceClient implements IGlobalExtensionE ...@@ -156,7 +156,7 @@ export class GlobalExtensionEnablementServiceClient implements IGlobalExtensionE
_serviceBrand: undefined; _serviceBrand: undefined;
get onDidChangeEnablement(): Event<IExtensionIdentifier[]> { return this.channel.listen('onDidChangeEnablement'); } get onDidChangeEnablement(): Event<{ readonly extensions: IExtensionIdentifier[], readonly source?: string }> { return this.channel.listen('onDidChangeEnablement'); }
constructor(private readonly channel: IChannel) { constructor(private readonly channel: IChannel) {
} }
......
...@@ -942,16 +942,6 @@ suite('ExtensionsWorkbenchServiceTest', () => { ...@@ -942,16 +942,6 @@ suite('ExtensionsWorkbenchServiceTest', () => {
}); });
}); });
test('test installing an extension re-eanbles it when disabled globally', async () => {
testObject = await aWorkbenchService();
const local = aLocalExtension('pub.a');
await instantiationService.get(IWorkbenchExtensionEnablementService).setEnablement([local], EnablementState.DisabledGlobally);
didInstallEvent.fire({ local, identifier: local.identifier, operation: InstallOperation.Install });
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
const actual = await testObject.queryLocal();
assert.equal(actual[0].enablementState, EnablementState.EnabledGlobally);
});
test('test updating an extension does not re-eanbles it when disabled globally', async () => { test('test updating an extension does not re-eanbles it when disabled globally', async () => {
testObject = await aWorkbenchService(); testObject = await aWorkbenchService();
const local = aLocalExtension('pub.a'); const local = aLocalExtension('pub.a');
...@@ -962,16 +952,6 @@ suite('ExtensionsWorkbenchServiceTest', () => { ...@@ -962,16 +952,6 @@ suite('ExtensionsWorkbenchServiceTest', () => {
assert.equal(actual[0].enablementState, EnablementState.DisabledGlobally); assert.equal(actual[0].enablementState, EnablementState.DisabledGlobally);
}); });
test('test installing an extension re-eanbles it when workspace disabled', async () => {
testObject = await aWorkbenchService();
const local = aLocalExtension('pub.a');
await instantiationService.get(IWorkbenchExtensionEnablementService).setEnablement([local], EnablementState.DisabledWorkspace);
didInstallEvent.fire({ local, identifier: local.identifier, operation: InstallOperation.Install });
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]);
const actual = await testObject.queryLocal();
assert.equal(actual[0].enablementState, EnablementState.EnabledGlobally);
});
test('test updating an extension does not re-eanbles it when workspace disabled', async () => { test('test updating an extension does not re-eanbles it when workspace disabled', async () => {
testObject = await aWorkbenchService(); testObject = await aWorkbenchService();
const local = aLocalExtension('pub.a'); const local = aLocalExtension('pub.a');
......
...@@ -19,6 +19,8 @@ import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; ...@@ -19,6 +19,8 @@ import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IProductService } from 'vs/platform/product/common/productService'; import { IProductService } from 'vs/platform/product/common/productService';
import { StorageManager } from 'vs/platform/extensionManagement/common/extensionEnablementService'; import { StorageManager } from 'vs/platform/extensionManagement/common/extensionEnablementService';
const SOURCE = 'IWorkbenchExtensionEnablementService';
export class ExtensionEnablementService extends Disposable implements IWorkbenchExtensionEnablementService { export class ExtensionEnablementService extends Disposable implements IWorkbenchExtensionEnablementService {
_serviceBrand: undefined; _serviceBrand: undefined;
...@@ -40,7 +42,7 @@ export class ExtensionEnablementService extends Disposable implements IWorkbench ...@@ -40,7 +42,7 @@ export class ExtensionEnablementService extends Disposable implements IWorkbench
) { ) {
super(); super();
this.storageManger = this._register(new StorageManager(storageService)); this.storageManger = this._register(new StorageManager(storageService));
this._register(this.globalExtensionEnablementService.onDidChangeEnablement(extensions => this.onDidChangeExtensions(extensions))); this._register(this.globalExtensionEnablementService.onDidChangeEnablement(({ extensions, source }) => this.onDidChangeExtensions(extensions, source)));
this._register(extensionManagementService.onDidUninstallExtension(this._onDidUninstallExtension, this)); this._register(extensionManagementService.onDidUninstallExtension(this._onDidUninstallExtension, this));
} }
...@@ -169,13 +171,13 @@ export class ExtensionEnablementService extends Disposable implements IWorkbench ...@@ -169,13 +171,13 @@ export class ExtensionEnablementService extends Disposable implements IWorkbench
private _enableExtension(identifier: IExtensionIdentifier): Promise<boolean> { private _enableExtension(identifier: IExtensionIdentifier): Promise<boolean> {
this._removeFromWorkspaceDisabledExtensions(identifier); this._removeFromWorkspaceDisabledExtensions(identifier);
this._removeFromWorkspaceEnabledExtensions(identifier); this._removeFromWorkspaceEnabledExtensions(identifier);
return this.globalExtensionEnablementService.enableExtension(identifier); return this.globalExtensionEnablementService.enableExtension(identifier, SOURCE);
} }
private _disableExtension(identifier: IExtensionIdentifier): Promise<boolean> { private _disableExtension(identifier: IExtensionIdentifier): Promise<boolean> {
this._removeFromWorkspaceDisabledExtensions(identifier); this._removeFromWorkspaceDisabledExtensions(identifier);
this._removeFromWorkspaceEnabledExtensions(identifier); this._removeFromWorkspaceEnabledExtensions(identifier);
return this.globalExtensionEnablementService.disableExtension(identifier); return this.globalExtensionEnablementService.disableExtension(identifier, SOURCE);
} }
private _enableExtensionInWorkspace(identifier: IExtensionIdentifier): void { private _enableExtensionInWorkspace(identifier: IExtensionIdentifier): void {
...@@ -273,10 +275,12 @@ export class ExtensionEnablementService extends Disposable implements IWorkbench ...@@ -273,10 +275,12 @@ export class ExtensionEnablementService extends Disposable implements IWorkbench
this.storageManger.set(storageId, extensions, StorageScope.WORKSPACE); this.storageManger.set(storageId, extensions, StorageScope.WORKSPACE);
} }
private async onDidChangeExtensions(extensionIdentifiers: ReadonlyArray<IExtensionIdentifier>): Promise<void> { private async onDidChangeExtensions(extensionIdentifiers: ReadonlyArray<IExtensionIdentifier>, source?: string): Promise<void> {
const installedExtensions = await this.extensionManagementService.getInstalled(); if (source !== SOURCE) {
const extensions = installedExtensions.filter(installedExtension => extensionIdentifiers.some(identifier => areSameExtensions(identifier, installedExtension.identifier))); const installedExtensions = await this.extensionManagementService.getInstalled();
this._onEnablementChanged.fire(extensions); const extensions = installedExtensions.filter(installedExtension => extensionIdentifiers.some(identifier => areSameExtensions(identifier, installedExtension.identifier)));
this._onEnablementChanged.fire(extensions);
}
} }
private _onDidUninstallExtension({ identifier, error }: DidUninstallExtensionEvent): void { private _onDidUninstallExtension({ identifier, error }: DidUninstallExtensionEvent): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册