mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-04 07:15:54 +01:00
debt - test for native helpers as a test
This commit is contained in:
@@ -207,46 +207,17 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
|
||||
this.workspacesManager = new WorkspacesManager(workspacesMainService, backupMainService, this);
|
||||
|
||||
this.lifecycleService.when(LifecycleMainPhase.Ready).then(() => this.registerListeners());
|
||||
this.lifecycleService.when(LifecycleMainPhase.AfterWindowOpen).then(() => this.setupNativeHelpers());
|
||||
this.lifecycleService.when(LifecycleMainPhase.AfterWindowOpen).then(() => this.installWindowsMutex());
|
||||
}
|
||||
|
||||
private setupNativeHelpers(): void {
|
||||
private installWindowsMutex(): void {
|
||||
if (isWindows) {
|
||||
|
||||
// Setup Windows mutex
|
||||
try {
|
||||
const WindowsMutex = (require.__$__nodeRequire('windows-mutex') as typeof import('windows-mutex')).Mutex;
|
||||
const mutex = new WindowsMutex(product.win32MutexName);
|
||||
once(this.lifecycleService.onWillShutdown)(() => mutex.release());
|
||||
} catch (e) {
|
||||
this.logService.error(e);
|
||||
|
||||
if (!this.environmentService.isBuilt) {
|
||||
this.showMessageBox({
|
||||
title: product.nameLong,
|
||||
type: 'warning',
|
||||
message: 'Failed to load windows-mutex!',
|
||||
detail: e.toString(),
|
||||
noLink: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Dev only: Ensure Windows foreground love module is present
|
||||
if (!this.environmentService.isBuilt) {
|
||||
try {
|
||||
require.__$__nodeRequire('windows-foreground-love');
|
||||
} catch (e) {
|
||||
this.logService.error(e);
|
||||
|
||||
this.showMessageBox({
|
||||
title: product.nameLong,
|
||||
type: 'warning',
|
||||
message: 'Failed to load windows-foreground-love!',
|
||||
detail: e.toString(),
|
||||
noLink: true
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
28
src/vs/code/test/electron-main/nativeHelpers.test.ts
Normal file
28
src/vs/code/test/electron-main/nativeHelpers.test.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
|
||||
suite('Windows Native Helpers', () => {
|
||||
test('windows-mutex', async () => {
|
||||
if (!isWindows) {
|
||||
return;
|
||||
}
|
||||
|
||||
const mutex = await import('windows-mutex');
|
||||
assert.ok(mutex, 'Unable to load windows-mutex dependency.');
|
||||
assert.ok(typeof mutex.isActive === 'function', 'Unable to load windows-mutex dependency.');
|
||||
});
|
||||
|
||||
test('windows-foreground-love', async () => {
|
||||
if (!isWindows) {
|
||||
return;
|
||||
}
|
||||
|
||||
const foregroundLove = await import('windows-foreground-love');
|
||||
assert.ok(foregroundLove, 'Unable to load windows-foreground-love dependency.');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user