Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: avd validator emulator version should obey headless #3614

Merged
merged 5 commits into from
Oct 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ class AVDValidator {
this._emulatorVersionResolver = emulatorVersionResolver;
}

async validate(avdName) {
async validate(avdName, isHeadless) {
const avds = await this._avdsResolver.resolve(avdName);
this._assertAVDs(avds);
await this._assertAVDMatch(avds, avdName);
await this._validateEmulatorVer();
await this._validateEmulatorVer(isHeadless);
}

_assertAVDs(avds) {
Expand All @@ -37,8 +37,8 @@ class AVDValidator {
}
}

async _validateEmulatorVer() {
const emulatorVersion = await this._emulatorVersionResolver.resolve();
async _validateEmulatorVer(isHeadless) {
const emulatorVersion = await this._emulatorVersionResolver.resolve(isHeadless);
if (!emulatorVersion) {
logger.warn({ event: 'AVD_VALIDATION' }, 'Emulator version detection failed (See previous logs)');
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,13 @@ describe('AVD validator', () => {
'Emulator version detection failed (See previous logs)'
);
});

it('should run emulator version resolver as headless if required', async () => {
givenExpectedAVD();
givenProperEmulatorVersion();

await uut.validate('mock-avd-name', true);

expect(versionResolver.resolve).toHaveBeenCalledWith(true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class EmulatorAllocDriver extends AllocationDriverBase {
async allocate(deviceConfig) {
const avdName = deviceConfig.device.avdName;

await this._avdValidator.validate(avdName);
await this._avdValidator.validate(avdName, deviceConfig.headless);
await this._fixAvdConfigIniSkinNameIfNeeded(avdName, deviceConfig.headless);

const allocResult = await this._allocationHelper.allocateDevice(avdName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,13 @@ describe('Allocation driver for Google emulators', () => {
it('should pre-validate proper AVD configuration', async () => {
givenValidAVD();
await allocDriver.allocate(deviceConfig);
expect(avdValidator.validate).toHaveBeenCalledWith(avdName);
expect(avdValidator.validate).toHaveBeenCalledWith(avdName, undefined);
});

it('should respect headless avd configuration during AVD validation', async () => {
givenValidAVD();
await allocDriver.allocate({ ...deviceConfig, headless: true });
expect(avdValidator.validate).toHaveBeenCalledWith(avdName, true);
});

it('should throw if AVD configuration is invalid', async () => {
Expand Down