-
Notifications
You must be signed in to change notification settings - Fork 4
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
Android 13880 Hide last divider in XML Lists #327
Changes from all commits
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.telefonica.mistica.list | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import android.widget.FrameLayout | ||
import androidx.recyclerview.widget.RecyclerView | ||
import androidx.test.espresso.Espresso | ||
import androidx.test.espresso.matcher.ViewMatchers | ||
import androidx.test.ext.junit.rules.activityScenarioRule | ||
import com.telefonica.mistica.DummyActivity | ||
import com.telefonica.mistica.R | ||
import com.telefonica.mistica.testutils.ScreenshotsTest | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.robolectric.RobolectricTestRunner | ||
|
||
@RunWith(RobolectricTestRunner::class) | ||
internal class MisticaRecyclerViewTest: ScreenshotsTest() { | ||
@get:Rule | ||
val rule = activityScenarioRule<DummyActivity>() | ||
|
||
@Test | ||
fun `check MisticaRecyclerView xml hides last divider`() { | ||
rule.scenario.onActivity { activity -> | ||
val wrapper: FrameLayout = activity.findViewById(R.id.dummy_activity_wrapper) | ||
val view = activity.layoutInflater.inflate(R.layout.test_mistica_recycler_view, wrapper, false) | ||
activity.setContentView(view) | ||
|
||
val list: MisticaRecyclerView = view.findViewById(R.id.test_list) | ||
list.adapter = ClickableListAdapter() | ||
compareScreenshot(Espresso.onView(ViewMatchers.withId(R.id.test_recycler_view))) | ||
} | ||
} | ||
|
||
class ListViewHolder(val rowView: ListRowView) : RecyclerView.ViewHolder(rowView) | ||
class ClickableListAdapter : RecyclerView.Adapter<ListViewHolder>() { | ||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ListViewHolder { | ||
return ListViewHolder( | ||
LayoutInflater.from(parent.context).inflate( | ||
R.layout.sheet_list_row_selectable_item, | ||
parent, | ||
false | ||
) as ListRowView | ||
) | ||
} | ||
|
||
override fun getItemCount(): Int = 2 | ||
|
||
override fun onBindViewHolder(holder: ListViewHolder, position: Int) { | ||
holder.rowView.setTitle("Row $position") | ||
} | ||
} | ||
|
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:id="@+id/test_recycler_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="16dp" | ||
android:orientation="vertical" | ||
> | ||
|
||
<com.telefonica.mistica.list.MisticaRecyclerView | ||
android:id="@+id/test_list" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="8dp" | ||
android:nestedScrollingEnabled="false" | ||
app:listLayoutType="full_width" | ||
/> | ||
Comment on lines
+11
to
+18
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. Perhaps this could also be created programmatically and inserted in the dummy layout. But I'm not against this, if we need to test several MisticaRecyclerView elements perhaps it's simpler this way. And it's only a layout in the test directory, should be fine. 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. I think this approach is simpler and, as you said, the layout is only added to the test directory :) |
||
</LinearLayout> |
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.
Shouldn't also be the screenshot (the image) here in the PR?
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.
Done!