diff --git a/ci-jobs/pr-validation-build.yml b/ci-jobs/pr-validation-build.yml index 70eb67ff7..587f660b7 100644 --- a/ci-jobs/pr-validation-build.yml +++ b/ci-jobs/pr-validation-build.yml @@ -1,11 +1,16 @@ # Pull request validation job +variables: +- name: SHOW_XCODE_LOG + value: true + jobs: - template: ./templates/xcuitest-e2e-template.yml parameters: - name: iPhoneX_13_4 - iosVersion: 13.4 - xcodeVersion: 11.4 + name: iPhoneX_13_7 + iosVersion: 13.7 + xcodeVersion: 11.7 deviceName: "iPhone X" + tvosVersion: 13.4 tvosName: AppleTV_13_4 tvosDeviceName: "Apple TV" vmImage: 'macOS-10.15' diff --git a/ci-jobs/templates/xcuitest-e2e-template.yml b/ci-jobs/templates/xcuitest-e2e-template.yml index 27e7b946e..519b3fe4b 100644 --- a/ci-jobs/templates/xcuitest-e2e-template.yml +++ b/ci-jobs/templates/xcuitest-e2e-template.yml @@ -1,6 +1,7 @@ parameters: name: '' iosVersion: '' + tvosVersion: '' xcodeVersion: '' deviceName: 'iphone simulator' skipTvOs: False @@ -63,7 +64,7 @@ jobs: - template: ./ios-e2e-template.yml parameters: name: e2e_tvos_${{ parameters.tvosName }} - iosVersion: ${{ parameters.iosVersion }} + iosVersion: ${{ parameters.tvosVersion }} skipTvOs: ${{ parameters.skipTvOs }} xcodeVersion: ${{ parameters.xcodeVersion }} deviceName: ${{ parameters.tvosDeviceName }} diff --git a/lib/commands/execute.js b/lib/commands/execute.js index 08c927260..fd1913919 100644 --- a/lib/commands/execute.js +++ b/lib/commands/execute.js @@ -98,6 +98,7 @@ extensions.executeMobile = async function executeMobile (mobileCommand, opts = { getPermission: 'mobileGetPermission', setPermission: 'mobileSetPermissions', + resetPermission: 'mobileResetPermission', getAppearance: 'mobileGetAppearance', setAppearance: 'mobileSetAppearance', diff --git a/lib/commands/permissions.js b/lib/commands/permissions.js index c642f20b5..94decf13e 100644 --- a/lib/commands/permissions.js +++ b/lib/commands/permissions.js @@ -1,7 +1,27 @@ import _ from 'lodash'; -let commands = {}, helpers = {}, extensions = {}; +const commands = {}, helpers = {}, extensions = {}; + +// https://developer.apple.com/documentation/xctest/xcuiprotectedresource?language=objc +const RESOURCE_NAME_TO_ID_MAP = { + calendar: 2, + camera: 6, + contacts: 1, + health: -0x40000003, + homekit: 8, + keyboardnet: -0x40000001, + location: -0x40000002, + medialibrary: 7, + microphone: 5, + photos: 4, + reminders: 3, + systemroot: 0x40000000, + userdesktop: 0x40000001, + userdocuments: 0x40000003, + userdownloads: 0x40000002, + bluetooth: -0x40000000, +}; function requireSimulator (driver) { if (!driver.isSimulator()) { @@ -17,6 +37,46 @@ function requireOptions (opts = {}) { } +/** + * @typedef {Object} ResetPermissionOptions + * + * @property {!string|number} service - One of available service names. See the keys of + * `RESOURCE_NAME_TO_ID_MAP` to get the list of supported service names. + * This could also be an integer protected resource identifier taken from + * https://developer.apple.com/documentation/xctest/xcuiprotectedresource?language=objc + */ + +/** + * Resets the given permission for the active application under test. + * Works for both Simulator and real devices using Xcode SDK 11.4+ + * + * @param {ResetPermissionOptions} opts - Permission options. + * @throws {Error} If permission reset fails on the device. + */ +commands.mobileResetPermission = async function mobileResetPermission (opts = {}) { + const { + service, + } = opts; + if (!service) { + throw new Error(`The 'service' option is expected to be present`); + } + let resource; + if (_.isString(service)) { + resource = RESOURCE_NAME_TO_ID_MAP[_.toLower(service)]; + if (!resource) { + throw new Error(`The 'service' value must be one of ` + + `${JSON.stringify(_.keys(RESOURCE_NAME_TO_ID_MAP))}`); + } + } else if (_.isInteger(service)) { + resource = service; + } else { + throw new Error(`The 'service' value must be either a string or an integer. ` + + `'${service}' is passed instead`); + } + + await this.proxyCommand('/wda/resetAppAuth', 'POST', {resource}); +}; + /** * @typedef {Object} GetPermissionOptions * diff --git a/package.json b/package.json index 4ea9fc85f..b0528ce04 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "appium-ios-simulator": "^3.24.0", "appium-remote-debugger": "^8.13.0", "appium-support": "^2.47.1", - "appium-webdriveragent": "^2.22.0", + "appium-webdriveragent": "^2.22.2", "appium-xcode": "^3.8.0", "async-lock": "^1.0.0", "asyncbox": "^2.3.1",