Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vscode.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/vs/workbench/services/dialogs/common/dialogService.ts')
-rw-r--r--src/vs/workbench/services/dialogs/common/dialogService.ts35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/vs/workbench/services/dialogs/common/dialogService.ts b/src/vs/workbench/services/dialogs/common/dialogService.ts
index d17f9fbbf5c..7360fe7d875 100644
--- a/src/vs/workbench/services/dialogs/common/dialogService.ts
+++ b/src/vs/workbench/services/dialogs/common/dialogService.ts
@@ -8,6 +8,8 @@ import { Disposable } from 'vs/base/common/lifecycle';
import { IConfirmation, IConfirmationResult, IDialogOptions, IDialogService, IInput, IInputResult, IShowResult } from 'vs/platform/dialogs/common/dialogs';
import { DialogsModel } from 'vs/workbench/common/dialogs';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
+import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
+import { ILogService } from 'vs/platform/log/common/log';
export class DialogService extends Disposable implements IDialogService {
@@ -19,25 +21,58 @@ export class DialogService extends Disposable implements IDialogService {
readonly onDidShowDialog = this.model.onDidShowDialog;
+ constructor(
+ @IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
+ @ILogService private readonly logService: ILogService
+ ) {
+ super();
+ }
+
+ private skipDialogs(): boolean {
+ if (this.environmentService.isExtensionDevelopment && this.environmentService.extensionTestsLocationURI) {
+ return true; // integration tests
+ }
+
+ return !!this.environmentService.enableSmokeTestDriver; // smoke tests
+ }
+
async confirm(confirmation: IConfirmation): Promise<IConfirmationResult> {
+ if (this.skipDialogs()) {
+ this.logService.trace('DialogService: refused to show confirmation dialog in tests.');
+
+ return { confirmed: true };
+ }
+
const handle = this.model.show({ confirmArgs: { confirmation } });
return await handle.result as IConfirmationResult;
}
async show(severity: Severity, message: string, buttons?: string[], options?: IDialogOptions): Promise<IShowResult> {
+ if (this.skipDialogs()) {
+ throw new Error('DialogService: refused to show dialog in tests.');
+ }
+
const handle = this.model.show({ showArgs: { severity, message, buttons, options } });
return await handle.result as IShowResult;
}
async input(severity: Severity, message: string, buttons: string[], inputs: IInput[], options?: IDialogOptions): Promise<IInputResult> {
+ if (this.skipDialogs()) {
+ throw new Error('DialogService: refused to show input dialog in tests.');
+ }
+
const handle = this.model.show({ inputArgs: { severity, message, buttons, inputs, options } });
return await handle.result as IInputResult;
}
async about(): Promise<void> {
+ if (this.skipDialogs()) {
+ throw new Error('DialogService: refused to show about dialog in tests.');
+ }
+
const handle = this.model.show({});
await handle.result;
}