Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions buildSrc/src/main/kotlin/paparazzi.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Software Name: OUDS Android
* SPDX-FileCopyrightText: Copyright (c) Orange SA
* SPDX-License-Identifier: MIT
*
* This software is distributed under the MIT license,
* the text of which is available at https://opensource.org/license/MIT/
* or see the "LICENSE" file for more details.
*
* Software description: Android library of reusable graphical components
*/

import org.gradle.api.DefaultTask

private val failuresDir = project.layout.buildDirectory.dir("paparazzi/failures").get().asFile

tasks.register<DefaultTask>("updatePaparazziFailures") {
group = "verification"
// Clean failures directory first to avoid copying old failures
dependsOn(tasks["cleanPaparazziFailures"])
// Using finalizedBy in conjunction with mustRunAfter allows to run verifyPaparazzi and copyPaparazziFailures
// in that order even if verifyPaparazzi fails
tasks["cleanPaparazziFailures"].finalizedBy("verifyPaparazzi", "copyPaparazziFailures")
tasks["copyPaparazziFailures"].mustRunAfter(tasks["verifyPaparazzi"])
}

tasks.register<DefaultTask>("cleanPaparazziFailures") {
doLast {
if (failuresDir.exists()) {
failuresDir.deleteRecursively()
logger.lifecycle("Cleaned failures in ${project.name}.")
}
}
}

tasks.register<DefaultTask>("copyPaparazziFailures") {
doLast {
val snapshotsDir = File("${project.projectDir}/src/test/snapshots/images")

// Get all PNG files except delta comparison images
val failureFiles = failuresDir.walkTopDown()
.filter { it.isFile && it.extension == "png" && !it.name.startsWith("delta-") }
.toList()

// Ensure snapshots directory exists
snapshotsDir.mkdirs()

// Copy failure files to snapshots directory
failureFiles.forEach { failureFile ->
val snapshotFile = snapshotsDir.resolve(failureFile.name)
failureFile.copyTo(snapshotFile, overwrite = true)
}

if (failureFiles.isEmpty()) {
logger.lifecycle("No snapshots updated in ${project.name}.")
} else {
val snapshotPlural = if (failureFiles.count() > 1) "s" else ""
logger.lifecycle("Updated ${failureFiles.count()} snapshot$snapshotPlural in ${project.name}.")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,31 @@
package com.orange.ouds.core.test

import com.orange.ouds.core.utilities.OudsPreviewableComponent
import org.junit.experimental.runners.Enclosed
import org.junit.runner.RunWith
import org.junit.runners.Parameterized

@RunWith(Parameterized::class)
internal class OudsAlertMessageTest(parameter: Any) : OudsComponentSnapshotTest(
OudsPreviewableComponent.AlertMessage,
parameter,
OudsComponentTestSuite.theme,
heightDp = OudsPreviewableComponent.AlertMessage.PreviewHeightDp
) {
@RunWith(Enclosed::class)
internal class OudsAlertMessageTest {

companion object {
@JvmStatic
@Parameterized.Parameters
internal fun data() = OudsPreviewableComponent.AlertMessage.parameters
@RunWith(Parameterized::class)
class Default(parameter: Any) : OudsComponentSnapshotTest(
OudsPreviewableComponent.AlertMessage.Default,
parameter,
OudsComponentTestSuite.theme,
heightDp = OudsPreviewableComponent.AlertMessage.Default.PreviewHeightDp
) {

companion object {
@JvmStatic
@Parameterized.Parameters
internal fun data() = OudsPreviewableComponent.AlertMessage.Default.parameters
}
}
}

class WithRichText : OudsComponentSnapshotTest(
OudsPreviewableComponent.AlertMessage.WithRichText,
null,
OudsComponentTestSuite.theme
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,10 @@ internal class OudsBulletListTest {
internal fun data() = OudsPreviewableComponent.BulletList.Rtl.parameters
}
}

class WithRichText : OudsComponentSnapshotTest(
OudsPreviewableComponent.BulletList.WithRichText,
null,
OudsComponentTestSuite.theme
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,10 @@ internal class OudsCheckboxItemTest {
internal fun data() = OudsPreviewableComponent.CheckboxItem.ConstrainedMaxWidth.parameters
}
}
}

class WithRichText : OudsComponentSnapshotTest(
OudsPreviewableComponent.CheckboxItem.WithRichText,
null,
OudsComponentTestSuite.theme
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,39 @@
package com.orange.ouds.core.test

import com.orange.ouds.core.utilities.OudsPreviewableComponent
import org.junit.experimental.runners.Enclosed
import org.junit.runner.RunWith
import org.junit.runners.Parameterized

@RunWith(Parameterized::class)
internal class OudsPasswordInputTest(parameter: Any) : OudsComponentSnapshotTest(
OudsPreviewableComponent.PasswordInput,
parameter,
OudsComponentTestSuite.theme,
heightDp = OudsPreviewableComponent.PasswordInput.PreviewHeightDp
) {
@RunWith(Enclosed::class)
internal class OudsPasswordInputTest {

companion object {
@JvmStatic
@Parameterized.Parameters
internal fun data() = OudsPreviewableComponent.PasswordInput.parameters
@RunWith(Parameterized::class)
class Default(parameter: Any) : OudsComponentSnapshotTest(
OudsPreviewableComponent.PasswordInput.Default,
parameter,
OudsComponentTestSuite.theme,
heightDp = OudsPreviewableComponent.PasswordInput.Default.PreviewHeightDp
) {

companion object {
@JvmStatic
@Parameterized.Parameters
internal fun data() = OudsPreviewableComponent.PasswordInput.Default.parameters
}
}

@RunWith(Parameterized::class)
class WithRichText(parameter: Any) : OudsComponentSnapshotTest(
OudsPreviewableComponent.PasswordInput.WithRichText,
parameter,
OudsComponentTestSuite.theme
) {

companion object {
@JvmStatic
@Parameterized.Parameters
internal fun data() = OudsPreviewableComponent.PasswordInput.WithRichText.parameters
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,18 @@ internal class OudsPinCodeInputTest {
internal fun data() = OudsPreviewableComponent.PinCodeInput.WithRoundedCorners.parameters
}
}

@RunWith(Parameterized::class)
class WithRichText(parameter: Any) : OudsComponentSnapshotTest(
OudsPreviewableComponent.PinCodeInput.WithRichText,
parameter,
OudsComponentTestSuite.theme
) {

companion object {
@JvmStatic
@Parameterized.Parameters
internal fun data() = OudsPreviewableComponent.PinCodeInput.WithRichText.parameters
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,10 @@ internal class OudsRadioButtonItemTest {
internal fun data() = OudsPreviewableComponent.RadioButtonItem.ConstrainedMaxWidth.parameters
}
}
}

class WithRichText : OudsComponentSnapshotTest(
OudsPreviewableComponent.RadioButtonItem.WithRichText,
null,
OudsComponentTestSuite.theme
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,10 @@ internal class OudsSwitchItemTest {
internal fun data() = OudsPreviewableComponent.SwitchItem.ConstrainedMaxWidth.parameters
}
}

class WithRichText : OudsComponentSnapshotTest(
OudsPreviewableComponent.SwitchItem.WithRichText,
null,
OudsComponentTestSuite.theme
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,18 @@ internal class OudsTextAreaTest {
internal fun data() = OudsPreviewableComponent.TextArea.MultiLineValue.parameters
}
}

@RunWith(Parameterized::class)
class WithRichText(parameter: Any) : OudsComponentSnapshotTest(
OudsPreviewableComponent.TextArea.WithRichText,
parameter,
OudsComponentTestSuite.theme
) {

companion object {
@JvmStatic
@Parameterized.Parameters
internal fun data() = OudsPreviewableComponent.TextArea.WithRichText.parameters
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,18 @@ internal class OudsTextInputTest {
internal fun data() = OudsPreviewableComponent.TextInput.ConstrainedMaxWidth.parameters
}
}

@RunWith(Parameterized::class)
class WithRichText(parameter: Any) : OudsComponentSnapshotTest(
OudsPreviewableComponent.TextInput.WithRichText,
parameter,
OudsComponentTestSuite.theme
) {

companion object {
@JvmStatic
@Parameterized.Parameters
internal fun data() = OudsPreviewableComponent.TextInput.WithRichText.parameters
}
}
}
Loading
Loading