use of com.android.settings.deviceinfo.StorageItemPreference in project platform_packages_apps_Settings by BlissRoms.
the class UserProfileController method displayPreference.
@Override
public void displayPreference(PreferenceScreen screen) {
mStoragePreference = new StorageItemPreference(screen.getContext());
mStoragePreference.setOrder(mPreferenceOrder);
mStoragePreference.setKey(PREFERENCE_KEY_BASE + mUser.id);
mStoragePreference.setTitle(mUser.name);
screen.addPreference(mStoragePreference);
}
use of com.android.settings.deviceinfo.StorageItemPreference in project platform_packages_apps_Settings by BlissRoms.
the class StorageItemPreferenceControllerTest method displayPreference_hideFilePreferenceWhenEmulatedStorageUnreadable.
@Test
public void displayPreference_hideFilePreferenceWhenEmulatedStorageUnreadable() {
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(false);
mController.displayPreference(screen);
verify(screen).removePreference(files);
}
use of com.android.settings.deviceinfo.StorageItemPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class StorageItemPreferenceControllerTest method displayPreference_updateFilePreferenceToShowAfterSettingVolume.
@Test
public void displayPreference_updateFilePreferenceToShowAfterSettingVolume() {
final StorageItemPreference audio = new StorageItemPreference(mContext);
final StorageItemPreference image = new StorageItemPreference(mContext);
final StorageItemPreference games = new StorageItemPreference(mContext);
final StorageItemPreference apps = new StorageItemPreference(mContext);
final StorageItemPreference system = new StorageItemPreference(mContext);
final StorageItemPreference files = new StorageItemPreference(mContext);
final PreferenceScreen screen = mock(PreferenceScreen.class);
when(screen.findPreference(eq(StorageItemPreferenceController.GAME_KEY))).thenReturn(games);
when(screen.findPreference(eq(StorageItemPreferenceController.AUDIO_KEY))).thenReturn(audio);
when(screen.findPreference(eq(StorageItemPreferenceController.PHOTO_KEY))).thenReturn(image);
when(screen.findPreference(eq(StorageItemPreferenceController.FILES_KEY))).thenReturn(files);
when(screen.findPreference(eq(StorageItemPreferenceController.SYSTEM_KEY))).thenReturn(system);
when(screen.findPreference(eq(StorageItemPreferenceController.OTHER_APPS_KEY))).thenReturn(apps);
// This will hide it initially.
mController.displayPreference(screen);
when(mSvp.findEmulatedForPrivate(nullable(VolumeInfo.class))).thenReturn(mVolume);
when(mVolume.isMountedReadable()).thenReturn(true);
// And we bring it back.
mController.setVolume(mVolume);
verify(screen).addPreference(files);
}
use of com.android.settings.deviceinfo.StorageItemPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class StorageItemPreferenceControllerTest method displayPreference_updateFilePreferenceToHideAfterSettingVolume.
@Test
public void displayPreference_updateFilePreferenceToHideAfterSettingVolume() {
final StorageItemPreference audio = new StorageItemPreference(mContext);
final StorageItemPreference image = new StorageItemPreference(mContext);
final StorageItemPreference games = new StorageItemPreference(mContext);
final StorageItemPreference apps = new StorageItemPreference(mContext);
final StorageItemPreference system = new StorageItemPreference(mContext);
final StorageItemPreference files = new StorageItemPreference(mContext);
final PreferenceScreen screen = mock(PreferenceScreen.class);
when(screen.findPreference(eq(StorageItemPreferenceController.GAME_KEY))).thenReturn(games);
when(screen.findPreference(eq(StorageItemPreferenceController.AUDIO_KEY))).thenReturn(audio);
when(screen.findPreference(eq(StorageItemPreferenceController.PHOTO_KEY))).thenReturn(image);
when(screen.findPreference(eq(StorageItemPreferenceController.FILES_KEY))).thenReturn(files);
when(screen.findPreference(eq(StorageItemPreferenceController.SYSTEM_KEY))).thenReturn(system);
when(screen.findPreference(eq(StorageItemPreferenceController.OTHER_APPS_KEY))).thenReturn(apps);
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);
}
use of com.android.settings.deviceinfo.StorageItemPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class StorageItemPreferenceControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
when(mFragment.getActivity()).thenReturn(mActivity);
when(mFragment.getFragmentManager()).thenReturn(mFragmentManager);
when(mFragmentManager.beginTransaction()).thenReturn(mFragmentTransaction);
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
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.
final LayoutInflater inflater = LayoutInflater.from(mContext);
inflater.inflate(mPreference.getLayoutResource(), new LinearLayout(mContext), false);
}
Aggregations