Skip to content

Commit

Permalink
fix bug where --safari wouldn't pre-launch
Browse files Browse the repository at this point in the history
and add tests
  • Loading branch information
jlipps committed Jan 21, 2014
1 parent da8d641 commit 0dceea2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/appium.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ Appium.prototype.getDeviceTypeFromApp = function(app) {
return "ios";
} else if (/\.apk/.test(app)) {
return "android";
} else if ((app && app.toLowerCase() === "safari") || this.args.safari) {
return "ios";
}
throw new Error("Could not determine your device type from --app");
};
Expand Down
15 changes: 13 additions & 2 deletions test/functional/appium/prelaunch.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ var path = require('path')
, crazyPort = 4799;

var waitForLaunch = function(app, extraArgs, cb) {
var args = [".", "-p", crazyPort, "-l", "-dd", "-m", "--app", app];
var args = [".", "-p", crazyPort, "-l", "-dd", "-m"];
if (app) {
args = args.concat(["--app", app]);
}
args = args.concat(extraArgs);
var proc = spawn('node', args, {cwd: path.resolve(__dirname, "..", "..", "..")});
proc.stdout.setEncoding('utf8');
Expand All @@ -19,7 +22,7 @@ var waitForLaunch = function(app, extraArgs, cb) {
calledBack = true;
proc.kill();
cb(new Error("Appium never started. Output was: " + output));
}, 30000);
}, 60000);
proc.stdout.on('data', function(data) {
output += data;
if (!calledBack &&/Appium REST http interface listener started on/.test(data)) {
Expand Down Expand Up @@ -50,4 +53,12 @@ describe('Pre-launching apps', function() {
".ApiDemos"];
waitForLaunch(androidApp, args, done);
});

it('should work for safari', function(done) {
waitForLaunch('safari', [], done);
});

it('should work for safari via --safari', function(done) {
waitForLaunch(null, ['--safari'], done);
});
});

0 comments on commit 0dceea2

Please sign in to comment.