refactor: unify installation on devices & emulators (#1123)

* refactor: unify installation on devices & emulators

This change replaces the almost identical methods `device.install` and
`emulator.install` with the generic `target.install`.

* fix: use unified installation in platform-centric bins
This commit is contained in:
Raphael von der Grün
2020-11-20 22:12:18 +01:00
committed by GitHub
parent aa679ea1d6
commit bb7d733cde
10 changed files with 222 additions and 358 deletions
+9 -4
View File
@@ -45,18 +45,23 @@ describe('run', () => {
describe('run method', () => {
let deviceSpyObj;
let emulatorSpyObj;
let targetSpyObj;
let eventsSpyObj;
let getInstallTargetSpy;
beforeEach(() => {
deviceSpyObj = jasmine.createSpyObj('deviceSpy', ['install', 'list', 'resolveTarget']);
emulatorSpyObj = jasmine.createSpyObj('emulatorSpy', ['install', 'list_images', 'list_started', 'resolveTarget', 'start', 'wait_for_boot']);
deviceSpyObj = jasmine.createSpyObj('deviceSpy', ['list', 'resolveTarget']);
emulatorSpyObj = jasmine.createSpyObj('emulatorSpy', ['list_images', 'list_started', 'resolveTarget', 'start', 'wait_for_boot']);
eventsSpyObj = jasmine.createSpyObj('eventsSpy', ['emit']);
getInstallTargetSpy = jasmine.createSpy('getInstallTargetSpy');
targetSpyObj = jasmine.createSpyObj('target', ['install']);
targetSpyObj.install.and.resolveTo();
run.__set__({
device: deviceSpyObj,
emulator: emulatorSpyObj,
target: targetSpyObj,
events: eventsSpyObj,
getInstallTarget: getInstallTargetSpy
});
@@ -187,7 +192,7 @@ describe('run', () => {
deviceSpyObj.resolveTarget.and.returnValue(deviceTarget);
return run.run().then(() => {
expect(deviceSpyObj.install).toHaveBeenCalledWith(deviceTarget, { apkPaths: [], buildType: 'debug' });
expect(targetSpyObj.install).toHaveBeenCalledWith(deviceTarget, { apkPaths: [], buildType: 'debug' });
});
});
@@ -199,7 +204,7 @@ describe('run', () => {
emulatorSpyObj.wait_for_boot.and.returnValue(Promise.resolve());
return run.run().then(() => {
expect(emulatorSpyObj.install).toHaveBeenCalledWith(emulatorTarget, { apkPaths: [], buildType: 'debug' });
expect(targetSpyObj.install).toHaveBeenCalledWith(emulatorTarget, { apkPaths: [], buildType: 'debug' });
});
});