Skip to content

Commit

Permalink
Make sure realdevice object is initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
imurchie committed Jul 20, 2015
1 parent 1301498 commit bf2c645
Showing 1 changed file with 33 additions and 6 deletions.
39 changes: 33 additions & 6 deletions lib/devices/ios/ios.js
Expand Up @@ -846,17 +846,19 @@ IOS.prototype.setBundleIdFromApp = function (cb) {
};

IOS.prototype.installToRealDevice = function (cb) {
// get a real device object to deal with incoming queries
try {
this.realDevice = this.getIDeviceObj();
} catch (e) {
return cb(e);
}

// if user has passed in desiredCaps.autoLaunch = false
// meaning they will manage app install / launching
if (this.args.autoLaunch === false) {
cb();
} else {
if (this.args.udid) {
try {
this.realDevice = this.getIDeviceObj();
} catch (e) {
return cb(e);
}
this.isAppInstalled(this.args.bundleId, function (err, installed) {
if (err || !installed) {
logger.debug("App is not installed. Will try to install the app.");
Expand Down Expand Up @@ -914,7 +916,11 @@ IOS.prototype.getIDeviceObj = function () {
IOS.prototype.installIpa = function (cb) {
logger.debug("Installing ipa found at " + this.args.ipa);
if (!this.realDevice) {
this.realDevice = this.getIDeviceObj();
try {
this.realDevice = this.getIDeviceObj();
} catch (e) {
return cb(e);
}
}
var d = this.realDevice;
async.waterfall([
Expand Down Expand Up @@ -1484,6 +1490,13 @@ IOS.prototype.push = function (elem) {

IOS.prototype.isAppInstalled = function (bundleId, cb) {
if (this.args.udid) {
if (!this.realDevice) {
try {
this.realDevice = this.getIDeviceObj();
} catch (e) {
return cb(e);
}
}
this.realDevice.isInstalled(bundleId, cb);
} else {
cb(new Error("You can not call isInstalled for the iOS simulator!"));
Expand All @@ -1492,6 +1505,13 @@ IOS.prototype.isAppInstalled = function (bundleId, cb) {

IOS.prototype.removeApp = function (bundleId, cb) {
if (this.args.udid) {
if (!this.realDevice) {
try {
this.realDevice = this.getIDeviceObj();
} catch (e) {
return cb(e);
}
}
this.realDevice.remove(bundleId, cb);
} else {
this.sim.remove(bundleId, cb);
Expand All @@ -1500,6 +1520,13 @@ IOS.prototype.removeApp = function (bundleId, cb) {

IOS.prototype.installApp = function (unzippedAppPath, cb) {
if (this.args.udid) {
if (!this.realDevice) {
try {
this.realDevice = this.getIDeviceObj();
} catch (e) {
return cb(e);
}
}
this.realDevice.install(unzippedAppPath, cb);
} else {
this.sim.install(unzippedAppPath, cb);
Expand Down

0 comments on commit bf2c645

Please sign in to comment.