diff --git a/ground/src/main/res/layout/multiple_choice_task_frag.xml b/ground/src/main/res/layout/multiple_choice_task_frag.xml index 8a7ac51dd5..2f1f95cba9 100644 --- a/ground/src/main/res/layout/multiple_choice_task_frag.xml +++ b/ground/src/main/res/layout/multiple_choice_task_frag.xml @@ -26,6 +26,7 @@ android:divider="@null" android:dividerHeight="0dp" android:orientation="vertical" + android:paddingBottom="10dp" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> \ No newline at end of file diff --git a/ground/src/main/res/layout/task_frag_with_header.xml b/ground/src/main/res/layout/task_frag_with_header.xml index 4153a05204..76cf0c8203 100644 --- a/ground/src/main/res/layout/task_frag_with_header.xml +++ b/ground/src/main/res/layout/task_frag_with_header.xml @@ -47,11 +47,12 @@ + app:layout_constraintTop_toBottomOf="@+id/data_collection_header" + app:layout_constraintBottom_toTopOf="@+id/action_buttons" /> (job, task) + // NOTE: The task container layout is given 0dp height to allow Android's constraint system to + // determine the appropriate height. Unfortunately, Espresso does not perform actions on views + // with height zero, and it doesn't seem to repro constraint calculations. Force the view to + // have a height of 1 to ensure the action performed below actually takes place. + val view: View? = fragment.view?.findViewById(R.id.task_container) + view?.layoutParams = ViewGroup.LayoutParams(0, 1) assertThat(fragment.getDatePickerDialog()).isNull() onView(withId(R.id.user_response_text)).perform(click()) - assertThat(fragment.getDatePickerDialog()!!.isShowing).isTrue() + assertThat(fragment.getDatePickerDialog()).isNotNull() + assertThat(fragment.getDatePickerDialog()?.isShowing).isTrue() } @Test diff --git a/ground/src/test/java/com/google/android/ground/ui/datacollection/tasks/time/TimeTaskFragmentTest.kt b/ground/src/test/java/com/google/android/ground/ui/datacollection/tasks/time/TimeTaskFragmentTest.kt index 56a48bbcae..54858cb349 100644 --- a/ground/src/test/java/com/google/android/ground/ui/datacollection/tasks/time/TimeTaskFragmentTest.kt +++ b/ground/src/test/java/com/google/android/ground/ui/datacollection/tasks/time/TimeTaskFragmentTest.kt @@ -15,6 +15,8 @@ */ package com.google.android.ground.ui.datacollection.tasks.time +import android.view.View +import android.view.ViewGroup import androidx.test.espresso.Espresso.onView import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.assertion.ViewAssertions.matches @@ -75,6 +77,12 @@ class TimeTaskFragmentTest : BaseTaskFragmentTest(job, task) + // NOTE: The task container layout is given 0dp height to allow Android's constraint system to + // determine the appropriate height. Unfortunately, Espresso does not perform actions on views + // with height zero, and it doesn't seem to repro constraint calculations. Force the view to + // have a height of 1 to ensure the action performed below actually takes place. + val view: View? = fragment.view?.findViewById(R.id.task_container) + view?.layoutParams = ViewGroup.LayoutParams(0, 1) assertThat(fragment.getTimePickerDialog()).isNull() onView(withId(R.id.user_response_text)).perform(click())