Skip to content

Commit

Permalink
Merge branch 'master' into feat_push_image_without_permission
Browse files Browse the repository at this point in the history
  • Loading branch information
aluedeke authored Jan 30, 2025
2 parents fb12cfb + 2f96435 commit 7ec7f3a
Show file tree
Hide file tree
Showing 11 changed files with 308 additions and 13 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/functional-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ jobs:
- driver
- web
- long
xcodeVersion: ['14.3.1', '15.4']
xcodeVersion: ['16.2', '15.4']
include:
- xcodeVersion: '14.3.1'
iosVersion: '16.4'
deviceName: 'iPhone 14'
tvosVersion: '16.4'
- xcodeVersion: '16.2'
iosVersion: '18.2'
deviceName: 'iPhone 16'
tvosVersion: '18.2'
tvosDeviceName: 'Apple TV'
platform: macos-13
platform: macos-15
- xcodeVersion: '15.4'
iosVersion: '17.5'
deviceName: 'iPhone 15'
Expand Down Expand Up @@ -70,13 +70,12 @@ jobs:
name: List Runtimes
- name: Prepare iOS simulator
id: prepareSimulator
uses: futureware-tech/simulator-action@v3
uses: futureware-tech/simulator-action@v4
with:
model: "${{ matrix.deviceName }}"
os_version: "${{ matrix.iosVersion }}"
shutdown_after_job: false
- run: xcrun simctl bootstatus ${{ steps.prepareSimulator.outputs.udid }} -b
name: Wait for Simulator to finish booting
wait_for_boot: true

- run: |
npm install --no-save mjpeg-consumer
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [8.2.0](https://github.com/appium/appium-xcuitest-driver/compare/v8.1.0...v8.2.0) (2025-01-29)

### Features

* add increase contrast and content size commands ([#2520](https://github.com/appium/appium-xcuitest-driver/issues/2520)) ([a3fc183](https://github.com/appium/appium-xcuitest-driver/commit/a3fc18322fcded1842acf7ce7d56ad82cb4312ca))

## [8.1.0](https://github.com/appium/appium-xcuitest-driver/compare/v8.0.0...v8.1.0) (2025-01-21)

### Features
Expand Down
74 changes: 74 additions & 0 deletions docs/reference/execute-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,80 @@ Name | Type | Required | Description | Example
--- | --- | --- | --- | ---
style | string | yes | Either `light` or `dark` | dark

### mobile: getIncreaseContrast

Get the device's "increase contrast" accessibility mode.
This API only works on simulators. An exception is thrown if executed with real devices.

#### Returned Result

One of below:

- `enabled`: Increase Contrast is enabled.
- `disabled`: Increase Contrast is disabled.
- `unsupported`: The platform or runtime version does not support the Increase Contrast setting.
- `unknown`: The current setting is unknown or there was an error detecting it.


### mobile: setIncreaseContrast

Enable or disable the device's "increase contrast" accessibility mode.
This API only works on simulators. An exception is thrown if executed with real devices.

#### Arguments

Name | Type | Required | Description | Example
--- | --- | --- | --- | ---
increaseContrast | string | yes | Either `enabled` or `disabled` (case insensitive) | 'enabled'

### mobile: contentSize

Get the device's content size.
This API only works on simulators. An exception is thrown if executed with real devices.

#### Returned Result

One of below:

- `extra-small`
- `small`
- `medium`
- `large`
- `extra-large`
- `extra-extra-large`
- `extra-extra-extra-large`
- `accessibility-medium`
- `accessibility-large`
- `accessibility-extra-large`
- `accessibility-extra-extra-large`
- `accessibility-extra-extra-extra-large`
- `unknown`
- `unsupported`

### mobile: setContentSize

Set the device's content size.
This API only works on simulators. An exception is thrown if executed with real devices.

#### Arguments

Name | Type | Required | Description | Example
--- | --- | --- | --- | ---
size | string | yes | One of the content sizes listed below in case-insensitive. | large

- `extra-small`
- `small`
- `medium`
- `large`
- `extra-large`
- `extra-extra-large`
- `extra-extra-extra-large`
- `accessibility-medium`
- `accessibility-large`
- `accessibility-extra-large`
- `accessibility-extra-extra-large`
- `accessibility-extra-extra-extra-large`

### mobile: getClipboard

Gets the content of the primary clipboard on the device under test.
Expand Down
70 changes: 70 additions & 0 deletions lib/commands/content-size.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import _ from 'lodash';
import {assertSimulator as _assertSimulator} from '../utils';
import { errors } from 'appium/driver';

const assertSimulator = _.partial(_assertSimulator, 'Content size ui command');

const CONTENT_SIZE = [
'extra-small',
'small',
'medium',
'large',
'extra-large',
'extra-extra-large',
'extra-extra-extra-large',
'accessibility-medium',
'accessibility-large',
'accessibility-extra-large',
'accessibility-extra-extra-large',
'accessibility-extra-extra-extra-large',
'increment',
'decrement'
];

export default {
/**
* Sets content size for the given simulator.
*
* @since Xcode 15 (but lower xcode could have this command)
* @param {ContentSizeAction} size - The content size action to set. Acceptable value is
* extra-small, small, medium, large, extra-large, extra-extra-large,
* extra-extra-extra-large, accessibility-medium, accessibility-large,
* accessibility-extra-large, accessibility-extra-extra-large,
* accessibility-extra-extra-extra-large with Xcode 16.2.
* @throws {Error} if the current platform does not support content size appearance changes
* @this {XCUITestDriver}
*/
async mobileSetContentSize(size) {
const simulator = assertSimulator(this);

if (!CONTENT_SIZE.includes(_.lowerCase(size))) {
throw new errors.InvalidArgumentError(
`The 'size' value is expected to be one of ${CONTENT_SIZE.join(',')}`
);
}

await simulator.setContentSize(size);
},

/**
* Retrieves the current content size value from the given simulator.
*
* @since Xcode 15 (but lower xcode could have this command)
* @returns {Promise<ContentSizeResult>} the content size value. Possible return value is
* extra-small, small, medium, large, extra-large, extra-extra-large,
* extra-extra-extra-large, accessibility-medium, accessibility-large,
* accessibility-extra-large, accessibility-extra-extra-large,
* accessibility-extra-extra-extra-large,
* unknown or unsupported with Xcode 16.2.
* @this {XCUITestDriver}
*/
async mobileGetContentSize() {
return /** @type {ContentSizeResult} */ (await assertSimulator(this).getContentSize());
},
};

/**
* @typedef {import('../driver').XCUITestDriver} XCUITestDriver
* @typedef {import('./types').ContentSizeAction} ContentSizeAction
* @typedef {import('./types').ContentSizeResult} ContentSizeResult
*/
52 changes: 52 additions & 0 deletions lib/commands/increase-contrast.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import _ from 'lodash';
import {assertSimulator as _assertSimulator} from '../utils';
import { errors } from 'appium/driver';

const assertSimulator = _.partial(_assertSimulator, 'Content size ui command');

const INCREASE_CONTRAST_CONFIG = [
'enabled',
'disabled',
];

export default {
/**
* Sets the increase contrast configuration for the given simulator.
*
* @since Xcode 15 (but lower xcode could have this command)
* @param {IncreaseContrastAction} increaseContrast valid increase constrast configuration value.
* Acceptable value is 'enabled' or 'disabled' with Xcode 16.2.
* @throws {Error} if the current platform does not support content size appearance changes
* @this {XCUITestDriver}
*/
async mobileSetIncreaseContrast(increaseContrast) {
const simulator = assertSimulator(this);

if (!INCREASE_CONTRAST_CONFIG.includes(_.lowerCase(increaseContrast))) {
throw new errors.InvalidArgumentError(
`The 'increaseContrast' value is expected to be one of ${INCREASE_CONTRAST_CONFIG.join(',')}`
);
}

await simulator.setIncreaseContrast(increaseContrast);
},

/**
* Retrieves the current increase contrast configuration value from the given simulator.
*
* @since Xcode 15 (but lower xcode could have this command)
* @returns {Promise<IncreaseContrastResult>} the contrast configuration value.
* Possible return value is 'enabled', 'disabled',
* 'unsupported' or 'unknown' with Xcode 16.2.
* @this {XCUITestDriver}
*/
async mobileGetIncreaseContrast() {
return /** @type {IncreaseContrastResult} */ (await assertSimulator(this).getIncreaseContrast());
},
};

/**
* @typedef {import('../driver').XCUITestDriver} XCUITestDriver
* @typedef {import('./types').IncreaseContrastAction} IncreaseContrastAction
* @typedef {import('./types').IncreaseContrastResult} IncreaseContrastResult
*/
4 changes: 4 additions & 0 deletions lib/commands/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import biometricExtensions from './biometric';
import certificateExtensions from './certificate';
import clipboardExtensions from './clipboard';
import conditionExtensions from './condition';
import contentSizeExtensions from './content-size';
import contextExtensions from './context';
import deviceInfoExtensions from './deviceInfo';
import elementExtensions from './element';
Expand All @@ -18,6 +19,7 @@ import findExtensions from './find';
import generalExtensions from './general';
import geolocationExtensions from './geolocation';
import gestureExtensions from './gesture';
import increaseContrastExtensions from './increase-contrast';
import iohidExtensions from './iohid';
import keychainsExtensions from './keychains';
import keyboardExtensions from './keyboard';
Expand Down Expand Up @@ -55,6 +57,7 @@ export default {
certificateExtensions,
clipboardExtensions,
conditionExtensions,
contentSizeExtensions,
contextExtensions,
deviceInfoExtensions,
elementExtensions,
Expand All @@ -64,6 +67,7 @@ export default {
generalExtensions,
geolocationExtensions,
gestureExtensions,
increaseContrastExtensions,
iohidExtensions,
keychainsExtensions,
keyboardExtensions,
Expand Down
54 changes: 54 additions & 0 deletions lib/commands/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,60 @@ export type ButtonName = AnyCase<
*/
export type Style = 'dark' | 'light' | 'unsupported' | 'unknown';

/**
* Returned in the {@linkcode XCUITest.mobileGetIncreaseContrast mobile: getIncreaseContrast} command response.
*/
export type IncreaseContrastResult =
| 'enabled'
| 'disabled'
| 'unsupported'
| 'unknown';

/**
* Argument in the {@linkcode XCUITest.mobileSetIncreaseContrast mobile: setIncreaseContrast} command.
*/
export type IncreaseContrastAction =
| 'enabled'
| 'disabled';

/**
* Argument in the {@linkcode XCUITest.mobileSetContentSize mobile: setContentSize} command.
*/
export type ContentSizeAction =
| 'extra-small'
| 'small'
| 'medium'
| 'large'
| 'extra-large'
| 'extra-extra-large'
| 'extra-extra-extra-large'
| 'accessibility-medium'
| 'accessibility-large'
| 'accessibility-extra-large'
| 'accessibility-extra-extra-large'
| 'accessibility-extra-extra-extra-large'
| 'increment'
| 'decrement';

/**
* Returned in the {@linkcode XCUITest.mobileGetContentSize mobile: getContentSize} command response.
*/
export type ContentSizeResult =
| 'extra-small'
| 'small'
| 'medium'
| 'large'
| 'extra-large'
| 'extra-extra-large'
| 'extra-extra-extra-large'
| 'accessibility-medium'
| 'accessibility-large'
| 'accessibility-extra-large'
| 'accessibility-extra-extra-large'
| 'accessibility-extra-extra-extra-large'
| 'unknown'
| 'unsupported';

export interface ScreenInfo {
/**
* Status bar dimensions
Expand Down
14 changes: 14 additions & 0 deletions lib/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -1825,6 +1825,20 @@ export class XCUITestDriver extends BaseDriver {
mobileSetAppearance = commands.appearanceExtensions.mobileSetAppearance;
mobileGetAppearance = commands.appearanceExtensions.mobileGetAppearance;

/*------------+
| INCREASE CONTRAST |
+------------+*/

mobileSetIncreaseContrast = commands.increaseContrastExtensions.mobileSetIncreaseContrast;
mobileGetIncreaseContrast = commands.increaseContrastExtensions.mobileGetIncreaseContrast;

/*------------+
| CONTENT SIZE |
+------------+*/

mobileSetContentSize = commands.contentSizeExtensions.mobileSetContentSize;
mobileGetContentSize = commands.contentSizeExtensions.mobileGetContentSize;

/*------------+
| AUDIT |
+------------+*/
Expand Down
18 changes: 18 additions & 0 deletions lib/execute-method-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,24 @@ export const executeMethodMap = {
required: ['style'],
},
},
'mobile: getIncreaseContrast': {
command: 'mobileGetIncreaseContrast'
},
'mobile: setIncreaseContrast': {
command: 'mobileSetIncreaseContrast',
params: {
required: ['increaseContrast'],
},
},
'mobile: contentSize': {
command: 'mobileGetContentSize'
},
'mobile: setContentSize': {
command: 'mobileSetContentSize',
params: {
required: ['size'],
},
},
'mobile: getClipboard': {
command: 'getClipboard',
params: {
Expand Down
Loading

0 comments on commit 7ec7f3a

Please sign in to comment.