Skip to content

Commit

Permalink
POC roborazzi classic views in xmls
Browse files Browse the repository at this point in the history
  • Loading branch information
jeprubio committed Sep 22, 2023
1 parent af575ee commit f31a83e
Show file tree
Hide file tree
Showing 10 changed files with 390 additions and 6 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Expand Up @@ -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`() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<DummyActivity>()

@Before
@Throws(Exception::class)
fun setUp() {
ShadowLog.stream = System.out
}

@Test
fun `check TextInput`() {
rule.scenario.onActivity { activity ->
Expand All @@ -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}"))
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading

0 comments on commit f31a83e

Please sign in to comment.