Add jank CUJ instrumentation for user dialog-to-dialog transitions
Bug: 232908404 Test: Unit tests Test: Example trace: https://ui.perfetto.dev/#!/?s=4ad89a6590720f7bb89b33640b5fea45452e91c49de569cbd8ab41258e7f54 Change-Id: I5feb9477e5b7f236fade37055da89c2a2729ac56
This commit is contained in:
@@ -150,15 +150,16 @@ constructor(
|
||||
fun showFromDialog(
|
||||
dialog: Dialog,
|
||||
animateFrom: Dialog,
|
||||
cuj: DialogCuj? = null,
|
||||
animateBackgroundBoundsChange: Boolean = false
|
||||
) {
|
||||
val view =
|
||||
openedDialogs.firstOrNull { it.dialog == animateFrom }?.dialogContentWithBackground
|
||||
?: throw IllegalStateException(
|
||||
"The animateFrom dialog was not animated using " +
|
||||
"DialogLaunchAnimator.showFrom(View|Dialog)"
|
||||
)
|
||||
showFromView(dialog, view, animateBackgroundBoundsChange = animateBackgroundBoundsChange)
|
||||
"DialogLaunchAnimator.showFrom(View|Dialog)")
|
||||
showFromView(
|
||||
dialog, view, animateBackgroundBoundsChange = animateBackgroundBoundsChange, cuj = cuj)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -128,15 +128,16 @@ class UserSwitchDialogController @VisibleForTesting constructor(
|
||||
private val animateFrom: Dialog,
|
||||
private val dialogLaunchAnimator: DialogLaunchAnimator
|
||||
) : DialogInterface by animateFrom, DialogShower {
|
||||
override fun showDialog(dialog: Dialog) {
|
||||
override fun showDialog(dialog: Dialog, cuj: DialogCuj) {
|
||||
dialogLaunchAnimator.showFromDialog(
|
||||
dialog,
|
||||
animateFrom = animateFrom
|
||||
animateFrom = animateFrom,
|
||||
cuj
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
interface DialogShower : DialogInterface {
|
||||
fun showDialog(dialog: Dialog)
|
||||
fun showDialog(dialog: Dialog, cuj: DialogCuj)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ import com.android.systemui.GuestResetOrExitSessionReceiver;
|
||||
import com.android.systemui.GuestResumeSessionReceiver;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.SystemUISecondaryUserService;
|
||||
import com.android.systemui.animation.DialogCuj;
|
||||
import com.android.systemui.animation.DialogLaunchAnimator;
|
||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||
import com.android.systemui.broadcast.BroadcastSender;
|
||||
@@ -116,6 +117,9 @@ public class UserSwitcherController implements Dumpable {
|
||||
private static final String PERMISSION_SELF = "com.android.systemui.permission.SELF";
|
||||
private static final long MULTI_USER_JOURNEY_TIMEOUT = 20000l;
|
||||
|
||||
private static final String INTERACTION_JANK_ADD_NEW_USER_TAG = "add_new_user";
|
||||
private static final String INTERACTION_JANK_EXIT_GUEST_MODE_TAG = "exit_guest_mode";
|
||||
|
||||
protected final Context mContext;
|
||||
protected final UserTracker mUserTracker;
|
||||
protected final UserManager mUserManager;
|
||||
@@ -597,7 +601,9 @@ public class UserSwitcherController implements Dumpable {
|
||||
}
|
||||
mExitGuestDialog = new ExitGuestDialog(mContext, id, isGuestEphemeral, targetId);
|
||||
if (dialogShower != null) {
|
||||
dialogShower.showDialog(mExitGuestDialog);
|
||||
dialogShower.showDialog(mExitGuestDialog, new DialogCuj(
|
||||
InteractionJankMonitor.CUJ_USER_DIALOG_OPEN,
|
||||
INTERACTION_JANK_EXIT_GUEST_MODE_TAG));
|
||||
} else {
|
||||
mExitGuestDialog.show();
|
||||
}
|
||||
@@ -609,7 +615,11 @@ public class UserSwitcherController implements Dumpable {
|
||||
}
|
||||
mAddUserDialog = new AddUserDialog(mContext);
|
||||
if (dialogShower != null) {
|
||||
dialogShower.showDialog(mAddUserDialog);
|
||||
dialogShower.showDialog(mAddUserDialog,
|
||||
new DialogCuj(
|
||||
InteractionJankMonitor.CUJ_USER_DIALOG_OPEN,
|
||||
INTERACTION_JANK_ADD_NEW_USER_TAG
|
||||
));
|
||||
} else {
|
||||
mAddUserDialog.show();
|
||||
}
|
||||
|
||||
@@ -170,19 +170,27 @@ class DialogLaunchAnimatorTest : SysuiTestCase() {
|
||||
@Test
|
||||
fun testCujSpecificationLogsInteraction() {
|
||||
val touchSurface = createTouchSurface()
|
||||
return runOnMainThreadAndWaitForIdleSync {
|
||||
runOnMainThreadAndWaitForIdleSync {
|
||||
val dialog = TestDialog(context)
|
||||
dialogLaunchAnimator.showFromView(
|
||||
dialog, touchSurface,
|
||||
cuj = DialogCuj(InteractionJankMonitor.CUJ_SHADE_DIALOG_OPEN)
|
||||
)
|
||||
dialog, touchSurface, cuj = DialogCuj(InteractionJankMonitor.CUJ_SHADE_DIALOG_OPEN))
|
||||
}
|
||||
|
||||
verify(interactionJankMonitor).begin(
|
||||
any()
|
||||
)
|
||||
verify(interactionJankMonitor)
|
||||
.end(InteractionJankMonitor.CUJ_SHADE_DIALOG_OPEN)
|
||||
verify(interactionJankMonitor).begin(any())
|
||||
verify(interactionJankMonitor).end(InteractionJankMonitor.CUJ_SHADE_DIALOG_OPEN)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testShowFromDialogCujSpecificationLogsInteraction() {
|
||||
val firstDialog = createAndShowDialog()
|
||||
runOnMainThreadAndWaitForIdleSync {
|
||||
val dialog = TestDialog(context)
|
||||
dialogLaunchAnimator.showFromDialog(
|
||||
dialog, firstDialog, cuj = DialogCuj(InteractionJankMonitor.CUJ_USER_DIALOG_OPEN))
|
||||
dialog
|
||||
}
|
||||
verify(interactionJankMonitor).begin(any())
|
||||
verify(interactionJankMonitor).end(InteractionJankMonitor.CUJ_USER_DIALOG_OPEN)
|
||||
}
|
||||
|
||||
private fun createAndShowDialog(): TestDialog {
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.android.systemui.GuestResumeSessionReceiver
|
||||
import com.android.systemui.GuestSessionNotification
|
||||
import com.android.systemui.R
|
||||
import com.android.systemui.SysuiTestCase
|
||||
import com.android.systemui.animation.DialogCuj
|
||||
import com.android.systemui.animation.DialogLaunchAnimator
|
||||
import com.android.systemui.broadcast.BroadcastDispatcher
|
||||
import com.android.systemui.broadcast.BroadcastSender
|
||||
@@ -72,12 +73,12 @@ import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.ArgumentMatchers.anyInt
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.mockito.Mockito.doNothing
|
||||
import org.mockito.Mockito.doReturn
|
||||
import org.mockito.Mockito.eq
|
||||
import org.mockito.Mockito.mock
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.mockito.MockitoAnnotations
|
||||
|
||||
@RunWith(AndroidTestingRunner::class)
|
||||
@@ -362,7 +363,10 @@ class UserSwitcherControllerTest : SysuiTestCase() {
|
||||
userSwitcherController.onUserListItemClicked(currentGuestUserRecord, dialogShower)
|
||||
assertNotNull(userSwitcherController.mExitGuestDialog)
|
||||
testableLooper.processAllMessages()
|
||||
verify(dialogShower).showDialog(userSwitcherController.mExitGuestDialog)
|
||||
verify(dialogShower)
|
||||
.showDialog(
|
||||
userSwitcherController.mExitGuestDialog,
|
||||
DialogCuj(InteractionJankMonitor.CUJ_USER_DIALOG_OPEN, "exit_guest_mode"))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user