-
-
Notifications
You must be signed in to change notification settings - Fork 745
espresso fixes and replacing manual smoke test #6150
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
base: main
Are you sure you want to change the base?
Changes from all commits
3975c3f
f574a41
8497ece
c31286f
b8f0c44
861cae3
c2e9a87
8a0bf68
1b22cee
897bf18
e703b6f
7aa423a
3202bb0
09c8243
cf0f481
1c2d2f5
ca37a12
9392ba8
eee3bb2
b5f4ede
074053a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ import androidx.core.widget.NestedScrollView | |
| import androidx.recyclerview.widget.RecyclerView | ||
| import androidx.test.espresso.Espresso.onData | ||
| import androidx.test.espresso.Espresso.onView | ||
| import androidx.test.espresso.NoMatchingViewException | ||
| import androidx.test.espresso.UiController | ||
| import androidx.test.espresso.ViewAction | ||
| import androidx.test.espresso.ViewAssertion | ||
|
|
@@ -25,6 +26,8 @@ import androidx.test.espresso.matcher.ViewMatchers.hasDescendant | |
| import androidx.test.espresso.matcher.ViewMatchers.isDisplayed | ||
| import androidx.test.espresso.matcher.ViewMatchers.withId | ||
| import androidx.test.espresso.matcher.ViewMatchers.withText | ||
| import com.google.android.material.tabs.TabLayout | ||
| import junit.framework.AssertionFailedError | ||
| import org.hamcrest.Description | ||
| import org.hamcrest.Matcher | ||
| import org.hamcrest.Matchers | ||
|
|
@@ -223,6 +226,50 @@ class ListActions { | |
| ) | ||
| } | ||
|
|
||
| fun isItemPresent( | ||
| recyclerViewId: Int = R.id.feed_view, | ||
| title: String, | ||
| textViewId: Int = R.id.view_card_header_title | ||
| ): Boolean { | ||
| return try { | ||
| onView(withId(recyclerViewId)) | ||
| .check(matches(hasDescendant(allOf( | ||
| withId(textViewId), | ||
| withText(title) | ||
| )))) | ||
| true | ||
| } catch (_: NoMatchingViewException) { | ||
| false | ||
| } catch (_: AssertionFailedError) { | ||
| false | ||
| } | ||
| } | ||
|
|
||
| fun selectTabWithText(@IdRes viewId: Int, text: String) { | ||
| onView(withId(viewId)) | ||
| .perform(object : ViewAction { | ||
| override fun getConstraints(): Matcher<View?> = isDisplayed() | ||
|
|
||
| override fun getDescription(): String = "Select tab with text: $text" | ||
|
|
||
| override fun perform( | ||
| uiController: UiController, | ||
| view: View | ||
| ) { | ||
| val tabLayout = view as TabLayout | ||
| for (i in 0 until tabLayout.tabCount) { | ||
| val tab = tabLayout.getTabAt(i) | ||
| val labelView = tab?.customView?.findViewById<TextView>(R.id.language_label) | ||
| if (labelView?.text == text) { | ||
| tab.select() | ||
| break | ||
| } | ||
| } | ||
| uiController.loopMainThreadUntilIdle() | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| private fun verifyItemAtPosition( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for this, is this still being used? and also this
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was used before but its not used now, there are lot of functions which are not used or i added for testing. I will remove them and refactor more after i finish fixing the tests. |
||
| recyclerViewId: Int, | ||
| position: Int, | ||
|
|
||
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.
Is this used?
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.
this was used before but its not used now, there are lot of functions which are not used or i added for testing. I will remove them and refactor more after i finish fixing the tests.