-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement automatic screenshot generation
- Loading branch information
1 parent
f6feb2c
commit 798cd1d
Showing
5 changed files
with
144 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
on: | ||
push: | ||
branches: | ||
- '*' | ||
|
||
name: Generate Screenshots | ||
|
||
jobs: | ||
|
||
screenshot: | ||
name: Generate screenshots | ||
runs-on: macos-latest | ||
strategy: | ||
matrix: | ||
api-level: [ 34 ] | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
|
||
- name: AVD cache | ||
uses: actions/cache@v3 | ||
id: avd-cache | ||
with: | ||
path: | | ||
~/.android/avd/* | ||
~/.android/adb* | ||
key: avd-${{ matrix.api-level }} | ||
|
||
- name: create AVD and generate snapshot for caching | ||
if: steps.avd-cache.outputs.cache-hit != 'true' | ||
uses: reactivecircus/android-emulator-runner@v2 | ||
with: | ||
api-level: ${{ matrix.api-level }} | ||
target: playstore | ||
arch: x86_64 | ||
profile: Pixel 4 | ||
force-avd-creation: false | ||
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | ||
disable-animations: false | ||
script: echo "Generated AVD snapshot for caching." | ||
|
||
- name: Set up Java environment | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 17 | ||
distribution: 'zulu' | ||
cache: 'gradle' | ||
|
||
- name: Build app | ||
run: ./gradlew assembleGoogleNormalDebug assembleGoogleNormalAndroidTest | ||
|
||
- name: Start System UI demo mode | ||
run: | | ||
- name: Run emulator and generate screenshots | ||
uses: reactivecircus/android-emulator-runner@v2 | ||
with: | ||
api-level: ${{ matrix.api-level }} | ||
target: playstore | ||
arch: x86_64 | ||
profile: Pixel 4 | ||
force-avd-creation: false | ||
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | ||
disable-animations: false | ||
script: | | ||
adb shell settings put global hidden_api_policy 1 | ||
# Start demo mode | ||
adb shell settings put global sysui_demo_allowed 1 | ||
# Display time 12:00 | ||
adb shell am broadcast -a com.android.systemui.demo -e command clock -e hhmm 1200 | ||
# Display full mobile data without type | ||
adb shell am broadcast -a com.android.systemui.demo -e command network -e mobile show -e level 4 -e datatype false | ||
adb shell am broadcast -a com.android.systemui.demo -e command network -e wifi show -e level 4 -e fully true | ||
# Hide notifications | ||
adb shell am broadcast -a com.android.systemui.demo -e command notifications -e visible false | ||
# Show full battery but not in charging state | ||
adb shell am broadcast -a com.android.systemui.demo -e command battery -e plugged false -e level 100 | ||
fastlane screengrab --app_apk_path app/build/outputs/apk/googleNormal/debug/app-google-normal-debug.apk --test_apk_path app/build/outputs/apk/androidTest/googleNormal/debug/app-google-normal-debug-androidTest.apk --tests_package_name=net.vonforst.evmap.debug.test --app_package_name net.vonforst.evmap.debug -p net.vonforst.evmap.screenshot --use_timestamp_suffix false --clear_previous_screenshots true -q en-US,de-DE | ||
adb shell am broadcast -a com.android.systemui.demo -e command exit | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
app/src/androidTest/java/net/vonforst/evmap/screenshot/ScreenshotTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package net.vonforst.evmap.screenshot | ||
|
||
import androidx.test.ext.junit.rules.ActivityScenarioRule | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import net.vonforst.evmap.MapsActivity | ||
import org.junit.AfterClass | ||
import org.junit.BeforeClass | ||
import org.junit.ClassRule | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import tools.fastlane.screengrab.Screengrab | ||
import tools.fastlane.screengrab.UiAutomatorScreenshotStrategy | ||
import tools.fastlane.screengrab.cleanstatusbar.BluetoothState | ||
import tools.fastlane.screengrab.cleanstatusbar.CleanStatusBar | ||
import tools.fastlane.screengrab.cleanstatusbar.MobileDataType | ||
import tools.fastlane.screengrab.locale.LocaleTestRule | ||
|
||
|
||
@RunWith(AndroidJUnit4::class) | ||
class ScreenshotTest { | ||
companion object { | ||
@JvmStatic | ||
@BeforeClass | ||
fun beforeAll() { | ||
Screengrab.setDefaultScreenshotStrategy(UiAutomatorScreenshotStrategy()) | ||
} | ||
} | ||
|
||
@Rule | ||
@JvmField | ||
val localeTestRule = LocaleTestRule() | ||
|
||
@get:Rule | ||
val activityRule = ActivityScenarioRule(MapsActivity::class.java) | ||
|
||
@Test | ||
fun testTakeScreenshot() { | ||
Screengrab.screenshot("main") | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...johan/evmap/storage/SavedRegionDaoTest.kt → ...forst/evmap/storage/SavedRegionDaoTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters