Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add roborazzi-compose-preview-scanner-support module to handle preview settings #427

Conversation

takahirom
Copy link
Owner

No description provided.

@takahirom takahirom changed the title Add roborazzi-compose-preview-scanner-support module to handle previews Add roborazzi-compose-preview-scanner-support module to handle preview settings Jul 9, 2024
Comment on lines +25 to +27
compileOnly libs.androidx.compose.runtime
compileOnly libs.composable.preview.scanner
compileOnly libs.robolectric
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be a point of discussion, but the current approach of depending on other libraries is using compileOnly in Roborazzi to prevent making breaking changes.

Comment on lines 49 to 60
val robolectricCapturerClass =
System.getProperty("roborazzi.generateRobolectricPreview.capturer.classFQDN", null)
if (robolectricCapturerClass != null) {
val capturerClass = Class.forName(robolectricCapturerClass)
if (!RobolectricPreviewCapturer::class.java.isAssignableFrom(capturerClass)) {
throw IllegalArgumentException("The class $robolectricCapturerClass must implement RobolectricPreviewCapturer")
}
val capturer = capturerClass.getDeclaredConstructor().newInstance() as RobolectricPreviewCapturer
capturer.capture(preview)
} else {
DefaultRobolectricPreviewCapturer().capture(preview)
}
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added the flexibility to customize using your own capturer to set up custom settings.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be good to have Gradle DSL option for this class setting.

Copy link

@sergio-sastre sergio-sastre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@takahirom
It looks already good.
I just have a concern regarding the default device PIXEL4 collapsing with the default config (I've seen you can set "sdk", but can you also set "qualifiers")?
Feel free to ignore the comments if you do not find them relevant enough

}
setUiMode(preview.previewInfo.uiMode)

fun setLocale(locale: String) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor:
Just for readability, I'd just move all these methods up and then execute

val preview = this
setUiMode(preview.previewInfo.uiMode)
setLocale(preview.previewInfo.locale)
setFontScale(preview.previewInfo.fontScale)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just thought that when we change this, we might need to frequently change the caller side as well. That's why I put it here. If we have other places to apply this, I would like to separate it. I think you're right normally, but I would like to try this style.

@@ -168,17 +186,32 @@ abstract class GeneratePreviewScreenshotTestsTask : DefaultTask() {
@get:Input
var scanPackageTrees: ListProperty<String> = project.objects.listProperty(String::class.java)

@get:Input
abstract val customTestClassFQDN: Property<String>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've checked the code where this is used and I still do not understand what FQDN stands for

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant to say 'fully qualified name.' It seems that it's not a commonly used term. I'll rename this to 'customTestQualifiedClassName.' Thank you.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.reflect/-k-class/qualified-name.html

val robolectricConfig = objects.mapProperty(String::class.java, String::class.java)
.convention(
mapOf(
"sdk" to "[33]"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am missing in the README.md how this is configured. Is it via Strings? If yes, I believe that is a bit error prone since only "sdk" and "qualifiers" are allowed, and it looks like the user could easily configure sth wrong?

Copy link
Owner Author

@takahirom takahirom Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I've added 'qualifiers' to robolectricConfig and KDoc to clarify.
robolectricConfig will be passed to Robolectric's @Config annotation in the generated test class.
If the user makes a mistake, it will result in a compilation error in the generated code.

@Config(sdk = [33], qualifiers = RobolectricDeviceQualifiers.Pixel4a)

It's just a string, so users can pass the manifest file path, application class name, and maxSdk if they want.
The reason I added this option is that Robolectric's @Config has many options, and I thought users might want to set up the package for the Application class or Manifest path, and so on. However, managing all these options would be challenging.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very true. I've also realised the user could also pass the fontScale there (it is the only config that is not passed via the qualifier string). For instance:
@Config(fontScale = 1.3f)

I would say that is a Config option we could ignore for now, since I believe not so many people will use it, and add it later, unless you think that is sth trivial to handle. Would create an issue not to forget about it though.

Since there are many options, maybe also makes sense to state in the README.md what options are supported, and even throw an error for those not supported yet.

But up to you, this looks already pretty good
Your call :)

}

override fun test(preview: ComposablePreview<AndroidPreviewInfo>) {
RuntimeEnvironment.setQualifiers(RobolectricDeviceQualifiers.Pixel4a)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you are using Pixel4a, but the user could set its own default "qualifiers" together with the "sdk", right?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -38,7 +65,7 @@ fun Preview2() {
apiLevel = 30,
widthDp = 320,
heightDp = 640,
locale = "ja_JP",
locale = "ja",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always have issues to understand how locale strings look like :P but I believe "ja-rJP" should work for @previews as stated here:
https://developer.android.com/guide/topics/resources/providing-resources

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems working now. Thanks!

}

override fun test(preview: ComposablePreview<AndroidPreviewInfo>) {
RuntimeEnvironment.setQualifiers(RobolectricDeviceQualifiers.Pixel4a)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I also expected the applyToRobolectricConfiguration() to be called after setting the device...
Somehow it seems to work because in the screenshot tests the dark mode is applied.
Out of curiosity... where is that method called?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I forgot to mention. I've added a new captureRoboImage() function that takes a ComposablePreview<AndroidPreviewInfo> parameter.
I've implemented it as shown below.
Even if users don't want to use the generateRobolectricPreviewTests Extension, they can use this roborazzi-compose-preview-scanner-support module to take preview screenshot tests.

@ExperimentalRoborazziApi
fun ComposablePreview<AndroidPreviewInfo>.captureRoboImage(
  filePath: String = DefaultFileNameGenerator.generateFilePath("png"),
  roborazziOptions: RoborazziOptions = RoborazziOptions(),
) {
  val composablePreview = this
  composablePreview.applyToRobolectricConfiguration() // ← here
  captureRoboImage(filePath = filePath, roborazziOptions = roborazziOptions) {
    composablePreview()
  }
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! It is very handy indeed!

@takahirom
Copy link
Owner Author

takahirom commented Jul 9, 2024

I've added the README section.

@sergio-sastre
Copy link

sergio-sastre commented Jul 10, 2024

Snapshot diff report

File name Image
PreviewNormal_compare.png
PreviewWithProperties.Preview_Name_Preview_Group_API_LEVEL_30_W320dp_H640dp_ja-rJP_FONT_1_5f_WITH_SYSTEM_UI_WITH_BACKGROUND_BG_COLOR_4278190335_NIGHT_NEXUS_5_WALLPAPER_GREEN_DOMINATED_compare.png
PreviewDarkMode.NIGHT_compare.png

@takahirom
Minor:
I wonder what would be the name of the screenshot files if:

  • A Preview with the same test name and preview parameters is placed in another folder... Would be overwritten?

Copy link

@sergio-sastre sergio-sastre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@takahirom
It looks very good to me. I wrote a couple of comments, but feel free to ignore them or handle them in next versions.

Already accepted. Let's ship it!

@takahirom
Copy link
Owner Author

takahirom commented Jul 10, 2024

@sergio-sastre

A Preview with the same test name and preview parameters is placed in another folder... Would be overwritten?

Yes, currently it is. Recently, I found that the Compose Preview Screenshot Testing by Google has made a good approach to this( New format: pkg/class/method_suffix.png ). I think we can add it to roborazzi.record.filePathStrategy, but the issue is that we are creating a path for the preview in the DefaultRobolectricPreviewTest. To implement this, it seems we would need to obtain the package name and class name.
https://android.googlesource.com/platform/tools/base/+/565124e60ced74eb5ad4274377abc60a7283a34c

We might have to be able to use the filePathStrategy for the preview.

@sergio-sastre
Copy link

@sergio-sastre

A Preview with the same test name and preview parameters is placed in another folder... Would be overwritten?

Yes, currently it is. Recently, I found that the Compose Preview Screenshot Testing by Google has made a good approach to this( New format: pkg/class/method_suffix.png ). I think we can add it to roborazzi.record.filePathStrategy, but the issue is that we are creating a path for the preview in the DefaultRobolectricPreviewTest. To implement this, it seems we would need to obtain the package name and class name. https://android.googlesource.com/platform/tools/base/+/565124e60ced74eb5ad4274377abc60a7283a34c

We might have to be able to use the filePathStrategy for the preview.

All good. I suggest to document it is a known issue, and tackle it in one of the next releases

@takahirom
Copy link
Owner Author

image
Now it is using roborazzi.record.namingStrategy for naming. So if we add a new strategy we can use it.
f088830
https://github.com/takahirom/roborazzi?tab=readme-ov-file#roborazzirecordnamingstrategy

@takahirom
Copy link
Owner Author

I also changed the naming of generateRobolectricPreviewTests to generateRobolectric**Compose**PreviewTests.
We have Test Preview in our IDE plugin, and it would be a bit confusing otherwise.

@sergio-sastre
Copy link

sergio-sastre commented Jul 11, 2024

image Now it is using roborazzi.record.namingStrategy for naming. So if we add a new strategy we can use it. f088830 https://github.com/takahirom/roborazzi?tab=readme-ov-file#roborazzirecordnamingstrategy

Looks good!
I assume record naming strategy is the same for verifying right?

Just as remark: if the package name is too long it can lead to file not found/long name errors

I believe it is worth mentioning, in that case the user should choose another naming strategy

In my opinion, the first version looks ready 👍

@takahirom
Copy link
Owner Author

takahirom commented Jul 11, 2024

I'll release this.
But I'll rename generateRobolectricComposePreviewTests to generateComposePreviewRobolectricTests before that.

@takahirom takahirom merged commit 6622443 into takahirom/add-autoPreviewScreenshots/2024-06-26 Jul 12, 2024
6 checks passed
@takahirom takahirom deleted the takahirom/add-roborazzi-compose-preview-scanner-support/2024-07-09 branch July 12, 2024 10:31
chrisbanes pushed a commit to chrisbanes/haze that referenced this pull request Jul 14, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[io.github.takahirom.roborazzi](https://github.com/takahirom/roborazzi)
| `1.21.0` -> `1.22.1` |
[![age](https://developer.mend.io/api/mc/badges/age/maven/io.github.takahirom.roborazzi/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/io.github.takahirom.roborazzi/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/io.github.takahirom.roborazzi/1.21.0/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/io.github.takahirom.roborazzi/1.21.0/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
|
[io.github.takahirom.roborazzi:roborazzi-junit-rule](https://github.com/takahirom/roborazzi)
| `1.21.0` -> `1.22.1` |
[![age](https://developer.mend.io/api/mc/badges/age/maven/io.github.takahirom.roborazzi:roborazzi-junit-rule/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/io.github.takahirom.roborazzi:roborazzi-junit-rule/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/io.github.takahirom.roborazzi:roborazzi-junit-rule/1.21.0/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/io.github.takahirom.roborazzi:roborazzi-junit-rule/1.21.0/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
|
[io.github.takahirom.roborazzi:roborazzi-compose-desktop](https://github.com/takahirom/roborazzi)
| `1.21.0` -> `1.22.1` |
[![age](https://developer.mend.io/api/mc/badges/age/maven/io.github.takahirom.roborazzi:roborazzi-compose-desktop/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/io.github.takahirom.roborazzi:roborazzi-compose-desktop/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/io.github.takahirom.roborazzi:roborazzi-compose-desktop/1.21.0/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/io.github.takahirom.roborazzi:roborazzi-compose-desktop/1.21.0/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
|
[io.github.takahirom.roborazzi:roborazzi-compose](https://github.com/takahirom/roborazzi)
| `1.21.0` -> `1.22.1` |
[![age](https://developer.mend.io/api/mc/badges/age/maven/io.github.takahirom.roborazzi:roborazzi-compose/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/io.github.takahirom.roborazzi:roborazzi-compose/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/io.github.takahirom.roborazzi:roborazzi-compose/1.21.0/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/io.github.takahirom.roborazzi:roborazzi-compose/1.21.0/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
|
[io.github.takahirom.roborazzi:roborazzi](https://github.com/takahirom/roborazzi)
| `1.21.0` -> `1.22.1` |
[![age](https://developer.mend.io/api/mc/badges/age/maven/io.github.takahirom.roborazzi:roborazzi/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/io.github.takahirom.roborazzi:roborazzi/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/io.github.takahirom.roborazzi:roborazzi/1.21.0/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/io.github.takahirom.roborazzi:roborazzi/1.21.0/1.22.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

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

###
[`v1.22.1`](https://github.com/takahirom/roborazzi/releases/tag/1.22.1)

[Compare
Source](https://github.com/takahirom/roborazzi/compare/1.22.0...1.22.1)

### Bug fixes

We've released Experimental Compose Preview Support in
[1.22.0](https://github.com/takahirom/roborazzi/releases/tag/1.22.0).
In this release, we are going to include a bug fix for it.
The strategy of `generateComposePreviewRobolectricTests{}` is not to
modify settings automatically, but to verify that the user settings are
correct. This allows our settings to be the single source of truth.
However, the assertion had some bugs, so I fixed them.

#### What's Changed

- \[Roborazzi Idea Plugin] Generate Roborazzi images via its IntelliJ
Plugin by [@&#8203;eyedol](https://github.com/eyedol) in
[takahirom/roborazzi#429
(We will address this topic in a future release)
- \[Bug fixes] Fix assertions in Automated Test Generation for
Experimental Compose Preview Support by
[@&#8203;takahirom](https://github.com/takahirom) in
[takahirom/roborazzi#432

**Full Changelog**:
takahirom/roborazzi@1.22.0...1.22.1

###
[`v1.22.0`](https://github.com/takahirom/roborazzi/releases/tag/1.22.0)

[Compare
Source](https://github.com/takahirom/roborazzi/compare/1.21.0...1.22.0)

### Experimental Compose Preview Support 🚀

We're excited to announce the experimental release of [Compose Preview
Support for
Roborazzi](https://takahirom.github.io/roborazzi/preview-support.html),
a powerful new feature that streamlines the process of generating
screenshot tests for Jetpack Compose Previews.

#### Key Features

- **Automated Test Generation**: Automatically generate screenshot tests
for Composable Previews using the
[ComposablePreviewScanner](https://github.com/sergio-sastre/ComposablePreviewScanner)
library
- **Manual Integration Support**: For those who prefer more control,
we've added helper functions to manually integrate Compose Preview
screenshot tests.

#### How to Use

To enable Compose Preview screenshot test generation, add the following
to your `build.gradle.kts`:

```kotlin
roborazzi {
  generateComposePreviewRobolectricTests {
    enable = true
  }
}
```

After configuration, run the `recordRoborazziDebug` task to generate
screenshots using the newly created tests.

#### Customization Options

Customize your setup with options like:

-   Specifying package names to scan
-   Defining a custom test class
-   Configuring Robolectric settings

#### Manual Integration

For manual integration, add the following dependency:

```kotlin
testImplementation("io.github.takahirom.roborazzi:roborazzi-compose-preview-scanner-support:[version]")
```

Then use the `ComposablePreview<AndroidPreviewInfo>.captureRoboImage()`
function in your tests. Note that `ComposablePreview` is a class
provided by the
[ComposablePreviewScanner](https://github.com/sergio-sastre/ComposablePreviewScanner)
library, which Roborazzi utilizes for this feature.
This approach allows for more fine-grained control over the screenshot
capture process for Compose Previews.

#### Acknowledgements

Special thanks to [@&#8203;yschimke](https://github.com/yschimke) for
the initial proposal, and to
[@&#8203;sergio-sastre](https://github.com/sergio-sastre) and
[@&#8203;yschimke](https://github.com/yschimke) for their valuable
design and code reviews.

For more detailed information on setup and usage, please visit our
[documentation](https://takahirom.github.io/roborazzi/preview-support.html).

### Enhanced Accessibility Text Capture

Thanks to [@&#8203;lukas-mercari](https://github.com/lukas-mercari) 's
contribution, we've improved accessibility text dumping for merged
Compose elements. Both content descriptions and text are now captured,
providing more comprehensive accessibility information in tests.


![image](https://github.com/user-attachments/assets/9b01a6b7-616b-46f8-bed8-cb2424eb9d17)

#### What's Changed

- \[roborazzi-idea-plugin] Fix: Icons are not shown in the new UI by
[@&#8203;takahirom](https://github.com/takahirom) in
[takahirom/roborazzi#421
- \[CI]Wait for main to succeed for compare ci by
[@&#8203;takahirom](https://github.com/takahirom) in
[takahirom/roborazzi#422
- \[CI] Remove main push trigger from compare ci by
[@&#8203;takahirom](https://github.com/takahirom) in
[takahirom/roborazzi#423
- \[CI] Add unit test for WebAssets class by
[@&#8203;eyedol](https://github.com/eyedol) in
[takahirom/roborazzi#412
- \[Sample]Update dependency androidx.compose.foundation:foundation to
v1.6.8 by [@&#8203;renovate](https://github.com/renovate) in
[takahirom/roborazzi#340
- \[Bug fixes] Dump both content description as well as text for the
case when two elements are merged by
[@&#8203;lukas-mercari](https://github.com/lukas-mercari) in
[takahirom/roborazzi#430
- \[Improvement] Add roborazzi-compose-preview-scanner-support module to
handle preview settings by
[@&#8203;takahirom](https://github.com/takahirom) in
[takahirom/roborazzi#427
- \[Feature] Implement generateRobolectricPreviewTests prototype by
[@&#8203;takahirom](https://github.com/takahirom) in
[takahirom/roborazzi#416

**Full Changelog**:
takahirom/roborazzi@1.21.0...1.22.0

</details>

---

### Configuration

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

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, 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 [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/chrisbanes/haze).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MjUuMSIsInVwZGF0ZWRJblZlciI6IjM3LjQzMS40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
github-merge-queue bot pushed a commit to slackhq/circuit that referenced this pull request Jul 17, 2024
This PR contains the following updates:

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

---

> [!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.22.2`](https://github.com/takahirom/roborazzi/releases/tag/1.22.2)

[Compare
Source](https://github.com/takahirom/roborazzi/compare/1.22.1...1.22.2)

##### Notice

[RobolectricPreviewTest and
roborazzi.generateComposePreviewRobolectricTests.customTestQualifiedClassName](https://takahirom.github.io/roborazzi/preview-support.html#customizing-the-preview-screenshot-test)
are used for customizing [Experimental Compose Preview
Support](https://takahirom.github.io/roborazzi/preview-support.html).
However, the name and class signature of RobolectricPreviewTest will be
changed in a future release(not in 1.22.2) to support the Compose
Multiplatform Preview Annotation.

##### Bug fixes

We didn't have integration tests for [Experimental Compose Preview
Support](https://takahirom.github.io/roborazzi/preview-support.html), so
we added them. In KMP projects, we used to check only
`testImplementation` (androidUnitTest.dependencies.implementation is
used for KMP Android Unit tests), and the verification for
generateComposePreviewRobolectricTests{} was failing. Therefore, we have
added integration tests and fixed the behavior for KMP projects.

##### What's Changed

- Refactor Roborazzi integration tests to support multiple modules by
[@&#8203;takahirom](https://github.com/takahirom) in
[takahirom/roborazzi#434
- Fix warning of RoborazziPreviewParameterizedTests by
[@&#8203;takahirom](https://github.com/takahirom) in
[takahirom/roborazzi#436
- Fix GenerateRobolectricComposePreviewTests to support KMP by
[@&#8203;takahirom](https://github.com/takahirom) in
[takahirom/roborazzi#435

**Full Changelog**:
takahirom/roborazzi@1.22.1...1.22.2

###
[`v1.22.1`](https://github.com/takahirom/roborazzi/releases/tag/1.22.1)

[Compare
Source](https://github.com/takahirom/roborazzi/compare/1.22.0...1.22.1)

##### Bug fixes

We've released Experimental Compose Preview Support in
[1.22.0](https://github.com/takahirom/roborazzi/releases/tag/1.22.0).
In this release, we are going to include a bug fix for it.
The strategy of `generateComposePreviewRobolectricTests{}` is not to
modify settings automatically, but to verify that the user settings are
correct. This allows our settings to be the single source of truth.
However, the assertion had some bugs, so I fixed them.

##### What's Changed

- \[Roborazzi Idea Plugin] Generate Roborazzi images via its IntelliJ
Plugin by [@&#8203;eyedol](https://github.com/eyedol) in
[takahirom/roborazzi#429
(We will address this topic in a future release)
- \[Bug fixes] Fix assertions in Automated Test Generation for
Experimental Compose Preview Support by
[@&#8203;takahirom](https://github.com/takahirom) in
[takahirom/roborazzi#432

**Full Changelog**:
takahirom/roborazzi@1.22.0...1.22.1

###
[`v1.22.0`](https://github.com/takahirom/roborazzi/releases/tag/1.22.0)

[Compare
Source](https://github.com/takahirom/roborazzi/compare/1.21.0...1.22.0)

##### Experimental Compose Preview Support 🚀

We're excited to announce the experimental release of [Compose Preview
Support for
Roborazzi](https://takahirom.github.io/roborazzi/preview-support.html),
a powerful new feature that streamlines the process of generating
screenshot tests for Jetpack Compose Previews.

##### Key Features

- **Automated Test Generation**: Automatically generate screenshot tests
for Composable Previews using the
[ComposablePreviewScanner](https://github.com/sergio-sastre/ComposablePreviewScanner)
library
- **Manual Integration Support**: For those who prefer more control,
we've added helper functions to manually integrate Compose Preview
screenshot tests.

##### How to Use

To enable Compose Preview screenshot test generation, add the following
to your `build.gradle.kts`:

```kotlin
roborazzi {
  generateComposePreviewRobolectricTests {
    enable = true
  }
}
```

After configuration, run the `recordRoborazziDebug` task to generate
screenshots using the newly created tests.

##### Customization Options

Customize your setup with options like:

-   Specifying package names to scan
-   Defining a custom test class
-   Configuring Robolectric settings

##### Manual Integration

For manual integration, add the following dependency:

```kotlin
testImplementation("io.github.takahirom.roborazzi:roborazzi-compose-preview-scanner-support:[version]")
```

Then use the `ComposablePreview<AndroidPreviewInfo>.captureRoboImage()`
function in your tests. Note that `ComposablePreview` is a class
provided by the
[ComposablePreviewScanner](https://github.com/sergio-sastre/ComposablePreviewScanner)
library, which Roborazzi utilizes for this feature.
This approach allows for more fine-grained control over the screenshot
capture process for Compose Previews.

##### Acknowledgements

Special thanks to [@&#8203;yschimke](https://github.com/yschimke) for
the initial proposal, and to
[@&#8203;sergio-sastre](https://github.com/sergio-sastre) and
[@&#8203;yschimke](https://github.com/yschimke) for their valuable
design and code reviews.

For more detailed information on setup and usage, please visit our
[documentation](https://takahirom.github.io/roborazzi/preview-support.html).

##### Enhanced Accessibility Text Capture

Thanks to [@&#8203;lukas-mercari](https://github.com/lukas-mercari) 's
contribution, we've improved accessibility text dumping for merged
Compose elements. Both content descriptions and text are now captured,
providing more comprehensive accessibility information in tests.


![image](https://github.com/user-attachments/assets/9b01a6b7-616b-46f8-bed8-cb2424eb9d17)

##### What's Changed

- \[roborazzi-idea-plugin] Fix: Icons are not shown in the new UI by
[@&#8203;takahirom](https://github.com/takahirom) in
[takahirom/roborazzi#421
- \[CI]Wait for main to succeed for compare ci by
[@&#8203;takahirom](https://github.com/takahirom) in
[takahirom/roborazzi#422
- \[CI] Remove main push trigger from compare ci by
[@&#8203;takahirom](https://github.com/takahirom) in
[takahirom/roborazzi#423
- \[CI] Add unit test for WebAssets class by
[@&#8203;eyedol](https://github.com/eyedol) in
[takahirom/roborazzi#412
- \[Sample]Update dependency androidx.compose.foundation:foundation to
v1.6.8 by [@&#8203;renovate](https://github.com/renovate) in
[takahirom/roborazzi#340
- \[Bug fixes] Dump both content description as well as text for the
case when two elements are merged by
[@&#8203;lukas-mercari](https://github.com/lukas-mercari) in
[takahirom/roborazzi#430
- \[Improvement] Add roborazzi-compose-preview-scanner-support module to
handle preview settings by
[@&#8203;takahirom](https://github.com/takahirom) in
[takahirom/roborazzi#427
- \[Feature] Implement generateRobolectricPreviewTests prototype by
[@&#8203;takahirom](https://github.com/takahirom) in
[takahirom/roborazzi#416

**Full Changelog**:
takahirom/roborazzi@1.21.0...1.22.0

</details>

---

### Configuration

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

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, 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://github.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MzEuNCIsInVwZGF0ZWRJblZlciI6IjM3LjQzMi4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants