Modern Apps git

← Modern-Apps.git

metadata: enable office screenshots automation

Commit
399d7b57dbd18199a9c2f268b4068752c190983a
Author
Vayun Mathur <[email protected]>
When
2026-07-07 00:55 UTC (5 months ago)
Parents
9180ce5

Diff

metadata_data/photos/office/1.png
diff --git a/metadata_data/photos/office/1.png b/metadata_data/photos/office/1.pngnew file mode 100644index 0000000000..d06ca6bd76Binary files /dev/null and b/metadata_data/photos/office/1.png differ
metadata_data/photos/office/2.png
diff --git a/metadata_data/photos/office/2.png b/metadata_data/photos/office/2.pngnew file mode 100644index 0000000000..6e8ecd9484Binary files /dev/null and b/metadata_data/photos/office/2.png differ
office/build.gradle.kts
diff --git a/office/build.gradle.kts b/office/build.gradle.ktsindex 0850d6657c..e43639e2bf 100644--- a/office/build.gradle.kts+++ b/office/build.gradle.kts@@ -1,5 +1,6 @@ plugins {     id("common-conventions-app")+    id("common-conventions-metadata") }  android {
office/src/androidTest/java/com/vayunmathur/office/MetadataScreenshots.kt
diff --git a/office/src/androidTest/java/com/vayunmathur/office/MetadataScreenshots.kt b/office/src/androidTest/java/com/vayunmathur/office/MetadataScreenshots.ktnew file mode 100644index 0000000000..d83ce9c2cf--- /dev/null+++ b/office/src/androidTest/java/com/vayunmathur/office/MetadataScreenshots.kt@@ -0,0 +1,55 @@+package com.vayunmathur.office++import android.graphics.Bitmap+import androidx.compose.ui.graphics.asAndroidBitmap+import androidx.compose.ui.test.captureToImage+import androidx.compose.ui.test.junit4.createAndroidComposeRule+import androidx.compose.ui.test.onNodeWithText+import androidx.compose.ui.test.onRoot+import androidx.compose.ui.test.performClick+import androidx.test.ext.junit.runners.AndroidJUnit4+import androidx.test.platform.app.InstrumentationRegistry+import org.junit.Rule+import org.junit.Test+import org.junit.runner.RunWith+import java.io.File++/**+ * Screenshot generator driven by `:office:metadata`. Leads with the document editor+ * (created via "New Doc"), followed by the offline home with the document-type options.+ */+@RunWith(AndroidJUnit4::class)+class MetadataScreenshots {++    @get:Rule+    val composeRule = createAndroidComposeRule<MainActivity>()++    private val ctx = InstrumentationRegistry.getInstrumentation().targetContext++    private val outDir: File by lazy {+        File(ctx.getExternalFilesDir(null), "metadata_screenshots").apply {+            deleteRecursively()+            mkdirs()+        }+    }++    private fun snap(index: Int) {+        composeRule.waitForIdle()+        val image = composeRule.onRoot().captureToImage()+        File(outDir, "$index.png").outputStream().use { out ->+            image.asAndroidBitmap().compress(Bitmap.CompressFormat.PNG, 100, out)+        }+    }++    @Test+    fun generateStoreScreenshots() {+        // Offline home is up at launch — second shot (New Doc / Sheet / Slides).+        Thread.sleep(1000)+        snap(2)++        // Create a new text document and let the editor's WebView render it.+        composeRule.onNodeWithText("New Doc").performClick()+        Thread.sleep(3000)+        snap(1)+    }+}