Search in sources :

Example 6 with LauncherActivityInfo

use of android.content.pm.LauncherActivityInfo in project robolectric by robolectric.

the class ShadowLauncherAppsTest method testGetActivityList_packageNull_getsActivitiesFromAllPackagesForUser.

@Test
@Config(minSdk = N, maxSdk = R)
public void testGetActivityList_packageNull_getsActivitiesFromAllPackagesForUser() {
    LauncherActivityInfo launcherActivityInfo1 = createLauncherActivityInfoPostN(TEST_PACKAGE_NAME, USER_HANDLE);
    LauncherActivityInfo launcherActivityInfo2 = createLauncherActivityInfoPostN(TEST_PACKAGE_NAME_2, USER_HANDLE);
    LauncherActivityInfo launcherActivityInfo3 = createLauncherActivityInfoPostN(TEST_PACKAGE_NAME_3, UserHandle.of(10));
    shadowOf(launcherApps).addActivity(USER_HANDLE, launcherActivityInfo1);
    shadowOf(launcherApps).addActivity(USER_HANDLE, launcherActivityInfo2);
    shadowOf(launcherApps).addActivity(UserHandle.of(10), launcherActivityInfo3);
    assertThat(launcherApps.getActivityList(null, USER_HANDLE)).containsExactly(launcherActivityInfo1, launcherActivityInfo2);
}
Also used : LauncherActivityInfo(android.content.pm.LauncherActivityInfo) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 7 with LauncherActivityInfo

use of android.content.pm.LauncherActivityInfo in project robolectric by robolectric.

the class ShadowLauncherAppsTest method getShortcutConfigActivityListS_getsShortcutsForUserHandle.

@Test
@Config(minSdk = S)
public void getShortcutConfigActivityListS_getsShortcutsForUserHandle() {
    LauncherActivityInfo launcherActivityInfo1 = createLauncherActivityInfoS(TEST_PACKAGE_NAME, USER_HANDLE);
    LauncherActivityInfo launcherActivityInfo2 = createLauncherActivityInfoS(TEST_PACKAGE_NAME, UserHandle.of(10));
    shadowOf(launcherApps).addShortcutConfigActivity(USER_HANDLE, launcherActivityInfo1);
    shadowOf(launcherApps).addShortcutConfigActivity(UserHandle.of(10), launcherActivityInfo2);
    assertThat(launcherApps.getShortcutConfigActivityList(TEST_PACKAGE_NAME, UserHandle.of(10))).contains(launcherActivityInfo2);
}
Also used : LauncherActivityInfo(android.content.pm.LauncherActivityInfo) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 8 with LauncherActivityInfo

use of android.content.pm.LauncherActivityInfo in project robolectric by robolectric.

the class ShadowLauncherAppsTest method testGetActivityListS_getsActivitiesFromAllPackagesForUser.

@Test
@Config(minSdk = S)
public void testGetActivityListS_getsActivitiesFromAllPackagesForUser() {
    LauncherActivityInfo launcherActivityInfo = createLauncherActivityInfoS(TEST_PACKAGE_NAME, USER_HANDLE);
    LauncherActivityInfo launcherActivityInfo2 = createLauncherActivityInfoS(TEST_PACKAGE_NAME_2, USER_HANDLE);
    shadowOf(launcherApps).addActivity(USER_HANDLE, launcherActivityInfo);
    shadowOf(launcherApps).addActivity(USER_HANDLE, launcherActivityInfo2);
    assertThat(launcherApps.getActivityList(null, USER_HANDLE)).containsExactly(launcherActivityInfo, launcherActivityInfo2);
}
Also used : LauncherActivityInfo(android.content.pm.LauncherActivityInfo) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 9 with LauncherActivityInfo

use of android.content.pm.LauncherActivityInfo in project robolectric by robolectric.

the class ShadowLauncherAppsTest method createLauncherActivityInfoPostN.

private LauncherActivityInfo createLauncherActivityInfoPostN(String packageName, UserHandle userHandle) {
    ActivityInfo info = new ActivityInfo();
    info.packageName = packageName;
    info.name = packageName;
    info.nonLocalizedLabel = packageName;
    return ReflectionHelpers.callConstructor(LauncherActivityInfo.class, ClassParameter.from(Context.class, ApplicationProvider.getApplicationContext()), ClassParameter.from(ActivityInfo.class, info), ClassParameter.from(UserHandle.class, userHandle));
}
Also used : Context(android.content.Context) ActivityInfo(android.content.pm.ActivityInfo) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) UserHandle(android.os.UserHandle)

Example 10 with LauncherActivityInfo

use of android.content.pm.LauncherActivityInfo in project robolectric by robolectric.

the class ShadowLauncherAppsTest method getShortcutConfigActivityList_getsShortcutsForPackageName.

@Test
@Config(minSdk = O, maxSdk = R)
public void getShortcutConfigActivityList_getsShortcutsForPackageName() {
    LauncherActivityInfo launcherActivityInfo1 = createLauncherActivityInfoPostN(TEST_PACKAGE_NAME, USER_HANDLE);
    LauncherActivityInfo launcherActivityInfo2 = createLauncherActivityInfoPostN(TEST_PACKAGE_NAME_2, USER_HANDLE);
    shadowOf(launcherApps).addShortcutConfigActivity(USER_HANDLE, launcherActivityInfo1);
    shadowOf(launcherApps).addShortcutConfigActivity(USER_HANDLE, launcherActivityInfo2);
    assertThat(launcherApps.getShortcutConfigActivityList(TEST_PACKAGE_NAME, USER_HANDLE)).contains(launcherActivityInfo1);
}
Also used : LauncherActivityInfo(android.content.pm.LauncherActivityInfo) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Aggregations

LauncherActivityInfo (android.content.pm.LauncherActivityInfo)82 LauncherApps (android.content.pm.LauncherApps)38 ArrayList (java.util.ArrayList)31 UserHandle (android.os.UserHandle)26 Intent (android.content.Intent)20 ComponentName (android.content.ComponentName)15 List (java.util.List)13 UserManager (android.os.UserManager)12 Test (org.junit.Test)11 Point (android.graphics.Point)10 PackageManager (android.content.pm.PackageManager)9 ResolveInfo (android.content.pm.ResolveInfo)9 Config (org.robolectric.annotation.Config)9 SuppressLint (android.annotation.SuppressLint)8 AppInfo (com.android.launcher3.model.data.AppInfo)8 Context (android.content.Context)7 SharedPreferences (android.content.SharedPreferences)7 ShortcutInfo (android.content.pm.ShortcutInfo)7 AppInfo (com.android.launcher3.AppInfo)7 SessionInfo (android.content.pm.PackageInstaller.SessionInfo)6