mirror of
https://github.com/hmalik144/Driver.git
synced 2025-12-10 02:45:20 +00:00
- mid commit
Took 55 minutes
This commit is contained in:
@@ -7,6 +7,7 @@ import android.content.res.Resources
|
||||
import android.net.Uri
|
||||
import android.widget.DatePicker
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.recyclerview.widget.RecyclerView.ViewHolder
|
||||
import androidx.test.espresso.Espresso.onData
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.ViewInteraction
|
||||
@@ -14,12 +15,13 @@ import androidx.test.espresso.action.ViewActions
|
||||
import androidx.test.espresso.action.ViewActions.swipeDown
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.contrib.PickerActions
|
||||
import androidx.test.espresso.contrib.RecyclerViewActions
|
||||
import androidx.test.espresso.intent.Intents
|
||||
import androidx.test.espresso.intent.Intents.intending
|
||||
import androidx.test.espresso.intent.matcher.IntentMatchers
|
||||
import androidx.test.espresso.intent.matcher.IntentMatchers.hasAction
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.espresso.matcher.ViewMatchers.*
|
||||
import h_mal.appttude.com.driver.helpers.DataHelper
|
||||
import h_mal.appttude.com.driver.helpers.EspressoHelper.waitForView
|
||||
import org.hamcrest.CoreMatchers.allOf
|
||||
@@ -53,6 +55,16 @@ open class BaseTestRobot {
|
||||
.atPosition(position).perform(ViewActions.click())
|
||||
}
|
||||
|
||||
fun <VH : ViewHolder> clickRecyclerItemWithText(recyclerId: Int, text: String) {
|
||||
onView(withId(recyclerId))
|
||||
.perform(
|
||||
// scrollTo will fail the test if no item matches.
|
||||
RecyclerViewActions.scrollTo<VH>(
|
||||
hasDescendant(withText(text))
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun checkErrorOnTextEntry(resId: Int, errorMessage: String): ViewInteraction =
|
||||
onView(withId(resId)).check(matches(checkErrorMessage(errorMessage)))
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package h_mal.appttude.com.driver.robots
|
||||
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.contrib.DrawerActions
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import h_mal.appttude.com.driver.BaseTestRobot
|
||||
import h_mal.appttude.com.driver.R
|
||||
import h_mal.appttude.com.driver.base.CustomViewHolder
|
||||
|
||||
fun home(func: HomeRobot.() -> Unit) = HomeRobot().apply { func() }
|
||||
class HomeRobot : BaseTestRobot() {
|
||||
|
||||
fun openDrawer() {
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
}
|
||||
|
||||
fun closeDrawer() {
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.close())
|
||||
}
|
||||
|
||||
fun updateProfile() {
|
||||
openDrawer()
|
||||
clickButton(R.id.nav_user_settings)
|
||||
}
|
||||
|
||||
fun clickOnItem(text: String) = clickRecyclerItemWithText<CustomViewHolder<*>>(R.id.recycler_view, text)
|
||||
|
||||
}
|
||||
@@ -3,10 +3,6 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="24dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:layout_marginBottom="64dp"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
||||
Reference in New Issue
Block a user