Fix wrong visibility of link button in a11y tutorial dialog

Root cause: the visibility of link button is not correctly set due to
the onPageSelected callback isn't called when the first page shows

Solution: Manually set the visibility of link button according to the
first tutirial page type when dialog is shown

Bug: 242141428
Test: make RunSettingsRoboTests ROBOTEST_FILTER=AccessibilityGestureNavigationTutorialTest
Change-Id: I33ed07bc7ae39d96baeeed85771c5f13e00ebf44
This commit is contained in:
Angela Wang
2022-08-12 08:29:24 +00:00
parent 8a932c81be
commit 67efcacbc1
2 changed files with 62 additions and 11 deletions

View File

@@ -31,6 +31,7 @@ import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.View;
import androidx.appcompat.app.AlertDialog;
import androidx.test.core.app.ApplicationProvider;
@@ -111,6 +112,44 @@ public final class AccessibilityGestureNavigationTutorialTest {
assertThat(alertDialog).isNotNull();
}
@Test
public void createTutorialPages_turnOnSoftwareShortcut_linkButtonVisible() {
mShortcutTypes |= UserShortcutType.SOFTWARE;
final AlertDialog alertDialog =
createAccessibilityTutorialDialog(mContext, mShortcutTypes);
alertDialog.show();
assertThat(alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE).getVisibility())
.isEqualTo(View.VISIBLE);
}
@Test
public void createTutorialPages_turnOnSoftwareAndHardwareShortcut_linkButtonVisible() {
mShortcutTypes |= UserShortcutType.SOFTWARE;
mShortcutTypes |= UserShortcutType.HARDWARE;
final AlertDialog alertDialog =
createAccessibilityTutorialDialog(mContext, mShortcutTypes);
alertDialog.show();
assertThat(alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE).getVisibility())
.isEqualTo(View.VISIBLE);
}
@Test
public void createTutorialPages_turnOnHardwareShortcut_linkButtonGone() {
mShortcutTypes |= UserShortcutType.HARDWARE;
final AlertDialog alertDialog =
createAccessibilityTutorialDialog(mContext, mShortcutTypes);
alertDialog.show();
assertThat(alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE).getVisibility())
.isEqualTo(View.GONE);
}
@Test
public void performClickOnPositiveButton_turnOnSoftwareShortcut_dismiss() {
mShortcutTypes |= UserShortcutType.SOFTWARE;