Skip to content

Commit

Permalink
Merge pull request #5395 from jlipps/ios9
Browse files Browse the repository at this point in the history
Initial iOS 9 Support
  • Loading branch information
jlipps committed Jul 31, 2015
2 parents 738d4ed + c46c5e9 commit b6cfeec
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 28 deletions.
8 changes: 8 additions & 0 deletions bin/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ios81_only=false
ios82_only=false
ios83_only=false
ios84_only=false
ios9_only=false
android_only=false
android_chrome=false
selendroid_only=false
Expand Down Expand Up @@ -57,6 +58,9 @@ for arg in "$@"; do
elif [ "$arg" = "--ios84" ]; then
ios84_only=true
all_tests=false
elif [ "$arg" = "--ios9" ]; then
ios9_only=true
all_tests=false
elif [ "$arg" = "--real-device" ]; then
real_device=true
elif [ "$arg" =~ " " ]; then
Expand Down Expand Up @@ -119,6 +123,10 @@ if $ios84_only || $all_tests; then
run_ios_tests "8.4" "ios84" "@skip-ios84|@skip-ios82|@skip-ios81|@skip-ios8|@skip-ios-all|@skip-ios7up"
fi

if $ios9_only || $all_tests; then
run_ios_tests "9" "ios9" "@skip-ios9|@skip-ios84|@skip-ios82|@skip-ios81|@skip-ios8|@skip-ios-all|@skip-ios7up"
fi

if $android_only || $all_tests; then
echo "RUNNING ANDROID TESTS"
echo "---------------------"
Expand Down
10 changes: 7 additions & 3 deletions lib/devices/ios/ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,8 @@ IOS.getDeviceStringFromOpts = function (opts) {
deviceName: opts.deviceName,
platformVersion: opts.platformVersion
}));
var xcodeMajorVer = parseInt(opts.xcodeVersion.substr(0,
opts.xcodeVersion.indexOf('.')), 10);
var isiPhone = opts.forceIphone || opts.forceIpad === null || (opts.forceIpad !== null && !opts.forceIpad);
var isTall = isiPhone;
var isRetina = opts.xcodeVersion[0] !== '4';
Expand All @@ -972,13 +974,13 @@ IOS.getDeviceStringFromOpts = function (opts) {
}

var iosDeviceString = isiPhone ? "iPhone" : "iPad";
if (opts.xcodeVersion[0] === '4') {
if (xcodeMajorVer === 4) {
if (isiPhone && isRetina) {
iosDeviceString += isTall ? " (Retina 4-inch)" : " (Retina 3.5-inch)";
} else {
iosDeviceString += isRetina ? " (Retina)" : "";
}
} else if (opts.xcodeVersion[0] === '5') {
} else if (xcodeMajorVer === 5) {
iosDeviceString += isRetina ? " Retina" : "";
if (isiPhone) {
if (isRetina && isTall) {
Expand All @@ -989,7 +991,7 @@ IOS.getDeviceStringFromOpts = function (opts) {
} else {
iosDeviceString += is64bit ? " (64-bit)" : "";
}
} else if (opts.xcodeVersion[0] === '6') {
} else if (_.contains([6, 7], xcodeMajorVer)) {
iosDeviceString = opts.deviceName ||
(isiPhone ? "iPhone Simulator" : "iPad Simulator");
}
Expand All @@ -1012,11 +1014,13 @@ IOS.getDeviceStringFromOpts = function (opts) {
'iPad Simulator (8.3 Simulator)': 'iPad 2 (8.3 Simulator)',
'iPad Simulator (8.4 Simulator)': 'iPad 2 (8.4 Simulator)',
'iPad Simulator (7.1 Simulator)': 'iPad 2 (7.1 Simulator)',
'iPad Simulator (9.0 Simulator)': 'iPad 2 (9.0 Simulator)',
'iPhone Simulator (8.4 Simulator)': 'iPhone 6 (8.4 Simulator)',
'iPhone Simulator (8.3 Simulator)': 'iPhone 6 (8.3 Simulator)',
'iPhone Simulator (8.2 Simulator)': 'iPhone 6 (8.2 Simulator)',
'iPhone Simulator (8.1 Simulator)': 'iPhone 6 (8.1 Simulator)',
'iPhone Simulator (8.0 Simulator)': 'iPhone 6 (8.0 Simulator)',
'iPhone Simulator (9.0 Simulator)': 'iPhone 6 (9.0 Simulator)',
'iPhone Simulator (7.1 Simulator)': 'iPhone 5s (7.1 Simulator)'
};
if (CONFIG_FIX[iosDeviceString]) {
Expand Down
10 changes: 7 additions & 3 deletions lib/doctor/ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var path = require('path')
, fs = require('fs')
, env = process.env
, exec = require('child_process').exec
, _s = require('underscore.string')
, async = require('async');

require("./common.js");
Expand All @@ -27,15 +28,18 @@ IOSChecker.prototype.runAllChecks = function (cb) {
IOSChecker.prototype.getMacOSXVersion = function (cb) {
exec("sw_vers -productVersion", function (err, stdout) {
if (err === null) {
if (stdout.match('10.8') !== null) {
if (_s.startsWith(stdout, '10.8')) {
this.osVersion = '10.8';
cb(null, "Mac OS X 10.8 is installed.");
} else if (stdout.match('10.9') !== null) {
} else if (_s.startsWith(stdout, '10.9')) {
this.osVersion = '10.9';
cb(null, "Mac OS X 10.9 is installed.");
} else if ((stdout.match('10.10') !== null) || (stdout.match('10.10.1') !== null)) {
} else if (_s.startsWith(stdout, '10.10')) {
this.osVersion = '10.10';
cb(null, "Mac OS X 10.10 is installed.");
} else if (_s.startsWith(stdout, '10.11')) {
this.osVersion = '10.11';
cb(null, "Mac OS X 10.11 is installed.");
} else {
this.log.fail("Could not detect Mac OS X Version", cb);
}
Expand Down
3 changes: 1 addition & 2 deletions test/functional/ios/crash-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('crash recovery @skip-real-device', function () {
.elementByAccessibilityId("Crash")
.click()
.then(function () {
return driver.sleep(10000);
return driver.sleep(30000);
})
.source() // will 404 because the session is gone
.should.eventually.be.rejectedWith('6')
Expand Down Expand Up @@ -48,4 +48,3 @@ describe('crash commands @skip-real-device', function () {
.nodeify(done);
});
});

6 changes: 3 additions & 3 deletions test/functional/ios/prefs/autocomplete-settings-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ describe("prefs @skip-ios6 @skip-real-device", function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });

it('should turn off autocomplete', function (done) {
var ios7up = env.IOS7 || env.IOS8;
it('should turn off autocorrection', function (done) {
var ios7up = env.IOS7 || env.IOS8 || env.IOS9;
var switchEl;
driver
.elementsByClassName("UIATableCell").at(ios7up ? 0 : 1).click()
.sleep(1000)
.elementsByClassName("UIATableCell").at(ios7up ? (env.IOS8 ? 2 : 3) : 1)
.elementsByClassName("UIATableCell").at(ios7up ? (env.IOS8 || env.IOS9 ? 2 : 3) : 1)
.click()
.elementByXPath('//UIASwitch[@name="Auto-Correction"]')
.then(function (el) { switchEl = el; return el; })
Expand Down
2 changes: 1 addition & 1 deletion test/functional/ios/safari/basics-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var env = require('../../../helpers/env'),
setup = require("../../common/setup-base");

describe('safari - basics @skip-ios6 @skip-real-device', function () {
if (env.IOS8 && !env.IOS80) {
if ((env.IOS8 || env.IOS9) && !env.IOS80) {
describe('default init' ,function () {
var driver;
setup(this, {browserName: 'safari'}).then(function (d) { driver = d; });
Expand Down
2 changes: 1 addition & 1 deletion test/functional/ios/testapp/location-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe('testapp - location - 5 @skip-ci', function () {
bundleId: 'io.appium.TestApp',
app: 'assets/TestApp7.1.app.zip'
});
if (env.IOS8) {
if (env.IOS8 || env.IOS9) {
newDesired.app = 'assets/TestApp8.app.zip';
}

Expand Down
16 changes: 8 additions & 8 deletions test/functional/ios/uicatalog/find-basics-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ describe('uicatalog - find - basics @skip-ios6', function () {
});

it('should find a single element using elementByAccessibilityId', function (done) {
var axId = env.IOS8 ? 'AAPLImageViewController' :
'Image View, AAPLImageViewController';
var axId = (env.IOS8 || env.IOS9) ? 'AAPLImageViewController' :
'Image View, AAPLImageViewController';
driver
.elementByAccessibilityId(axId)
.then(function (el) {
Expand Down Expand Up @@ -56,7 +56,7 @@ describe('uicatalog - find - basics @skip-ios6', function () {
});

it('should find some elements within itself', function (done) {
var elLength = env.IOS8 ? 2 : 1;
var elLength = (env.IOS8 || env.IOS9) ? 2 : 1;
driver
.elementByXPath("//UIATableCell[contains(@name, 'Buttons')]")
.then(function (el) {
Expand All @@ -78,7 +78,7 @@ describe('uicatalog - find - basics @skip-ios6', function () {

describe('no mix up', function () {
after(function (done) {
if (!env.IOS81 && !env.IOS82 && !env.IOS83 && !env.IOS84) {
if (!env.IOS81 && !env.IOS82 && !env.IOS83 && !env.IOS84 && !env.IOS9) {
driver
.clickButton('UICatalog')
.nodeify(done);
Expand Down Expand Up @@ -129,15 +129,15 @@ describe('uicatalog - find - basics @skip-ios6', function () {

describe('findElementsByClassName textfield case', function () {
after(function (done) {
if (!env.IOS81 && !env.IOS82 && !env.IOS83 && !env.IOS84) {
if (!env.IOS81 && !env.IOS82 && !env.IOS83 && !env.IOS84 && !env.IOS9) {
driver
.clickButton('UICatalog')
.nodeify(done);
} else {
done();
}
});
var axIdExt = env.IOS8 ? '' : ', AAPLActionSheetViewController';
var axIdExt = (env.IOS8 || env.IOS9) ? '' : ', AAPLActionSheetViewController';
it('should find only one textfield', function (done) {
driver
.elementByAccessibilityId("Action Sheets" + axIdExt).click()
Expand All @@ -156,7 +156,7 @@ describe('uicatalog - find - basics @skip-ios6', function () {
.nodeify(done);
});

var axIdExt = env.IOS8 ? '' : ', AAPLActionSheetViewController';
var axIdExt = (env.IOS8 || env.IOS9) ? '' : ', AAPLActionSheetViewController';
it('should find one element', function (done) {
driver
.elementByAccessibilityId("Action Sheets" + axIdExt).click()
Expand All @@ -182,7 +182,7 @@ describe('uicatalog - find - basics @skip-ios6', function () {
.nodeify(done);
});

var axIdExt = env.IOS8 ? '' : ', AAPLTextFieldViewController';
var axIdExt = (env.IOS8 || env.IOS9) ? '' : ', AAPLTextFieldViewController';
it('should find only one element per text field', function (done) {
driver
.execute("mobile: scroll", {direction: 'down'})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('uicatalog - find by accessibility id @skip-ios6', function () {
});

it('should find an element by name beneath another element', function (done) {
var axIdExt = env.IOS8 ? '' : ', AAPLActionSheetViewController';
var axIdExt = env.IOS8 || env.IOS9 ? '' : ', AAPLActionSheetViewController';
driver
.elementByAccessibilityId("UICatalog").click()
.elementByAccessibilityId("Action Sheets" + axIdExt)
Expand Down
6 changes: 3 additions & 3 deletions test/functional/ios/uicatalog/find-by-ui-automation-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('uicatalog - find by ios-ui-automation @skip-ios6', function () {
.nodeify(done);
});
it('should get a single element with non-zero index', function (done) {
var variableName = env.IOS8 ? '' : 'Empty list';
var variableName = env.IOS8 || env.IOS9 ? '' : 'Empty list';
driver.element(byUIA, '.elements()[1]').getAttribute('name')
.should.become(variableName)
.nodeify(done);
Expand Down Expand Up @@ -81,12 +81,12 @@ describe('uicatalog - find by ios-ui-automation @skip-ios6', function () {
driver.element(byUIA, '.elements()[1]').then(function (el) {
el
.elements(byUIA, filterVisible('.elements();'))
.should.eventually.have.length(12)
.should.eventually.have.length(env.IOS9 ? 10 : 12)
.nodeify(done);
});
});
it('should find elements by name', function (done) {
var axIdExt = env.IOS8 ? "" : ", AAPLButtonViewController";
var axIdExt = env.IOS8 || env.IOS9 ? "" : ", AAPLButtonViewController";
driver.element(byUIA, '.elements()[1]').then(function (el) {
el
.element(byUIA, '.elements()["Buttons' + axIdExt + '"]')
Expand Down
2 changes: 1 addition & 1 deletion test/functional/ios/uicatalog/lock-device-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var env = require('../../../helpers/env'),
describe('uicatalog - lock device @skip-ios6', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });
var allowance = (env.IOS7 || env.IOS8) ? 9 : 2;
var allowance = (env.IOS7 || env.IOS8 || env.IOS9) ? 9 : 2;
it("should lock the device for 4 seconds (+/- " + allowance + " secs)", function (done) {
var before = new Date().getTime() / 1000;
driver
Expand Down
2 changes: 1 addition & 1 deletion test/functional/ios/uicatalog/move-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('uicatalog - move @skip-ios6', function () {
setup(this, desired).then(function (d) { driver = d; });

it('should be able to click on arbitrary x-y elements', function (done) {
var axIdExt = env.IOS8 ? "" : ", AAPLButtonViewController";
var axIdExt = env.IOS8 || env.IOS9 ? "" : ", AAPLButtonViewController";
driver
.elementByAccessibilityId("Buttons" + axIdExt).moveTo(10, 10).click()
.elementByXPath("//UIAElement['SYSTEM (CONTACT ADD)']")
Expand Down
16 changes: 15 additions & 1 deletion test/helpers/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ function iphoneOrIpadSimulator(device, version) {
return isIpad ? 'iPad 2' : 'iPhone 6';
case '8.4':
return isIpad ? 'iPad 2' : 'iPhone 6';
case '9.0':
return isIpad ? 'iPad 2' : 'iPhone 6';
default:
throw new Error("invalid version");
}
Expand Down Expand Up @@ -152,6 +154,15 @@ switch (env.DEVICE) {
, app: process.env.APP ? path.resolve(__dirname, "../../sample-code/apps/" + process.env.APP + "/build/Release-iphonesimulator/" + process.env.APP + ".app") : ''
};
break;
case 'ios9':
case 'ios9_iphone':
case 'ios9_ipad':
env.CAPS = {
browserName: ''
, deviceName: iphoneOrIpadSimulator(env.DEVICE, "9.0")
, app: process.env.APP ? path.resolve(__dirname, "../../sample-code/apps/" + process.env.APP + "/build/Release-iphonesimulator/" + process.env.APP + ".app") : ''
};
break;
case 'android':
env.CAPS = {
browserName: ''
Expand Down Expand Up @@ -191,12 +202,13 @@ env.IOS81 = env.DEVICE.match(/ios81/i);
env.IOS82 = env.DEVICE.match(/ios82/i);
env.IOS83 = env.DEVICE.match(/ios83/i);
env.IOS84 = env.DEVICE.match(/ios84/i);
env.IOS9 = env.DEVICE.match(/ios9/i);
env.ANDROID = env.DEVICE.match(/android/i);
env.SELENDROID = env.DEVICE.match(/selendroid/i);

// better timeout settings for 71
env.LAUNCH_TIMEOUT = process.env.LAUNCH_TIMEOUT ? JSON.parse(process.env.LAUNCH_TIMEOUT) :
((env.IOS71 || env.IOS8) ? {"global": 60000, "afterSimLaunch": 10000} : 60000);
((env.IOS71 || env.IOS8 || env.IOS9) ? {"global": 60000, "afterSimLaunch": 10000} : 60000);

env.CAPS.launchTimeout = env.LAUNCH_TIMEOUT;

Expand Down Expand Up @@ -230,6 +242,8 @@ if (env.VERSION) {
env.CAPS.platformVersion = "8.4";
} else if (env.IOS8) {
env.CAPS.platformVersion = "8.0";
} else if (env.IOS9) {
env.CAPS.platformVersion = "9.0";
}

// max retry
Expand Down

0 comments on commit b6cfeec

Please sign in to comment.