Skip to content

Commit

Permalink
Added optional offset to tap action (#31)
Browse files Browse the repository at this point in the history
* Added optional offset to tap action

* Fixed missing comma

* Bumped version to 1.1.1

* Fixed parameter type
  • Loading branch information
bianca-stan authored Sep 12, 2023
1 parent 60af8ca commit 036c418
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion uiTestGlaze/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {

ext {
PUBLISH_GROUP_ID = 'io.github.getyourguide'
PUBLISH_VERSION = '1.1.0'
PUBLISH_VERSION = '1.1.1'
PUBLISH_ARTIFACT_ID = 'uitestglaze'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ internal class TapHelper(
optional: Boolean,
retryCount: Int,
longPress: Boolean,
offsetX: Int,
offsetY: Int,
hierarchy: TreeNode,
device: UiDevice,
) {
Expand All @@ -24,19 +26,21 @@ internal class TapHelper(
optional,
device,
) ?: return
tapOnTreeNode(foundUiElement, optional, retryCount, longPress, device)
tapOnTreeNode(foundUiElement, optional, retryCount, longPress, offsetX, offsetY, device)
}

private fun tapOnTreeNode(
uiElement: UiElement,
optional: Boolean,
retryCount: Int,
longPress: Boolean,
offsetX: Int,
offsetY: Int,
device: UiDevice,
) {
tap(
uiElement.x + (uiElement.width) / 2,
uiElement.y + (uiElement.height) / 2,
uiElement.x + (uiElement.width) / 2 + offsetX,
uiElement.y + (uiElement.height) / 2 + offsetY,
optional,
retryCount,
longPress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ data class UiTestGlaze(
optional: Boolean = false,
retryCount: Int = 3,
longPress: Boolean = false,
offsetX: Int = 0,
offsetY: Int = 0,
) {
val hierarchy =
hierarchySettleHelper.waitTillHierarchySettles(
Expand All @@ -101,7 +103,7 @@ data class UiTestGlaze(
config.waitTillLoadingViewsGoneTimeout,
config.waitTillHierarchySettlesTimeout,
)
tapHelper.tap(uiElementIdentifier, optional, retryCount, longPress, hierarchy, device)
tapHelper.tap(uiElementIdentifier, optional, retryCount, longPress, offsetX, offsetY, hierarchy, device)
}

/**
Expand Down

0 comments on commit 036c418

Please sign in to comment.