test: remove redundant color diffing dependency (#33215)
This commit is contained in:
parent
b3fd5eb258
commit
e8ae0571b8
9 changed files with 93 additions and 572 deletions
|
@ -10,7 +10,7 @@ import { app, BrowserWindow, BrowserView, dialog, ipcMain, OnBeforeSendHeadersLi
|
|||
import { emittedOnce, emittedUntil, emittedNTimes } from './events-helpers';
|
||||
import { ifit, ifdescribe, defer, delay } from './spec-helpers';
|
||||
import { closeWindow, closeAllWindows } from './window-helpers';
|
||||
import { areColorsSimilar, captureScreen, CHROMA_COLOR_HEX, getPixelColor } from './screen-helpers';
|
||||
import { areColorsSimilar, captureScreen, HexColors, getPixelColor } from './screen-helpers';
|
||||
|
||||
const features = process._linkedBinding('electron_common_features');
|
||||
const fixtures = path.resolve(__dirname, 'fixtures');
|
||||
|
@ -2070,15 +2070,7 @@ describe('BrowserWindow module', () => {
|
|||
});
|
||||
|
||||
ifdescribe(process.platform === 'darwin')('BrowserWindow.setVibrancy(type)', () => {
|
||||
let appProcess: childProcess.ChildProcessWithoutNullStreams | childProcess.ChildProcess | undefined;
|
||||
|
||||
afterEach(() => {
|
||||
if (appProcess && !appProcess.killed) {
|
||||
appProcess.kill();
|
||||
appProcess = undefined;
|
||||
}
|
||||
closeAllWindows();
|
||||
});
|
||||
afterEach(closeAllWindows);
|
||||
|
||||
it('allows setting, changing, and removing the vibrancy', () => {
|
||||
const w = new BrowserWindow({ show: false });
|
||||
|
@ -2097,18 +2089,6 @@ describe('BrowserWindow module', () => {
|
|||
w.setVibrancy('i-am-not-a-valid-vibrancy-type' as any);
|
||||
}).to.not.throw();
|
||||
});
|
||||
|
||||
// TODO(nornagon): disabled due to flakiness.
|
||||
it.skip('Allows setting a transparent window via CSS', async () => {
|
||||
const appPath = path.join(__dirname, 'fixtures', 'apps', 'background-color-transparent');
|
||||
|
||||
appProcess = childProcess.spawn(process.execPath, [appPath], {
|
||||
stdio: 'inherit'
|
||||
});
|
||||
|
||||
const [code] = await emittedOnce(appProcess, 'exit');
|
||||
expect(code).to.equal(0);
|
||||
});
|
||||
});
|
||||
|
||||
ifdescribe(process.platform === 'darwin')('trafficLightPosition', () => {
|
||||
|
@ -5527,7 +5507,7 @@ describe('BrowserWindow module', () => {
|
|||
const backgroundWindow = new BrowserWindow({
|
||||
...display.bounds,
|
||||
frame: false,
|
||||
backgroundColor: CHROMA_COLOR_HEX,
|
||||
backgroundColor: HexColors.GREEN,
|
||||
hasShadow: false
|
||||
});
|
||||
|
||||
|
@ -5541,9 +5521,10 @@ describe('BrowserWindow module', () => {
|
|||
hasShadow: false
|
||||
});
|
||||
|
||||
foregroundWindow.loadFile(path.join(__dirname, 'fixtures', 'pages', 'half-background-color.html'));
|
||||
await emittedOnce(foregroundWindow, 'ready-to-show');
|
||||
const colorFile = path.join(__dirname, 'fixtures', 'pages', 'half-background-color.html');
|
||||
await foregroundWindow.loadFile(colorFile);
|
||||
|
||||
await delay(1000);
|
||||
const screenCapture = await captureScreen();
|
||||
const leftHalfColor = getPixelColor(screenCapture, {
|
||||
x: display.size.width / 4,
|
||||
|
@ -5554,22 +5535,57 @@ describe('BrowserWindow module', () => {
|
|||
y: display.size.height / 2
|
||||
});
|
||||
|
||||
expect(areColorsSimilar(leftHalfColor, CHROMA_COLOR_HEX)).to.be.true();
|
||||
expect(areColorsSimilar(rightHalfColor, '#ff0000')).to.be.true();
|
||||
expect(areColorsSimilar(leftHalfColor, HexColors.GREEN)).to.be.true();
|
||||
expect(areColorsSimilar(rightHalfColor, HexColors.RED)).to.be.true();
|
||||
});
|
||||
|
||||
ifit(process.platform !== 'linux' && process.arch !== 'arm64')('Allows setting a transparent window via CSS', async () => {
|
||||
const display = screen.getPrimaryDisplay();
|
||||
|
||||
const backgroundWindow = new BrowserWindow({
|
||||
...display.bounds,
|
||||
frame: false,
|
||||
backgroundColor: HexColors.PURPLE,
|
||||
hasShadow: false
|
||||
});
|
||||
|
||||
await backgroundWindow.loadURL('about:blank');
|
||||
|
||||
const foregroundWindow = new BrowserWindow({
|
||||
...display.bounds,
|
||||
frame: false,
|
||||
transparent: true,
|
||||
hasShadow: false,
|
||||
webPreferences: {
|
||||
contextIsolation: false,
|
||||
nodeIntegration: true
|
||||
}
|
||||
});
|
||||
|
||||
foregroundWindow.loadFile(path.join(__dirname, 'fixtures', 'pages', 'css-transparent.html'));
|
||||
await emittedOnce(ipcMain, 'set-transparent');
|
||||
|
||||
await delay();
|
||||
const screenCapture = await captureScreen();
|
||||
const centerColor = getPixelColor(screenCapture, {
|
||||
x: display.size.width / 2,
|
||||
y: display.size.height / 2
|
||||
});
|
||||
|
||||
expect(areColorsSimilar(centerColor, HexColors.PURPLE)).to.be.true();
|
||||
});
|
||||
});
|
||||
|
||||
describe('"backgroundColor" option', () => {
|
||||
afterEach(closeAllWindows);
|
||||
|
||||
// Linux/WOA doesn't return any capture sources.
|
||||
ifit(process.platform !== 'linux' && (process.platform !== 'win32' || process.arch !== 'arm64'))('should display the set color', async () => {
|
||||
ifit(process.platform !== 'linux' && process.arch !== 'arm64')('should display the set color', async () => {
|
||||
const display = screen.getPrimaryDisplay();
|
||||
|
||||
const w = new BrowserWindow({
|
||||
...display.bounds,
|
||||
show: true,
|
||||
backgroundColor: CHROMA_COLOR_HEX
|
||||
backgroundColor: HexColors.BLUE
|
||||
});
|
||||
|
||||
w.loadURL('about:blank');
|
||||
|
@ -5581,7 +5597,7 @@ describe('BrowserWindow module', () => {
|
|||
y: display.size.height / 2
|
||||
});
|
||||
|
||||
expect(areColorsSimilar(centerColor, CHROMA_COLOR_HEX)).to.be.true();
|
||||
expect(areColorsSimilar(centerColor, HexColors.BLUE)).to.be.true();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue