Loading packages/SystemUI/screenshot/src/com/android/systemui/testing/screenshot/ViewScreenshotTestRule.kt +9 −2 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import org.junit.runners.model.Statement import platform.test.screenshot.DeviceEmulationRule import platform.test.screenshot.DeviceEmulationSpec import platform.test.screenshot.MaterialYouColorsRule import platform.test.screenshot.PathConfig import platform.test.screenshot.ScreenshotTestRule import platform.test.screenshot.getEmulatedDevicePathConfig import platform.test.screenshot.matchers.BitmapMatcher Loading @@ -41,13 +42,19 @@ import platform.test.screenshot.matchers.BitmapMatcher /** A rule for View screenshot diff unit tests. */ class ViewScreenshotTestRule( emulationSpec: DeviceEmulationSpec, private val matcher: BitmapMatcher = UnitTestBitmapMatcher private val matcher: BitmapMatcher = UnitTestBitmapMatcher, pathConfig: PathConfig = getEmulatedDevicePathConfig(emulationSpec), assetsPathRelativeToRepo: String = "" ) : TestRule { private val colorsRule = MaterialYouColorsRule() private val deviceEmulationRule = DeviceEmulationRule(emulationSpec) private val screenshotRule = ScreenshotTestRule( SystemUIGoldenImagePathManager(getEmulatedDevicePathConfig(emulationSpec)) if (assetsPathRelativeToRepo.isBlank()) { SystemUIGoldenImagePathManager(pathConfig) } else { SystemUIGoldenImagePathManager(pathConfig, assetsPathRelativeToRepo) } ) private val activityRule = ActivityScenarioRule(ScreenshotActivity::class.java) private val delegateRule = Loading packages/SystemUI/src/com/android/systemui/biometrics/TEST_MAPPING 0 → 100644 +16 −0 Original line number Diff line number Diff line { "presubmit": [ { // TODO(b/251476085): Consider merging with SystemUIGoogleScreenshotTests (in U+) "name": "SystemUIGoogleBiometricsScreenshotTests", "options": [ { "exclude-annotation": "org.junit.Ignore" }, { "exclude-annotation": "androidx.test.filters.FlakyTest" } ] } ] } packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/CredentialPasswordViewBinder.kt +5 −3 Original line number Diff line number Diff line Loading @@ -13,7 +13,6 @@ import com.android.systemui.biometrics.ui.CredentialPasswordView import com.android.systemui.biometrics.ui.CredentialView import com.android.systemui.biometrics.ui.viewmodel.CredentialViewModel import com.android.systemui.lifecycle.repeatWhenAttached import kotlinx.coroutines.flow.collect import kotlinx.coroutines.launch /** Sub-binder for the [CredentialPasswordView]. */ Loading @@ -24,14 +23,17 @@ object CredentialPasswordViewBinder { view: CredentialPasswordView, host: CredentialView.Host, viewModel: CredentialViewModel, requestFocusForInput: Boolean, ) { val imeManager = view.context.getSystemService(InputMethodManager::class.java)!! val passwordField: ImeAwareEditText = view.requireViewById(R.id.lockPassword) view.repeatWhenAttached { if (requestFocusForInput) { passwordField.requestFocus() passwordField.scheduleShowSoftInput() } repeatOnLifecycle(Lifecycle.State.STARTED) { // observe credential validation attempts and submit/cancel buttons Loading packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/CredentialPatternViewBinder.kt +2 −3 Original line number Diff line number Diff line Loading @@ -9,7 +9,6 @@ import com.android.systemui.biometrics.ui.CredentialPatternView import com.android.systemui.biometrics.ui.CredentialView import com.android.systemui.biometrics.ui.viewmodel.CredentialViewModel import com.android.systemui.lifecycle.repeatWhenAttached import kotlinx.coroutines.flow.collect import kotlinx.coroutines.launch /** Sub-binder for the [CredentialPatternView]. */ Loading @@ -30,7 +29,7 @@ object CredentialPatternViewBinder { viewModel.header.collect { header -> lockPatternView.setOnPatternListener( OnPatternDetectedListener { pattern -> if (pattern.isPatternLongEnough()) { if (pattern.isPatternTooShort()) { // Pattern size is less than the minimum // do not count it as a failed attempt viewModel.showPatternTooShortError() Loading Loading @@ -71,5 +70,5 @@ private class OnPatternDetectedListener( } } private fun List<LockPatternView.Cell>.isPatternLongEnough(): Boolean = private fun List<LockPatternView.Cell>.isPatternTooShort(): Boolean = size < LockPatternUtils.MIN_PATTERN_REGISTER_FAIL packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/CredentialViewBinder.kt +3 −2 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ import com.android.systemui.biometrics.ui.viewmodel.CredentialViewModel import com.android.systemui.lifecycle.repeatWhenAttached import kotlinx.coroutines.Job import kotlinx.coroutines.delay import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch Loading @@ -40,6 +39,7 @@ object CredentialViewBinder { panelViewController: AuthPanelController, animatePanel: Boolean, maxErrorDuration: Long = 3_000L, requestFocusForInput: Boolean = true, ) { val titleView: TextView = view.requireViewById(R.id.title) val subtitleView: TextView = view.requireViewById(R.id.subtitle) Loading Loading @@ -110,7 +110,8 @@ object CredentialViewBinder { // bind the auth widget when (view) { is CredentialPasswordView -> CredentialPasswordViewBinder.bind(view, host, viewModel) is CredentialPasswordView -> CredentialPasswordViewBinder.bind(view, host, viewModel, requestFocusForInput) is CredentialPatternView -> CredentialPatternViewBinder.bind(view, host, viewModel) else -> throw IllegalStateException("unexpected view type: ${view.javaClass.name}") } Loading Loading
packages/SystemUI/screenshot/src/com/android/systemui/testing/screenshot/ViewScreenshotTestRule.kt +9 −2 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import org.junit.runners.model.Statement import platform.test.screenshot.DeviceEmulationRule import platform.test.screenshot.DeviceEmulationSpec import platform.test.screenshot.MaterialYouColorsRule import platform.test.screenshot.PathConfig import platform.test.screenshot.ScreenshotTestRule import platform.test.screenshot.getEmulatedDevicePathConfig import platform.test.screenshot.matchers.BitmapMatcher Loading @@ -41,13 +42,19 @@ import platform.test.screenshot.matchers.BitmapMatcher /** A rule for View screenshot diff unit tests. */ class ViewScreenshotTestRule( emulationSpec: DeviceEmulationSpec, private val matcher: BitmapMatcher = UnitTestBitmapMatcher private val matcher: BitmapMatcher = UnitTestBitmapMatcher, pathConfig: PathConfig = getEmulatedDevicePathConfig(emulationSpec), assetsPathRelativeToRepo: String = "" ) : TestRule { private val colorsRule = MaterialYouColorsRule() private val deviceEmulationRule = DeviceEmulationRule(emulationSpec) private val screenshotRule = ScreenshotTestRule( SystemUIGoldenImagePathManager(getEmulatedDevicePathConfig(emulationSpec)) if (assetsPathRelativeToRepo.isBlank()) { SystemUIGoldenImagePathManager(pathConfig) } else { SystemUIGoldenImagePathManager(pathConfig, assetsPathRelativeToRepo) } ) private val activityRule = ActivityScenarioRule(ScreenshotActivity::class.java) private val delegateRule = Loading
packages/SystemUI/src/com/android/systemui/biometrics/TEST_MAPPING 0 → 100644 +16 −0 Original line number Diff line number Diff line { "presubmit": [ { // TODO(b/251476085): Consider merging with SystemUIGoogleScreenshotTests (in U+) "name": "SystemUIGoogleBiometricsScreenshotTests", "options": [ { "exclude-annotation": "org.junit.Ignore" }, { "exclude-annotation": "androidx.test.filters.FlakyTest" } ] } ] }
packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/CredentialPasswordViewBinder.kt +5 −3 Original line number Diff line number Diff line Loading @@ -13,7 +13,6 @@ import com.android.systemui.biometrics.ui.CredentialPasswordView import com.android.systemui.biometrics.ui.CredentialView import com.android.systemui.biometrics.ui.viewmodel.CredentialViewModel import com.android.systemui.lifecycle.repeatWhenAttached import kotlinx.coroutines.flow.collect import kotlinx.coroutines.launch /** Sub-binder for the [CredentialPasswordView]. */ Loading @@ -24,14 +23,17 @@ object CredentialPasswordViewBinder { view: CredentialPasswordView, host: CredentialView.Host, viewModel: CredentialViewModel, requestFocusForInput: Boolean, ) { val imeManager = view.context.getSystemService(InputMethodManager::class.java)!! val passwordField: ImeAwareEditText = view.requireViewById(R.id.lockPassword) view.repeatWhenAttached { if (requestFocusForInput) { passwordField.requestFocus() passwordField.scheduleShowSoftInput() } repeatOnLifecycle(Lifecycle.State.STARTED) { // observe credential validation attempts and submit/cancel buttons Loading
packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/CredentialPatternViewBinder.kt +2 −3 Original line number Diff line number Diff line Loading @@ -9,7 +9,6 @@ import com.android.systemui.biometrics.ui.CredentialPatternView import com.android.systemui.biometrics.ui.CredentialView import com.android.systemui.biometrics.ui.viewmodel.CredentialViewModel import com.android.systemui.lifecycle.repeatWhenAttached import kotlinx.coroutines.flow.collect import kotlinx.coroutines.launch /** Sub-binder for the [CredentialPatternView]. */ Loading @@ -30,7 +29,7 @@ object CredentialPatternViewBinder { viewModel.header.collect { header -> lockPatternView.setOnPatternListener( OnPatternDetectedListener { pattern -> if (pattern.isPatternLongEnough()) { if (pattern.isPatternTooShort()) { // Pattern size is less than the minimum // do not count it as a failed attempt viewModel.showPatternTooShortError() Loading Loading @@ -71,5 +70,5 @@ private class OnPatternDetectedListener( } } private fun List<LockPatternView.Cell>.isPatternLongEnough(): Boolean = private fun List<LockPatternView.Cell>.isPatternTooShort(): Boolean = size < LockPatternUtils.MIN_PATTERN_REGISTER_FAIL
packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/CredentialViewBinder.kt +3 −2 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ import com.android.systemui.biometrics.ui.viewmodel.CredentialViewModel import com.android.systemui.lifecycle.repeatWhenAttached import kotlinx.coroutines.Job import kotlinx.coroutines.delay import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch Loading @@ -40,6 +39,7 @@ object CredentialViewBinder { panelViewController: AuthPanelController, animatePanel: Boolean, maxErrorDuration: Long = 3_000L, requestFocusForInput: Boolean = true, ) { val titleView: TextView = view.requireViewById(R.id.title) val subtitleView: TextView = view.requireViewById(R.id.subtitle) Loading Loading @@ -110,7 +110,8 @@ object CredentialViewBinder { // bind the auth widget when (view) { is CredentialPasswordView -> CredentialPasswordViewBinder.bind(view, host, viewModel) is CredentialPasswordView -> CredentialPasswordViewBinder.bind(view, host, viewModel, requestFocusForInput) is CredentialPatternView -> CredentialPatternViewBinder.bind(view, host, viewModel) else -> throw IllegalStateException("unexpected view type: ${view.javaClass.name}") } Loading