Skip to content

Commit

Permalink
migrate firefoxos config
Browse files Browse the repository at this point in the history
  • Loading branch information
jlipps committed Mar 4, 2014
1 parent 3cab56e commit f7011a5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 45 deletions.
26 changes: 2 additions & 24 deletions lib/appium.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ Appium.prototype.invoke = function (cb) {

Appium.prototype.getDevice = function (deviceType) {
var caps = this.desiredCapabilities;
var Device = (function () {
var DeviceClass = (function () {
switch (deviceType) {
case DT_IOS:
return (caps.safari || caps.iwebview) ? Safari : IOS;
Expand All @@ -253,29 +253,7 @@ Appium.prototype.getDevice = function (deviceType) {
deviceType);
}
});
return new Device();

} else if (this.isAndroid()) {
var androidOpts = {
, port: this.args.chromeDriverPort
};
if (this.isChrome()) {
this.device = new Chrome(androidOpts);
} else {
this.device = new Android(androidOpts);
}
} else if (this.isSelendroid()) {
} else if (this.isFirefoxOS()) {
var firefoxOpts = {
app: this.args.app
, desiredCaps: this.desiredCapabilities
, verbose: !this.args.quiet
};
this.device = new FirefoxOs(firefoxOpts);
} else {
throw new Error("Tried to start a device that doesn't exist: " +
this.deviceType);
}
return new DeviceClass();
};

Appium.prototype.timeoutWaitingForCommand = function () {
Expand Down
43 changes: 22 additions & 21 deletions lib/devices/firefoxos/firefoxos.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,23 @@ var errors = require('../../server/errors.js')
, async = require('async')
, NotYetImplementedError = errors.NotYetImplementedError;

var Firefox = function (opts) {
this.rest = opts.rest;
this.app = opts.app;
this.opts = opts;
this.udid = opts.udid;
this.verbose = opts.verbose;
this.port = opts.port || 2828;
var Firefox = function () {
this.init();
};

_.extend(Firefox.prototype, Device.prototype);
Firefox.prototype._deviceInit = Device.prototype.init;
Firefox.prototype.init = function () {
this._deviceInit();
this.capabilities = {
platform: 'LINUX'
, browserName: 'FirefoxOS'
, version: '18.0'
, webStorageEnabled: false
, takesScreenshot: true
, javascriptEnabled: true
, databaseEnabled: false
};
this.queue = [];
this.progress = 0;
this.onStop = function () {};
Expand All @@ -32,23 +42,14 @@ var Firefox = function (opts) {
this.socket = null;
this.receiveStream = null;
this.expectedRcvBytes = null;
this.capabilities = {
platform: 'LINUX'
, browserName: 'FirefoxOS'
, version: '18.0'
, webStorageEnabled: false
, takesScreenshot: true
, javascriptEnabled: true
, databaseEnabled: false
};
this.lastCmd = null;
this.initCommandMap();
};

_.extend(Firefox.prototype, Device.prototype);

Firefox.prototype._deviceConfigure = Device.prototype.configure;
Firefox.prototype.configure = function (args, caps, cb) {
this.setArgsAndCaps(args, caps);
this._deviceConfigure(args, caps);
this.args.systemPort = 2828;
cb();
};

Expand All @@ -59,7 +60,7 @@ Firefox.prototype.start = function (cb, onDie) {
});
this.socket.on('data', this.receive.bind(this));

this.socket.connect(this.port, 'localhost', function () { });
this.socket.connect(this.args.systemPort, 'localhost', function () { });


this.onConnect = function () {
Expand Down Expand Up @@ -106,7 +107,7 @@ Firefox.prototype.launchAppByName = function (cb) {
logger.info("Launching our app by its name");
var atomSrc = getAtomSrc('gaia_apps');
var wrappedScript = atomSrc +
";GaiaApps.launchWithName('" + this.app + "');";
";GaiaApps.launchWithName('" + this.args.app + "');";
var cmd = {
type: 'executeAsyncScript'
, args: []
Expand Down

0 comments on commit f7011a5

Please sign in to comment.