Fixes api 27 tests and removes debug stuff

Change-Id: I1badc84c616c8eb571cb83e95472a813d273365f
ja/edge-to-edge-dropshots
Jose Alcérreca 7 months ago
parent 8e5153a24b
commit 94df4d93df

@ -308,10 +308,6 @@ jobs:
- name: Create directory for AVD
run: mkdir -p /home/runner/.android/avd
- name: Print debug avd
run: |
ls -alR ~/.android/avd/
- name: Build projects and run instrumented screenshot tests
id: dropshotsverify
continue-on-error: true
@ -325,11 +321,6 @@ jobs:
heap-size: 600M
profile: ${{ matrix.profile }}
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
# TODO DEBUG
pre-emulator-launch-script: |
which sdkmanager
sdkmanager --version
sdkmanager --install 'system-images;android-33;default;x86_64' --channel=0
# Run tests, if they fail, record screenshots and exit with a failure
script: >
./gradlew connectedDemoDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.annotation=com.google.samples.apps.nowinandroid.ui.InstrumentedScreenshotTests --daemon
@ -338,14 +329,6 @@ jobs:
; echo "Done recording new screenshots, exiting with failure"
; exit 5
- name: Print debug avdmanager list
run: avdmanager list
- name: Print debug sdkmanager
run: |
sdkmanager --version
which sdkmanager
- name: Prevent pushing new screenshots if this is a fork
id: checkfork_screenshots_instrumented
continue-on-error: false

@ -17,6 +17,8 @@
package com.google.samples.apps.nowinandroid.ui
import android.graphics.Bitmap
import android.os.Build
import android.os.Build.VERSION_CODES
import android.util.Log
import androidx.core.view.WindowInsetsCompat
import androidx.test.core.app.takeScreenshot
@ -92,11 +94,26 @@ class EdgeToEdgeTest {
fun enableDemoMode() {
UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()).apply {
executeShellCommand("settings put global sysui_demo_allowed 1")
executeShellCommand("am broadcast -a com.android.systemui.demo -e command enter")
executeShellCommand("am broadcast -a com.android.systemui.demo -e command notifications -e visible false")
executeShellCommand("am broadcast -a com.android.systemui.demo -e command clock -e hhmm 1234")
executeShellCommand("am broadcast -a com.android.systemui.demo -e command network -e wifi hide")
executeShellCommand("am broadcast -a com.android.systemui.demo -e command network -e mobile hide")
executeShellCommand(
"am broadcast -a com.android.systemui.demo -e command " +
"enter",
)
executeShellCommand(
"am broadcast -a com.android.systemui.demo -e command " +
"notifications -e visible false",
)
executeShellCommand(
"am broadcast -a com.android.systemui.demo -e command " +
"clock -e hhmm 1234",
)
executeShellCommand(
"am broadcast -a com.android.systemui.demo -e command " +
"network -e wifi hide",
)
executeShellCommand(
"am broadcast -a com.android.systemui.demo -e command " +
"network -e mobile hide",
)
}
}
@ -154,15 +171,20 @@ class EdgeToEdgeTest {
var width: Int? = null
waitForWindowUpdate()
activityScenarioRule.scenario.onActivity { activity ->
val metrics = WindowMetricsCalculator.getOrCreate()
.computeCurrentWindowMetrics(activity)
topInset = metrics.getWindowInsets().getInsets(
WindowInsetsCompat.Type.systemBars(),
).bottom
.computeMaximumWindowMetrics(activity)
// TODO: Get the real inset dimension in <R
topInset = if (Build.VERSION.SDK_INT >= VERSION_CODES.R) {
metrics.getWindowInsets().getInsets(
WindowInsetsCompat.Type.systemBars(),
).bottom
} else {
100
}
width = metrics.bounds.width()
}
Log.d("jalc", "width: $width")
Log.d("jalc", "topInset: $topInset")
Log.d("EdgeToEdgeTests", "System bar inset height: $topInset")
// Crop the top, adding extra pixels to check continuity
val bitmap = takeScreenshot().let {
Bitmap.createBitmap(it, 0, 0, width!!, (topInset!! * 2))
@ -177,16 +199,20 @@ class EdgeToEdgeTest {
waitForWindowUpdate()
activityScenarioRule.scenario.onActivity { activity ->
val metrics = WindowMetricsCalculator.getOrCreate()
.computeCurrentWindowMetrics(activity)
bottomInset = metrics.getWindowInsets().getInsets(
WindowInsetsCompat.Type.navigationBars(),
).bottom
.computeMaximumWindowMetrics(activity)
// TODO: Get the real inset dimension in <R
bottomInset = if (Build.VERSION.SDK_INT >= VERSION_CODES.R) {
metrics.getWindowInsets().getInsets(
WindowInsetsCompat.Type.navigationBars(),
).bottom
} else {
100
}
width = metrics.bounds.width()
height = metrics.bounds.height()
}
Log.d("jalc", "height: $height")
Log.d("jalc", "bottomInset: $bottomInset")
Log.d("EdgeToEdgeTests", "Navigation bar inset height: $bottomInset")
// Crop the top, adding extra pixels to check continuity
val bitmap = takeScreenshot().let {
Bitmap.createBitmap(it, 0, height!! - (bottomInset!! * 2), width!!, (bottomInset!! * 2))

Loading…
Cancel
Save