Skip to content

Commit

Permalink
ANDROID-14098 add roborazzi tests for the xml layout
Browse files Browse the repository at this point in the history
  • Loading branch information
jeprubio committed Dec 19, 2023
1 parent 396f739 commit 2aa3ecc
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
Binary file added library/screenshots/check_ListRowView_xml.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.telefonica.mistica.list

import android.widget.FrameLayout
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 ListRowViewTest: ScreenshotsTest() {
@get:Rule
val rule = activityScenarioRule<DummyActivity>()

@Test
fun `check ListRowView xml`() {
rule.scenario.onActivity { activity ->
val wrapper: FrameLayout = activity.findViewById(R.id.dummy_activity_wrapper)
activity.layoutInflater.inflate(R.layout.test_list_row_view, wrapper, true)

compareScreenshot(Espresso.onView(ViewMatchers.withId(R.id.dummy_activity_wrapper)))
}
}
}
14 changes: 14 additions & 0 deletions library/src/test/res/drawable/placeholder.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="200dp"
android:height="200dp"
android:viewportWidth="120"
android:viewportHeight="120">
<path
android:pathData="M0,0h120v120h-120z"
android:fillColor="#EFF1F3"/>
<path
android:pathData="M7.71,18.03C7.73,15.2 10.02,12.91 12.85,12.89h93.3c2.84,0 5.14,2.3 5.14,5.14v82.93c-0.02,2.83 -2.31,5.12 -5.14,5.14H12.85c-2.84,-0 -5.14,-2.3 -5.14,-5.14zM100.93,23.25H18.07v72.5l48.12,-48.13c2.02,-2.02 5.3,-2.02 7.32,0L100.93,75.09ZM28.43,43.96c0,5.72 4.64,10.36 10.36,10.36 5.72,0 10.36,-4.64 10.36,-10.36 0,-5.72 -4.64,-10.36 -10.36,-10.36 -5.72,0 -10.36,4.64 -10.36,10.36z"
android:strokeWidth="1.97283"
android:fillColor="#687787"
android:fillType="evenOdd"/>
</vector>
46 changes: 46 additions & 0 deletions library/src/test/res/layout/test_list_row_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?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:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:orientation="vertical">

<com.telefonica.mistica.list.ListRowView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:listRowActionLayout="@layout/list_row_chevron_action"
app:listRowAssetDrawable="@drawable/placeholder"
app:listRowBadgeCount="gone"
app:listRowBadgeVisible="false"
app:listRowDescription="Test Subtitle"
app:listRowAssetType="image_rounded"
app:listRowIsBoxed="true"
app:listRowTitle="Image 32 x 32"
app:listRowAssetHeight="32"
app:listRowAssetWidth="32" />
<com.telefonica.mistica.list.ListRowView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:listRowActionLayout="@layout/list_row_chevron_action"
app:listRowAssetDrawable="@drawable/placeholder"
app:listRowBadgeCount="gone"
app:listRowBadgeVisible="false"
app:listRowDescription="Test Subtitle"
app:listRowAssetType="image_rounded"
app:listRowIsBoxed="true"
app:listRowTitle="Image 64 x 64"
app:listRowAssetHeight="64"
app:listRowAssetWidth="64" />
<com.telefonica.mistica.list.ListRowView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:listRowActionLayout="@layout/list_row_chevron_action"
app:listRowAssetDrawable="@drawable/placeholder"
app:listRowBadgeCount="gone"
app:listRowBadgeVisible="false"
app:listRowDescription="Test Subtitle"
app:listRowAssetType="image_1_1"
app:listRowIsBoxed="true"
app:listRowTitle="Image_1_1" />
</LinearLayout>

0 comments on commit 2aa3ecc

Please sign in to comment.