From 312d2ac6773ffb19b689a7d20f8c4b317d2f7392 Mon Sep 17 00:00:00 2001 From: hmalik144 Date: Tue, 16 May 2023 13:08:26 +0100 Subject: [PATCH] - mid commit Took 55 minutes --- .../appttude/com/driver/BaseTestRobot.kt | 14 +++++++++- .../com/driver/robots/HomeAdminRobot.kt | 28 +++++++++++++++++++ .../res/layout/driver_profile_request.xml | 4 --- 3 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 app/src/androidTestAdmin/java/h_mal/appttude/com/driver/robots/HomeAdminRobot.kt diff --git a/app/src/androidTest/java/h_mal/appttude/com/driver/BaseTestRobot.kt b/app/src/androidTest/java/h_mal/appttude/com/driver/BaseTestRobot.kt index acb161d..4dfdfa0 100644 --- a/app/src/androidTest/java/h_mal/appttude/com/driver/BaseTestRobot.kt +++ b/app/src/androidTest/java/h_mal/appttude/com/driver/BaseTestRobot.kt @@ -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 clickRecyclerItemWithText(recyclerId: Int, text: String) { + onView(withId(recyclerId)) + .perform( + // scrollTo will fail the test if no item matches. + RecyclerViewActions.scrollTo( + hasDescendant(withText(text)) + ) + ) + } + fun checkErrorOnTextEntry(resId: Int, errorMessage: String): ViewInteraction = onView(withId(resId)).check(matches(checkErrorMessage(errorMessage))) diff --git a/app/src/androidTestAdmin/java/h_mal/appttude/com/driver/robots/HomeAdminRobot.kt b/app/src/androidTestAdmin/java/h_mal/appttude/com/driver/robots/HomeAdminRobot.kt new file mode 100644 index 0000000..7aea1a1 --- /dev/null +++ b/app/src/androidTestAdmin/java/h_mal/appttude/com/driver/robots/HomeAdminRobot.kt @@ -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>(R.id.recycler_view, text) + +} \ No newline at end of file diff --git a/app/src/driver/res/layout/driver_profile_request.xml b/app/src/driver/res/layout/driver_profile_request.xml index fb7c4ac..4eb86e8 100644 --- a/app/src/driver/res/layout/driver_profile_request.xml +++ b/app/src/driver/res/layout/driver_profile_request.xml @@ -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"