detox
Version:
E2E tests and automation for mobile
416 lines (389 loc) • 14.1 kB
JavaScript
/**
This code is generated.
For more information see generation/README.md.
*/
function sanitize_android_edge(edge) {
switch (edge) {
case 'left':
return 1;
case 'right':
return 2;
case 'top':
return 3;
case 'bottom':
return 4;
default:
throw new Error(`edge must be a 'left'/'right'/'top'/'bottom', got ${edge}`);
}
}
function sanitize_android_direction(direction) {
switch (direction) {
case 'left':
return 1;
case 'right':
return 2;
case 'up':
return 3;
case 'down':
return 4;
default:
throw new Error(`direction must be a 'left'/'right'/'up'/'down', got ${direction}`);
}
}
class DetoxAction {
static multiClick(times) {
if (typeof times !== "number") throw new Error("times should be a number, but got " + (times + (" (" + (typeof times + ")"))));
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "multiClick",
args: [{
type: "Integer",
value: times
}]
};
}
static tapAtLocation(x, y) {
if (typeof x !== "number") throw new Error("x should be a number, but got " + (x + (" (" + (typeof x + ")"))));
if (typeof y !== "number") throw new Error("y should be a number, but got " + (y + (" (" + (typeof y + ")"))));
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "tapAtLocation",
args: [{
type: "Integer",
value: x
}, {
type: "Integer",
value: y
}]
};
}
static createCoordinatesProvider(x, y) {
if (typeof x !== "number") throw new Error("x should be a number, but got " + (x + (" (" + (typeof x + ")"))));
if (typeof y !== "number") throw new Error("y should be a number, but got " + (y + (" (" + (typeof y + ")"))));
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "createCoordinatesProvider",
args: [{
type: "Integer",
value: x
}, {
type: "Integer",
value: y
}]
};
}
static scrollToEdge(edge, startOffsetPercentX, startOffsetPercentY) {
if (typeof edge !== "string") throw new Error("edge should be a string, but got " + (edge + (" (" + (typeof edge + ")"))));
if (typeof startOffsetPercentX !== "number") throw new Error("startOffsetPercentX should be a number, but got " + (startOffsetPercentX + (" (" + (typeof startOffsetPercentX + ")"))));
if (typeof startOffsetPercentY !== "number") throw new Error("startOffsetPercentY should be a number, but got " + (startOffsetPercentY + (" (" + (typeof startOffsetPercentY + ")"))));
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "scrollToEdge",
args: [{
type: "Integer",
value: sanitize_android_edge(edge)
}, {
type: "Double",
value: startOffsetPercentX
}, {
type: "Double",
value: startOffsetPercentY
}]
};
}
static scrollInDirection(direction, amountInDP, startOffsetPercentX, startOffsetPercentY) {
if (typeof direction !== "string") throw new Error("direction should be a string, but got " + (direction + (" (" + (typeof direction + ")"))));
if (typeof amountInDP !== "number") throw new Error("amountInDP should be a number, but got " + (amountInDP + (" (" + (typeof amountInDP + ")"))));
if (typeof startOffsetPercentX !== "number") throw new Error("startOffsetPercentX should be a number, but got " + (startOffsetPercentX + (" (" + (typeof startOffsetPercentX + ")"))));
if (typeof startOffsetPercentY !== "number") throw new Error("startOffsetPercentY should be a number, but got " + (startOffsetPercentY + (" (" + (typeof startOffsetPercentY + ")"))));
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "scrollInDirection",
args: [{
type: "Integer",
value: sanitize_android_direction(direction)
}, {
type: "Double",
value: amountInDP
}, {
type: "Double",
value: startOffsetPercentX
}, {
type: "Double",
value: startOffsetPercentY
}]
};
}
static scrollInDirectionStaleAtEdge(direction, amountInDP, startOffsetPercentX, startOffsetPercentY) {
if (typeof direction !== "string") throw new Error("direction should be a string, but got " + (direction + (" (" + (typeof direction + ")"))));
if (typeof amountInDP !== "number") throw new Error("amountInDP should be a number, but got " + (amountInDP + (" (" + (typeof amountInDP + ")"))));
if (typeof startOffsetPercentX !== "number") throw new Error("startOffsetPercentX should be a number, but got " + (startOffsetPercentX + (" (" + (typeof startOffsetPercentX + ")"))));
if (typeof startOffsetPercentY !== "number") throw new Error("startOffsetPercentY should be a number, but got " + (startOffsetPercentY + (" (" + (typeof startOffsetPercentY + ")"))));
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "scrollInDirectionStaleAtEdge",
args: [{
type: "Integer",
value: sanitize_android_direction(direction)
}, {
type: "Double",
value: amountInDP
}, {
type: "Double",
value: startOffsetPercentX
}, {
type: "Double",
value: startOffsetPercentY
}]
};
}
static swipeInDirection(direction, fast, normalizedOffset, normalizedStartingPointX, normalizedStartingPointY) {
if (typeof direction !== "string") throw new Error("direction should be a string, but got " + (direction + (" (" + (typeof direction + ")"))));
if (typeof fast !== "boolean") throw new Error("fast should be a boolean, but got " + (fast + (" (" + (typeof fast + ")"))));
if (typeof normalizedOffset !== "number") throw new Error("normalizedOffset should be a number, but got " + (normalizedOffset + (" (" + (typeof normalizedOffset + ")"))));
if (typeof normalizedStartingPointX !== "number") throw new Error("normalizedStartingPointX should be a number, but got " + (normalizedStartingPointX + (" (" + (typeof normalizedStartingPointX + ")"))));
if (typeof normalizedStartingPointY !== "number") throw new Error("normalizedStartingPointY should be a number, but got " + (normalizedStartingPointY + (" (" + (typeof normalizedStartingPointY + ")"))));
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "swipeInDirection",
args: [{
type: "Integer",
value: sanitize_android_direction(direction)
}, {
type: "boolean",
value: fast
}, {
type: "Double",
value: normalizedOffset
}, {
type: "Double",
value: normalizedStartingPointX
}, {
type: "Double",
value: normalizedStartingPointY
}]
};
}
static getAttributes() {
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "getAttributes",
args: []
};
}
static scrollToIndex(index) {
if (typeof index !== "number") throw new Error("index should be a number, but got " + (index + (" (" + (typeof index + ")"))));
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "scrollToIndex",
args: [{
type: "Integer",
value: index
}]
};
}
static setDatePickerDate(dateString, formatString) {
if (typeof dateString !== "string") throw new Error("dateString should be a string, but got " + (dateString + (" (" + (typeof dateString + ")"))));
if (typeof formatString !== "string") throw new Error("formatString should be a string, but got " + (formatString + (" (" + (typeof formatString + ")"))));
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "setDatePickerDate",
args: [dateString, formatString]
};
}
static adjustSliderToPosition(newPosition) {
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "adjustSliderToPosition",
args: [{
type: "Float",
value: newPosition
}]
};
}
static longPressAndDrag(duration, normalizedPositionX, normalizedPositionY, targetElement, normalizedTargetPositionX, normalizedTargetPositionY, isFast, holdDuration) {
if (typeof duration !== "number") throw new Error("duration should be a number, but got " + (duration + (" (" + (typeof duration + ")"))));
if (typeof normalizedPositionX !== "number") throw new Error("normalizedPositionX should be a number, but got " + (normalizedPositionX + (" (" + (typeof normalizedPositionX + ")"))));
if (typeof normalizedPositionY !== "number") throw new Error("normalizedPositionY should be a number, but got " + (normalizedPositionY + (" (" + (typeof normalizedPositionY + ")"))));
if (typeof normalizedTargetPositionX !== "number") throw new Error("normalizedTargetPositionX should be a number, but got " + (normalizedTargetPositionX + (" (" + (typeof normalizedTargetPositionX + ")"))));
if (typeof normalizedTargetPositionY !== "number") throw new Error("normalizedTargetPositionY should be a number, but got " + (normalizedTargetPositionY + (" (" + (typeof normalizedTargetPositionY + ")"))));
if (typeof isFast !== "boolean") throw new Error("isFast should be a boolean, but got " + (isFast + (" (" + (typeof isFast + ")"))));
if (typeof holdDuration !== "number") throw new Error("holdDuration should be a number, but got " + (holdDuration + (" (" + (typeof holdDuration + ")"))));
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "longPressAndDrag",
args: [{
type: "Integer",
value: duration
}, {
type: "Double",
value: normalizedPositionX
}, {
type: "Double",
value: normalizedPositionY
}, {
type: "Invocation",
value: targetElement
}, {
type: "Double",
value: normalizedTargetPositionX
}, {
type: "Double",
value: normalizedTargetPositionY
}, {
type: "boolean",
value: isFast
}, {
type: "Integer",
value: holdDuration
}]
};
}
static longPress() {
function longPress0() {
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "longPress",
args: []
};
}
function longPress1(duration) {
if (typeof duration !== "number") throw new Error("duration should be a number, but got " + (duration + (" (" + (typeof duration + ")"))));
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "longPress",
args: [{
type: "Integer",
value: duration
}]
};
}
function longPress2(x, y) {
if (typeof x !== "number") throw new Error("x should be a number, but got " + (x + (" (" + (typeof x + ")"))));
if (typeof y !== "number") throw new Error("y should be a number, but got " + (y + (" (" + (typeof y + ")"))));
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "longPress",
args: [{
type: "Integer",
value: x
}, {
type: "Integer",
value: y
}]
};
}
function longPress3(x, y, duration) {
if (typeof x !== "number") throw new Error("x should be a number, but got " + (x + (" (" + (typeof x + ")"))));
if (typeof y !== "number") throw new Error("y should be a number, but got " + (y + (" (" + (typeof y + ")"))));
if (typeof duration !== "number") throw new Error("duration should be a number, but got " + (duration + (" (" + (typeof duration + ")"))));
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "longPress",
args: [{
type: "Integer",
value: x
}, {
type: "Integer",
value: y
}, {
type: "Integer",
value: duration
}]
};
}
if (arguments.length === 0) {
return longPress0.apply(null, arguments);
}
if (arguments.length === 1) {
return longPress1.apply(null, arguments);
}
if (arguments.length === 2) {
return longPress2.apply(null, arguments);
}
if (arguments.length === 3) {
return longPress3.apply(null, arguments);
}
}
static takeViewScreenshot() {
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "takeViewScreenshot",
args: []
};
}
static accessibilityAction(actionName) {
if (typeof actionName !== "string") throw new Error("actionName should be a string, but got " + (actionName + (" (" + (typeof actionName + ")"))));
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "accessibilityAction",
args: [actionName]
};
}
static parseDateISO8601(dateString) {
if (typeof dateString !== "string") throw new Error("dateString should be a string, but got " + (dateString + (" (" + (typeof dateString + ")"))));
return {
target: {
type: "Class",
value: "com.wix.detox.espresso.DetoxAction"
},
method: "parseDateISO8601",
args: [dateString]
};
}
}
module.exports = DetoxAction;