Skip to content

Commit

Permalink
Merge pull request #642 from siarhei-luskanau/ComposePrintToString3
Browse files Browse the repository at this point in the history
Print collection content in ComposePrintToString to stabilize output in Dump screenshots.
  • Loading branch information
takahirom authored Jan 25, 2025
2 parents bb57d8c + e9d6c15 commit b246902
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.github.takahirom.roborazzi

import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.semantics.AccessibilityAction
import androidx.compose.ui.semantics.CollectionInfo
import androidx.compose.ui.semantics.SemanticsConfiguration
import androidx.compose.ui.semantics.SemanticsNode
import androidx.compose.ui.semantics.SemanticsProperties
Expand Down Expand Up @@ -135,6 +136,8 @@ private fun StringBuilder.appendConfigInfo(config: SemanticsConfiguration, inden
}
} else if (value is Iterable<*>) {
append(value.sortedBy { it.toString() })
} else if (value is CollectionInfo) {
append("(rowCount=${value.rowCount}, columnCount=${value.columnCount})")
} else {
append(value)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@ import android.app.Activity
import android.graphics.Color
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.test.core.app.ActivityScenario
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.github.takahirom.roborazzi.Dump
import com.github.takahirom.roborazzi.ExperimentalRoborazziApi
import com.github.takahirom.roborazzi.RobolectricDeviceQualifiers
import com.github.takahirom.roborazzi.RoborazziComposeActivityScenarioOption
import com.github.takahirom.roborazzi.RoborazziComposeComposableOption
import com.github.takahirom.roborazzi.RoborazziComposeOptions
import com.github.takahirom.roborazzi.RoborazziOptions
import com.github.takahirom.roborazzi.activityTheme
import com.github.takahirom.roborazzi.captureRoboImage
import com.github.takahirom.roborazzi.fontScale
Expand All @@ -40,6 +43,19 @@ class ComposeLambdaTest {
}
}

@OptIn(ExperimentalRoborazziApi::class)
@Test
fun captureComposeCollection() {
captureRoboImage(
filePath = "${roborazziSystemPropertyOutputDirectory()}/manual_compose_collection.png",
roborazziOptions = RoborazziOptions(captureType = RoborazziOptions.CaptureType.Dump())
) {
Row {
listOf("Hello", "Compose!").forEach { Text(it) }
}
}
}

@OptIn(ExperimentalRoborazziApi::class)
@Test
fun whenNonTransparentThemeItShouldHaveNonTransparentBackground() {
Expand Down

0 comments on commit b246902

Please sign in to comment.