make safari its own device module

This commit is contained in:
Jonathan Lipps
2013-11-14 18:03:04 -08:00
parent 45f47c6610
commit f0721cf2b5
3 changed files with 34 additions and 14 deletions

View File

@@ -1,6 +1,5 @@
// Appium webserver controller methods
// https://github.com/hugs/appium/blob/master/appium/appium.py
"use strict";
var routing = require('./server/routing.js')
, loggerjs = require('./server/logger.js')
, logger = loggerjs.get('appium')
@@ -14,6 +13,7 @@ var routing = require('./server/routing.js')
, _ = require('underscore')
, fs = require('fs')
, IOS = require('./devices/ios/ios.js')
, Safari = require('./devices/ios/safari.js')
, Android = require('./devices/android/android.js')
, Selendroid = require('./devices/android/selendroid.js')
, Chrome = require('./devices/android/chrome.js')
@@ -536,7 +536,6 @@ Appium.prototype.initDevice = function() {
, removeTraceDir: !this.args.keepArtifacts
, withoutDelay: !this.args.nativeInstrumentsLib
, reset: !this.args.noReset
, autoWebview: this.desiredCapabilities.safari
, launchTimeout: this.desiredCapabilities.launchTimeout
, version: this.desiredCapabilities.version
, deviceType: this.iosDeviceType
@@ -550,7 +549,12 @@ Appium.prototype.initDevice = function() {
, desiredCapabilities: this.desiredCapabilities
, logNoColors: this.args.logNoColors
};
this.device = new IOS(iosOpts);
if (this.desiredCapabilities.safari) {
iosOpts.autoWebview = true;
this.device = new Safari(iosOpts);
} else {
this.device = new IOS(iosOpts);
}
} else if (this.isAndroid()) {
var androidOpts = {
rest: this.rest

View File

@@ -22,7 +22,21 @@ var path = require('path')
, iOSHybrid = require('./ios-hybrid.js')
, UnknownError = errors.UnknownError;
// XML Plist library helper
var xmlPlistFile = function(filename, callback) {
try {
var result = xmlplist.parseFileSync(filename);
return callback(null, result);
} catch (ex) {
return callback(ex);
}
};
var IOS = function(args) {
this.init(args);
};
IOS.prototype.init = function(args) {
this.rest = args.rest;
this.version = args.version;
this.webSocket = args.webSocket;
@@ -84,16 +98,6 @@ var IOS = function(args) {
this.localizableStrings = {};
};
// XML Plist library helper
var xmlPlistFile = function(filename, callback) {
try {
var result = xmlplist.parseFileSync(filename);
return callback(null, result);
} catch (ex) {
return callback(ex);
}
};
IOS.prototype.cleanup = function(cb) {
var removeTracedirs = function(innerCb) {
if (this.removeTraceDir) {

12
lib/devices/ios/safari.js Normal file
View File

@@ -0,0 +1,12 @@
"use strict";
var IOS = require('./ios.js')
, _ = require('underscore');
var Safari = function(args) {
this.init(args);
};
_.extend(Safari.prototype, IOS.prototype);
module.exports = Safari;