Skip to content

Commit

Permalink
Fail fast if screenshot tests are run on an incompatible device
Browse files Browse the repository at this point in the history
  • Loading branch information
saket committed Apr 27, 2024
1 parent 81af516 commit 05ec6c9
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import android.view.WindowManager
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.core.view.WindowCompat
import androidx.core.view.doOnLayout
import androidx.core.view.doOnNextLayout
import androidx.test.platform.app.InstrumentationRegistry

fun Activity.prepareForScreenshotTest() {
Expand All @@ -29,4 +31,10 @@ fun Activity.prepareForScreenshotTest() {
println("Failed to prepare activity for screenshot test:")
e.printStackTrace()
}

window.decorView.doOnNextLayout {
check (Build.VERSION.SDK_INT == 31 && it.width == 1080 && it.height == 2400) {
"telephoto's test screenshots were generated on an API 31 device with a 1080 x 2400 display/window size."
}
}
}

0 comments on commit 05ec6c9

Please sign in to comment.