diff --git a/library/screenshots/check_TextInput_from_layout_1.png b/library/screenshots/check_TextInput_from_layout_1.png new file mode 100644 index 000000000..bc2fdc470 Binary files /dev/null and b/library/screenshots/check_TextInput_from_layout_1.png differ diff --git a/library/screenshots/check_TextInput_from_layout_2.png b/library/screenshots/check_TextInput_from_layout_2.png new file mode 100644 index 000000000..82702e758 Binary files /dev/null and b/library/screenshots/check_TextInput_from_layout_2.png differ diff --git a/library/screenshots/check_TextInput_from_layout_3.png b/library/screenshots/check_TextInput_from_layout_3.png new file mode 100644 index 000000000..2c2be05e4 Binary files /dev/null and b/library/screenshots/check_TextInput_from_layout_3.png differ diff --git a/library/screenshots/check_TextInput_from_layout_4.png b/library/screenshots/check_TextInput_from_layout_4.png new file mode 100644 index 000000000..599b7beb9 Binary files /dev/null and b/library/screenshots/check_TextInput_from_layout_4.png differ diff --git a/library/screenshots/check_TextInput_from_layout_5.png b/library/screenshots/check_TextInput_from_layout_5.png new file mode 100644 index 000000000..fcecc3963 Binary files /dev/null and b/library/screenshots/check_TextInput_from_layout_5.png differ diff --git a/library/screenshots/check_TextInput_from_layout_6.png b/library/screenshots/check_TextInput_from_layout_6.png new file mode 100644 index 000000000..6587087a6 Binary files /dev/null and b/library/screenshots/check_TextInput_from_layout_6.png differ diff --git a/library/src/test/java/com/telefonica/mistica/compose/button/ButtonKtTest.kt b/library/src/test/java/com/telefonica/mistica/compose/button/ButtonKtTest.kt index 64741d049..13b0ca095 100644 --- a/library/src/test/java/com/telefonica/mistica/compose/button/ButtonKtTest.kt +++ b/library/src/test/java/com/telefonica/mistica/compose/button/ButtonKtTest.kt @@ -73,7 +73,7 @@ internal class ButtonKtTest { private fun `then screenshot is OK`(brand: Brand) { composeTestRule.onRoot() - .captureRoboImage(ScreenshotUtils.getScreenshotName(brand)) + .captureRoboImage(ScreenshotUtils.getScreenshotName(brand = brand)) } private fun TestScope.`then the onClickListener has been invoked`() { diff --git a/library/src/test/java/com/telefonica/mistica/input/TextInputTest.kt b/library/src/test/java/com/telefonica/mistica/input/TextInputTest.kt index 94cc47f1e..efb64fd3a 100644 --- a/library/src/test/java/com/telefonica/mistica/input/TextInputTest.kt +++ b/library/src/test/java/com/telefonica/mistica/input/TextInputTest.kt @@ -1,25 +1,35 @@ package com.telefonica.mistica.input -import android.view.ViewGroup +import android.util.Log +import android.view.LayoutInflater import android.widget.FrameLayout +import android.widget.ScrollView import androidx.test.espresso.Espresso.onView import androidx.test.espresso.matcher.ViewMatchers +import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.ext.junit.rules.activityScenarioRule import com.github.takahirom.roborazzi.captureRoboImage -import com.github.takahirom.roborazzi.withViewId import com.telefonica.mistica.DummyActivity +import com.telefonica.mistica.R import com.telefonica.mistica.testutils.ScreenshotUtils +import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner -import com.telefonica.mistica.R +import org.robolectric.shadows.ShadowLog @RunWith(RobolectricTestRunner::class) internal class TextInputTest { @get:Rule val rule = activityScenarioRule() + @Before + @Throws(Exception::class) + fun setUp() { + ShadowLog.stream = System.out + } + @Test fun `check TextInput`() { rule.scenario.onActivity { activity -> @@ -31,4 +41,23 @@ internal class TextInputTest { onView(ViewMatchers.withId(R.id.dummy_activity_wrapper)).captureRoboImage(ScreenshotUtils.getScreenshotName()) } } + + @Test + fun `check TextInput from layout`() { + rule.scenario.onActivity { activity -> + val wrapper: FrameLayout = activity.findViewById(R.id.dummy_activity_wrapper) + val inflater = LayoutInflater.from(activity) + val customLayout = inflater.inflate(R.layout.screen_inputs_catalog, wrapper, false) + wrapper.setPadding(0, 0, 0, 0) + wrapper.addView(customLayout) + + repeat(times = 6) { i -> + Log.d("TextInputTest", "Scrolling to $i") + val scrollView: ScrollView = activity.findViewById(R.id.scroll_view) + scrollView.scrollTo(0, wrapper.height * i) + + onView(withId(R.id.dummy_activity_wrapper)).captureRoboImage(ScreenshotUtils.getScreenshotName(extra = "_${i + 1}")) + } + } + } } diff --git a/library/src/test/java/com/telefonica/mistica/testutils/ScreenshotUtils.kt b/library/src/test/java/com/telefonica/mistica/testutils/ScreenshotUtils.kt index ebefaf0fe..6fbdd5e8d 100644 --- a/library/src/test/java/com/telefonica/mistica/testutils/ScreenshotUtils.kt +++ b/library/src/test/java/com/telefonica/mistica/testutils/ScreenshotUtils.kt @@ -3,8 +3,8 @@ package com.telefonica.mistica.testutils import com.telefonica.mistica.compose.theme.brand.Brand object ScreenshotUtils { - fun getScreenshotName(brand: Brand? = null): String { - return "screenshots/${TestUtils.findRunningTestMethodName()}${brandName(brand)}.png" + fun getScreenshotName(brand: Brand? = null, extra: String = ""): String { + return "screenshots/${TestUtils.findRunningTestMethodName()}${brandName(brand)}${extra}.png" } private fun brandName(brand: Brand?): String { diff --git a/library/src/test/res/layout/screen_inputs_catalog.xml b/library/src/test/res/layout/screen_inputs_catalog.xml new file mode 100644 index 000000000..2ff8f7d70 --- /dev/null +++ b/library/src/test/res/layout/screen_inputs_catalog.xml @@ -0,0 +1,355 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file