-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 342/enable horizontal scrolling #419
Open
sergio-sastre
wants to merge
3
commits into
KasperskyLab:master
Choose a base branch
from
sergio-sastre:issue-342/enable_horizontal_scrolling
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
17 changes: 17 additions & 0 deletions
17
...ain/kotlin/com/kaspersky/components/kautomator/component/scroll/UiHorizontalScrollView.kt
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,17 @@ | ||
@file:Suppress("unused") | ||
package com.kaspersky.components.kautomator.component.scroll | ||
|
||
import androidx.test.uiautomator.UiScrollable | ||
import com.kaspersky.components.kautomator.component.common.actions.UiScrollableActions | ||
import com.kaspersky.components.kautomator.component.common.actions.UiSwipeableActions | ||
import com.kaspersky.components.kautomator.component.common.builders.UiViewBuilder | ||
import com.kaspersky.components.kautomator.component.common.builders.UiViewSelector | ||
import com.kaspersky.components.kautomator.component.common.views.UiBaseView | ||
|
||
class UiHorizontalScrollView : UiBaseView<UiScrollView>, UiSwipeableActions, UiScrollableActions { | ||
constructor(selector: UiViewSelector) : super(selector) | ||
constructor(builder: UiViewBuilder.() -> Unit) : super(builder) | ||
|
||
override val setUiScrollableOrientation: UiScrollable.() -> UiScrollable | ||
get() = { setAsHorizontalList() } | ||
} |
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
18 changes: 18 additions & 0 deletions
18
...droidTest/java/com/kaspersky/kaspresso/kautomatorsample/screen/NestedScrollViewsScreen.kt
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,18 @@ | ||
package com.kaspersky.kaspresso.kautomatorsample.screen | ||
|
||
import com.kaspersky.components.kautomator.component.scroll.UiHorizontalScrollView | ||
import com.kaspersky.components.kautomator.component.text.UiButton | ||
import com.kaspersky.components.kautomator.screen.UiScreen | ||
|
||
object NestedScrollViewsScreen : UiScreen<NestedScrollViewsScreen>() { | ||
|
||
override val packageName: String = "com.kaspersky.kaspresso.kautomatorsample" | ||
|
||
val hscrollView = UiHorizontalScrollView { withId([email protected], "hscrollView") } | ||
val nnHscrollView = UiHorizontalScrollView { withId([email protected], "nnHscrollView") } | ||
val hbutton1 = UiButton { withId([email protected], "hvText1") } | ||
val hbutton7 = UiButton { withId([email protected], "hvText7") } | ||
val button1 = UiButton { withId([email protected], "tvText1") } | ||
val button20 = UiButton { withId([email protected], "tvText20") } | ||
val nnHbutton5 = UiButton { withId([email protected], "nnHtvText5") } | ||
} |
85 changes: 85 additions & 0 deletions
85
...st/java/com/kaspersky/kaspresso/kautomatorsample/test/components/NestedScrollViewsTest.kt
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,85 @@ | ||
package com.kaspersky.kaspresso.kautomatorsample.test.components | ||
|
||
import androidx.test.ext.junit.rules.activityScenarioRule | ||
import com.kaspersky.kaspresso.kautomatorsample.scroll.NestedScrollViewsActivity | ||
import com.kaspersky.kaspresso.kautomatorsample.screen.NestedScrollViewsScreen | ||
import com.kaspersky.kaspresso.testcases.api.testcase.TestCase | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
/** | ||
* This sample shows how to work with nested vertical and horizontal ScrollViews | ||
*/ | ||
class NestedScrollViewsTest : TestCase() { | ||
|
||
@get:Rule | ||
val activityRule = activityScenarioRule<NestedScrollViewsActivity>() | ||
|
||
@Test | ||
fun click_last_button_in_ScrollView_and_then_first_one() = | ||
run { | ||
step("Click button20 in ScrollView, last item") { | ||
NestedScrollViewsScreen { | ||
button20.click() | ||
} | ||
} | ||
|
||
step("Click button1 in ScrollView, first item") { | ||
NestedScrollViewsScreen { | ||
button1.click() | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun click_last_button_in_ScrollView_and_then_last_one_in_HorizontalScrollView() = | ||
run { | ||
step("Click button20 in ScrollView, last item") { | ||
NestedScrollViewsScreen { | ||
button20.click() | ||
} | ||
} | ||
|
||
step("Click hbutton7 in HorizontalScrollView, first item") { | ||
NestedScrollViewsScreen { | ||
hscrollView.scrollToView(hbutton7) | ||
hbutton7.click() | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun click_last_button_in_HorizontalScrollView_and_then_first_one() = | ||
run { | ||
step("Click hbutton7 in HorizontalScrollView, last item") { | ||
NestedScrollViewsScreen { | ||
hscrollView.scrollToView(hbutton7) | ||
hbutton7.click() | ||
} | ||
} | ||
step("Click hbutton1 in HorizontalScrollView, first item") { | ||
NestedScrollViewsScreen { | ||
hscrollView.scrollToView(hbutton1) | ||
hbutton1.click() | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun click_last_button_in_3LevelNestedHorizontalScrollView_and_then_last_one_in_1LevelNestedHorizontalScrollView() = | ||
run { | ||
step("Click nnHbutton5 in 3LevelNestedScrollView, middle item") { | ||
NestedScrollViewsScreen { | ||
nnHscrollView.scrollToView(nnHbutton5) | ||
nnHbutton5.click() | ||
} | ||
} | ||
|
||
step("Click button7 in HorizontalScrollView, last item") { | ||
NestedScrollViewsScreen { | ||
hscrollView.scrollToView(hbutton7) | ||
hbutton7.click() | ||
} | ||
} | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
...rc/main/java/com/kaspersky/kaspresso/kautomatorsample/scroll/NestedScrollViewsActivity.kt
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,13 @@ | ||
package com.kaspersky.kaspresso.kautomatorsample.scroll | ||
|
||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.kaspersky.kaspresso.kautomatorsample.R | ||
|
||
class NestedScrollViewsActivity : AppCompatActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_nested_scrollviews) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by implementing point 2 #342 (comment), nnHscrollView.scrollToView(nnHbutton5) would not be needed since it would be done by the autoscroll.
Same for the other horizontalScrollView#scrollToView() calls in other tests of this class