Loading packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/keygesture/ui/KeyGestureDialogStartableTest.kt +29 −0 Original line number Diff line number Diff line Loading @@ -99,6 +99,35 @@ class KeyGestureDialogStartableTest : SysuiTestCase() { assertThat(underTest.currentDialog?.isShowing).isTrue() } @Test fun start_onValidRequestReceived_dialogShowing_ignoreAdditionalRequests() = testScope.runTest { underTest.start() runCurrent() // Trigger to send a broadcast event at the first-time for Magnification sendIntentBroadcast( KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_MAGNIFICATION, KeyEvent.META_META_ON or KeyEvent.META_ALT_ON, KeyEvent.KEYCODE_M, "targetNameForMagnification", ) runCurrent() // Trigger to send a broadcast event at the second-time for TalkBack sendIntentBroadcast( KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_SCREEN_READER, KeyEvent.META_META_ON or KeyEvent.META_ALT_ON, KeyEvent.KEYCODE_T, "targetNameForScreenReader", ) runCurrent() // Only show the Magnification dialog. assertThat(underTest.currentDialog?.isShowing).isTrue() assertThat(underTest.dialogType) .isEqualTo(KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_MAGNIFICATION) } @Test fun start_onInvalidRequestReceived_noDialog() = testScope.runTest { Loading packages/SystemUI/src/com/android/systemui/accessibility/keygesture/ui/KeyGestureDialogStartable.kt +18 −15 Original line number Diff line number Diff line Loading @@ -62,6 +62,8 @@ constructor( ) : CoreStartable { @VisibleForTesting var currentDialog: ComponentSystemUIDialog? = null @VisibleForTesting var dialogType: Int = 0 override fun start() { if ( !Flags.enableTalkbackAndMagnifierKeyGestures() && Loading @@ -79,11 +81,14 @@ constructor( } private fun createDialog(keyGestureConfirmInfo: KeyGestureConfirmInfo?) { // Ignore other type of first-time keyboard shortcuts while the dialog is showing. if (currentDialog != null) { return } if (keyGestureConfirmInfo == null) { dismissDialog() return } dismissDialog() currentDialog = dialogFactory.create { dialog -> Loading Loading @@ -124,23 +129,21 @@ constructor( } currentDialog?.let { dialog -> dialog.show() // We need to announce the text for the TalkBack dialog. if ( keyGestureConfirmInfo.keyGestureType == KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_SCREEN_READER ) { val tts = interactor.performTtsPromptForText(keyGestureConfirmInfo.contentText) dialog.setOnDismissListener { tts.dismiss() } } } dialogType = keyGestureConfirmInfo.keyGestureType val tts = if (dialogType == KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_SCREEN_READER) { interactor.performTtsPromptForText(keyGestureConfirmInfo.contentText) } else { null } private fun dismissDialog() { currentDialog?.dismiss() dialog.setOnDismissListener { tts?.dismiss() currentDialog = null } dialog.show() } } private fun buildAnnotatedStringFromResource(resourceText: CharSequence): AnnotatedString { // `resourceText` is an instance of SpannableStringBuilder, so we can cast it to a Spanned. Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/keygesture/ui/KeyGestureDialogStartableTest.kt +29 −0 Original line number Diff line number Diff line Loading @@ -99,6 +99,35 @@ class KeyGestureDialogStartableTest : SysuiTestCase() { assertThat(underTest.currentDialog?.isShowing).isTrue() } @Test fun start_onValidRequestReceived_dialogShowing_ignoreAdditionalRequests() = testScope.runTest { underTest.start() runCurrent() // Trigger to send a broadcast event at the first-time for Magnification sendIntentBroadcast( KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_MAGNIFICATION, KeyEvent.META_META_ON or KeyEvent.META_ALT_ON, KeyEvent.KEYCODE_M, "targetNameForMagnification", ) runCurrent() // Trigger to send a broadcast event at the second-time for TalkBack sendIntentBroadcast( KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_SCREEN_READER, KeyEvent.META_META_ON or KeyEvent.META_ALT_ON, KeyEvent.KEYCODE_T, "targetNameForScreenReader", ) runCurrent() // Only show the Magnification dialog. assertThat(underTest.currentDialog?.isShowing).isTrue() assertThat(underTest.dialogType) .isEqualTo(KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_MAGNIFICATION) } @Test fun start_onInvalidRequestReceived_noDialog() = testScope.runTest { Loading
packages/SystemUI/src/com/android/systemui/accessibility/keygesture/ui/KeyGestureDialogStartable.kt +18 −15 Original line number Diff line number Diff line Loading @@ -62,6 +62,8 @@ constructor( ) : CoreStartable { @VisibleForTesting var currentDialog: ComponentSystemUIDialog? = null @VisibleForTesting var dialogType: Int = 0 override fun start() { if ( !Flags.enableTalkbackAndMagnifierKeyGestures() && Loading @@ -79,11 +81,14 @@ constructor( } private fun createDialog(keyGestureConfirmInfo: KeyGestureConfirmInfo?) { // Ignore other type of first-time keyboard shortcuts while the dialog is showing. if (currentDialog != null) { return } if (keyGestureConfirmInfo == null) { dismissDialog() return } dismissDialog() currentDialog = dialogFactory.create { dialog -> Loading Loading @@ -124,23 +129,21 @@ constructor( } currentDialog?.let { dialog -> dialog.show() // We need to announce the text for the TalkBack dialog. if ( keyGestureConfirmInfo.keyGestureType == KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_SCREEN_READER ) { val tts = interactor.performTtsPromptForText(keyGestureConfirmInfo.contentText) dialog.setOnDismissListener { tts.dismiss() } } } dialogType = keyGestureConfirmInfo.keyGestureType val tts = if (dialogType == KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_SCREEN_READER) { interactor.performTtsPromptForText(keyGestureConfirmInfo.contentText) } else { null } private fun dismissDialog() { currentDialog?.dismiss() dialog.setOnDismissListener { tts?.dismiss() currentDialog = null } dialog.show() } } private fun buildAnnotatedStringFromResource(resourceText: CharSequence): AnnotatedString { // `resourceText` is an instance of SpannableStringBuilder, so we can cast it to a Spanned. Loading