https://kotlinlang.org logo
Title
p

pajatopmr

02/17/2022, 9:37 PM
The compose-jb issue #368 documents the difficulties users of Compose Multiplatform have been having trying to write non-Android GUI tests. It clearly identifies an example (ScrollBarTest) that actually works. But there are many operations, particularly
checkIsDisplayed()
, that are not currently implemented in the
ui-test-junit4
component thus causing a serious problem for those of us wanting to write GUI tests for our Compose Multiplatform apps. To address this problem, I have volunteered to work on implementing some of these not yet implemented functions. The first step is to set up a development environment for this work. That environment is the subject of this post, a Readers Digest version of material provided by @Igor Demin (for which I am so, so grateful). The basic work is described in https://android.googlesource.com/platform/frameworks/support.git/+/refs/heads/android-arch-work-release/README.md and essentially entails: 1. Getting the source code 2. Setting up java 3. Setting up Android Studio 4. Verifying the development setup by running a working test 5. Developing a fix, with test, for some unimplemented method 6. Getting the code reviewed by @olonho and/or @Igor Demin 7. Generating a PR to the JetBrains fork Getting the source code The source code is obtained using a Google tool, '`repo`', which is a layer on top of git. For work on Compose Multiplatform, the branch to use is "androidx-main". The download uses ~40G and takes a while. A gigabit network, or better, is highly recommended. The repo installation instructions can be found at https://source.android.com/setup/develop#installing-repo . I used homebrew (
brew install repo
) on a MacBook Pro. Once repo is installed, the branch (androidx-main) is initialized and downloaded using steps from https://source.android.com/setup/build/downloading : mkdir <path/for/androidx-main/code> cd <path/for/androidx-main/code> repo init -u https://android/googlesource.com/platform/manifest repo init -u https://android.googlesource.com/platform/manifest -b androidx-main repo sync -c -j8 Setting up Java The Compose Multiplatform team recommends using JDK15 but I have been using JDK11 successfully for ui-test-junit4 so far. Homebrew is an excellent way to manage multiple JDK versions simultaneously, particularly Open JDK. I am also told that JDK11 is provided by the
repo
download, but I seem to recall needing an installed JDK11 at one point. Setting up Android Studio At this point, when the script completes, we are ready to use Android Studio (Dolphin), which is included in the download of "androidx-main", as a source file editor by executing:
cd frameworks/support
./gradlew studio
Verifying the development setup by running a working test The next step is to verify that the ScrollBarTest can be run successfully. While this usually can be done using Android Studio or Gradle, a known bug in Dolphin generates a "Nothing here" message so we use Gradle with:
./gradlew cleanDesktopTest :compose:foundation:foundation:desktopTest --tests "androidx.compose.foundation.ScrollbarTest"
The remaining three steps will be performed in the coming days and I will edit this post accordingly. My hope is that others will find this documentation useful and enable them to contribute fixes also.
👍🏻 1
👍 2
k

Kirill Grouchnikov

02/17/2022, 10:20 PM
This should be a document somewhere on compose-jb. I'd suggest starting a PR and updating it as you go along. Slack is not really well suited for such a collaborative effort.
👍🏻 1
👍 2
m

mark

02/21/2022, 6:12 PM
I had recently watched the "Android Day on Google Open Source Live" on Feb 3, 2022, and it covered topics of how to build and contribute to AOSP. For replay videos see here: https://opensourcelive.withgoogle.com/events/android-day I followed your instructions, did the repo init commands and sync. Question: I have seen this command:
repo init -u <https://android.googlesource.com/platform/manifest> -b androidx-main --partial-clone --clone-filter=blob:limit=10M
which contains more arguments than what you gave. Does anyone know the difference, and if I have already done: $ repo init -u https://android.googlesource.com/platform/manifest -b androidx-main $ repo sync -j8 -c This downloaded 44GB Should I leave things alone as is, or redo with: $ repo init -u https://android.googlesource.com/platform/manifest -b androidx-main --partial-clone --clone-filter=blob:limit=10M $ repo sync -j8 -c I was able to $ cd support/framework but in order to start Android Studio needed to do: $ ANDROIDX_PROJECTS=MAIN ./gradlew studio Android Studio started okay. The gradlew command to run the ScrollbarTest failed, the task "cleanDesktopTest" was not found. -- mark@T530:~/workspace/aosp/frameworks/support$ ./gradlew cleanDesktopTest \:compose\:foundation:foundation:desktopTest --tests "androidx.compose.foundation.ScrollbarTest" Configuration cache is an incubating feature. Configuration on demand is an incubating feature. Calculating task graph as no configuration cache is available for tasks: cleanDesktopTest \:compose\:foundation:foundation:desktopTest --tests androidx.compose.foundation.ScrollbarTest Type-safe dependency accessors is an incubating feature. 0 problems were found storing the configuration cache. See the complete report at file:///home/mark/workspace/aosp/frameworks/support/build/reports/configuration-cache/8y984v4wuj734xrnmjx6r8hmj/ecrjffk5e0cp08uq3c7tysa3r/configuration-cache-report.html FAILURE: Build failed with an exception. * What went wrong: Task 'cleanDesktopTest' not found in root project 'androidx'. -- [? I did a copy and paste and somehow picked up the emoji/icons] Hah! \:compose\: is translated to :compose: I cannot escape it [esc] doesn't seem to work for me. Ignore the '\' in the command exmples I played around and was able to explore the tasks and run some tests: ./gradlew \:compose\:foundation:foundation:test worked mark@T530:~/workspace/aosp/frameworks/support$ ./gradlew \:compose\:ui:ui:ui-samples:test Configuration cache is an incubating feature. Configuration on demand is an incubating feature. Reusing configuration cache. BUILD SUCCESSFUL in 2s 173 actionable tasks: 11 executed, 16 from cache, 146 up-to-date Configuration cache entry reused. mark@T530:~/workspace/aosp/frameworks/support$ I'm not sure what to do next at this point.
i

Igor Demin

02/21/2022, 7:16 PM
The gradlew command to run the ScrollbarTest failed, the task "cleanDesktopTest" was not found.
There is one missing piece. You should add
androidx.compose.multiplatformEnabled=true
to
~/.gradle/gradle.properties
(or add
-Pandroidx.compose.multiplatformEnabled=true
to every Gradle command, but it doesn't work for IDE sync)
\:compose\
You can wrap it into a code block 🙂
:compose: