add a pre-launch mode that doesn't listen until sim is running

This commit is contained in:
Jonathan Lipps
2013-01-29 10:29:26 -08:00
parent 24a0eb8c20
commit 2734b7fefe
4 changed files with 32 additions and 4 deletions
+15
View File
@@ -39,6 +39,21 @@ Appium.prototype.attachTo = function(rest, cb) {
}
};
Appium.prototype.preLaunch = function(cb) {
logger.info("Pre-launching app");
if (!this.args.app) {
logger.error("Cannot pre-launch app if it isn't passed in via --app");
process.exit();
} else {
var me = this;
this.start({}, function(err, device) {
me.stop(function(err, res) {
cb(me);
});
});
}
};
Appium.prototype.start = function(desiredCaps, cb) {
this.origApp = this.args.app;
this.configure(desiredCaps, _.bind(function(err) {
+4
View File
@@ -32,5 +32,9 @@ module.exports = function() {
, { defaultValue: true, required: false, help: 'remove Instruments trace directories'
});
parser.addArgument([ '-l', '--launch' ]
, { defaultValue: false, required: false, help: 'pre-launch the ios-sim'
});
return parser;
};
+12 -4
View File
@@ -48,13 +48,21 @@ var main = function(args, readyCb, doneCb) {
// Hook up REST http interface
appiumServer.attachTo(rest);
// Start the web server that receives all the commands
server.listen(args.port, args.address, function() {
var logMessage = "Appium REST http interface listener started on "+args.address+":"+args.port;
logger.info(logMessage.cyan);
var next = function(appiumServer) {
server.listen(args.port, args.address, function() {
var logMessage = "Appium REST http interface listener started on "+args.address+":"+args.port;
logger.info(logMessage.cyan);
});
if (readyCb) {
readyCb(appiumServer);
}
});
};
if (args.launch) {
logger.info("Starting Appium in pre-launch mode".cyan);
appiumServer.preLaunch(next);
} else {
next(appiumServer);
}
server.on('close', doneCb);
return server;
};
+1
View File
@@ -18,6 +18,7 @@ describe("appiumutils", function() {
app: path.resolve(__dirname, "../../../sample-code/apps/UICatalog/build/Release-iphonesimulator/UICatalog.app")
, verbose: false
, udid: null
, launch: true
, port: 4723
, address: '127.0.0.1'
, remove: true }