Skip to content

Commit

Permalink
Fixes api 27 tests and removes debug stuff
Browse files Browse the repository at this point in the history
Change-Id: I1badc84c616c8eb571cb83e95472a813d273365f
  • Loading branch information
JoseAlcerreca committed May 27, 2024
1 parent 07d622a commit dac5b22
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 34 deletions.
17 changes: 0 additions & 17 deletions .github/workflows/Build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
)
}
}

Expand Down Expand Up @@ -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))
Expand All @@ -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))
Expand Down

0 comments on commit dac5b22

Please sign in to comment.