Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit abd6278

Browse files
authored
Fixed launch of Android emulator (#1779)
1 parent 5ce2300 commit abd6278

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

code-push-plugin-testing-framework/script/platform.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,28 @@ var AndroidEmulatorManager = (function () {
170170
if (this.targetEmulator)
171171
return Q(this.targetEmulator);
172172
else {
173-
this.targetEmulator = testUtil_1.TestUtil.readMochaCommandLineOption(AndroidEmulatorManager.ANDROID_EMULATOR_OPTION_NAME, AndroidEmulatorManager.DEFAULT_ANDROID_EMULATOR);
174-
console.log("Using Android emulator named " + this.targetEmulator);
175-
return Q(this.targetEmulator);
173+
const deferred = Q.defer();
174+
const targetAndroidEmulator = testUtil_1.TestUtil.readMochaCommandLineOption(AndroidEmulatorManager.ANDROID_EMULATOR_OPTION_NAME);
175+
if (!targetAndroidEmulator) {
176+
// If no Android simulator is specified, get the most recent Android simulator to run tests on.
177+
testUtil_1.TestUtil.getProcessOutput("emulator -list-avds", { noLogCommand: true, noLogStdOut: true, noLogStdErr: true })
178+
.then((Devices) => {
179+
const listOfDevices = Devices.trim().split("\n");
180+
deferred.resolve(listOfDevices[listOfDevices.length - 1]);
181+
}, (error) => {
182+
deferred.reject(error);
183+
});
184+
}
185+
else {
186+
// Use the simulator specified on the command line.
187+
deferred.resolve(targetAndroidEmulator);
188+
}
189+
return deferred.promise
190+
.then((targetEmulator) => {
191+
this.targetEmulator = targetEmulator;
192+
console.log("Using Android simulator named " + this.targetEmulator);
193+
return this.targetEmulator;
194+
});
176195
}
177196
};
178197
/**
@@ -254,7 +273,6 @@ var AndroidEmulatorManager = (function () {
254273
return commandWithCheckAppExistence("adb uninstall", appId);
255274
};
256275
AndroidEmulatorManager.ANDROID_EMULATOR_OPTION_NAME = "--androidemu";
257-
AndroidEmulatorManager.DEFAULT_ANDROID_EMULATOR = "emulator";
258276
return AndroidEmulatorManager;
259277
}());
260278
exports.AndroidEmulatorManager = AndroidEmulatorManager;

code-push-plugin-testing-framework/typings/code-push-plugin-testing-framework.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ declare module 'code-push-plugin-testing-framework/script/platform' {
127127
}
128128
export class AndroidEmulatorManager implements IEmulatorManager {
129129
private static ANDROID_EMULATOR_OPTION_NAME;
130-
private static DEFAULT_ANDROID_EMULATOR;
131130
private targetEmulator;
132131
/**
133132
* Returns the target emulator, which is specified through the command line.

0 commit comments

Comments
 (0)