Skip to content

Commit

Permalink
Update roborazzi to v1.37.0 (#1836)
Browse files Browse the repository at this point in the history
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
|
[io.github.takahirom.roborazzi](https://redirect.github.com/takahirom/roborazzi)
| plugin | minor | `1.34.0` -> `1.37.0` |
|
[io.github.takahirom.roborazzi:roborazzi-junit-rule](https://redirect.github.com/takahirom/roborazzi)
| dependencies | minor | `1.34.0` -> `1.37.0` |
|
[io.github.takahirom.roborazzi:roborazzi-compose](https://redirect.github.com/takahirom/roborazzi)
| dependencies | minor | `1.34.0` -> `1.37.0` |
|
[io.github.takahirom.roborazzi:roborazzi](https://redirect.github.com/takahirom/roborazzi)
| dependencies | minor | `1.34.0` -> `1.37.0` |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>takahirom/roborazzi (io.github.takahirom.roborazzi)</summary>

###
[`v1.37.0`](https://redirect.github.com/takahirom/roborazzi/releases/tag/1.37.0)

[Compare
Source](https://redirect.github.com/takahirom/roborazzi/compare/1.36.0...1.37.0)

##### Bug Fixes and Workarounds

##### Compose AlertDialog Support

Support for capturing Alert Dialogs has been fixed, ensuring correct
screenshot display. `captureScreenRoboImage()`, which merges all
windows, is now used only when multiple windows are present. Thanks to
[@&#8203;ashughes](https://redirect.github.com/ashughes) for reporting
this and to [@&#8203;mhidaka](https://redirect.github.com/mhidaka) and
[@&#8203;hiroaki404](https://redirect.github.com/hiroaki404) for
bringing it to my attention at a Japan Android testing event.

<img width="366" alt="image"
src="https://github.com/user-attachments/assets/e339de2e-ea28-44e8-9946-a24fa22a5286"
/>

##### Workaround for Overlap Handling for SDK 35 Compose Screenshots
##### Problem

When updating to SDK 35 and using the default theme, the ActionBar is
included in screenshots, leading to overlap when using
`createComposeRule()`. This occurs because `createComposeRule()` uses
the default theme by default. Thank you for letting me know about this,
[@&#8203;keyboardsurfer](https://redirect.github.com/keyboardsurfer)!

<img width=400
src=https://github.com/user-attachments/assets/ba5f29ae-24bb-48f9-aa27-f335f80b784f
/>

I have filed an issue for this:
https://issuetracker.google.com/issues/383368165

##### Why this happens

SDK 35 enforces edge-to-edge display, which means it **does not provide
automatic padding for the ActionBar**.

##### How Roborazzi currently workarounds this

Roborazzi now automatically hides the ActionBar when taking screenshots
on SDK 35 and higher. This functions similarly to
`view.getActivity()?.actionBar?.hide()`. However, this workaround may
cause performance issues and should not be relied upon. Roborazzi
outputs warning logs with alternative suggestions. Thank you to
[@&#8203;sergio-sastre](https://redirect.github.com/sergio-sastre) for
advising on this workaround!

**If you need to include the ActionBar in screenshots,** Roborazzi
provides a flag, `roborazzi.compose.actionbar.overlap.fix=false`, that
can be added to your `gradle.properties` file.

##### What should we do?

A permanent solution will likely require changes from Google. In the
meantime, adding `<application
android:theme="@&#8203;style/android:Theme.Material.Light.NoActionBar"
/>` to the module's `src/test/AndroidManifest.xml` file changes the
Activity's default theme and resolves the issue. Thank you to
[@&#8203;mattinger](https://redirect.github.com/mattinger) for finding
this!


[https://github.com/takahirom/roborazzi/issues/598#issuecomment-2533372700](https://redirect.github.com/takahirom/roborazzi/issues/598#issuecomment-2533372700)

##### Stabilized Output for Dump Screenshots

Thanks to
[@&#8203;siarhei-luskanau](https://redirect.github.com/siarhei-luskanau)
for contributing an improvement that reduces unnecessary diffs for the
Roborazzi dump feature.

##### New Features

##### Add `inspectionMode()` for Compose Previews

Thanks to
[@&#8203;YusukeMoriJapan](https://redirect.github.com/YusukeMoriJapan)'s
contribution, `inspectionMode()` is now available in
`RoborazziComposeOptions`. This is particularly useful when working with
libraries that have specific preview implementations. This mode is off
by default to maintain high fidelity.

Here's how to enable it:

```kotlin
captureRoboImage(
    roborazziComposeOptions = RoborazziComposeOptions {
        inspectionMode(true)
    }
) {
    ...
}
```

***

##### What's Changed

- Fix document build by
[@&#8203;takahirom](https://redirect.github.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/597](https://redirect.github.com/takahirom/roborazzi/pull/597)
- Sort units and actions of ComposePrintToString to stabilize output in
Dump screenshots. by
[@&#8203;siarhei-luskanau](https://redirect.github.com/siarhei-luskanau)
in
[https://github.com/takahirom/roborazzi/pull/600](https://redirect.github.com/takahirom/roborazzi/pull/600)
- Update API version for sample by
[@&#8203;takahirom](https://redirect.github.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/601](https://redirect.github.com/takahirom/roborazzi/pull/601)
- add localInspectionMode property to RoborazziComposeOptions by
[@&#8203;YusukeMoriJapan](https://redirect.github.com/YusukeMoriJapan)
in
[https://github.com/takahirom/roborazzi/pull/588](https://redirect.github.com/takahirom/roborazzi/pull/588)
- \[Refactor] Separate compose lambda test by
[@&#8203;takahirom](https://redirect.github.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/606](https://redirect.github.com/takahirom/roborazzi/pull/606)
- Add elevation for PreviewNormal preview test by
[@&#8203;takahirom](https://redirect.github.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/608](https://redirect.github.com/takahirom/roborazzi/pull/608)
- Fix alert dialog support by
[@&#8203;takahirom](https://redirect.github.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/555](https://redirect.github.com/takahirom/roborazzi/pull/555)
- Add default theme test by
[@&#8203;takahirom](https://redirect.github.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/603](https://redirect.github.com/takahirom/roborazzi/pull/603)
- Revert compileSdk and targetSdk for library by
[@&#8203;takahirom](https://redirect.github.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/609](https://redirect.github.com/takahirom/roborazzi/pull/609)
- Add overlap workaround by
[@&#8203;takahirom](https://redirect.github.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/604](https://redirect.github.com/takahirom/roborazzi/pull/604)

##### New Contributors

-
[@&#8203;siarhei-luskanau](https://redirect.github.com/siarhei-luskanau)
made their first contribution in
[https://github.com/takahirom/roborazzi/pull/600](https://redirect.github.com/takahirom/roborazzi/pull/600)

**Full Changelog**:
takahirom/roborazzi@1.36.0...1.37.0

###
[`v1.36.0`](https://redirect.github.com/takahirom/roborazzi/releases/tag/1.36.0)

[Compare
Source](https://redirect.github.com/takahirom/roborazzi/compare/1.35.0...1.36.0)

##### Behavior Changes to `roborazzi.outputDir.set(file("somedir"))` in
`build.gradle`

Previously, when modifying `roborazzi.outputDir`, such as setting it to
`src/screenshots`, this option also affected the paths for comparison
images, like `foo_compare.png`. This behavior often caused issues, such
as unintentionally saving comparison images to version control systems
(e.g., Git). To address this, we have discontinued this behavior.
Comparison images are now saved in `build/outputs/roborazzi` by default,
while the behavior for reference images remains unchanged.

For users who wish to customize the path for comparison images, we have
introduced a new option: `roborazzi.compare.outputDir`.

While I don't believe there are strong use cases for this, if you want
to save the comparison images in a custom directory as you did before,
you can specify `roborazzi.compare.outputDir` as follows:

```kotlin
roborazzi {
  outputDir.set(file("src/screenshots"))
  compare {
    outputDir.set(file("src/screenshots"))
  }
}
```

I believe this adjustment will be highly beneficial for most use cases
involving changes to `outputDir`.

> \[!NOTE]
> By default, when you use `captureRoboImage("image.png")`, the image
will be saved as `module/image.png`.\
> You can customize the file path strategy for the recorded image. The
default strategy is `relativePathFromCurrentDirectory`. If you select
`relativePathFromRoborazziContextOutputDirectory`, the file will be
saved in the output directory specified by `roborazzi.outputDir`.\
> This can be configured in your `gradle.properties` file:
>
> ```properties
>
roborazzi.record.filePathStrategy=relativePathFromRoborazziContextOutputDirectory
> ```

##### What's Changed

- \[Not library dependency update for users] Update dependency
org.robolectric:robolectric to v4.14.1 by
[@&#8203;renovate](https://redirect.github.com/renovate) in
[https://github.com/takahirom/roborazzi/pull/583](https://redirect.github.com/takahirom/roborazzi/pull/583)
- Add roborazzi.compare.output.dir gradle.properties by
[@&#8203;takahirom](https://redirect.github.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/592](https://redirect.github.com/takahirom/roborazzi/pull/592)
- Add README section of outputDir by
[@&#8203;takahirom](https://redirect.github.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/593](https://redirect.github.com/takahirom/roborazzi/pull/593)
- Fix documentation README tag problem by
[@&#8203;takahirom](https://redirect.github.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/594](https://redirect.github.com/takahirom/roborazzi/pull/594)

**Full Changelog**:
takahirom/roborazzi@1.35.0...1.36.0

###
[`v1.35.0`](https://redirect.github.com/takahirom/roborazzi/releases/tag/1.35.0)

[Compare
Source](https://redirect.github.com/takahirom/roborazzi/compare/1.34.0...1.35.0)

##### Add support for heightDp, widthDp, showBackground, and
backgroundColor of Compose Preview parameters

We have introduced [**Experimental Compose Preview Support in
1.22.0**](https://takahirom.github.io/roborazzi/preview-support.html),
but it does not yet support all parameters of the `@Preview` annotation.
Thanks to
[@&#8203;sergio-sastre](https://redirect.github.com/sergio-sastre) 's
pull request, the Experimental Compose Preview Support now includes
support for heightDp, widthDp, showBackground, and backgroundColor.

##### Introduce RoborazziComposeOptions

To accommodate the changes in preview parameters, we’ve made the API
more flexible.

We’ve added the `RoborazziComposeOptions` parameter to
`ComposablePreview<AndroidPreviewInfo>.captureRoboImage()` and the
composable function version, `captureRoboImage{}`. Previously, the API
was limited; for example, you couldn’t access the ActivityScenario or
the composable function directly. Now, you have full control over these
components. Thank you for your code review
[@&#8203;sergio-sastre](https://redirect.github.com/sergio-sastre)

Here’s an example of a custom option:

```kotlin
    captureRoboImage(
      roborazziComposeOptions = RoborazziComposeOptions {
        // We have several options to configure the test environment.
        fontScale(2f)
        // We can also configure the activity scenario and the composable content.
        addOption(
          object : RoborazziComposeComposableOption,
            RoborazziComposeActivityScenarioOption {
            override fun configureWithActivityScenario(scenario: ActivityScenario<out Activity>) {
              scenario.onActivity {
                it.window.decorView.setBackgroundColor(Color.BLUE)
              }
            }

            override fun configureWithComposable(content: @&#8203;Composable () -> Unit): @&#8203;Composable () -> Unit {
              return {
                Box(Modifier
                  .padding(10.dp)
                  .background(color = androidx.compose.ui.graphics.Color.Red)
                  .padding(10.dp)
                ) {
                  content()
                }
              }
            }
          }
        )
      },
    ) {
      Text("Hello Compose!")
    }
```


![image](https://redirect.github.com/user-attachments/assets/5ef30741-b9de-42a5-8d40-a146ac0453bd)

##### Breaking Change: `fun
ComposablePreview<AndroidPreviewInfo>.applyToRobolectricConfiguration()`
is now deprecated and marked as an error

As part of our updates to how composables are configured, the
`applyToRobolectricConfiguration()` function is now deprecated and
marked as an error. Instead, you can use one of the following
alternatives:

- `previewInfo.toRoborazziComposeOptions().apply(scenario,
composeContent)`
-
`ComposablePreview<AndroidPreviewInfo>.captureRoboImage(roborazziComposeOptions)`

We believe this feature is not widely used, and the migration should be
straightforward. However, if you encounter any issues, please don’t
hesitate to reach out.

##### Breaking Change: Composable `captureRoboImage{}` Behavior Change

We intended to use a transparent background for the Compose
`captureRoboImage` function, but it was not applied due to Robolectric's
resource merging mechanism. We have fixed this behavior; however, this
change will result in altered screenshots. You can now specify the
background in the new `RoborazziComposeOptions` as we had previously.

```kotlin
@&#8203;Test
fun captureComposeLambdaImage() {
    captureRoboImage(
        roborazziComposeOptions = RoborazziComposeOptions {
            background(
                showBackground = true
            )
        }
    ) {
        Text("Hello Compose!")
    }
}
```

##### What's Changed

- \[Not Library dependency Update] Update dependency
androidx.compose.runtime:runtime to v1.7.5 by
[@&#8203;renovate](https://redirect.github.com/renovate) in
[https://github.com/takahirom/roborazzi/pull/548](https://redirect.github.com/takahirom/roborazzi/pull/548)
- Add .gitignore by
[@&#8203;takahirom](https://redirect.github.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/578](https://redirect.github.com/takahirom/roborazzi/pull/578)
- Refactor Add support for heightDp, widthDp, showBackground,
backgroundColor by
[@&#8203;takahirom](https://redirect.github.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/577](https://redirect.github.com/takahirom/roborazzi/pull/577)
- Add support for heightDp, widthDp, showBackground, backgroundColor by
[@&#8203;sergio-sastre](https://redirect.github.com/sergio-sastre) in
[https://github.com/takahirom/roborazzi/pull/576](https://redirect.github.com/takahirom/roborazzi/pull/576)
- Rename Applier to Config by
[@&#8203;takahirom](https://redirect.github.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/579](https://redirect.github.com/takahirom/roborazzi/pull/579)
- Refactor naming by
[@&#8203;takahirom](https://redirect.github.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/582](https://redirect.github.com/takahirom/roborazzi/pull/582)
- Add Assertion for minus or zero fontScale by
[@&#8203;takahirom](https://redirect.github.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/584](https://redirect.github.com/takahirom/roborazzi/pull/584)
- Add a deprecated method of
ComposablePreview<AndroidPreviewInfo>.applyToRobolectricConfiguration()
as it was a ExperimentalApi by
[@&#8203;takahirom](https://redirect.github.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/585](https://redirect.github.com/takahirom/roborazzi/pull/585)
- Adjustment for compose preview config by
[@&#8203;takahirom](https://redirect.github.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/586](https://redirect.github.com/takahirom/roborazzi/pull/586)
- Refactor RoborazziComposeConfigBuilder by
[@&#8203;takahirom](https://redirect.github.com/takahirom) in
[https://github.com/takahirom/roborazzi/pull/590](https://redirect.github.com/takahirom/roborazzi/pull/590)

**Full Changelog**:
takahirom/roborazzi@1.34.0...1.35.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://redirect.github.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS41Ny4xIiwidXBkYXRlZEluVmVyIjoiMzkuNzIuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

---------

Co-authored-by: Josh Stagg <[email protected]>
  • Loading branch information
slack-oss-bot and stagg authored Dec 18, 2024
1 parent 70ffb49 commit d061c28
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ okio = "3.9.1"
paparazzi = "1.3.5"
picnic = "0.7.0"
robolectric = "4.14.1"
roborazzi = "1.34.0"
roborazzi = "1.37.0"
skie = "0.10.0"
spotless = "7.0.0.BETA2"
sqldelight = "2.0.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onRoot
import coil.annotation.ExperimentalCoilApi
import com.github.takahirom.roborazzi.ExperimentalRoborazziApi
import com.github.takahirom.roborazzi.RoborazziRule
import com.github.takahirom.roborazzi.RoborazziTransparentActivity
import com.github.takahirom.roborazzi.captureRoboImage
Expand Down Expand Up @@ -63,7 +62,6 @@ class PetListSnapshotTest(private val useDarkMode: Boolean) {

@get:Rule val composeTestRule = createAndroidComposeRule<RoborazziTransparentActivity>()

@OptIn(ExperimentalRoborazziApi::class)
@get:Rule
val roborazziRule =
RoborazziRule(
Expand Down
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.

0 comments on commit d061c28

Please sign in to comment.