Skip to content

Commit 19f5b72

Browse files
author
Benjamin Pasero
committed
debt - test for native helpers as a test
1 parent 4c952de commit 19f5b72

2 files changed

Lines changed: 30 additions & 31 deletions

File tree

src/vs/code/electron-main/windows.ts

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -207,46 +207,17 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
207207
this.workspacesManager = new WorkspacesManager(workspacesMainService, backupMainService, this);
208208

209209
this.lifecycleService.when(LifecycleMainPhase.Ready).then(() => this.registerListeners());
210-
this.lifecycleService.when(LifecycleMainPhase.AfterWindowOpen).then(() => this.setupNativeHelpers());
210+
this.lifecycleService.when(LifecycleMainPhase.AfterWindowOpen).then(() => this.installWindowsMutex());
211211
}
212212

213-
private setupNativeHelpers(): void {
213+
private installWindowsMutex(): void {
214214
if (isWindows) {
215-
216-
// Setup Windows mutex
217215
try {
218216
const WindowsMutex = (require.__$__nodeRequire('windows-mutex') as typeof import('windows-mutex')).Mutex;
219217
const mutex = new WindowsMutex(product.win32MutexName);
220218
once(this.lifecycleService.onWillShutdown)(() => mutex.release());
221219
} catch (e) {
222220
this.logService.error(e);
223-
224-
if (!this.environmentService.isBuilt) {
225-
this.showMessageBox({
226-
title: product.nameLong,
227-
type: 'warning',
228-
message: 'Failed to load windows-mutex!',
229-
detail: e.toString(),
230-
noLink: true
231-
});
232-
}
233-
}
234-
235-
// Dev only: Ensure Windows foreground love module is present
236-
if (!this.environmentService.isBuilt) {
237-
try {
238-
require.__$__nodeRequire('windows-foreground-love');
239-
} catch (e) {
240-
this.logService.error(e);
241-
242-
this.showMessageBox({
243-
title: product.nameLong,
244-
type: 'warning',
245-
message: 'Failed to load windows-foreground-love!',
246-
detail: e.toString(),
247-
noLink: true
248-
});
249-
}
250221
}
251222
}
252223
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import * as assert from 'assert';
7+
import { isWindows } from 'vs/base/common/platform';
8+
9+
suite('Windows Native Helpers', () => {
10+
test('windows-mutex', async () => {
11+
if (!isWindows) {
12+
return;
13+
}
14+
15+
const mutex = await import('windows-mutex');
16+
assert.ok(mutex, 'Unable to load windows-mutex dependency.');
17+
assert.ok(typeof mutex.isActive === 'function', 'Unable to load windows-mutex dependency.');
18+
});
19+
20+
test('windows-foreground-love', async () => {
21+
if (!isWindows) {
22+
return;
23+
}
24+
25+
const foregroundLove = await import('windows-foreground-love');
26+
assert.ok(foregroundLove, 'Unable to load windows-foreground-love dependency.');
27+
});
28+
});

0 commit comments

Comments
 (0)