SDA-1880 & SDA-1882 - Fix background throttling issue (#925)

This commit is contained in:
Kiran Niranjan
2020-03-18 19:50:27 +05:30
committed by GitHub
parent 79b2c42fdc
commit 996bd858a7
6 changed files with 113 additions and 17 deletions
+84 -1
View File
@@ -5,17 +5,27 @@ import { app } from './__mocks__/electron';
jest.mock('../src/app/config-handler', () => {
return {
CloudConfigDataTypes: {
NOT_SET: 'NOT_SET',
ENABLED: 'ENABLED',
DISABLED: 'DISABLED',
},
config: {
getConfigFields: jest.fn(() => {
return {
customFlags: {
authServerWhitelist: 'url',
authNegotiateDelegateWhitelist: 'whitelist',
disableThrottling: false,
disableThrottling: 'DISABLED',
},
disableGpu: true,
};
}),
getCloudConfigFields: jest.fn(() => {
return {
disableThrottling: 'DISABLED',
};
}),
},
};
});
@@ -75,6 +85,79 @@ describe('chrome flags', () => {
expect(spy).not.nthCalledWith(4);
});
it('should set `disable-renderer-backgrounding` chrome flag correctly when cloud config is ENABLED', () => {
config.getConfigFields = jest.fn(() => {
return {
customFlags: {
authServerWhitelist: 'url',
authNegotiateDelegateWhitelist: 'whitelist',
disableGpu: false,
disableThrottling: 'ENABLED',
},
};
});
const spy = jest.spyOn(app.commandLine, 'appendSwitch');
setChromeFlags();
expect(spy).nthCalledWith(4, 'disable-renderer-backgrounding', 'true');
expect(spy).not.nthCalledWith(5);
});
it('should set `disable-renderer-backgrounding` chrome flag correctly when cloud config PMP setting is ENABLED', () => {
config.getCloudConfigFields = jest.fn(() => {
return {
disableThrottling: 'ENABLED',
};
});
const spy = jest.spyOn(app.commandLine, 'appendSwitch');
setChromeFlags();
expect(spy).nthCalledWith(7, 'disable-renderer-backgrounding', 'true');
expect(spy).not.nthCalledWith(8);
});
it('should set `disable-renderer-backgrounding` chrome flag when any one is ENABLED ', () => {
config.getConfigFields = jest.fn(() => {
return {
customFlags: {
authServerWhitelist: 'url',
authNegotiateDelegateWhitelist: 'whitelist',
disableGpu: false,
disableThrottling: 'DISABLED',
},
};
});
config.getCloudConfigFields = jest.fn(() => {
return {
disableThrottling: 'ENABLED',
};
});
const spy = jest.spyOn(app.commandLine, 'appendSwitch');
setChromeFlags();
expect(spy).nthCalledWith(4, 'disable-renderer-backgrounding', 'true');
expect(spy).not.nthCalledWith(5);
});
it('should set `disable-renderer-backgrounding` chrome flag when PMP is ENABLED', () => {
config.getConfigFields = jest.fn(() => {
return {
customFlags: {
authServerWhitelist: 'url',
authNegotiateDelegateWhitelist: 'whitelist',
disableGpu: false,
disableThrottling: 'ENABLED',
},
};
});
config.getCloudConfigFields = jest.fn(() => {
return {
disableThrottling: 'DISABLED',
};
});
const spy = jest.spyOn(app.commandLine, 'appendSwitch');
setChromeFlags();
expect(spy).nthCalledWith(4, 'disable-renderer-backgrounding', 'true');
expect(spy).not.nthCalledWith(5);
});
describe('`isDevEnv`', () => {
beforeEach(() => {
(isDevEnv as any) = true;