Skip to content

Conversation

@opatry
Copy link
Owner

@opatry opatry commented May 20, 2025

Description

  • Add adb_demo_mode.sh script to ease screenshot generation

  • Introduce demo flavor

  • Create pre-filled Demo content

  • Add StoreScreenshotTest to generate store screenshots programmatically

  • Only relying on TestTasksApplication instead of a dedicated flavor could simplify the whole thing

    • move dependencies from demoImplementation to androidTestImplementation
    • move the flavor init mechanism from flavor to test (and remove dummy/empty impls)
    • find a way to determine which is the test (class) being launch, if it's screenshot gen, then trigger the flavor init mechanism now available on tests
    • ➡️ or use Koin & DI from test to tweak behavior locally
class KoinTestRule(
    private val modules: List<Module>
) : TestWatcher() {
    override fun starting(description: Description) {
        if (getKoinApplicationOrNull() == null) {
            startKoin {
                androidContext(InstrumentationRegistry.getInstrumentation().targetContext.applicationContext)
                modules(modules)
            }
        } else {
            loadKoinModules(modules)
        }
    }

    override fun finished(description: Description) {
        unloadKoinModules(modules)
    }
}
    @get:Rule
    val koinTestRule = KoinTestRule(
        listOf(
            // here tweak module with prefilled DB
            databaseTestModule,
            ...
        )
    )
  • Fix test package name
  • Fix screenshot rule package name

Checklist

  • I have read the CONTRIBUTING guide
  • Code compiles correctly
  • Created tests which fail without the change (if possible)
  • All tests passing

@opatry opatry changed the title Screenshot gen Programatic store screenshot generation May 20, 2025
@opatry opatry linked an issue May 20, 2025 that may be closed by this pull request
5 tasks
@opatry opatry added ui ✨ User interface related issues android app 🤖 Related to the Android application labels May 20, 2025
@opatry opatry changed the title Programatic store screenshot generation Programmatic store screenshot generation May 20, 2025
@github-actions
Copy link
Contributor

Job Summary for Gradle

Build & Test :: build
Gradle Root Project Requested Tasks Gradle Version Build Outcome Build Scan®
Taskfolio :tasks-app-desktop:assemble 8.12.1 Build Scan not published
Taskfolio :tasks-app-android:assembleStoreRelease 8.12.1 Build Scan not published
Taskfolio test :tasks-app-android:testStoreReleaseUnitTest jvmTest 8.12.1 Build Scan not published
Taskfolio :tasks-app-android:exportLibraryDefinitions 8.12.1 Build Scan not published
Taskfolio :tasks-app-desktop:exportLibraryDefinitions 8.12.1 Build Scan not published

ktor = "3.1.3"
activity-compose = "1.11.0-rc01"
compose-plugin = "1.8.0"
compose = "1.8.0"
Copy link
Owner Author

Choose a reason for hiding this comment

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

Suggested change
compose = "1.8.0"
compose = "1.8.2"

androidx-test-core = { module = "androidx.test:core", version = "1.6.1" }
androidx-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest", version.ref = "compose" }
androidx-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "compose" }
androidx-uiautomator = { module = "androidx.test.uiautomator:uiautomator", version = "2.3.0" }
Copy link
Owner Author

@opatry opatry May 21, 2025

Choose a reason for hiding this comment

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

  • check latest version before merging

@opatry opatry mentioned this pull request May 26, 2025
14 tasks
@opatry opatry force-pushed the screenshot-gen branch 2 times, most recently from df21956 to 37b918e Compare May 26, 2025 21:50
@opatry opatry changed the base branch from main to e2e-happy-path-test May 26, 2025 21:51
@opatry opatry force-pushed the e2e-happy-path-test branch 6 times, most recently from 50d4e78 to 59439ff Compare May 27, 2025 22:15
Base automatically changed from e2e-happy-path-test to main May 28, 2025 17:17
@opatry opatry force-pushed the screenshot-gen branch 2 times, most recently from 5260253 to 4ddecd6 Compare May 31, 2025 08:45
@opatry
Copy link
Owner Author

opatry commented Jun 25, 2025

/gemini review this pr

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces a 'demo' flavor to facilitate programmatic screenshot generation for the store, along with UI tests and scripts to automate the process. The changes include adding dependencies, creating a demo flavor, pre-filling demo content, and adding a screenshot test. The code looks well-structured and addresses the stated goals.

Comment on lines +173 to +175
"demoImplementation"(projects.tasksCore) {
because("needed for prefilled content for screenshot generation")
}

Choose a reason for hiding this comment

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

medium

Consider moving this dependency to androidTestImplementation if it's only needed for tests. This avoids including it in the main application code, reducing the app size. If tasksCore is truly needed for prefilled content in the demo flavor's main code (not just the tests), then this placement is correct.

Comment on lines +42 to +45
// TODO would be more elegant to use Room preloaded data mechanism.
// Was tested but didn't work first time, not investigated a lot.
// That being said, it's simpler to make evolution on pre-filled content programmatically.
// see https://developer.android.com/training/data-storage/room/prepopulate

Choose a reason for hiding this comment

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

medium

The comment suggests that using Room's preloaded data mechanism would be more elegant. If feasible, explore this option to simplify the initialization process and potentially improve performance. If the programmatic approach is preferred due to easier evolution, consider documenting the reasons for this choice more explicitly.

Comment on lines +43 to 45
if (target in arrayOf("test", "demo") && dbFile.exists()) {
dbFile.delete()
}

Choose a reason for hiding this comment

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

medium

This logic deletes the database if the target is 'test' or 'demo'. While this is useful for testing and demo purposes, ensure that this behavior is clearly documented and doesn't inadvertently affect production or development environments. Consider using a more specific flag or environment variable to control this behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

android app 🤖 Related to the Android application ui ✨ User interface related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automate store screenshots generation with a UI test 🖼

2 participants