-
-
Notifications
You must be signed in to change notification settings - Fork 424
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add increase contrast and content size commands (#2520)
* feat: add content size stuff * add increase contrast and documents * case insensitive was fine * add doc * bump ios simulator * fix lint * Update execute-methods.md * rename command names * return simulator instance * remove redundant lines * reflect review * remove redundant * * address simulator only
- Loading branch information
Showing
9 changed files
with
293 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters