aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Judd <sam.a.judd@gmail.com>2023-09-02 22:23:08 -0700
committerSam <sam.a.judd@gmail.com>2023-09-02 23:39:04 -0700
commitcbdc1e78b4ee0f335054bb2781f46cf8db82f914 (patch)
tree34661b33af538ace5aa43ca696f6c74a0affdd4b
parent3472f80fc0b258e0962ff1966255d5284e2a40d1 (diff)
downloadglide-cbdc1e78b4ee0f335054bb2781f46cf8db82f914.tar.gz
Add device attribtues to golden file names
-rw-r--r--integration/compose/build.gradle25
-rw-r--r--integration/compose/src/androidTest/assets/glideImage_startsAnimatedDrawable_2.625_33.png (renamed from integration/compose/src/androidTest/assets/glideImage_startsAnimatedDrawable.png)bin6344 -> 6344 bytes
-rw-r--r--integration/compose/src/androidTest/assets/glideImage_startsAnimatedDrawable_2.75_34.pngbin0 -> 7380 bytes
-rw-r--r--integration/compose/src/androidTest/assets/glideImage_withDrawBehind_drawsImageOnTopOfBackground_2.625_33.png (renamed from integration/compose/src/androidTest/assets/glideImage_withDrawBehind_drawsImageOnTopOfBackground.png)bin10416 -> 10416 bytes
-rw-r--r--integration/compose/src/androidTest/assets/glideImage_withDrawBehind_drawsImageOnTopOfBackground_2.75_34.pngbin0 -> 10427 bytes
-rw-r--r--integration/compose/src/androidTest/assets/glideImage_withPadding_appliesPaddingOnce_2.625_33.png (renamed from integration/compose/src/androidTest/assets/glideImage_withPadding_appliesPaddingOnce.png)bin32888 -> 32888 bytes
-rw-r--r--integration/compose/src/androidTest/assets/glideImage_withPadding_appliesPaddingOnce_2.75_34.pngbin0 -> 32888 bytes
-rw-r--r--integration/compose/src/androidTest/assets/glideSubcomposition_withPadding_appliesPaddingOnce_2.625_33.png (renamed from integration/compose/src/androidTest/assets/glideSubcomposition_withPadding_appliesPaddingOnce.png)bin2131 -> 2131 bytes
-rw-r--r--integration/compose/src/androidTest/assets/glideSubcomposition_withPadding_appliesPaddingOnce_2.75_34.pngbin0 -> 2114 bytes
-rw-r--r--integration/compose/src/androidTest/java/com/bumptech/glide/test/goldens.kt11
10 files changed, 34 insertions, 2 deletions
diff --git a/integration/compose/build.gradle b/integration/compose/build.gradle
index db26ff18..82028230 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
index abb73212..abb73212 100644
--- a/integration/compose/src/androidTest/assets/glideImage_startsAnimatedDrawable.png
+++ b/integration/compose/src/androidTest/assets/glideImage_startsAnimatedDrawable_2.625_33.png
Binary files differ
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 00000000..42daa9ab
--- /dev/null
+++ b/integration/compose/src/androidTest/assets/glideImage_startsAnimatedDrawable_2.75_34.png
Binary files 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
index e6da9a36..e6da9a36 100644
--- a/integration/compose/src/androidTest/assets/glideImage_withDrawBehind_drawsImageOnTopOfBackground.png
+++ b/integration/compose/src/androidTest/assets/glideImage_withDrawBehind_drawsImageOnTopOfBackground_2.625_33.png
Binary files differ
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 00000000..ac722d0a
--- /dev/null
+++ b/integration/compose/src/androidTest/assets/glideImage_withDrawBehind_drawsImageOnTopOfBackground_2.75_34.png
Binary files 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
index 2fbf3bc4..2fbf3bc4 100644
--- a/integration/compose/src/androidTest/assets/glideImage_withPadding_appliesPaddingOnce.png
+++ b/integration/compose/src/androidTest/assets/glideImage_withPadding_appliesPaddingOnce_2.625_33.png
Binary files differ
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 00000000..2fbf3bc4
--- /dev/null
+++ b/integration/compose/src/androidTest/assets/glideImage_withPadding_appliesPaddingOnce_2.75_34.png
Binary files 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
index be29ef15..be29ef15 100644
--- a/integration/compose/src/androidTest/assets/glideSubcomposition_withPadding_appliesPaddingOnce.png
+++ b/integration/compose/src/androidTest/assets/glideSubcomposition_withPadding_appliesPaddingOnce_2.625_33.png
Binary files differ
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 00000000..d3b2adc9
--- /dev/null
+++ b/integration/compose/src/androidTest/assets/glideSubcomposition_withPadding_appliesPaddingOnce_2.75_34.png
Binary files 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 8f59e09a..6e680616 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<Context>()
+ .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" }