Merge "Use IntentSubject to simplify NoteTaskControllerTest" into udc-dev am: d130b60d0a

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23108519

Change-Id: I125d93a7f344eb1aee6571bed412b540f80924d4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Marcello Galhardo
2023-05-12 10:21:00 +00:00
committed by Automerger Merge Worker

View File

@@ -25,8 +25,11 @@ import android.app.role.RoleManager.ROLE_NOTES
import android.content.ComponentName import android.content.ComponentName
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.Intent.ACTION_CREATE_NOTE
import android.content.Intent.ACTION_MAIN import android.content.Intent.ACTION_MAIN
import android.content.Intent.ACTION_MANAGE_DEFAULT_APP
import android.content.Intent.CATEGORY_HOME import android.content.Intent.CATEGORY_HOME
import android.content.Intent.EXTRA_USE_STYLUS_MODE
import android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK import android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK
import android.content.Intent.FLAG_ACTIVITY_NEW_DOCUMENT import android.content.Intent.FLAG_ACTIVITY_NEW_DOCUMENT
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
@@ -47,8 +50,10 @@ import com.android.systemui.SysuiTestCase
import com.android.systemui.notetask.NoteTaskController.Companion.EXTRA_SHORTCUT_BADGE_OVERRIDE_PACKAGE import com.android.systemui.notetask.NoteTaskController.Companion.EXTRA_SHORTCUT_BADGE_OVERRIDE_PACKAGE
import com.android.systemui.notetask.NoteTaskController.Companion.SHORTCUT_ID import com.android.systemui.notetask.NoteTaskController.Companion.SHORTCUT_ID
import com.android.systemui.notetask.NoteTaskEntryPoint.APP_CLIPS import com.android.systemui.notetask.NoteTaskEntryPoint.APP_CLIPS
import com.android.systemui.notetask.NoteTaskEntryPoint.KEYBOARD_SHORTCUT
import com.android.systemui.notetask.NoteTaskEntryPoint.QUICK_AFFORDANCE import com.android.systemui.notetask.NoteTaskEntryPoint.QUICK_AFFORDANCE
import com.android.systemui.notetask.NoteTaskEntryPoint.TAIL_BUTTON import com.android.systemui.notetask.NoteTaskEntryPoint.TAIL_BUTTON
import com.android.systemui.notetask.NoteTaskEntryPoint.WIDGET_PICKER_SHORTCUT
import com.android.systemui.notetask.shortcut.CreateNoteTaskShortcutActivity import com.android.systemui.notetask.shortcut.CreateNoteTaskShortcutActivity
import com.android.systemui.notetask.shortcut.LaunchNoteTaskActivity import com.android.systemui.notetask.shortcut.LaunchNoteTaskActivity
import com.android.systemui.notetask.shortcut.LaunchNoteTaskManagedProfileProxyActivity import com.android.systemui.notetask.shortcut.LaunchNoteTaskManagedProfileProxyActivity
@@ -221,31 +226,22 @@ internal class NoteTaskControllerTest : SysuiTestCase() {
// region showNoteTask // region showNoteTask
@Test @Test
fun showNoteTask_keyguardIsLocked_shouldStartActivityAndLogUiEvent() { fun showNoteTask_keyguardIsLocked_shouldStartActivityAndLogUiEvent() {
val expectedInfo = val expectedInfo = NOTE_TASK_INFO.copy(entryPoint = TAIL_BUTTON, isKeyguardLocked = true)
NOTE_TASK_INFO.copy(
entryPoint = NoteTaskEntryPoint.TAIL_BUTTON,
isKeyguardLocked = true,
)
whenever(keyguardManager.isKeyguardLocked).thenReturn(expectedInfo.isKeyguardLocked) whenever(keyguardManager.isKeyguardLocked).thenReturn(expectedInfo.isKeyguardLocked)
whenever(resolver.resolveInfo(any(), any(), any())).thenReturn(expectedInfo) whenever(resolver.resolveInfo(any(), any(), any())).thenReturn(expectedInfo)
createNoteTaskController() createNoteTaskController().showNoteTask(entryPoint = expectedInfo.entryPoint!!)
.showNoteTask(
entryPoint = expectedInfo.entryPoint!!,
)
val intentCaptor = argumentCaptor<Intent>() val intentCaptor = argumentCaptor<Intent>()
val userCaptor = argumentCaptor<UserHandle>() val userCaptor = argumentCaptor<UserHandle>()
verify(context).startActivityAsUser(capture(intentCaptor), capture(userCaptor)) verify(context).startActivityAsUser(capture(intentCaptor), capture(userCaptor))
intentCaptor.value.let { intent -> assertThat(intentCaptor.value).run {
assertThat(intent.action).isEqualTo(Intent.ACTION_CREATE_NOTE) hasAction(ACTION_CREATE_NOTE)
assertThat(intent.`package`).isEqualTo(NOTE_TASK_PACKAGE_NAME) hasPackage(NOTE_TASK_PACKAGE_NAME)
assertThat(intent.flags and FLAG_ACTIVITY_NEW_TASK).isEqualTo(FLAG_ACTIVITY_NEW_TASK) hasFlags(FLAG_ACTIVITY_NEW_TASK)
assertThat(intent.flags and FLAG_ACTIVITY_MULTIPLE_TASK) hasFlags(FLAG_ACTIVITY_MULTIPLE_TASK)
.isEqualTo(FLAG_ACTIVITY_MULTIPLE_TASK) hasFlags(FLAG_ACTIVITY_NEW_DOCUMENT)
assertThat(intent.flags and FLAG_ACTIVITY_NEW_DOCUMENT) extras().bool(EXTRA_USE_STYLUS_MODE).isTrue()
.isEqualTo(FLAG_ACTIVITY_NEW_DOCUMENT)
assertThat(intent.getBooleanExtra(Intent.EXTRA_USE_STYLUS_MODE, false)).isTrue()
} }
assertThat(userCaptor.value).isEqualTo(userTracker.userHandle) assertThat(userCaptor.value).isEqualTo(userTracker.userHandle)
verify(eventLogger).logNoteTaskOpened(expectedInfo) verify(eventLogger).logNoteTaskOpened(expectedInfo)
@@ -256,32 +252,23 @@ internal class NoteTaskControllerTest : SysuiTestCase() {
fun showNoteTaskWithUser_keyguardIsLocked_shouldStartActivityWithExpectedUserAndLogUiEvent() { fun showNoteTaskWithUser_keyguardIsLocked_shouldStartActivityWithExpectedUserAndLogUiEvent() {
val user10 = UserHandle.of(/* userId= */ 10) val user10 = UserHandle.of(/* userId= */ 10)
val expectedInfo = val expectedInfo =
NOTE_TASK_INFO.copy( NOTE_TASK_INFO.copy(entryPoint = TAIL_BUTTON, isKeyguardLocked = true, user = user10)
entryPoint = NoteTaskEntryPoint.TAIL_BUTTON,
isKeyguardLocked = true,
user = user10,
)
whenever(keyguardManager.isKeyguardLocked).thenReturn(expectedInfo.isKeyguardLocked) whenever(keyguardManager.isKeyguardLocked).thenReturn(expectedInfo.isKeyguardLocked)
whenever(resolver.resolveInfo(any(), any(), any())).thenReturn(expectedInfo) whenever(resolver.resolveInfo(any(), any(), any())).thenReturn(expectedInfo)
createNoteTaskController() createNoteTaskController()
.showNoteTaskAsUser( .showNoteTaskAsUser(entryPoint = expectedInfo.entryPoint!!, user = user10)
entryPoint = expectedInfo.entryPoint!!,
user = user10,
)
val intentCaptor = argumentCaptor<Intent>() val intentCaptor = argumentCaptor<Intent>()
val userCaptor = argumentCaptor<UserHandle>() val userCaptor = argumentCaptor<UserHandle>()
verify(context).startActivityAsUser(capture(intentCaptor), capture(userCaptor)) verify(context).startActivityAsUser(capture(intentCaptor), capture(userCaptor))
intentCaptor.value.let { intent -> assertThat(intentCaptor.value).run {
assertThat(intent.action).isEqualTo(Intent.ACTION_CREATE_NOTE) hasAction(ACTION_CREATE_NOTE)
assertThat(intent.`package`).isEqualTo(NOTE_TASK_PACKAGE_NAME) hasPackage(NOTE_TASK_PACKAGE_NAME)
assertThat(intent.flags and FLAG_ACTIVITY_NEW_TASK).isEqualTo(FLAG_ACTIVITY_NEW_TASK) hasFlags(FLAG_ACTIVITY_NEW_TASK)
assertThat(intent.flags and FLAG_ACTIVITY_MULTIPLE_TASK) hasFlags(FLAG_ACTIVITY_MULTIPLE_TASK)
.isEqualTo(FLAG_ACTIVITY_MULTIPLE_TASK) hasFlags(FLAG_ACTIVITY_NEW_DOCUMENT)
assertThat(intent.flags and FLAG_ACTIVITY_NEW_DOCUMENT) extras().bool(EXTRA_USE_STYLUS_MODE).isTrue()
.isEqualTo(FLAG_ACTIVITY_NEW_DOCUMENT)
assertThat(intent.getBooleanExtra(Intent.EXTRA_USE_STYLUS_MODE, false)).isTrue()
} }
assertThat(userCaptor.value).isEqualTo(user10) assertThat(userCaptor.value).isEqualTo(user10)
verify(eventLogger).logNoteTaskOpened(expectedInfo) verify(eventLogger).logNoteTaskOpened(expectedInfo)
@@ -290,11 +277,7 @@ internal class NoteTaskControllerTest : SysuiTestCase() {
@Test @Test
fun showNoteTask_keyguardIsLocked_noteIsOpen_shouldCloseActivityAndLogUiEvent() { fun showNoteTask_keyguardIsLocked_noteIsOpen_shouldCloseActivityAndLogUiEvent() {
val expectedInfo = val expectedInfo = NOTE_TASK_INFO.copy(entryPoint = TAIL_BUTTON, isKeyguardLocked = true)
NOTE_TASK_INFO.copy(
entryPoint = NoteTaskEntryPoint.TAIL_BUTTON,
isKeyguardLocked = true,
)
whenever(keyguardManager.isKeyguardLocked).thenReturn(expectedInfo.isKeyguardLocked) whenever(keyguardManager.isKeyguardLocked).thenReturn(expectedInfo.isKeyguardLocked)
whenever(resolver.resolveInfo(any(), any(), any())).thenReturn(expectedInfo) whenever(resolver.resolveInfo(any(), any(), any())).thenReturn(expectedInfo)
whenever(activityManager.getRunningTasks(anyInt())) whenever(activityManager.getRunningTasks(anyInt()))
@@ -305,10 +288,10 @@ internal class NoteTaskControllerTest : SysuiTestCase() {
val intentCaptor = argumentCaptor<Intent>() val intentCaptor = argumentCaptor<Intent>()
val userCaptor = argumentCaptor<UserHandle>() val userCaptor = argumentCaptor<UserHandle>()
verify(context).startActivityAsUser(capture(intentCaptor), capture(userCaptor)) verify(context).startActivityAsUser(capture(intentCaptor), capture(userCaptor))
intentCaptor.value.let { intent -> assertThat(intentCaptor.value).run {
assertThat(intent.action).isEqualTo(ACTION_MAIN) hasAction(ACTION_MAIN)
assertThat(intent.categories).contains(CATEGORY_HOME) categories().contains(CATEGORY_HOME)
assertThat(intent.flags and FLAG_ACTIVITY_NEW_TASK).isEqualTo(FLAG_ACTIVITY_NEW_TASK) hasFlags(FLAG_ACTIVITY_NEW_TASK)
} }
assertThat(userCaptor.value).isEqualTo(userTracker.userHandle) assertThat(userCaptor.value).isEqualTo(userTracker.userHandle)
verify(eventLogger).logNoteTaskClosed(expectedInfo) verify(eventLogger).logNoteTaskClosed(expectedInfo)
@@ -317,18 +300,11 @@ internal class NoteTaskControllerTest : SysuiTestCase() {
@Test @Test
fun showNoteTask_keyguardIsUnlocked_shouldStartBubblesWithoutLoggingUiEvent() { fun showNoteTask_keyguardIsUnlocked_shouldStartBubblesWithoutLoggingUiEvent() {
val expectedInfo = val expectedInfo = NOTE_TASK_INFO.copy(entryPoint = TAIL_BUTTON, isKeyguardLocked = false)
NOTE_TASK_INFO.copy(
entryPoint = NoteTaskEntryPoint.TAIL_BUTTON,
isKeyguardLocked = false,
)
whenever(resolver.resolveInfo(any(), any(), any())).thenReturn(expectedInfo) whenever(resolver.resolveInfo(any(), any(), any())).thenReturn(expectedInfo)
whenever(keyguardManager.isKeyguardLocked).thenReturn(expectedInfo.isKeyguardLocked) whenever(keyguardManager.isKeyguardLocked).thenReturn(expectedInfo.isKeyguardLocked)
createNoteTaskController() createNoteTaskController().showNoteTask(entryPoint = expectedInfo.entryPoint!!)
.showNoteTask(
entryPoint = expectedInfo.entryPoint!!,
)
// Context package name used to create bubble icon from drawable resource id // Context package name used to create bubble icon from drawable resource id
verify(context).packageName verify(context).packageName
@@ -338,10 +314,7 @@ internal class NoteTaskControllerTest : SysuiTestCase() {
@Test @Test
fun showNoteTask_bubblesIsNull_shouldDoNothing() { fun showNoteTask_bubblesIsNull_shouldDoNothing() {
createNoteTaskController(bubbles = null) createNoteTaskController(bubbles = null).showNoteTask(entryPoint = TAIL_BUTTON)
.showNoteTask(
entryPoint = NoteTaskEntryPoint.TAIL_BUTTON,
)
verifyZeroInteractions(context, bubbles, eventLogger) verifyZeroInteractions(context, bubbles, eventLogger)
} }
@@ -352,7 +325,7 @@ internal class NoteTaskControllerTest : SysuiTestCase() {
val noteTaskController = spy(createNoteTaskController()) val noteTaskController = spy(createNoteTaskController())
doNothing().whenever(noteTaskController).showNoDefaultNotesAppToast() doNothing().whenever(noteTaskController).showNoDefaultNotesAppToast()
noteTaskController.showNoteTask(entryPoint = NoteTaskEntryPoint.TAIL_BUTTON) noteTaskController.showNoteTask(entryPoint = TAIL_BUTTON)
verify(noteTaskController).showNoDefaultNotesAppToast() verify(noteTaskController).showNoDefaultNotesAppToast()
verifyZeroInteractions(context, bubbles, eventLogger) verifyZeroInteractions(context, bubbles, eventLogger)
@@ -360,10 +333,7 @@ internal class NoteTaskControllerTest : SysuiTestCase() {
@Test @Test
fun showNoteTask_flagDisabled_shouldDoNothing() { fun showNoteTask_flagDisabled_shouldDoNothing() {
createNoteTaskController(isEnabled = false) createNoteTaskController(isEnabled = false).showNoteTask(entryPoint = TAIL_BUTTON)
.showNoteTask(
entryPoint = NoteTaskEntryPoint.TAIL_BUTTON,
)
verifyZeroInteractions(context, bubbles, eventLogger) verifyZeroInteractions(context, bubbles, eventLogger)
} }
@@ -372,10 +342,7 @@ internal class NoteTaskControllerTest : SysuiTestCase() {
fun showNoteTask_userIsLocked_shouldDoNothing() { fun showNoteTask_userIsLocked_shouldDoNothing() {
whenever(userManager.isUserUnlocked).thenReturn(false) whenever(userManager.isUserUnlocked).thenReturn(false)
createNoteTaskController() createNoteTaskController().showNoteTask(entryPoint = TAIL_BUTTON)
.showNoteTask(
entryPoint = NoteTaskEntryPoint.TAIL_BUTTON,
)
verifyZeroInteractions(context, bubbles, eventLogger) verifyZeroInteractions(context, bubbles, eventLogger)
} }
@@ -383,30 +350,22 @@ internal class NoteTaskControllerTest : SysuiTestCase() {
@Test @Test
fun showNoteTask_keyboardShortcut_shouldStartActivity() { fun showNoteTask_keyboardShortcut_shouldStartActivity() {
val expectedInfo = val expectedInfo =
NOTE_TASK_INFO.copy( NOTE_TASK_INFO.copy(entryPoint = KEYBOARD_SHORTCUT, isKeyguardLocked = true)
entryPoint = NoteTaskEntryPoint.KEYBOARD_SHORTCUT,
isKeyguardLocked = true,
)
whenever(keyguardManager.isKeyguardLocked).thenReturn(expectedInfo.isKeyguardLocked) whenever(keyguardManager.isKeyguardLocked).thenReturn(expectedInfo.isKeyguardLocked)
whenever(resolver.resolveInfo(any(), any(), any())).thenReturn(expectedInfo) whenever(resolver.resolveInfo(any(), any(), any())).thenReturn(expectedInfo)
createNoteTaskController() createNoteTaskController().showNoteTask(entryPoint = expectedInfo.entryPoint!!)
.showNoteTask(
entryPoint = expectedInfo.entryPoint!!,
)
val intentCaptor = argumentCaptor<Intent>() val intentCaptor = argumentCaptor<Intent>()
val userCaptor = argumentCaptor<UserHandle>() val userCaptor = argumentCaptor<UserHandle>()
verify(context).startActivityAsUser(capture(intentCaptor), capture(userCaptor)) verify(context).startActivityAsUser(capture(intentCaptor), capture(userCaptor))
intentCaptor.value.let { intent -> assertThat(intentCaptor.value).run {
assertThat(intent.action).isEqualTo(Intent.ACTION_CREATE_NOTE) hasAction(ACTION_CREATE_NOTE)
assertThat(intent.`package`).isEqualTo(NOTE_TASK_PACKAGE_NAME) hasPackage(NOTE_TASK_PACKAGE_NAME)
assertThat(intent.flags and FLAG_ACTIVITY_NEW_TASK).isEqualTo(FLAG_ACTIVITY_NEW_TASK) hasFlags(FLAG_ACTIVITY_NEW_TASK)
assertThat(intent.flags and FLAG_ACTIVITY_MULTIPLE_TASK) hasFlags(FLAG_ACTIVITY_MULTIPLE_TASK)
.isEqualTo(FLAG_ACTIVITY_MULTIPLE_TASK) hasFlags(FLAG_ACTIVITY_NEW_DOCUMENT)
assertThat(intent.flags and FLAG_ACTIVITY_NEW_DOCUMENT) extras().bool(EXTRA_USE_STYLUS_MODE).isFalse()
.isEqualTo(FLAG_ACTIVITY_NEW_DOCUMENT)
assertThat(intent.getBooleanExtra(Intent.EXTRA_USE_STYLUS_MODE, true)).isFalse()
} }
assertThat(userCaptor.value).isEqualTo(userTracker.userHandle) assertThat(userCaptor.value).isEqualTo(userTracker.userHandle)
verify(eventLogger).logNoteTaskOpened(expectedInfo) verify(eventLogger).logNoteTaskOpened(expectedInfo)
@@ -583,7 +542,7 @@ internal class NoteTaskControllerTest : SysuiTestCase() {
whenever(devicePolicyManager.isOrganizationOwnedDeviceWithManagedProfile).thenReturn(true) whenever(devicePolicyManager.isOrganizationOwnedDeviceWithManagedProfile).thenReturn(true)
userTracker.set(mainAndWorkProfileUsers, mainAndWorkProfileUsers.indexOf(mainUserInfo)) userTracker.set(mainAndWorkProfileUsers, mainAndWorkProfileUsers.indexOf(mainUserInfo))
createNoteTaskController().showNoteTask(entryPoint = NoteTaskEntryPoint.TAIL_BUTTON) createNoteTaskController().showNoteTask(entryPoint = TAIL_BUTTON)
verifyNoteTaskOpenInBubbleInUser(workUserInfo.userHandle) verifyNoteTaskOpenInBubbleInUser(workUserInfo.userHandle)
} }
@@ -593,8 +552,7 @@ internal class NoteTaskControllerTest : SysuiTestCase() {
whenever(devicePolicyManager.isOrganizationOwnedDeviceWithManagedProfile).thenReturn(true) whenever(devicePolicyManager.isOrganizationOwnedDeviceWithManagedProfile).thenReturn(true)
userTracker.set(mainAndWorkProfileUsers, mainAndWorkProfileUsers.indexOf(mainUserInfo)) userTracker.set(mainAndWorkProfileUsers, mainAndWorkProfileUsers.indexOf(mainUserInfo))
createNoteTaskController() createNoteTaskController().showNoteTask(entryPoint = WIDGET_PICKER_SHORTCUT)
.showNoteTask(entryPoint = NoteTaskEntryPoint.WIDGET_PICKER_SHORTCUT)
verifyNoteTaskOpenInBubbleInUser(mainUserInfo.userHandle) verifyNoteTaskOpenInBubbleInUser(mainUserInfo.userHandle)
} }
@@ -604,7 +562,7 @@ internal class NoteTaskControllerTest : SysuiTestCase() {
whenever(devicePolicyManager.isOrganizationOwnedDeviceWithManagedProfile).thenReturn(true) whenever(devicePolicyManager.isOrganizationOwnedDeviceWithManagedProfile).thenReturn(true)
userTracker.set(mainAndWorkProfileUsers, mainAndWorkProfileUsers.indexOf(mainUserInfo)) userTracker.set(mainAndWorkProfileUsers, mainAndWorkProfileUsers.indexOf(mainUserInfo))
createNoteTaskController().showNoteTask(entryPoint = NoteTaskEntryPoint.APP_CLIPS) createNoteTaskController().showNoteTask(entryPoint = APP_CLIPS)
verifyNoteTaskOpenInBubbleInUser(mainUserInfo.userHandle) verifyNoteTaskOpenInBubbleInUser(mainUserInfo.userHandle)
} }
@@ -615,13 +573,13 @@ internal class NoteTaskControllerTest : SysuiTestCase() {
val iconCaptor = argumentCaptor<Icon>() val iconCaptor = argumentCaptor<Icon>()
verify(bubbles) verify(bubbles)
.showOrHideAppBubble(capture(intentCaptor), eq(userHandle), capture(iconCaptor)) .showOrHideAppBubble(capture(intentCaptor), eq(userHandle), capture(iconCaptor))
intentCaptor.value.let { intent -> assertThat(intentCaptor.value).run {
assertThat(intent.action).isEqualTo(Intent.ACTION_CREATE_NOTE) hasAction(ACTION_CREATE_NOTE)
assertThat(intent.`package`).isEqualTo(NOTE_TASK_PACKAGE_NAME) hasPackage(NOTE_TASK_PACKAGE_NAME)
assertThat(intent.flags).isEqualTo(FLAG_ACTIVITY_NEW_TASK) hasFlags(FLAG_ACTIVITY_NEW_TASK)
assertThat(intent.getBooleanExtra(Intent.EXTRA_USE_STYLUS_MODE, false)).isTrue() extras().bool(EXTRA_USE_STYLUS_MODE).isTrue()
} }
iconCaptor.value.let { icon -> iconCaptor.value?.let { icon ->
assertThat(icon).isNotNull() assertThat(icon).isNotNull()
assertThat(icon.resId).isEqualTo(R.drawable.ic_note_task_shortcut_widget) assertThat(icon.resId).isEqualTo(R.drawable.ic_note_task_shortcut_widget)
} }
@@ -679,9 +637,10 @@ internal class NoteTaskControllerTest : SysuiTestCase() {
verify(shortcutManager).updateShortcuts(actualShortcuts.capture()) verify(shortcutManager).updateShortcuts(actualShortcuts.capture())
val actualShortcut = actualShortcuts.value.first() val actualShortcut = actualShortcuts.value.first()
assertThat(actualShortcut.id).isEqualTo(SHORTCUT_ID) assertThat(actualShortcut.id).isEqualTo(SHORTCUT_ID)
assertThat(actualShortcut.intent?.component?.className) assertThat(actualShortcut.intent).run {
.isEqualTo(LaunchNoteTaskActivity::class.java.name) hasComponentClass(LaunchNoteTaskActivity::class.java)
assertThat(actualShortcut.intent?.action).isEqualTo(Intent.ACTION_CREATE_NOTE) hasAction(ACTION_CREATE_NOTE)
}
assertThat(actualShortcut.shortLabel).isEqualTo(NOTE_TASK_SHORT_LABEL) assertThat(actualShortcut.shortLabel).isEqualTo(NOTE_TASK_SHORT_LABEL)
assertThat(actualShortcut.isLongLived).isEqualTo(true) assertThat(actualShortcut.isLongLived).isEqualTo(true)
assertThat(actualShortcut.icon.resId).isEqualTo(R.drawable.ic_note_task_shortcut_widget) assertThat(actualShortcut.icon.resId).isEqualTo(R.drawable.ic_note_task_shortcut_widget)
@@ -737,12 +696,9 @@ internal class NoteTaskControllerTest : SysuiTestCase() {
val intentCaptor = argumentCaptor<Intent>() val intentCaptor = argumentCaptor<Intent>()
verify(context).startActivityAsUser(intentCaptor.capture(), eq(user0)) verify(context).startActivityAsUser(intentCaptor.capture(), eq(user0))
intentCaptor.value.let { intent -> assertThat(intentCaptor.value).run {
assertThat(intent) hasComponentClass(LaunchNoteTaskManagedProfileProxyActivity::class.java)
.hasComponent( hasFlags(FLAG_ACTIVITY_NEW_TASK)
ComponentName(context, LaunchNoteTaskManagedProfileProxyActivity::class.java)
)
assertThat(intent).hasFlags(FLAG_ACTIVITY_NEW_TASK)
} }
} }
// endregion // endregion
@@ -817,9 +773,7 @@ internal class NoteTaskControllerTest : SysuiTestCase() {
val intentCaptor = argumentCaptor<Intent>() val intentCaptor = argumentCaptor<Intent>()
val userCaptor = argumentCaptor<UserHandle>() val userCaptor = argumentCaptor<UserHandle>()
verify(context).startActivityAsUser(capture(intentCaptor), capture(userCaptor)) verify(context).startActivityAsUser(capture(intentCaptor), capture(userCaptor))
intentCaptor.value.let { intent -> assertThat(intentCaptor.value).hasAction(ACTION_MANAGE_DEFAULT_APP)
assertThat(intent).hasAction(Intent.ACTION_MANAGE_DEFAULT_APP)
}
assertThat(userCaptor.value).isEqualTo(UserHandle.of(workUserInfo.id)) assertThat(userCaptor.value).isEqualTo(UserHandle.of(workUserInfo.id))
} }
@@ -833,9 +787,7 @@ internal class NoteTaskControllerTest : SysuiTestCase() {
val intentCaptor = argumentCaptor<Intent>() val intentCaptor = argumentCaptor<Intent>()
val userCaptor = argumentCaptor<UserHandle>() val userCaptor = argumentCaptor<UserHandle>()
verify(context).startActivityAsUser(capture(intentCaptor), capture(userCaptor)) verify(context).startActivityAsUser(capture(intentCaptor), capture(userCaptor))
intentCaptor.value.let { intent -> assertThat(intentCaptor.value).hasAction(ACTION_MANAGE_DEFAULT_APP)
assertThat(intent).hasAction(Intent.ACTION_MANAGE_DEFAULT_APP)
}
assertThat(userCaptor.value).isEqualTo(UserHandle.of(mainUserInfo.id)) assertThat(userCaptor.value).isEqualTo(UserHandle.of(mainUserInfo.id))
} }
@@ -848,9 +800,7 @@ internal class NoteTaskControllerTest : SysuiTestCase() {
val intentCaptor = argumentCaptor<Intent>() val intentCaptor = argumentCaptor<Intent>()
val userCaptor = argumentCaptor<UserHandle>() val userCaptor = argumentCaptor<UserHandle>()
verify(context).startActivityAsUser(capture(intentCaptor), capture(userCaptor)) verify(context).startActivityAsUser(capture(intentCaptor), capture(userCaptor))
intentCaptor.value.let { intent -> assertThat(intentCaptor.value).hasAction(ACTION_MANAGE_DEFAULT_APP)
assertThat(intent).hasAction(Intent.ACTION_MANAGE_DEFAULT_APP)
}
assertThat(userCaptor.value).isEqualTo(UserHandle.of(mainUserInfo.id)) assertThat(userCaptor.value).isEqualTo(UserHandle.of(mainUserInfo.id))
} }
@@ -863,9 +813,7 @@ internal class NoteTaskControllerTest : SysuiTestCase() {
val intentCaptor = argumentCaptor<Intent>() val intentCaptor = argumentCaptor<Intent>()
val userCaptor = argumentCaptor<UserHandle>() val userCaptor = argumentCaptor<UserHandle>()
verify(context).startActivityAsUser(capture(intentCaptor), capture(userCaptor)) verify(context).startActivityAsUser(capture(intentCaptor), capture(userCaptor))
intentCaptor.value.let { intent -> assertThat(intentCaptor.value).hasAction(ACTION_MANAGE_DEFAULT_APP)
assertThat(intent).hasAction(Intent.ACTION_MANAGE_DEFAULT_APP)
}
assertThat(userCaptor.value).isEqualTo(UserHandle.of(mainUserInfo.id)) assertThat(userCaptor.value).isEqualTo(UserHandle.of(mainUserInfo.id))
} }
// endregion // endregion