Search in sources :

Example 51 with StorageItemPreference

use of com.android.settings.deviceinfo.StorageItemPreference in project android_packages_apps_Settings by crdroidandroid.

the class StorageItemPreferenceControllerTest method displayPreference_dontHideFilePreferenceWhenEmulatedInternalStorageUsed.

@Test
public void displayPreference_dontHideFilePreferenceWhenEmulatedInternalStorageUsed() {
    StorageItemPreference audio = new StorageItemPreference(mContext);
    StorageItemPreference image = new StorageItemPreference(mContext);
    StorageItemPreference games = new StorageItemPreference(mContext);
    StorageItemPreference apps = new StorageItemPreference(mContext);
    StorageItemPreference system = new StorageItemPreference(mContext);
    StorageItemPreference files = new StorageItemPreference(mContext);
    PreferenceScreen screen = mock(PreferenceScreen.class);
    when(screen.findPreference(eq(StorageItemPreferenceController.AUDIO_KEY))).thenReturn(audio);
    when(screen.findPreference(eq(StorageItemPreferenceController.PHOTO_KEY))).thenReturn(image);
    when(screen.findPreference(eq(StorageItemPreferenceController.GAME_KEY))).thenReturn(games);
    when(screen.findPreference(eq(StorageItemPreferenceController.OTHER_APPS_KEY))).thenReturn(apps);
    when(screen.findPreference(eq(StorageItemPreferenceController.SYSTEM_KEY))).thenReturn(system);
    when(screen.findPreference(eq(StorageItemPreferenceController.FILES_KEY))).thenReturn(files);
    when(mSvp.findEmulatedForPrivate(nullable(VolumeInfo.class))).thenReturn(mVolume);
    when(mVolume.isMountedReadable()).thenReturn(true);
    mController.displayPreference(screen);
    verify(screen, times(0)).removePreference(files);
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) VolumeInfo(android.os.storage.VolumeInfo) StorageItemPreference(com.android.settings.deviceinfo.StorageItemPreference) Test(org.junit.Test)

Example 52 with StorageItemPreference

use of com.android.settings.deviceinfo.StorageItemPreference in project android_packages_apps_Settings by crdroidandroid.

the class StorageItemPreferenceControllerTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application.getApplicationContext());
    FakeFeatureFactory.setupForTest(mContext);
    mFakeFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
    mMetricsFeatureProvider = mFakeFeatureFactory.getMetricsFeatureProvider();
    mVolume = spy(new VolumeInfo("id", 0, null, "id"));
    // Note: null is passed as the Lifecycle because we are handling it outside of the normal
    // Settings fragment lifecycle for test purposes.
    mController = new StorageItemPreferenceController(mContext, mFragment, mVolume, mSvp);
    mPreference = new StorageItemPreference(mContext);
    // Inflate the preference and the widget.
    LayoutInflater inflater = LayoutInflater.from(mContext);
    final View view = inflater.inflate(mPreference.getLayoutResource(), new LinearLayout(mContext), false);
}
Also used : LayoutInflater(android.view.LayoutInflater) VolumeInfo(android.os.storage.VolumeInfo) StorageItemPreference(com.android.settings.deviceinfo.StorageItemPreference) View(android.view.View) LinearLayout(android.widget.LinearLayout) Before(org.junit.Before)

Example 53 with StorageItemPreference

use of com.android.settings.deviceinfo.StorageItemPreference in project android_packages_apps_Settings by SudaMod.

the class StorageItemPreferenceControllerTest method displayPreference_updateFilePreferenceToHideAfterSettingVolume.

@Test
public void displayPreference_updateFilePreferenceToHideAfterSettingVolume() {
    StorageItemPreference audio = new StorageItemPreference(mContext);
    StorageItemPreference image = new StorageItemPreference(mContext);
    StorageItemPreference games = new StorageItemPreference(mContext);
    StorageItemPreference apps = new StorageItemPreference(mContext);
    StorageItemPreference system = new StorageItemPreference(mContext);
    StorageItemPreference files = new StorageItemPreference(mContext);
    PreferenceScreen screen = mock(PreferenceScreen.class);
    when(screen.findPreference(eq(StorageItemPreferenceController.AUDIO_KEY))).thenReturn(audio);
    when(screen.findPreference(eq(StorageItemPreferenceController.PHOTO_KEY))).thenReturn(image);
    when(screen.findPreference(eq(StorageItemPreferenceController.GAME_KEY))).thenReturn(games);
    when(screen.findPreference(eq(StorageItemPreferenceController.OTHER_APPS_KEY))).thenReturn(apps);
    when(screen.findPreference(eq(StorageItemPreferenceController.SYSTEM_KEY))).thenReturn(system);
    when(screen.findPreference(eq(StorageItemPreferenceController.FILES_KEY))).thenReturn(files);
    when(mSvp.findEmulatedForPrivate(nullable(VolumeInfo.class))).thenReturn(mVolume);
    when(mVolume.isMountedReadable()).thenReturn(true);
    mController.displayPreference(screen);
    when(mSvp.findEmulatedForPrivate(nullable(VolumeInfo.class))).thenReturn(null);
    mController.setVolume(mVolume);
    verify(screen).removePreference(files);
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) VolumeInfo(android.os.storage.VolumeInfo) StorageItemPreference(com.android.settings.deviceinfo.StorageItemPreference) Test(org.junit.Test)

Example 54 with StorageItemPreference

use of com.android.settings.deviceinfo.StorageItemPreference in project android_packages_apps_Settings by SudaMod.

the class StorageItemPreferenceControllerTest method settingUserIdAppliesNewIcons.

@Test
public void settingUserIdAppliesNewIcons() {
    StorageItemPreference audio = spy(new StorageItemPreference(mContext));
    audio.setIcon(R.drawable.ic_media_stream);
    StorageItemPreference video = spy(new StorageItemPreference(mContext));
    video.setIcon(R.drawable.ic_local_movies);
    StorageItemPreference image = spy(new StorageItemPreference(mContext));
    image.setIcon(R.drawable.ic_photo_library);
    StorageItemPreference games = spy(new StorageItemPreference(mContext));
    games.setIcon(R.drawable.ic_videogame_vd_theme_24);
    StorageItemPreference apps = spy(new StorageItemPreference(mContext));
    apps.setIcon(R.drawable.ic_storage_apps);
    StorageItemPreference system = spy(new StorageItemPreference(mContext));
    system.setIcon(R.drawable.ic_system_update_vd_theme_24);
    StorageItemPreference files = spy(new StorageItemPreference(mContext));
    files.setIcon(R.drawable.ic_folder_vd_theme_24);
    PreferenceScreen screen = mock(PreferenceScreen.class);
    when(screen.findPreference(eq(StorageItemPreferenceController.AUDIO_KEY))).thenReturn(audio);
    when(screen.findPreference(eq(StorageItemPreferenceController.MOVIES_KEY))).thenReturn(video);
    when(screen.findPreference(eq(StorageItemPreferenceController.PHOTO_KEY))).thenReturn(image);
    when(screen.findPreference(eq(StorageItemPreferenceController.GAME_KEY))).thenReturn(games);
    when(screen.findPreference(eq(StorageItemPreferenceController.OTHER_APPS_KEY))).thenReturn(apps);
    when(screen.findPreference(eq(StorageItemPreferenceController.SYSTEM_KEY))).thenReturn(system);
    when(screen.findPreference(eq(StorageItemPreferenceController.FILES_KEY))).thenReturn(files);
    mController.displayPreference(screen);
    mController.setUserId(new UserHandle(10));
    verify(audio, times(2)).setIcon(nullable(Drawable.class));
    verify(video, times(2)).setIcon(nullable(Drawable.class));
    verify(image, times(2)).setIcon(nullable(Drawable.class));
    verify(games, times(2)).setIcon(nullable(Drawable.class));
    verify(apps, times(2)).setIcon(nullable(Drawable.class));
    verify(system, times(2)).setIcon(nullable(Drawable.class));
    verify(files, times(2)).setIcon(nullable(Drawable.class));
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) UserHandle(android.os.UserHandle) Drawable(android.graphics.drawable.Drawable) StorageItemPreference(com.android.settings.deviceinfo.StorageItemPreference) Test(org.junit.Test)

Example 55 with StorageItemPreference

use of com.android.settings.deviceinfo.StorageItemPreference in project android_packages_apps_Settings by SudaMod.

the class StorageItemPreferenceControllerTest method displayPreference_dontHideFilePreferenceWhenEmulatedInternalStorageUsed.

@Test
public void displayPreference_dontHideFilePreferenceWhenEmulatedInternalStorageUsed() {
    StorageItemPreference audio = new StorageItemPreference(mContext);
    StorageItemPreference image = new StorageItemPreference(mContext);
    StorageItemPreference games = new StorageItemPreference(mContext);
    StorageItemPreference apps = new StorageItemPreference(mContext);
    StorageItemPreference system = new StorageItemPreference(mContext);
    StorageItemPreference files = new StorageItemPreference(mContext);
    PreferenceScreen screen = mock(PreferenceScreen.class);
    when(screen.findPreference(eq(StorageItemPreferenceController.AUDIO_KEY))).thenReturn(audio);
    when(screen.findPreference(eq(StorageItemPreferenceController.PHOTO_KEY))).thenReturn(image);
    when(screen.findPreference(eq(StorageItemPreferenceController.GAME_KEY))).thenReturn(games);
    when(screen.findPreference(eq(StorageItemPreferenceController.OTHER_APPS_KEY))).thenReturn(apps);
    when(screen.findPreference(eq(StorageItemPreferenceController.SYSTEM_KEY))).thenReturn(system);
    when(screen.findPreference(eq(StorageItemPreferenceController.FILES_KEY))).thenReturn(files);
    when(mSvp.findEmulatedForPrivate(nullable(VolumeInfo.class))).thenReturn(mVolume);
    when(mVolume.isMountedReadable()).thenReturn(true);
    mController.displayPreference(screen);
    verify(screen, times(0)).removePreference(files);
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) VolumeInfo(android.os.storage.VolumeInfo) StorageItemPreference(com.android.settings.deviceinfo.StorageItemPreference) Test(org.junit.Test)

Aggregations

StorageItemPreference (com.android.settings.deviceinfo.StorageItemPreference)71 Test (org.junit.Test)48 VolumeInfo (android.os.storage.VolumeInfo)42 PreferenceScreen (android.support.v7.preference.PreferenceScreen)41 PreferenceScreen (androidx.preference.PreferenceScreen)8 SparseArray (android.util.SparseArray)7 LayoutInflater (android.view.LayoutInflater)7 LinearLayout (android.widget.LinearLayout)7 StorageStatsSource (com.android.settingslib.applications.StorageStatsSource)7 Before (org.junit.Before)7 Drawable (android.graphics.drawable.Drawable)6 UserHandle (android.os.UserHandle)6 PreferenceGroup (android.support.v7.preference.PreferenceGroup)5 View (android.view.View)5 PreferenceGroup (androidx.preference.PreferenceGroup)1