From 5a0576402cfa12058c0f48fedaf3f609704acfcf Mon Sep 17 00:00:00 2001 From: Kiran Niranjan Date: Mon, 20 Aug 2018 17:35:40 +0530 Subject: [PATCH] ELECTRON-651 (Assign focused window to the screen picker) [Windows] (#468) * ELECTRON-651 - Assign focused window to the screen picker which disables user interaction with the content below * ELECTRON-651 - Fix jest-html-reporter's path in jest config * ELECTRON-651 - Fix unit tests --- js/desktopCapturer/index.js | 4 ++++ tests/__mocks__/electron.js | 10 +++++----- tests/config.test.js | 4 ++-- tests/jest_unit.json | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/js/desktopCapturer/index.js b/js/desktopCapturer/index.js index 1d950b1a..087f6751 100644 --- a/js/desktopCapturer/index.js +++ b/js/desktopCapturer/index.js @@ -79,6 +79,10 @@ function openScreenPickerWindow(eventSender, sources, id) { windowConfig.x = Math.round(centerX - (windowWidth / 2.0)); windowConfig.y = Math.round(centerY - (windowHeight / 2.0)); } + + if (isWindowsOS) { + windowConfig.parent = focusedWindow; + } } // Store the window ref to send event diff --git a/tests/__mocks__/electron.js b/tests/__mocks__/electron.js index 069f9762..bee4a08a 100644 --- a/tests/__mocks__/electron.js +++ b/tests/__mocks__/electron.js @@ -70,11 +70,11 @@ const ipcRenderer = { }; module.exports = { - require: jest.genMockFunction(), - match: jest.genMockFunction(), - app: jest.genMockFunction(), + require: jest.fn(), + match: jest.fn(), + app: jest.fn(), ipcMain: ipcMain, ipcRenderer: ipcRenderer, - remote: jest.genMockFunction(), - dialog: jest.genMockFunction() + remote: jest.fn(), + dialog: jest.fn() }; diff --git a/tests/config.test.js b/tests/config.test.js index c91811c1..f1c9e48f 100644 --- a/tests/config.test.js +++ b/tests/config.test.js @@ -270,7 +270,7 @@ describe('read/write config tests', function() { return updateConfigField('url2', 'hello world') .catch(function (err) { - expect(err).toThrow(err); + expect(err.message).toBe('Path must be a string. Received null'); }); }); @@ -309,7 +309,7 @@ describe('read/write config tests', function() { return saveUserConfig('url2', 'hello world') .catch(function (err) { - expect(err).toThrow(err); + expect(err.message).toBe('Path must be a string. Received null'); }); }); diff --git a/tests/jest_unit.json b/tests/jest_unit.json index f3b331c2..590a1b71 100644 --- a/tests/jest_unit.json +++ b/tests/jest_unit.json @@ -1,6 +1,6 @@ { "testMatch": ["**/*.test.js"], "verbose": true, - "testResultsProcessor": "./node_modules/jest-html-reporter" + "testResultsProcessor": "../node_modules/jest-html-reporter" } \ No newline at end of file