Search in sources :

Example 21 with UserIconDrawable

use of com.android.settingslib.drawable.UserIconDrawable in project android_packages_apps_Settings by SudaMod.

the class UserProfileControllerTest method iconCallbackChangesPreferenceIcon.

@Test
public void iconCallbackChangesPreferenceIcon() throws Exception {
    SparseArray<Drawable> icons = new SparseArray<>();
    Bitmap userBitmap = BitmapFactory.decodeResource(RuntimeEnvironment.application.getResources(), R.drawable.home);
    UserIconDrawable drawable = new UserIconDrawable(100).setIcon(userBitmap).bake();
    icons.put(10, drawable);
    mController.handleUserIcons(icons);
    final ArgumentCaptor<Preference> argumentCaptor = ArgumentCaptor.forClass(Preference.class);
    verify(mScreen).addPreference(argumentCaptor.capture());
    Preference preference = argumentCaptor.getValue();
    assertThat(preference.getIcon()).isEqualTo(drawable);
}
Also used : SparseArray(android.util.SparseArray) Bitmap(android.graphics.Bitmap) Preference(android.support.v7.preference.Preference) Drawable(android.graphics.drawable.Drawable) UserIconDrawable(com.android.settingslib.drawable.UserIconDrawable) UserIconDrawable(com.android.settingslib.drawable.UserIconDrawable) Test(org.junit.Test)

Example 22 with UserIconDrawable

use of com.android.settingslib.drawable.UserIconDrawable in project platform_packages_apps_Settings by BlissRoms.

the class SecondaryUserControllerTest method iconCallbackChangesPreferenceIcon.

@Test
public void iconCallbackChangesPreferenceIcon() throws Exception {
    SparseArray<Drawable> icons = new SparseArray<>();
    Bitmap userBitmap = BitmapFactory.decodeResource(RuntimeEnvironment.application.getResources(), R.drawable.home);
    UserIconDrawable drawable = new UserIconDrawable(100).setIcon(userBitmap).bake();
    icons.put(10, drawable);
    mPrimaryUser.name = TEST_NAME;
    mPrimaryUser.id = 10;
    mController.displayPreference(mScreen);
    mController.handleUserIcons(icons);
    final ArgumentCaptor<Preference> argumentCaptor = ArgumentCaptor.forClass(Preference.class);
    verify(mGroup).addPreference(argumentCaptor.capture());
    Preference preference = argumentCaptor.getValue();
    assertThat(preference.getIcon()).isEqualTo(drawable);
}
Also used : SparseArray(android.util.SparseArray) Bitmap(android.graphics.Bitmap) Preference(android.support.v7.preference.Preference) Drawable(android.graphics.drawable.Drawable) UserIconDrawable(com.android.settingslib.drawable.UserIconDrawable) UserIconDrawable(com.android.settingslib.drawable.UserIconDrawable) Test(org.junit.Test)

Example 23 with UserIconDrawable

use of com.android.settingslib.drawable.UserIconDrawable in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SecondaryUserControllerTest method setIcon_doesntNpeOnNullPreference.

@Test
public void setIcon_doesntNpeOnNullPreference() {
    final SparseArray<Drawable> icons = new SparseArray<>();
    final UserIconDrawable drawable = mock(UserIconDrawable.class);
    mPrimaryUser.name = TEST_NAME;
    mPrimaryUser.id = 10;
    icons.put(mPrimaryUser.id, drawable);
    mController.handleUserIcons(icons);
// Doesn't crash
}
Also used : SparseArray(android.util.SparseArray) Drawable(android.graphics.drawable.Drawable) UserIconDrawable(com.android.settingslib.drawable.UserIconDrawable) UserIconDrawable(com.android.settingslib.drawable.UserIconDrawable) Test(org.junit.Test)

Example 24 with UserIconDrawable

use of com.android.settingslib.drawable.UserIconDrawable in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class UserProfileControllerTest method iconCallbackChangesPreferenceIcon.

@Test
public void iconCallbackChangesPreferenceIcon() {
    final SparseArray<Drawable> icons = new SparseArray<>();
    final UserIconDrawable drawable = mock(UserIconDrawable.class);
    when(drawable.mutate()).thenReturn(drawable);
    icons.put(mPrimaryProfile.id, drawable);
    mController.handleUserIcons(icons);
    final ArgumentCaptor<Preference> argumentCaptor = ArgumentCaptor.forClass(Preference.class);
    verify(mScreen).addPreference(argumentCaptor.capture());
    final Preference preference = argumentCaptor.getValue();
    assertThat(preference.getIcon()).isEqualTo(drawable);
}
Also used : SparseArray(android.util.SparseArray) Preference(androidx.preference.Preference) Drawable(android.graphics.drawable.Drawable) UserIconDrawable(com.android.settingslib.drawable.UserIconDrawable) UserIconDrawable(com.android.settingslib.drawable.UserIconDrawable) Test(org.junit.Test)

Example 25 with UserIconDrawable

use of com.android.settingslib.drawable.UserIconDrawable in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SecondaryUserControllerTest method iconCallbackChangesPreferenceIcon.

@Test
public void iconCallbackChangesPreferenceIcon() {
    final SparseArray<Drawable> icons = new SparseArray<>();
    final UserIconDrawable drawable = mock(UserIconDrawable.class);
    when(drawable.mutate()).thenReturn(drawable);
    mPrimaryUser.name = TEST_NAME;
    mPrimaryUser.id = 10;
    icons.put(mPrimaryUser.id, drawable);
    mController.displayPreference(mScreen);
    mController.handleUserIcons(icons);
    final ArgumentCaptor<Preference> argumentCaptor = ArgumentCaptor.forClass(Preference.class);
    verify(mGroup).addPreference(argumentCaptor.capture());
    final Preference preference = argumentCaptor.getValue();
    assertThat(preference.getIcon()).isEqualTo(drawable);
}
Also used : SparseArray(android.util.SparseArray) Preference(androidx.preference.Preference) Drawable(android.graphics.drawable.Drawable) UserIconDrawable(com.android.settingslib.drawable.UserIconDrawable) UserIconDrawable(com.android.settingslib.drawable.UserIconDrawable) Test(org.junit.Test)

Aggregations

Drawable (android.graphics.drawable.Drawable)26 UserIconDrawable (com.android.settingslib.drawable.UserIconDrawable)26 Bitmap (android.graphics.Bitmap)21 SparseArray (android.util.SparseArray)21 Test (org.junit.Test)21 Preference (android.support.v7.preference.Preference)11 Context (android.content.Context)5 PackageManager (android.content.pm.PackageManager)5 UserInfo (android.content.pm.UserInfo)5 Resources (android.content.res.Resources)5 Cursor (android.database.Cursor)5 RemoteException (android.os.RemoteException)5 UserHandle (android.os.UserHandle)5 UserManager (android.os.UserManager)5 Pair (android.util.Pair)5 Preference (androidx.preference.Preference)3