MCPcopy Create free account
hub / github.com/appium/appium / android

Function android

packages/universal-xml-plugin/lib/transformers.ts:23–41  ·  view source on GitHub ↗

* Normalizes Android-specific attributes in source XML. * @param nodeObj Node object to transform. * @param metadata Transformation metadata.

(nodeObj: any, metadata: TransformMetadata)

Source from the content-addressed store, hash-verified

21 * @param metadata Transformation metadata.
22 */
23function android(nodeObj: any, metadata: TransformMetadata): void {
24 // strip android:id from front of id
25 const resId = nodeObj[`${ATTR_PREFIX}resource-id`];
26 if (resId && metadata.appPackage) {
27 nodeObj[`${ATTR_PREFIX}resource-id`] = resId.replace(`${metadata.appPackage}:id/`, '');
28 }
29
30 // turn bounds attr into rect-based attrs
31 if (nodeObj[`${ATTR_PREFIX}bounds`]) {
32 const boundsArray = nodeObj[`${ATTR_PREFIX}bounds`].split(/\[|\]|,/).filter((str: string) => str !== '');
33 const [x, y, x2, y2] = boundsArray;
34 const width = parseInt(x2, 10) - parseInt(x, 10);
35 const height = parseInt(y2, 10) - parseInt(y, 10);
36 nodeObj[`${ATTR_PREFIX}x`] = x;
37 nodeObj[`${ATTR_PREFIX}y`] = y;
38 nodeObj[`${ATTR_PREFIX}width`] = width.toString();
39 nodeObj[`${ATTR_PREFIX}height`] = height.toString();
40 }
41}

Callers

nothing calls this directly

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected