Move generation to babel 7 (#762)

* update babel to version 7

This enables us to generate better comments

* use new addComment function of babel to generate nicer comments

* improve tightly coupled test
This commit is contained in:
Daniel Schmidt
2018-10-13 21:44:09 +03:00
committed by Rotem Mizrachi-Meidan
parent 3bfce91803
commit 38f6932da1
13 changed files with 545 additions and 536 deletions
+35 -35
View File
@@ -15,14 +15,14 @@ function sanitize_uiDeviceOrientation(value) {
}
class EarlGreyImpl {
/*Provides the file name and line number of the code that is calling into EarlGrey.
In case of a failure, the information is used to tell XCTest the exact line which caused
the failure so it can be highlighted in the IDE.
@param fileName The name of the file where the failing code exists.
@param lineNumber The line number of the failing code.
@return An EarlGreyImpl instance, with details of the code invoking EarlGrey.
*/static invokedFromFileLineNumber(fileName, lineNumber) {
In case of a failure, the information is used to tell XCTest the exact line which caused
the failure so it can be highlighted in the IDE.
@param fileName The name of the file where the failing code exists.
@param lineNumber The line number of the failing code.
@return An EarlGreyImpl instance, with details of the code invoking EarlGrey.*/
static invokedFromFileLineNumber(fileName, lineNumber) {
if (typeof fileName !== "string") throw new Error("fileName should be a string, but got " + (fileName + (" (" + (typeof fileName + ")"))));
if (typeof lineNumber !== "number") throw new Error("lineNumber should be a number, but got " + (lineNumber + (" (" + (typeof lineNumber + ")"))));
return {
@@ -42,16 +42,16 @@ the failure so it can be highlighted in the IDE.
}
/*Rotate the device to a given @c deviceOrientation. All device orientations except for
@c UIDeviceOrientationUnknown are supported. If a non-nil @c errorOrNil is provided, it will
be populated with the failure reason if the orientation change fails, otherwise a test failure
will be registered.
@param deviceOrientation The desired orientation of the device.
@param[out] errorOrNil Error that will be populated on failure. If @c nil, a test
failure will be reported if the rotation attempt fails.
@return @c YES if the rotation was successful, @c NO otherwise.
*/static rotateDeviceToOrientationErrorOrNil(element, deviceOrientation) {
@c UIDeviceOrientationUnknown are supported. If a non-nil @c errorOrNil is provided, it will
be populated with the failure reason if the orientation change fails, otherwise a test failure
will be registered.
@param deviceOrientation The desired orientation of the device.
@param[out] errorOrNil Error that will be populated on failure. If @c nil, a test
failure will be reported if the rotation attempt fails.
@return @c YES if the rotation was successful, @c NO otherwise.*/
static rotateDeviceToOrientationErrorOrNil(element, deviceOrientation) {
if (!["landscape", "portrait"].some(option => option === deviceOrientation)) throw new Error("deviceOrientation should be one of [landscape, portrait], but got " + deviceOrientation);
return {
target: element,
@@ -64,16 +64,16 @@ failure will be reported if the rotation attempt fails.
}
/*Shakes the device. If a non-nil @c errorOrNil is provided, it will
be populated with the failure reason if the orientation change fails, otherwise a test failure
will be registered.
@param[out] errorOrNil Error that will be populated on failure. If @c nil, the a test
failure will be reported if the shake attempt fails.
@throws GREYFrameworkException if the action fails and @c errorOrNil is @c nil.
@return @c YES if the shake was successful, @c NO otherwise. If @c errorOrNil is @c nil and
the operation fails, it will throw an exception.
*/static shakeDeviceWithError(element) {
be populated with the failure reason if the orientation change fails, otherwise a test failure
will be registered.
@param[out] errorOrNil Error that will be populated on failure. If @c nil, the a test
failure will be reported if the shake attempt fails.
@throws GREYFrameworkException if the action fails and @c errorOrNil is @c nil.
@return @c YES if the shake was successful, @c NO otherwise. If @c errorOrNil is @c nil and
the operation fails, it will throw an exception.*/
static shakeDeviceWithError(element) {
return {
target: element,
method: "shakeDeviceWithError:",
@@ -82,13 +82,13 @@ the operation fails, it will throw an exception.
}
/*Dismisses the keyboard by resigning the first responder, if any. Will populate the provided
error if the first responder is not present or if the keyboard is not visible.
@param[out] errorOrNil Error that will be populated on failure. If @c nil, a test
failure will be reported if the dismissing fails.
@return @c YES if the dismissing of the keyboard was successful, @c NO otherwise.
*/static dismissKeyboardWithError(element) {
error if the first responder is not present or if the keyboard is not visible.
@param[out] errorOrNil Error that will be populated on failure. If @c nil, a test
failure will be reported if the dismissing fails.
@return @c YES if the dismissing of the keyboard was successful, @c NO otherwise.*/
static dismissKeyboardWithError(element) {
return {
target: element,
method: "dismissKeyboardWithError:",
+157 -157
View File
@@ -36,8 +36,8 @@ function sanitize_greyContentEdge(action) {
}
}
class GREYActions {
/*@return A GREYAction that performs multiple taps of a specified @c count.
*/static actionForMultipleTapsWithCount(count) {
/*@return A GREYAction that performs multiple taps of a specified @c count.*/
static actionForMultipleTapsWithCount(count) {
if (typeof count !== "number") throw new Error("count should be a number, but got " + (count + (" (" + (typeof count + ")"))));
return {
target: {
@@ -53,8 +53,8 @@ class GREYActions {
}
/*@return A GREYAction that performs multiple taps of a specified @c count at a specified
@c point.
*/static actionForMultipleTapsWithCountAtPoint(count, point) {
@c point.*/
static actionForMultipleTapsWithCountAtPoint(count, point) {
if (typeof count !== "number") throw new Error("count should be a number, but got " + (count + (" (" + (typeof count + ")"))));
if (typeof point !== "object") throw new Error("point should be a object, but got " + (point + (" (" + (typeof point + ")"))));
if (typeof point.x !== "number") throw new Error("point.x should be a number, but got " + (point.x + (" (" + (typeof point.x + ")"))));
@@ -76,10 +76,10 @@ class GREYActions {
}
/*Returns an action that holds down finger for 1.0 second (@c kGREYLongPressDefaultDuration) to
simulate a long press.
@return A GREYAction that performs a long press on an element.
*/static actionForLongPress() {
simulate a long press.
@return A GREYAction that performs a long press on an element.*/
static actionForLongPress() {
return {
target: {
type: "Class",
@@ -91,11 +91,11 @@ simulate a long press.
}
/*Returns an action that holds down finger for specified @c duration to simulate a long press.
@param duration The duration of the long press.
@return A GREYAction that performs a long press on an element.
*/static actionForLongPressWithDuration(duration) {
@param duration The duration of the long press.
@return A GREYAction that performs a long press on an element.*/
static actionForLongPressWithDuration(duration) {
if (typeof duration !== "number") throw new Error("duration should be a number, but got " + (duration + (" (" + (typeof duration + ")"))));
return {
target: {
@@ -111,13 +111,13 @@ simulate a long press.
}
/*Returns an action that holds down finger for specified @c duration at the specified @c point
(interpreted as being relative to the element) to simulate a long press.
@param point The point that should be tapped.
@param duration The duration of the long press.
@return A GREYAction that performs a long press on an element.
*/static actionForLongPressAtPointDuration(point, duration) {
(interpreted as being relative to the element) to simulate a long press.
@param point The point that should be tapped.
@param duration The duration of the long press.
@return A GREYAction that performs a long press on an element.*/
static actionForLongPressAtPointDuration(point, duration) {
if (typeof point !== "object") throw new Error("point should be a object, but got " + (point + (" (" + (typeof point + ")"))));
if (typeof point.x !== "number") throw new Error("point.x should be a number, but got " + (point.x + (" (" + (typeof point.x + ")"))));
if (typeof point.y !== "number") throw new Error("point.y should be a number, but got " + (point.y + (" (" + (typeof point.y + ")"))));
@@ -139,13 +139,13 @@ simulate a long press.
}
/*Returns an action that scrolls a @c UIScrollView by @c amount (in points) in the specified
@c direction.
@param direction The direction of the swipe.
@param amount The amount of points in CGPoints to scroll.
@return A GREYAction that scrolls a scroll view in a given @c direction for a given @c amount.
*/static actionForScrollInDirectionAmount(direction, amount) {
@c direction.
@param direction The direction of the swipe.
@param amount The amount of points in CGPoints to scroll.
@return A GREYAction that scrolls a scroll view in a given @c direction for a given @c amount.*/
static actionForScrollInDirectionAmount(direction, amount) {
if (!["left", "right", "up", "down"].some(option => option === direction)) throw new Error("direction should be one of [left, right, up, down], but got " + direction);
if (typeof amount !== "number") throw new Error("amount should be a number, but got " + (amount + (" (" + (typeof amount + ")"))));
return {
@@ -165,22 +165,22 @@ simulate a long press.
}
/*Returns a scroll action that scrolls in a @c direction for an @c amount of points starting from
the given start point specified as percentages. @c xOriginStartPercentage is the x start
position as a percentage of the total width of the scrollable visible area,
@c yOriginStartPercentage is the y start position as a percentage of the total height of the
scrollable visible area. @c xOriginStartPercentage and @c yOriginStartPercentage must be between
0 and 1, exclusive.
@param direction The direction of the scroll.
@param amount The amount scroll in points to inject.
@param xOriginStartPercentage X coordinate of the start point specified as a percentage (0, 1)
exclusive, of the total width of the scrollable visible area.
@param yOriginStartPercentage Y coordinate of the start point specified as a percentage (0, 1)
exclusive, of the total height of the scrollable visible area.
@return A GREYAction that scrolls a scroll view in a given @c direction for a given @c amount
starting from the given start points.
*/static actionForScrollInDirectionAmountXOriginStartPercentageYOriginStartPercentage(direction, amount, xOriginStartPercentage, yOriginStartPercentage) {
the given start point specified as percentages. @c xOriginStartPercentage is the x start
position as a percentage of the total width of the scrollable visible area,
@c yOriginStartPercentage is the y start position as a percentage of the total height of the
scrollable visible area. @c xOriginStartPercentage and @c yOriginStartPercentage must be between
0 and 1, exclusive.
@param direction The direction of the scroll.
@param amount The amount scroll in points to inject.
@param xOriginStartPercentage X coordinate of the start point specified as a percentage (0, 1)
exclusive, of the total width of the scrollable visible area.
@param yOriginStartPercentage Y coordinate of the start point specified as a percentage (0, 1)
exclusive, of the total height of the scrollable visible area.
@return A GREYAction that scrolls a scroll view in a given @c direction for a given @c amount
starting from the given start points.*/
static actionForScrollInDirectionAmountXOriginStartPercentageYOriginStartPercentage(direction, amount, xOriginStartPercentage, yOriginStartPercentage) {
if (!["left", "right", "up", "down"].some(option => option === direction)) throw new Error("direction should be one of [left, right, up, down], but got " + direction);
if (typeof amount !== "number") throw new Error("amount should be a number, but got " + (amount + (" (" + (typeof amount + ")"))));
if (typeof xOriginStartPercentage !== "number") throw new Error("xOriginStartPercentage should be a number, but got " + (xOriginStartPercentage + (" (" + (typeof xOriginStartPercentage + ")"))));
@@ -207,8 +207,8 @@ starting from the given start points.
};
}
/*@return A GREYAction that scrolls to the given content @c edge of a scroll view.
*/static actionForScrollToContentEdge(edge) {
/*@return A GREYAction that scrolls to the given content @c edge of a scroll view.*/
static actionForScrollToContentEdge(edge) {
if (!["left", "right", "top", "bottom"].some(option => option === edge)) throw new Error("edge should be one of [left, right, top, bottom], but got " + edge);
return {
target: {
@@ -224,21 +224,21 @@ starting from the given start points.
}
/*A GREYAction that scrolls to the given content @c edge of a scroll view with the scroll action
starting from the given start point specified as percentages. @c xOriginStartPercentage is the x
start position as a percentage of the total width of the scrollable visible area,
@c yOriginStartPercentage is the y start position as a percentage of the total height of the
scrollable visible area. @c xOriginStartPercentage and @c yOriginStartPercentage must be between
0 and 1, exclusive.
@param edge The edge towards which the scrolling is to take place.
@param xOriginStartPercentage X coordinate of the start point specified as a percentage (0, 1)
exclusive, of the total width of the scrollable visible area.
@param yOriginStartPercentage Y coordinate of the start point specified as a percentage (0, 1)
exclusive, of the total height of the scrollable visible area.
@return A GREYAction that scrolls to the given content @c edge of a scroll view with the scroll
action starting from the given start point.
*/static actionForScrollToContentEdgeXOriginStartPercentageYOriginStartPercentage(edge, xOriginStartPercentage, yOriginStartPercentage) {
starting from the given start point specified as percentages. @c xOriginStartPercentage is the x
start position as a percentage of the total width of the scrollable visible area,
@c yOriginStartPercentage is the y start position as a percentage of the total height of the
scrollable visible area. @c xOriginStartPercentage and @c yOriginStartPercentage must be between
0 and 1, exclusive.
@param edge The edge towards which the scrolling is to take place.
@param xOriginStartPercentage X coordinate of the start point specified as a percentage (0, 1)
exclusive, of the total width of the scrollable visible area.
@param yOriginStartPercentage Y coordinate of the start point specified as a percentage (0, 1)
exclusive, of the total height of the scrollable visible area.
@return A GREYAction that scrolls to the given content @c edge of a scroll view with the scroll
action starting from the given start point.*/
static actionForScrollToContentEdgeXOriginStartPercentageYOriginStartPercentage(edge, xOriginStartPercentage, yOriginStartPercentage) {
if (!["left", "right", "top", "bottom"].some(option => option === edge)) throw new Error("edge should be one of [left, right, top, bottom], but got " + edge);
if (typeof xOriginStartPercentage !== "number") throw new Error("xOriginStartPercentage should be a number, but got " + (xOriginStartPercentage + (" (" + (typeof xOriginStartPercentage + ")"))));
if (typeof yOriginStartPercentage !== "number") throw new Error("yOriginStartPercentage should be a number, but got " + (yOriginStartPercentage + (" (" + (typeof yOriginStartPercentage + ")"))));
@@ -262,12 +262,12 @@ action starting from the given start point.
}
/*Returns an action that fast swipes through the view. The start point of the swipe is chosen to
achieve the maximum the swipe possible to the other edge.
@param direction The direction of the swipe.
@return A GREYAction that performs a fast swipe in the given direction.
*/static actionForSwipeFastInDirection(direction) {
achieve the maximum the swipe possible to the other edge.
@param direction The direction of the swipe.
@return A GREYAction that performs a fast swipe in the given direction.*/
static actionForSwipeFastInDirection(direction) {
if (!["left", "right", "up", "down"].some(option => option === direction)) throw new Error("direction should be one of [left, right, up, down], but got " + direction);
return {
target: {
@@ -283,12 +283,12 @@ achieve the maximum the swipe possible to the other edge.
}
/*Returns an action that slow swipes through the view. The start point of the swipe is chosen to
achieve maximum the swipe possible to the other edge.
@param direction The direction of the swipe.
@return A GREYAction that performs a slow swipe in the given direction.
*/static actionForSwipeSlowInDirection(direction) {
achieve maximum the swipe possible to the other edge.
@param direction The direction of the swipe.
@return A GREYAction that performs a slow swipe in the given direction.*/
static actionForSwipeSlowInDirection(direction) {
if (!["left", "right", "up", "down"].some(option => option === direction)) throw new Error("direction should be one of [left, right, up, down], but got " + direction);
return {
target: {
@@ -304,17 +304,17 @@ achieve maximum the swipe possible to the other edge.
}
/*Returns an action that swipes through the view quickly in the given @c direction from a specific
origin.
@param direction The direction of the swipe.
@param xOriginStartPercentage the x start position as a percentage of the total width
of the view. This must be between 0 and 1.
@param yOriginStartPercentage the y start position as a percentage of the total height
of the view. This must be between 0 and 1.
@return A GREYAction that performs a fast swipe through a view in a specific direction from
the specified point.
*/static actionForSwipeFastInDirectionXOriginStartPercentageYOriginStartPercentage(direction, xOriginStartPercentage, yOriginStartPercentage) {
origin.
@param direction The direction of the swipe.
@param xOriginStartPercentage the x start position as a percentage of the total width
of the view. This must be between 0 and 1.
@param yOriginStartPercentage the y start position as a percentage of the total height
of the view. This must be between 0 and 1.
@return A GREYAction that performs a fast swipe through a view in a specific direction from
the specified point.*/
static actionForSwipeFastInDirectionXOriginStartPercentageYOriginStartPercentage(direction, xOriginStartPercentage, yOriginStartPercentage) {
if (!["left", "right", "up", "down"].some(option => option === direction)) throw new Error("direction should be one of [left, right, up, down], but got " + direction);
if (typeof xOriginStartPercentage !== "number") throw new Error("xOriginStartPercentage should be a number, but got " + (xOriginStartPercentage + (" (" + (typeof xOriginStartPercentage + ")"))));
if (typeof yOriginStartPercentage !== "number") throw new Error("yOriginStartPercentage should be a number, but got " + (yOriginStartPercentage + (" (" + (typeof yOriginStartPercentage + ")"))));
@@ -338,17 +338,17 @@ the specified point.
}
/*Returns an action that swipes through the view quickly in the given @c direction from a
specific origin.
@param direction The direction of the swipe.
@param xOriginStartPercentage the x start position as a percentage of the total width
of the view. This must be between 0 and 1.
@param yOriginStartPercentage the y start position as a percentage of the total height
of the view. This must be between 0 and 1.
@return A GREYAction that performs a slow swipe through a view in a specific direction from
the specified point.
*/static actionForSwipeSlowInDirectionXOriginStartPercentageYOriginStartPercentage(direction, xOriginStartPercentage, yOriginStartPercentage) {
specific origin.
@param direction The direction of the swipe.
@param xOriginStartPercentage the x start position as a percentage of the total width
of the view. This must be between 0 and 1.
@param yOriginStartPercentage the y start position as a percentage of the total height
of the view. This must be between 0 and 1.
@return A GREYAction that performs a slow swipe through a view in a specific direction from
the specified point.*/
static actionForSwipeSlowInDirectionXOriginStartPercentageYOriginStartPercentage(direction, xOriginStartPercentage, yOriginStartPercentage) {
if (!["left", "right", "up", "down"].some(option => option === direction)) throw new Error("direction should be one of [left, right, up, down], but got " + direction);
if (typeof xOriginStartPercentage !== "number") throw new Error("xOriginStartPercentage should be a number, but got " + (xOriginStartPercentage + (" (" + (typeof xOriginStartPercentage + ")"))));
if (typeof yOriginStartPercentage !== "number") throw new Error("yOriginStartPercentage should be a number, but got " + (yOriginStartPercentage + (" (" + (typeof yOriginStartPercentage + ")"))));
@@ -372,14 +372,14 @@ the specified point.
}
/*Returns an action that performs a multi-finger slow swipe through the view in the given
@c direction.
@param direction The direction of the swipe.
@param numberOfFingers Number of fingers touching the screen for the swipe.
@return A GREYAction that performs a multi-finger slow swipe through a view in a specific
direction from the specified point.
*/static actionForMultiFingerSwipeSlowInDirectionNumberOfFingers(direction, numberOfFingers) {
@c direction.
@param direction The direction of the swipe.
@param numberOfFingers Number of fingers touching the screen for the swipe.
@return A GREYAction that performs a multi-finger slow swipe through a view in a specific
direction from the specified point.*/
static actionForMultiFingerSwipeSlowInDirectionNumberOfFingers(direction, numberOfFingers) {
if (!["left", "right", "up", "down"].some(option => option === direction)) throw new Error("direction should be one of [left, right, up, down], but got " + direction);
if (typeof numberOfFingers !== "number") throw new Error("numberOfFingers should be a number, but got " + (numberOfFingers + (" (" + (typeof numberOfFingers + ")"))));
return {
@@ -399,14 +399,14 @@ direction from the specified point.
}
/*Returns an action that performs a multi-finger fast swipe through the view in the given
@c direction.
@param direction The direction of the swipe.
@param numberOfFingers Number of fingers touching the screen for the swipe.
@return A GREYAction that performs a multi-finger fast swipe through a view in a specific
direction from the specified point.
*/static actionForMultiFingerSwipeFastInDirectionNumberOfFingers(direction, numberOfFingers) {
@c direction.
@param direction The direction of the swipe.
@param numberOfFingers Number of fingers touching the screen for the swipe.
@return A GREYAction that performs a multi-finger fast swipe through a view in a specific
direction from the specified point.*/
static actionForMultiFingerSwipeFastInDirectionNumberOfFingers(direction, numberOfFingers) {
if (!["left", "right", "up", "down"].some(option => option === direction)) throw new Error("direction should be one of [left, right, up, down], but got " + direction);
if (typeof numberOfFingers !== "number") throw new Error("numberOfFingers should be a number, but got " + (numberOfFingers + (" (" + (typeof numberOfFingers + ")"))));
return {
@@ -426,14 +426,14 @@ direction from the specified point.
}
/*Returns an action that performs a multi-finger slow swipe through the view in the given
@c direction.
@param direction The direction of the swipe.
@param numberOfFingers Number of fingers touching the screen for the swipe.
@return A GREYAction that performs a multi-finger slow swipe through a view in a specific
direction from the specified point.
*/static actionForMultiFingerSwipeSlowInDirectionNumberOfFingersXOriginStartPercentageYOriginStartPercentage(direction, numberOfFingers, xOriginStartPercentage, yOriginStartPercentage) {
@c direction.
@param direction The direction of the swipe.
@param numberOfFingers Number of fingers touching the screen for the swipe.
@return A GREYAction that performs a multi-finger slow swipe through a view in a specific
direction from the specified point.*/
static actionForMultiFingerSwipeSlowInDirectionNumberOfFingersXOriginStartPercentageYOriginStartPercentage(direction, numberOfFingers, xOriginStartPercentage, yOriginStartPercentage) {
if (!["left", "right", "up", "down"].some(option => option === direction)) throw new Error("direction should be one of [left, right, up, down], but got " + direction);
if (typeof numberOfFingers !== "number") throw new Error("numberOfFingers should be a number, but got " + (numberOfFingers + (" (" + (typeof numberOfFingers + ")"))));
if (typeof xOriginStartPercentage !== "number") throw new Error("xOriginStartPercentage should be a number, but got " + (xOriginStartPercentage + (" (" + (typeof xOriginStartPercentage + ")"))));
@@ -461,14 +461,14 @@ direction from the specified point.
}
/*Returns an action that performs a multi-finger fast swipe through the view in the given
@c direction.
@param direction The direction of the swipe.
@param numberOfFingers Number of fingers touching the screen for the swipe.
@return A GREYAction that performs a multi-finger fast swipe through a view in a specific
direction from the specified point.
*/static actionForMultiFingerSwipeFastInDirectionNumberOfFingersXOriginStartPercentageYOriginStartPercentage(direction, numberOfFingers, xOriginStartPercentage, yOriginStartPercentage) {
@c direction.
@param direction The direction of the swipe.
@param numberOfFingers Number of fingers touching the screen for the swipe.
@return A GREYAction that performs a multi-finger fast swipe through a view in a specific
direction from the specified point.*/
static actionForMultiFingerSwipeFastInDirectionNumberOfFingersXOriginStartPercentageYOriginStartPercentage(direction, numberOfFingers, xOriginStartPercentage, yOriginStartPercentage) {
if (!["left", "right", "up", "down"].some(option => option === direction)) throw new Error("direction should be one of [left, right, up, down], but got " + direction);
if (typeof numberOfFingers !== "number") throw new Error("numberOfFingers should be a number, but got " + (numberOfFingers + (" (" + (typeof numberOfFingers + ")"))));
if (typeof xOriginStartPercentage !== "number") throw new Error("xOriginStartPercentage should be a number, but got " + (xOriginStartPercentage + (" (" + (typeof xOriginStartPercentage + ")"))));
@@ -496,9 +496,9 @@ direction from the specified point.
}
/*Returns an action that taps on an element at the activation point of the element.
@return A GREYAction to tap on an element.
*/static actionForTap() {
@return A GREYAction to tap on an element.*/
static actionForTap() {
return {
target: {
type: "Class",
@@ -510,13 +510,13 @@ direction from the specified point.
}
/*Returns an action that taps on an element at the specified @c point.
@param point The point that should be tapped. It must be in the coordinate system of the
element and it's position is relative to the origin of the element, as in
(element_width/2, element_height/2) will tap at the center of element.
@return A GREYAction to tap on an element at a specific point.
*/static actionForTapAtPoint(point) {
@param point The point that should be tapped. It must be in the coordinate system of the
element and it's position is relative to the origin of the element, as in
(element_width/2, element_height/2) will tap at the center of element.
@return A GREYAction to tap on an element at a specific point.*/
static actionForTapAtPoint(point) {
if (typeof point !== "object") throw new Error("point should be a object, but got " + (point + (" (" + (typeof point + ")"))));
if (typeof point.x !== "number") throw new Error("point.x should be a number, but got " + (point.x + (" (" + (typeof point.x + ")"))));
if (typeof point.y !== "number") throw new Error("point.y should be a number, but got " + (point.y + (" (" + (typeof point.y + ")"))));
@@ -534,14 +534,14 @@ element and it's position is relative to the origin of the element, as in
}
/*Returns an action that uses the iOS keyboard to input a string.
@param text The text to be typed. For Objective-C, backspace is supported by using "\b" in the
string and "\u{8}" in Swift strings. Return key is supported with "\n".
For Example: @"Helpo\b\bloWorld" will type HelloWorld in Objective-C.
"Helpo\u{8}\u{8}loWorld" will type HelloWorld in Swift.
@return A GREYAction to type a specific text string in a text field.
*/static actionForTypeText(text) {
@param text The text to be typed. For Objective-C, backspace is supported by using "\b" in the
string and "\u{8}" in Swift strings. Return key is supported with "\n".
For Example: @"Helpo\b\bloWorld" will type HelloWorld in Objective-C.
"Helpo\u{8}\u{8}loWorld" will type HelloWorld in Swift.
@return A GREYAction to type a specific text string in a text field.*/
static actionForTypeText(text) {
if (typeof text !== "string") throw new Error("text should be a string, but got " + (text + (" (" + (typeof text + ")"))));
return {
target: {
@@ -557,11 +557,11 @@ For Example: @"Helpo\b\bloWorld" will type HelloWorld in Objective-C.
}
/*Returns an action that sets text on a UITextField or webview input directly.
@param text The text to be typed.
@return A GREYAction to type a specific text string in a text field.
*/static actionForReplaceText(text) {
@param text The text to be typed.
@return A GREYAction to type a specific text string in a text field.*/
static actionForReplaceText(text) {
if (typeof text !== "string") throw new Error("text should be a string, but got " + (text + (" (" + (typeof text + ")"))));
return {
target: {
@@ -576,8 +576,8 @@ For Example: @"Helpo\b\bloWorld" will type HelloWorld in Objective-C.
};
}
/*@return A GREYAction that clears a text field by injecting back-spaces.
*/static actionForClearText() {
/*@return A GREYAction that clears a text field by injecting back-spaces.*/
static actionForClearText() {
return {
target: {
type: "Class",
@@ -589,12 +589,12 @@ For Example: @"Helpo\b\bloWorld" will type HelloWorld in Objective-C.
}
/*Returns an action that selects @c value on the given @c column of a UIPickerView.
@param column The UIPickerView column being set.
@param value The value to set the UIPickerView.
@return A GREYAction to set the value of a specified column of a UIPickerView.
*/static actionForSetPickerColumnToValue(column, value) {
@param column The UIPickerView column being set.
@param value The value to set the UIPickerView.
@return A GREYAction to set the value of a specified column of a UIPickerView.*/
static actionForSetPickerColumnToValue(column, value) {
if (typeof column !== "number") throw new Error("column should be a number, but got " + (column + (" (" + (typeof column + ")"))));
if (typeof value !== "string") throw new Error("value should be a string, but got " + (value + (" (" + (typeof value + ")"))));
return {
+22 -22
View File
@@ -8,18 +8,18 @@
class GREYCondition {
/*Waits for the condition to be met until the specified @c seconds have elapsed.
Will poll the condition as often as possible on the main thread while still giving a fair chance
for other sources and handlers to be serviced.
@remark Waiting on conditions with this method is very CPU intensive on the main thread. If
you do not need to return immediately after the condition is met, the consider using
GREYCondition::waitWithTimeout:pollInterval:
@param seconds Amount of time to wait for the condition to be met, in seconds.
@return @c YES if the condition was met before the timeout, @c NO otherwise.
*/static waitWithTimeout(element, seconds) {
Will poll the condition as often as possible on the main thread while still giving a fair chance
for other sources and handlers to be serviced.
@remark Waiting on conditions with this method is very CPU intensive on the main thread. If
you do not need to return immediately after the condition is met, the consider using
GREYCondition::waitWithTimeout:pollInterval:
@param seconds Amount of time to wait for the condition to be met, in seconds.
@return @c YES if the condition was met before the timeout, @c NO otherwise.*/
static waitWithTimeout(element, seconds) {
if (typeof seconds !== "number") throw new Error("seconds should be a number, but got " + (seconds + (" (" + (typeof seconds + ")"))));
return {
target: element,
@@ -32,16 +32,16 @@ GREYCondition::waitWithTimeout:pollInterval:
}
/*Waits for the condition to be met until the specified @c seconds have elapsed. Will poll the
condition immediately and then no more than once every @c interval seconds. Will attempt to poll
the condition as close as possible to every @c interval seconds.
@remark Will allow the main thread to sleep instead of busily checking the condition.
@param seconds Amount of time to wait for the condition to be met, in seconds.
@param interval The minimum time that should elapse between checking the condition.
@return @c YES if the condition was met before the timeout, @c NO otherwise.
*/static waitWithTimeoutPollInterval(element, seconds, interval) {
condition immediately and then no more than once every @c interval seconds. Will attempt to poll
the condition as close as possible to every @c interval seconds.
@remark Will allow the main thread to sleep instead of busily checking the condition.
@param seconds Amount of time to wait for the condition to be met, in seconds.
@param interval The minimum time that should elapse between checking the condition.
@return @c YES if the condition was met before the timeout, @c NO otherwise.*/
static waitWithTimeoutPollInterval(element, seconds, interval) {
if (typeof seconds !== "number") throw new Error("seconds should be a number, but got " + (seconds + (" (" + (typeof seconds + ")"))));
if (typeof interval !== "number") throw new Error("interval should be a number, but got " + (interval + (" (" + (typeof interval + ")"))));
return {
+56 -56
View File
@@ -7,8 +7,8 @@
class GREYConfiguration {
/*@return The singleton GREYConfiguration instance.
*/static sharedInstance() {
/*@return The singleton GREYConfiguration instance.*/
static sharedInstance() {
return {
target: {
type: "Class",
@@ -20,15 +20,15 @@ class GREYConfiguration {
}
/*If a user-configured value is associated with the given @c configKey, it is returned,
otherwise the default value is returned. If a default value is not found, or an
NSInvalidArgumentException is raised.
@param configKey The key whose value is being queried. Must be a valid @c NSString.
@throws NSInvalidArgumentException If no value could be found associated with @c configKey.
@return The value for the configuration stored associate with @c configKey.
*/static valueForConfigKey(element, configKey) {
otherwise the default value is returned. If a default value is not found, or an
NSInvalidArgumentException is raised.
@param configKey The key whose value is being queried. Must be a valid @c NSString.
@throws NSInvalidArgumentException If no value could be found associated with @c configKey.
@return The value for the configuration stored associate with @c configKey.*/
static valueForConfigKey(element, configKey) {
if (typeof configKey !== "string") throw new Error("configKey should be a string, but got " + (configKey + (" (" + (typeof configKey + ")"))));
return {
target: element,
@@ -41,15 +41,15 @@ NSInvalidArgumentException is raised.
}
/*If a user-configured value is associated with the given @c configKey, it is returned, otherwise
the default value is returned. If a default value is not found, NSInvalidArgumentException is
raised.
@param configKey The key whose value is being queried. Must be a valid @c NSString.
@throws NSInvalidArgumentException If no value could be found for the given @c configKey.
@return The @c BOOL value for the configuration associated with @c configKey.
*/static boolValueForConfigKey(element, configKey) {
the default value is returned. If a default value is not found, NSInvalidArgumentException is
raised.
@param configKey The key whose value is being queried. Must be a valid @c NSString.
@throws NSInvalidArgumentException If no value could be found for the given @c configKey.
@return The @c BOOL value for the configuration associated with @c configKey.*/
static boolValueForConfigKey(element, configKey) {
if (typeof configKey !== "string") throw new Error("configKey should be a string, but got " + (configKey + (" (" + (typeof configKey + ")"))));
return {
target: element,
@@ -62,15 +62,15 @@ raised.
}
/*If a user-configured value is associated with the given @c configKey, it is returned, otherwise
the default value is returned. If a default value is not found, NSInvalidArgumentException is
raised.
@param configKey The key whose value is being queried. Must be a valid @c NSString.
@throws NSInvalidArgumentException If no value could be found for the given @c configKey.
@return The integer value for the configuration associated with @c configKey.
*/static integerValueForConfigKey(element, configKey) {
the default value is returned. If a default value is not found, NSInvalidArgumentException is
raised.
@param configKey The key whose value is being queried. Must be a valid @c NSString.
@throws NSInvalidArgumentException If no value could be found for the given @c configKey.
@return The integer value for the configuration associated with @c configKey.*/
static integerValueForConfigKey(element, configKey) {
if (typeof configKey !== "string") throw new Error("configKey should be a string, but got " + (configKey + (" (" + (typeof configKey + ")"))));
return {
target: element,
@@ -83,15 +83,15 @@ raised.
}
/*If a user-configured value is associated with the given @c configKey, it is returned, otherwise
the default value is returned. If a default value is not found, NSInvalidArgumentException is
raised.
@param configKey The key whose value is being queried. Must be a valid @c NSString.
@throws NSInvalidArgumentException If no value could be found for the given @c configKey.
@return The @c double value for the configuration associated with @c configKey.
*/static doubleValueForConfigKey(element, configKey) {
the default value is returned. If a default value is not found, NSInvalidArgumentException is
raised.
@param configKey The key whose value is being queried. Must be a valid @c NSString.
@throws NSInvalidArgumentException If no value could be found for the given @c configKey.
@return The @c double value for the configuration associated with @c configKey.*/
static doubleValueForConfigKey(element, configKey) {
if (typeof configKey !== "string") throw new Error("configKey should be a string, but got " + (configKey + (" (" + (typeof configKey + ")"))));
return {
target: element,
@@ -104,10 +104,10 @@ raised.
}
/*Resets all configurations to default values, removing all the configured values.
@remark Any default values added by calling GREYConfiguration:setDefaultValue:forConfigKey:
are not reset.
*/static reset(element) {
@remark Any default values added by calling GREYConfiguration:setDefaultValue:forConfigKey:
are not reset.*/
static reset(element) {
return {
target: element,
method: "reset",
@@ -116,13 +116,13 @@ are not reset.
}
/*Given a value and a key that identifies a configuration, set the value of the configuration.
Overwrites any previous value for the configuration.
@remark To restore original values, call GREYConfiguration::reset.
@param value The configuration value to be set. Scalars should be wrapped in @c NSValue.
@param configKey Key identifying an existing or new configuration. Must be a valid @c NSString.
*/static setValueForConfigKey(element, value, configKey) {
Overwrites any previous value for the configuration.
@remark To restore original values, call GREYConfiguration::reset.
@param value The configuration value to be set. Scalars should be wrapped in @c NSValue.
@param configKey Key identifying an existing or new configuration. Must be a valid @c NSString.*/
static setValueForConfigKey(element, value, configKey) {
if (typeof configKey !== "string") throw new Error("configKey should be a string, but got " + (configKey + (" (" + (typeof configKey + ")"))));
return {
target: element,
@@ -135,13 +135,13 @@ Overwrites any previous value for the configuration.
}
/*Associates configuration identified by @c configKey with the provided @c value.
@remark Default values persist even after resetting the configuration
(using GREYConfiguration::reset)
@param value The configuration value to be set. Scalars should be wrapped in @c NSValue.
@param configKey Key identifying an existing or new configuration. Must be a valid @c NSString.
*/static setDefaultValueForConfigKey(element, value, configKey) {
@remark Default values persist even after resetting the configuration
(using GREYConfiguration::reset)
@param value The configuration value to be set. Scalars should be wrapped in @c NSValue.
@param configKey Key identifying an existing or new configuration. Must be a valid @c NSString.*/
static setDefaultValueForConfigKey(element, value, configKey) {
if (typeof configKey !== "string") throw new Error("configKey should be a string, but got " + (configKey + (" (" + (typeof configKey + ")"))));
return {
target: element,
+55 -55
View File
@@ -8,13 +8,13 @@
class GREYInteraction {
/*Indicates that the current interaction should be performed on a UI element contained inside
another UI element that is uniquely matched by @c rootMatcher.
@param rootMatcher Matcher used to select the container of the element the interaction
will be performed on.
@return The provided GREYInteraction instance, with an appropriate rootMatcher.
*/static inRoot(element, rootMatcher) {
another UI element that is uniquely matched by @c rootMatcher.
@param rootMatcher Matcher used to select the container of the element the interaction
will be performed on.
@return The provided GREYInteraction instance, with an appropriate rootMatcher.*/
static inRoot(element, rootMatcher) {
if (typeof rootMatcher !== "object" || rootMatcher.type !== "Invocation" || typeof rootMatcher.value !== "object" || typeof rootMatcher.value.target !== "object" || rootMatcher.value.target.value !== "GREYMatchers") {
throw new Error('rootMatcher should be a GREYMatcher, but got ' + JSON.stringify(rootMatcher));
}
@@ -27,27 +27,27 @@ will be performed on.
}
/*Performs the @c action repeatedly on the element matching the @c matcher until the element
to interact with (specified by GREYInteraction::selectElementWithMatcher:) is found or a
timeout occurs. The search action is only performed when coupled with
GREYInteraction::performAction:, GREYInteraction::assert:, or
GREYInteraction::assertWithMatcher: APIs. This API only creates an interaction consisting of
repeated executions of the search action provided. You need to call an action or assertion
after this in order to interaction with the element being searched for.
For example, this code will perform an upward scroll of 50 points until an element is found
and then tap on it:
@code
[[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"elementToFind")]
usingSearchAction:grey_scrollInDirection(kGREYDirectionUp, 50.0f)
onElementWithMatcher:grey_accessibilityID(@"ScrollingWindow")]
performAction:grey_tap()] // This should be separately called for the action.
@endcode
@param action The action to be performed on the element.
@param matcher The matcher that the element matches.
@return The provided GREYInteraction instance, with an appropriate action and matcher.
*/static usingSearchActionOnElementWithMatcher(element, action, matcher) {
to interact with (specified by GREYInteraction::selectElementWithMatcher:) is found or a
timeout occurs. The search action is only performed when coupled with
GREYInteraction::performAction:, GREYInteraction::assert:, or
GREYInteraction::assertWithMatcher: APIs. This API only creates an interaction consisting of
repeated executions of the search action provided. You need to call an action or assertion
after this in order to interaction with the element being searched for.
For example, this code will perform an upward scroll of 50 points until an element is found
and then tap on it:
@code
[[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"elementToFind")]
usingSearchAction:grey_scrollInDirection(kGREYDirectionUp, 50.0f)
onElementWithMatcher:grey_accessibilityID(@"ScrollingWindow")]
performAction:grey_tap()] // This should be separately called for the action.
@endcode
@param action The action to be performed on the element.
@param matcher The matcher that the element matches.
@return The provided GREYInteraction instance, with an appropriate action and matcher.*/
static usingSearchActionOnElementWithMatcher(element, action, matcher) {
if (typeof action !== "object" || action.type !== "Invocation" || typeof action.value !== "object" || typeof action.value.target !== "object" || action.value.target.value !== "GREYActions") {
throw new Error('action should be a GREYAction, but got ' + JSON.stringify(action));
}
@@ -64,12 +64,12 @@ performAction:grey_tap()] // This should be separately called for the action.
}
/*Performs an @c action on the selected UI element.
@param action The action to be performed on the @c element.
@throws NSException if the action fails.
@return The provided GREYInteraction instance with an appropriate action.
*/static performAction(element, action) {
@param action The action to be performed on the @c element.
@throws NSException if the action fails.
@return The provided GREYInteraction instance with an appropriate action.*/
static performAction(element, action) {
if (typeof action !== "object" || action.type !== "Invocation" || typeof action.value !== "object" || typeof action.value.target !== "object" || action.value.target.value !== "GREYActions") {
throw new Error('action should be a GREYAction, but got ' + JSON.stringify(action));
}
@@ -82,11 +82,11 @@ performAction:grey_tap()] // This should be separately called for the action.
}
/*Performs an assertion that evaluates @c matcher on the selected UI element.
@param matcher The matcher to be evaluated on the @c element.
@return The provided GREYInteraction instance with a matcher to be evaluated on an element.
*/static assertWithMatcher(element, matcher) {
@param matcher The matcher to be evaluated on the @c element.
@return The provided GREYInteraction instance with a matcher to be evaluated on an element.*/
static assertWithMatcher(element, matcher) {
if (typeof matcher !== "object" || matcher.type !== "Invocation" || typeof matcher.value !== "object" || typeof matcher.value.target !== "object" || matcher.value.target.value !== "GREYMatchers") {
throw new Error('matcher should be a GREYMatcher, but got ' + JSON.stringify(matcher));
}
@@ -99,22 +99,22 @@ performAction:grey_tap()] // This should be separately called for the action.
}
/*In case of multiple matches, selects the element at the specified index. In case of the
index being over the number of matched elements, it throws an exception. Please make sure
that this is used after you've created the matcher. For example, in case three elements are
matched, and you wish to match with the second one, then @c atIndex would be used in this
manner:
@code
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Generic Matcher")] atIndex:1];
@endcode
@param index The zero-indexed position of the element in the list of matched elements
to be selected.
@throws NSException if the @c index is more than the number of matched elements.
@return An interaction (assertion or an action) to be performed on the element at the
specified index in the list of matched elements.
*/static atIndex(element, index) {
index being over the number of matched elements, it throws an exception. Please make sure
that this is used after you've created the matcher. For example, in case three elements are
matched, and you wish to match with the second one, then @c atIndex would be used in this
manner:
@code
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Generic Matcher")] atIndex:1];
@endcode
@param index The zero-indexed position of the element in the list of matched elements
to be selected.
@throws NSException if the @c index is more than the number of matched elements.
@return An interaction (assertion or an action) to be performed on the element at the
specified index in the list of matched elements.*/
static atIndex(element, index) {
if (typeof index !== "number") throw new Error("index should be a number, but got " + (index + (" (" + (typeof index + ")"))));
return {
target: element,
+167 -167
View File
@@ -83,9 +83,9 @@ function sanitize_greyContentEdge(action) {
}
class GREYMatchers {
/*Matcher for application's key window.
@return A matcher for the application's key window.
*/static matcherForKeyWindow() {
@return A matcher for the application's key window.*/
static matcherForKeyWindow() {
return {
target: {
type: "Class",
@@ -97,11 +97,11 @@ class GREYMatchers {
}
/*Matcher for UI element with the provided accessibility @c label.
@param label The accessibility label to be matched.
@return A matcher for the accessibility label of an accessible element.
*/static matcherForAccessibilityLabel(label) {
@param label The accessibility label to be matched.
@return A matcher for the accessibility label of an accessible element.*/
static matcherForAccessibilityLabel(label) {
if (typeof label !== "string") throw new Error("label should be a string, but got " + (label + (" (" + (typeof label + ")"))));
return {
target: {
@@ -117,11 +117,11 @@ class GREYMatchers {
}
/*Matcher for UI element with the provided accessibility ID @c accessibilityID.
@param accessibilityID The accessibility ID to be matched.
@return A matcher for the accessibility ID of an accessible element.
*/static matcherForAccessibilityID(accessibilityID) {
@param accessibilityID The accessibility ID to be matched.
@return A matcher for the accessibility ID of an accessible element.*/
static matcherForAccessibilityID(accessibilityID) {
if (typeof accessibilityID !== "string") throw new Error("accessibilityID should be a string, but got " + (accessibilityID + (" (" + (typeof accessibilityID + ")"))));
return {
target: {
@@ -137,11 +137,11 @@ class GREYMatchers {
}
/*Matcher for UI element with the provided accessibility @c value.
@param value The accessibility value to be matched.
@return A matcher for the accessibility value of an accessible element.
*/static matcherForAccessibilityValue(value) {
@param value The accessibility value to be matched.
@return A matcher for the accessibility value of an accessible element.*/
static matcherForAccessibilityValue(value) {
if (typeof value !== "string") throw new Error("value should be a string, but got " + (value + (" (" + (typeof value + ")"))));
return {
target: {
@@ -157,12 +157,12 @@ class GREYMatchers {
}
/*Matcher for UI element with the provided accessibility @c traits.
@param traits The accessibility traits to be matched.
@return A matcher for the accessibility traits of an accessible element.
*/static matcherForAccessibilityTraits(traits) {
@param traits The accessibility traits to be matched.
@return A matcher for the accessibility traits of an accessible element.
*/
static matcherForAccessibilityTraits(traits) {
if (typeof traits !== 'object' || !traits instanceof Array) {
throw new Error('traits must be an array, got ' + typeof traits);
}
@@ -181,11 +181,11 @@ class GREYMatchers {
}
/*Matcher for UI element with the provided accessiblity @c hint.
@param hint The accessibility hint to be matched.
@return A matcher for the accessibility hint of an accessible element.
*/static matcherForAccessibilityHint(hint) {
@param hint The accessibility hint to be matched.
@return A matcher for the accessibility hint of an accessible element.*/
static matcherForAccessibilityHint(hint) {
if (typeof hint !== "string") throw new Error("hint should be a string, but got " + (hint + (" (" + (typeof hint + ")"))));
return {
target: {
@@ -201,9 +201,9 @@ class GREYMatchers {
}
/*Matcher for UI element with accessiblity focus.
@return A matcher for the accessibility focus of an accessible element.
*/static matcherForAccessibilityElementIsFocused() {
@return A matcher for the accessibility focus of an accessible element.*/
static matcherForAccessibilityElementIsFocused() {
return {
target: {
type: "Class",
@@ -215,12 +215,12 @@ class GREYMatchers {
}
/*Matcher for UI elements of type UIButton, UILabel, UITextField or UITextView displaying the
provided @c inputText.
@param text The text to be matched in the UI elements.
@return A matcher to check for any UI elements with a text field containing the given text.
*/static matcherForText(text) {
provided @c inputText.
@param text The text to be matched in the UI elements.
@return A matcher to check for any UI elements with a text field containing the given text.*/
static matcherForText(text) {
if (typeof text !== "string") throw new Error("text should be a string, but got " + (text + (" (" + (typeof text + ")"))));
return {
target: {
@@ -236,9 +236,9 @@ provided @c inputText.
}
/*Matcher for element that is the first responder.
@return A matcher that verifies if a UI element is the first responder.
*/static matcherForFirstResponder() {
@return A matcher that verifies if a UI element is the first responder.*/
static matcherForFirstResponder() {
return {
target: {
type: "Class",
@@ -250,9 +250,9 @@ provided @c inputText.
}
/*Matcher to check if system alert view is shown.
@return A matcher to check if a system alert view is being shown.
*/static matcherForSystemAlertViewShown() {
@return A matcher to check if a system alert view is being shown.*/
static matcherForSystemAlertViewShown() {
return {
target: {
type: "Class",
@@ -264,14 +264,14 @@ provided @c inputText.
}
/*Matcher for UI element whose percent visible area (of its accessibility frame) exceeds the
given @c percent.
@param percent The percent visible area that the UI element being matched has to be visible.
Allowed values for @c percent are [0,1] inclusive.
@return A matcher that checks if a UI element has a visible area at least equal
to a minimum value.
*/static matcherForMinimumVisiblePercent(percent) {
given @c percent.
@param percent The percent visible area that the UI element being matched has to be visible.
Allowed values for @c percent are [0,1] inclusive.
@return A matcher that checks if a UI element has a visible area at least equal
to a minimum value.*/
static matcherForMinimumVisiblePercent(percent) {
if (typeof percent !== "number") throw new Error("percent should be a number, but got " + (percent + (" (" + (typeof percent + ")"))));
return {
target: {
@@ -287,12 +287,12 @@ to a minimum value.
}
/*Matcher for UI element that is sufficiently visible to the user. EarlGrey considers elements
that are more than @c kElementSufficientlyVisiblePercentage (75 %) visible areawise to be
sufficiently visible.
@return A matcher intialized with a visibility percentage that confirms an element is
sufficiently visible.
*/static matcherForSufficientlyVisible() {
that are more than @c kElementSufficientlyVisiblePercentage (75 %) visible areawise to be
sufficiently visible.
@return A matcher intialized with a visibility percentage that confirms an element is
sufficiently visible.*/
static matcherForSufficientlyVisible() {
return {
target: {
type: "Class",
@@ -304,9 +304,9 @@ sufficiently visible.
}
/*Matcher for UI element that is not visible to the user at all i.e. it has a zero visible area.
@return A matcher for verifying if an element is not visible.
*/static matcherForNotVisible() {
@return A matcher for verifying if an element is not visible.*/
static matcherForNotVisible() {
return {
target: {
type: "Class",
@@ -318,13 +318,13 @@ sufficiently visible.
}
/*Matcher for UI element that matches EarlGrey's criteria for user interaction. Currently it must
satisfy at least the following criteria:
1) At least a few pixels of the element are visible to the user.
2) The element's accessibility activation point OR the center of the element's visible area
is completely visible.
@return A matcher that checks if a UI element is interactable.
*/static matcherForInteractable() {
satisfy at least the following criteria:
1) At least a few pixels of the element are visible to the user.
2) The element's accessibility activation point OR the center of the element's visible area
is completely visible.
@return A matcher that checks if a UI element is interactable.*/
static matcherForInteractable() {
return {
target: {
type: "Class",
@@ -336,9 +336,9 @@ is completely visible.
}
/*Matcher to check if a UI element is accessible.
@return A matcher that checks if a UI element is accessible.
*/static matcherForAccessibilityElement() {
@return A matcher that checks if a UI element is accessible.*/
static matcherForAccessibilityElement() {
return {
target: {
type: "Class",
@@ -350,15 +350,15 @@ is completely visible.
}
/*Matcher for matching UIProgressView's values. Use greaterThan, greaterThanOrEqualTo,
lessThan etc to create @c comparisonMatcher. For example, to match the UIProgressView
elements that have progress value greater than 50.2, use
@code [GREYMatchers matcherForProgress:grey_greaterThan(@(50.2))] @endcode. In case if an
unimplemented matcher is required, please implement it similar to @c grey_closeTo.
@param comparisonMatcher The matcher with the value to check the progress against.
@return A matcher for checking a UIProgessView's value.
*/static matcherForProgress(comparisonMatcher) {
lessThan etc to create @c comparisonMatcher. For example, to match the UIProgressView
elements that have progress value greater than 50.2, use
@code [GREYMatchers matcherForProgress:grey_greaterThan(@(50.2))] @endcode. In case if an
unimplemented matcher is required, please implement it similar to @c grey_closeTo.
@param comparisonMatcher The matcher with the value to check the progress against.
@return A matcher for checking a UIProgessView's value.*/
static matcherForProgress(comparisonMatcher) {
if (typeof comparisonMatcher !== "object" || comparisonMatcher.type !== "Invocation" || typeof comparisonMatcher.value !== "object" || typeof comparisonMatcher.value.target !== "object" || comparisonMatcher.value.target.value !== "GREYMatchers") {
throw new Error('comparisonMatcher should be a GREYMatcher, but got ' + JSON.stringify(comparisonMatcher));
}
@@ -374,13 +374,13 @@ unimplemented matcher is required, please implement it similar to @c grey_closeT
}
/*Matcher that matches any UI element with an ancestor matching the given @c ancestorMatcher.
@param ancestorMatcher A matcher that's run against the ancestors of the UI element being
matched.
@return A matcher to check if a specified element has an ancestor that matches
@c ancestorMatcher.
*/static matcherForAncestor(ancestorMatcher) {
@param ancestorMatcher A matcher that's run against the ancestors of the UI element being
matched.
@return A matcher to check if a specified element has an ancestor that matches
@c ancestorMatcher.*/
static matcherForAncestor(ancestorMatcher) {
if (typeof ancestorMatcher !== "object" || ancestorMatcher.type !== "Invocation" || typeof ancestorMatcher.value !== "object" || typeof ancestorMatcher.value.target !== "object" || ancestorMatcher.value.target.value !== "GREYMatchers") {
throw new Error('ancestorMatcher should be a GREYMatcher, but got ' + JSON.stringify(ancestorMatcher));
}
@@ -396,13 +396,13 @@ matched.
}
/*Matcher that matches any UI element with a descendant matching the given @c descendantMatcher.
@param descendantMatcher A matcher that's run against the descendants of the UI element being
matched.
@return A matcher to check if a specified element has a descendant that matches
@c descendantMatcher.
*/static matcherForDescendant(descendantMatcher) {
@param descendantMatcher A matcher that's run against the descendants of the UI element being
matched.
@return A matcher to check if a specified element has a descendant that matches
@c descendantMatcher.*/
static matcherForDescendant(descendantMatcher) {
if (typeof descendantMatcher !== "object" || descendantMatcher.type !== "Invocation" || typeof descendantMatcher.value !== "object" || typeof descendantMatcher.value.target !== "object" || descendantMatcher.value.target.value !== "GREYMatchers") {
throw new Error('descendantMatcher should be a GREYMatcher, but got ' + JSON.stringify(descendantMatcher));
}
@@ -418,11 +418,11 @@ matched.
}
/*Matcher that matches UIButton that has title label as @c text.
@param title The title to be checked on the UIButtons being matched.
@return A matcher to confirm UIButton titles.
*/static matcherForButtonTitle(title) {
@param title The title to be checked on the UIButtons being matched.
@return A matcher to confirm UIButton titles.*/
static matcherForButtonTitle(title) {
if (typeof title !== "string") throw new Error("title should be a string, but got " + (title + (" (" + (typeof title + ")"))));
return {
target: {
@@ -438,12 +438,12 @@ matched.
}
/*Matcher that matches UIScrollView that has contentOffset as @c offset.
@param offset The content offset to be checked on the UIScrollView being
matched.
@return A matcher to confirm UIScrollView content offset.
*/static matcherForScrollViewContentOffset(offset) {
@param offset The content offset to be checked on the UIScrollView being
matched.
@return A matcher to confirm UIScrollView content offset.*/
static matcherForScrollViewContentOffset(offset) {
if (typeof offset !== "object") throw new Error("offset should be a object, but got " + (offset + (" (" + (typeof offset + ")"))));
if (typeof offset.x !== "number") throw new Error("offset.x should be a number, but got " + (offset.x + (" (" + (typeof offset.x + ")"))));
if (typeof offset.y !== "number") throw new Error("offset.y should be a number, but got " + (offset.y + (" (" + (typeof offset.y + ")"))));
@@ -461,18 +461,18 @@ matched.
}
/*Matcher that matches a UISlider's value.
@param valueMatcher A matcher for the UISlider's value. You must provide a valid
@c valueMatcher for the floating point value comparison. The
@c valueMatcher should be of the type @c closeTo, @c greaterThan,
@c lessThan, @c lessThanOrEqualTo, @c greaterThanOrEqualTo. The
value matchers should account for any loss in precision for the given
floating point value. If you are using @c grey_closeTo, use delta diff as
@c kGREYAcceptableFloatDifference. In case if an unimplemented matcher
is required, please implement it similar to @c grey_closeTo.
@return A matcher for checking a UISlider's value.
*/static matcherForSliderValueMatcher(valueMatcher) {
@param valueMatcher A matcher for the UISlider's value. You must provide a valid
@c valueMatcher for the floating point value comparison. The
@c valueMatcher should be of the type @c closeTo, @c greaterThan,
@c lessThan, @c lessThanOrEqualTo, @c greaterThanOrEqualTo. The
value matchers should account for any loss in precision for the given
floating point value. If you are using @c grey_closeTo, use delta diff as
@c kGREYAcceptableFloatDifference. In case if an unimplemented matcher
is required, please implement it similar to @c grey_closeTo.
@return A matcher for checking a UISlider's value.*/
static matcherForSliderValueMatcher(valueMatcher) {
if (typeof valueMatcher !== "object" || valueMatcher.type !== "Invocation" || typeof valueMatcher.value !== "object" || typeof valueMatcher.value.target !== "object" || valueMatcher.value.target.value !== "GREYMatchers") {
throw new Error('valueMatcher should be a GREYMatcher, but got ' + JSON.stringify(valueMatcher));
}
@@ -488,9 +488,9 @@ is required, please implement it similar to @c grey_closeTo.
}
/*Matcher that verifies whether an element, that is a UIControl, is enabled.
@return A matcher for checking whether a UI element is an enabled UIControl.
*/static matcherForEnabledElement() {
@return A matcher for checking whether a UI element is an enabled UIControl.*/
static matcherForEnabledElement() {
return {
target: {
type: "Class",
@@ -502,9 +502,9 @@ is required, please implement it similar to @c grey_closeTo.
}
/*Matcher that verifies whether an element, that is a UIControl, is selected.
@return A matcher for checking whether a UI element is a selected UIControl.
*/static matcherForSelectedElement() {
@return A matcher for checking whether a UI element is a selected UIControl.*/
static matcherForSelectedElement() {
return {
target: {
type: "Class",
@@ -516,9 +516,9 @@ is required, please implement it similar to @c grey_closeTo.
}
/*Matcher that verifies whether a view has its userInteractionEnabled property set to @c YES.
@return A matcher for checking whether a view' userInteractionEnabled property is set to @c YES.
*/static matcherForUserInteractionEnabled() {
@return A matcher for checking whether a view' userInteractionEnabled property is set to @c YES.*/
static matcherForUserInteractionEnabled() {
return {
target: {
type: "Class",
@@ -530,9 +530,9 @@ is required, please implement it similar to @c grey_closeTo.
}
/*Matcher primarily for asserting that the element is @c nil or not found.
@return A matcher to check if a specified element is @c nil or not found.
*/static matcherForNil() {
@return A matcher to check if a specified element is @c nil or not found.*/
static matcherForNil() {
return {
target: {
type: "Class",
@@ -544,9 +544,9 @@ is required, please implement it similar to @c grey_closeTo.
}
/*Matcher for asserting that the element exists in the UI hierarchy (i.e. not @c nil).
@return A matcher to check if a specified element is not @c nil.
*/static matcherForNotNil() {
@return A matcher to check if a specified element is not @c nil.*/
static matcherForNotNil() {
return {
target: {
type: "Class",
@@ -558,9 +558,9 @@ is required, please implement it similar to @c grey_closeTo.
}
/*A Matcher that matches against any object, including @c nils.
@return A matcher that matches any object.
*/static matcherForAnything() {
@return A matcher that matches any object.*/
static matcherForAnything() {
return {
target: {
type: "Class",
@@ -572,14 +572,14 @@ is required, please implement it similar to @c grey_closeTo.
}
/*A Matcher that checks if a provided object is equal to the specified @c value. The equality is
determined by calling the @c isEqual: method of the object being examined. In case the @c
value is @c nil, then the object itself is checked to be @c nil.
@param value The value to be checked for equality. Please ensure that scalar types are
passed in as boxed (object) values.
@return A matcher that checks if an object is equal to the provided one.
*/static matcherForEqualTo(value) {
determined by calling the @c isEqual: method of the object being examined. In case the @c
value is @c nil, then the object itself is checked to be @c nil.
@param value The value to be checked for equality. Please ensure that scalar types are
passed in as boxed (object) values.
@return A matcher that checks if an object is equal to the provided one.*/
static matcherForEqualTo(value) {
return {
target: {
type: "Class",
@@ -591,13 +591,13 @@ passed in as boxed (object) values.
}
/*A Matcher that checks if a provided object is less than a specified @c value. The comparison
is made by calling the @c compare: method of the object being examined.
@param value The value to be compared, which should return @c NSOrderedDescending. Please
ensure that scalar values are passed in as boxed (object) values.
@return A matcher that checks an object is lesser than another provided @c value.
*/static matcherForLessThan(value) {
is made by calling the @c compare: method of the object being examined.
@param value The value to be compared, which should return @c NSOrderedDescending. Please
ensure that scalar values are passed in as boxed (object) values.
@return A matcher that checks an object is lesser than another provided @c value.*/
static matcherForLessThan(value) {
return {
target: {
type: "Class",
@@ -609,13 +609,13 @@ ensure that scalar values are passed in as boxed (object) values.
}
/*A Matcher that checks if a provided object is greater than a specified @c value. The comparison
is made by calling the @c compare: method of the object being examined.
@param value The value to be compared, which should return @c NSOrderedAscending. Please
ensure that scalar values are passed in as boxed (object) values.
@return A matcher that checks an object is greater than another provided @c value.
*/static matcherForGreaterThan(value) {
is made by calling the @c compare: method of the object being examined.
@param value The value to be compared, which should return @c NSOrderedAscending. Please
ensure that scalar values are passed in as boxed (object) values.
@return A matcher that checks an object is greater than another provided @c value.*/
static matcherForGreaterThan(value) {
return {
target: {
type: "Class",
@@ -627,11 +627,11 @@ ensure that scalar values are passed in as boxed (object) values.
}
/*Matcher that matches a UIScrollView scrolled to content @c edge.
@param edge The content edge UIScrollView should be scrolled to.
@return A matcher that matches a UIScrollView scrolled to content @c edge.
*/static matcherForScrolledToContentEdge(edge) {
@param edge The content edge UIScrollView should be scrolled to.
@return A matcher that matches a UIScrollView scrolled to content @c edge.*/
static matcherForScrolledToContentEdge(edge) {
if (!["left", "right", "top", "bottom"].some(option => option === edge)) throw new Error("edge should be one of [left, right, top, bottom], but got " + edge);
return {
target: {
@@ -647,11 +647,11 @@ ensure that scalar values are passed in as boxed (object) values.
}
/*Matcher that matches a UITextField's content.
@param value The text string contained inside the UITextField.
@return A matcher that matches the value inside a UITextField.
*/static matcherForTextFieldValue(value) {
@param value The text string contained inside the UITextField.
@return A matcher that matches the value inside a UITextField.*/
static matcherForTextFieldValue(value) {
if (typeof value !== "string") throw new Error("value should be a string, but got " + (value + (" (" + (typeof value + ")"))));
return {
target: {
+2 -1
View File
@@ -32,7 +32,8 @@ describe('iOS generation', () => {
});
it('should include multi line comments', () => {
expect(exampleContent.indexOf('Multi Line Comment here\nAwesome')).not.toBe(-1);
expect(exampleContent.indexOf('Multi Line Comment here')).not.toBe(-1);
expect(exampleContent.indexOf('Awesome')).not.toBe(-1);
});
});
+1 -1
View File
@@ -1,4 +1,4 @@
const t = require('babel-types');
const t = require('@babel/types');
const generator = require('../core/generator');
const { callGlobal } = require('../helpers');
+1 -1
View File
@@ -1,4 +1,4 @@
const t = require('babel-types');
const t = require('@babel/types');
const generator = require('../core/generator');
const {
isNumber,
+4 -10
View File
@@ -1,8 +1,8 @@
const t = require('babel-types');
const template = require('babel-template');
const t = require('@babel/types');
const template = require('@babel/template').default;
const generate = require('@babel/generator').default;
const objectiveCParser = require('objective-c-parser');
const javaMethodParser = require('java-method-parser');
const generate = require('babel-generator').default;
const fs = require('fs');
const { methodNameToSnakeCase } = require('../helpers');
@@ -101,13 +101,7 @@ module.exports = function getGenerator({
);
if (json.comment) {
const comment = {
type: json.comment.indexOf('\n') === -1 ? 'LineComment' : 'BlockComment',
value: json.comment + '\n'
};
m.leadingComments = m.leadingComments || [];
m.leadingComments.push(comment);
t.addComment(m, 'leading', json.comment);
}
return m;
}
+40 -26
View File
@@ -1,7 +1,15 @@
const t = require('babel-types');
const template = require('babel-template');
const t = require('@babel/types');
const template = require('@babel/template').default;
const { generateTypeCheck, generateIsOneOfCheck } = require('babel-generate-guard-clauses');
const templateFromString = (templateStr, argValue) =>
template(templateStr, {
placeholderPattern: false,
placeholderWhitelist: new Set(['ARG'])
})({
ARG: argValue
});
const isNumber = generateTypeCheck('number');
const isString = generateTypeCheck('string');
const isBoolean = generateTypeCheck('boolean');
@@ -12,7 +20,8 @@ const isPoint = [
];
const isOneOf = generateIsOneOfCheck;
function isGreyMatcher({ name }) {
return template(`
return templateFromString(
`
if (
typeof ARG !== "object" ||
ARG.type !== "Invocation" ||
@@ -22,13 +31,14 @@ function isGreyMatcher({ name }) {
) {
throw new Error('${name} should be a GREYMatcher, but got ' + JSON.stringify(ARG));
}
`)({
ARG: t.identifier(name)
});
`,
t.identifier(name)
);
}
function isGreyAction({ name }) {
return template(`
return templateFromString(
`
if (
typeof ARG !== "object" ||
ARG.type !== "Invocation" ||
@@ -38,39 +48,42 @@ function isGreyAction({ name }) {
) {
throw new Error('${name} should be a GREYAction, but got ' + JSON.stringify(ARG));
}
`)({
ARG: t.identifier(name)
});
`,
t.identifier(name)
);
}
function isGreyElementInteraction({ name }) {
return template(`
return templateFromString(
`
if (
typeof ARG !== "object"
) {
// TODO: This currently only checks for object, we should add more fine grained checks here
throw new Error('${name} should be a GREYElementInteraction, but got ' + JSON.stringify(ARG));
}
`)({
ARG: t.identifier(name)
});
`,
t.identifier(name)
);
}
function isArray({ name }) {
return template(`
return templateFromString(
`
if (
(typeof ARG !== 'object') ||
(!ARG instanceof Array)
) {
throw new Error('${name} must be an array, got ' + typeof ARG);
}
`)({
ARG: t.identifier(name)
});
`,
t.identifier(name)
);
}
function isOfClass(className) {
return ({ name }) =>
template(`
templateFromString(
`
if (
typeof ARG !== 'object' ||
typeof ARG.constructor !== 'function' ||
@@ -81,20 +94,21 @@ function isOfClass(className) {
throw new Error('${name} should be an instance of ${className}, got "' + ARG + '", it appears that ' + additionalErrorInfo);
}
`)({
ARG: t.identifier(name)
});
`,
t.identifier(name)
);
}
function isDefined() {
return ({ name }) =>
template(`
templateFromString(
`
if (!ARG) {
throw new Error('${name} should be truthy, but it is "' + ARG + '"');
}
`)({
ARG: t.identifier(name)
});
`,
t.identifier(name)
);
}
module.exports = {
+1 -1
View File
@@ -1,4 +1,4 @@
const t = require("babel-types");
const t = require("@babel/types");
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
+4 -4
View File
@@ -20,10 +20,10 @@
]
},
"dependencies": {
"babel-generate-guard-clauses": "2.0.5",
"babel-generator": "6.26.1",
"babel-template": "6.26.0",
"babel-types": "6.25.0",
"babel-generate-guard-clauses": "3.0.0-1",
"@babel/generator": "7.0.0-beta.49",
"@babel/types": "7.0.0-beta.49",
"@babel/template": "7.0.0-beta.49",
"download-file-sync": "1.0.4",
"java-method-parser": "0.4.7",
"objective-c-parser": "1.2.4",