Fixes api 27 tests and removes debug stuff

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

@ -308,10 +308,6 @@ jobs:
- name: Create directory for AVD - name: Create directory for AVD
run: mkdir -p /home/runner/.android/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 - name: Build projects and run instrumented screenshot tests
id: dropshotsverify id: dropshotsverify
continue-on-error: true continue-on-error: true
@ -325,11 +321,6 @@ jobs:
heap-size: 600M heap-size: 600M
profile: ${{ matrix.profile }} profile: ${{ matrix.profile }}
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none 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 # Run tests, if they fail, record screenshots and exit with a failure
script: > script: >
./gradlew connectedDemoDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.annotation=com.google.samples.apps.nowinandroid.ui.InstrumentedScreenshotTests --daemon ./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" ; echo "Done recording new screenshots, exiting with failure"
; exit 5 ; 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 - name: Prevent pushing new screenshots if this is a fork
id: checkfork_screenshots_instrumented id: checkfork_screenshots_instrumented
continue-on-error: false continue-on-error: false

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

Loading…
Cancel
Save