mirror of
https://github.com/apache/cordova-android.git
synced 2026-04-23 00:00:09 +08:00
CB-12546: based on android command exit code and stdout, conditionally try to invoke avdmanager to list out AVD images. tweak relevant test to match behaviour. small tweak to use exposed methods for checking platform (for easier future stubbing).
This commit is contained in:
@@ -84,13 +84,24 @@ describe("emulator", function () {
|
||||
});
|
||||
it("should catch if `android` exits with non-zero code and specific stdout, and delegate to `avdmanager` if it can find it", function() {
|
||||
spyOn(shelljs, "which").and.callFake(function(cmd) {
|
||||
if (cmd == "avdmanager") {
|
||||
if (cmd == "android") {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
var avdmanager_spy = spyOn(emu, "list_images_using_avdmanager");
|
||||
// Fake out the old promise to feign a failed `android` command
|
||||
spyOn(emu, "list_images_using_android").and.returnValue({
|
||||
catch:function(cb) {
|
||||
cb({
|
||||
code: 1,
|
||||
stdout: ["The android command is no longer available.",
|
||||
"For manual SDK and AVD management, please use Android Studio.",
|
||||
"For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager"].join("\n")
|
||||
});
|
||||
}
|
||||
});
|
||||
emu.list_images();
|
||||
expect(avdmanager_spy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user