Skip to content

Commit

Permalink
UI: Constrain task layouts to avoid overlap. (#2582)
Browse files Browse the repository at this point in the history
* UI: Constrain task layouts to avoid overlap.

Fixes #2516 by constraining our task container to the position of the action button dock. This ensures long multiple choice tasks aren't covered by the action buttons—the scroll region is limited to viewable area above the action button drawer.

* UI: Fix date/time task tests

The previous change (setting the task container layout to 0dp) causes espresso actions to fail in our tests on these views. Normally, android computes the height correctly given view constraints, but this doesn't appear to take place in our tests. For now, fix this by forcing the view to have a height of 1, so that the action may be performed.

* addedd test cases (#2591)

* Create codecov.yml

* Update codecov.yml

* Upgrade versioner plugin (#2595)

* Upgrade versioner plugin

* Fix gitversioner path

* Reenable codecov reports and PR comments (#2593)

* Rename unit test target

* Always generate code coverage report

* Run tests against devDebug

* Update path of report

* Upgrade versioner version

* Upgrade versioner plugin

* Fix gitversioner path

* Add unit tests for AboutFragment (#2587)

---------

Co-authored-by: Akshay Nandwana <akshaynandwana001@gmail.com>
Co-authored-by: Gino Miceli <228050+gino-m@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 1, 2024
1 parent da84209 commit fd197fc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions ground/src/main/res/layout/multiple_choice_task_frag.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
android:divider="@null"
android:dividerHeight="0dp"
android:orientation="vertical"
android:paddingBottom="10dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />

</layout>
5 changes: 3 additions & 2 deletions ground/src/main/res/layout/task_frag_with_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@
<FrameLayout
android:id="@+id/task_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="0dp"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/data_collection_header" />
app:layout_constraintTop_toBottomOf="@+id/data_collection_header"
app:layout_constraintBottom_toTopOf="@+id/action_buttons" />

<include
android:id="@+id/action_buttons"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package com.google.android.ground.ui.datacollection.tasks.date

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
Expand Down Expand Up @@ -76,10 +78,17 @@ class DateTaskFragmentTest : BaseTaskFragmentTest<DateTaskFragment, DateTaskView
@Test
fun testResponse_onUserInput() {
setupTaskFragment<DateTaskFragment>(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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -75,6 +77,12 @@ class TimeTaskFragmentTest : BaseTaskFragmentTest<TimeTaskFragment, TimeTaskView
@Test
fun testResponse_onUserInput() {
setupTaskFragment<TimeTaskFragment>(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())
Expand Down

0 comments on commit fd197fc

Please sign in to comment.