diff --git a/integration/compose/build.gradle b/integration/compose/build.gradle index db26ff18db..8202823048 100644 --- a/integration/compose/build.gradle +++ b/integration/compose/build.gradle @@ -66,3 +66,28 @@ dependencies { } apply from: "${rootProject.projectDir}/scripts/upload.gradle" + +task cleanGoldensOnDevice(type: Exec) { + commandLine = ['adb', 'shell', 'rm -rf /storage/emulated/0/DCIM/compose_goldens'] +} + +task pullGoldens(type: Exec) { + commandLine = [ + 'bash', + '-c', + 'adb shell \'find /storage/emulated/0/DCIM/compose_goldens -iname "*.png"\' ' + + '| tr -d "\015" ' + + '| while read line; do adb pull "$line" src/androidTest/assets/; done' + ] + +} + +afterEvaluate { + task rebuildGoldens(type: Exec) { + ignoreExitValue = true + dependsOn( + cleanGoldensOnDevice, + tasks.getByName("connectedDebugAndroidTest").finalizedBy(pullGoldens) + ) + } +} diff --git a/integration/compose/src/androidTest/assets/glideImage_startsAnimatedDrawable.png b/integration/compose/src/androidTest/assets/glideImage_startsAnimatedDrawable_2.625_33.png similarity index 100% rename from integration/compose/src/androidTest/assets/glideImage_startsAnimatedDrawable.png rename to integration/compose/src/androidTest/assets/glideImage_startsAnimatedDrawable_2.625_33.png diff --git a/integration/compose/src/androidTest/assets/glideImage_startsAnimatedDrawable_2.75_34.png b/integration/compose/src/androidTest/assets/glideImage_startsAnimatedDrawable_2.75_34.png new file mode 100644 index 0000000000..42daa9ab03 Binary files /dev/null and b/integration/compose/src/androidTest/assets/glideImage_startsAnimatedDrawable_2.75_34.png differ diff --git a/integration/compose/src/androidTest/assets/glideImage_withDrawBehind_drawsImageOnTopOfBackground.png b/integration/compose/src/androidTest/assets/glideImage_withDrawBehind_drawsImageOnTopOfBackground_2.625_33.png similarity index 100% rename from integration/compose/src/androidTest/assets/glideImage_withDrawBehind_drawsImageOnTopOfBackground.png rename to integration/compose/src/androidTest/assets/glideImage_withDrawBehind_drawsImageOnTopOfBackground_2.625_33.png diff --git a/integration/compose/src/androidTest/assets/glideImage_withDrawBehind_drawsImageOnTopOfBackground_2.75_34.png b/integration/compose/src/androidTest/assets/glideImage_withDrawBehind_drawsImageOnTopOfBackground_2.75_34.png new file mode 100644 index 0000000000..ac722d0a77 Binary files /dev/null and b/integration/compose/src/androidTest/assets/glideImage_withDrawBehind_drawsImageOnTopOfBackground_2.75_34.png differ diff --git a/integration/compose/src/androidTest/assets/glideImage_withPadding_appliesPaddingOnce.png b/integration/compose/src/androidTest/assets/glideImage_withPadding_appliesPaddingOnce_2.625_33.png similarity index 100% rename from integration/compose/src/androidTest/assets/glideImage_withPadding_appliesPaddingOnce.png rename to integration/compose/src/androidTest/assets/glideImage_withPadding_appliesPaddingOnce_2.625_33.png diff --git a/integration/compose/src/androidTest/assets/glideImage_withPadding_appliesPaddingOnce_2.75_34.png b/integration/compose/src/androidTest/assets/glideImage_withPadding_appliesPaddingOnce_2.75_34.png new file mode 100644 index 0000000000..2fbf3bc474 Binary files /dev/null and b/integration/compose/src/androidTest/assets/glideImage_withPadding_appliesPaddingOnce_2.75_34.png differ diff --git a/integration/compose/src/androidTest/assets/glideSubcomposition_withPadding_appliesPaddingOnce.png b/integration/compose/src/androidTest/assets/glideSubcomposition_withPadding_appliesPaddingOnce_2.625_33.png similarity index 100% rename from integration/compose/src/androidTest/assets/glideSubcomposition_withPadding_appliesPaddingOnce.png rename to integration/compose/src/androidTest/assets/glideSubcomposition_withPadding_appliesPaddingOnce_2.625_33.png diff --git a/integration/compose/src/androidTest/assets/glideSubcomposition_withPadding_appliesPaddingOnce_2.75_34.png b/integration/compose/src/androidTest/assets/glideSubcomposition_withPadding_appliesPaddingOnce_2.75_34.png new file mode 100644 index 0000000000..d3b2adc913 Binary files /dev/null and b/integration/compose/src/androidTest/assets/glideSubcomposition_withPadding_appliesPaddingOnce_2.75_34.png differ diff --git a/integration/compose/src/androidTest/java/com/bumptech/glide/test/goldens.kt b/integration/compose/src/androidTest/java/com/bumptech/glide/test/goldens.kt index 8f59e09aec..6e680616bc 100644 --- a/integration/compose/src/androidTest/java/com/bumptech/glide/test/goldens.kt +++ b/integration/compose/src/androidTest/java/com/bumptech/glide/test/goldens.kt @@ -3,6 +3,7 @@ package com.bumptech.glide.test import android.content.Context import android.graphics.Bitmap import android.graphics.BitmapFactory +import android.os.Build import android.os.Environment import androidx.compose.runtime.Composable import androidx.compose.ui.graphics.ImageBitmap @@ -19,6 +20,7 @@ import java.lang.IllegalStateException const val GENERATED_FILES_DIR = "compose_goldens" const val EXTENSION = "png" +const val SEPARATOR = "_" @Composable fun Int.pxToDp() = with(LocalDensity.current) { toDp() } @@ -68,13 +70,18 @@ private fun readExistingGolden(testName: String): Bitmap? { } } -private fun testFileName(testName: String) = "$testName.$EXTENSION" - +private fun testFileName(testName: String) = "$testName$SEPARATOR${getDeviceString()}.$EXTENSION" private fun getTestFilesDir(): File { val dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM) return File(dir, GENERATED_FILES_DIR) } +private fun getDeviceString() = + "${ApplicationProvider.getApplicationContext() + .resources + .displayMetrics + .density}$SEPARATOR${Build.VERSION.SDK_INT}" + private fun writeBitmap(bitmap: Bitmap, testName: String): String { val testFilesDir = getTestFilesDir() require(!(!testFilesDir.exists() && !testFilesDir.mkdirs())) { "Failed to make directory: $testFilesDir" }