[Settings] Hide data usage when SIM support is turn OFF
Enable the UI control through configuration. Bug: 240515161 Test: local, auto test Change-Id: I4e0db5688dc1b074d43f9d77dd2f6d4cc53a353c
This commit is contained in:
@@ -110,7 +110,10 @@ public class AppDataUsageTest {
|
||||
@Test
|
||||
@Config(shadows = ShadowFragment.class)
|
||||
public void onCreate_appUid_shouldGetAppLabelFromAppInfo() throws NameNotFoundException {
|
||||
mFragment = spy(new AppDataUsage());
|
||||
mFragment = spy(new AppDataUsage() {
|
||||
@Override
|
||||
public boolean isSimHardwareVisible(Context context) { return true; }
|
||||
});
|
||||
final FragmentActivity activity = spy(Robolectric.setupActivity(FragmentActivity.class));
|
||||
doReturn(mPackageManager).when(activity).getPackageManager();
|
||||
doReturn(activity).when(mFragment).getActivity();
|
||||
@@ -140,7 +143,10 @@ public class AppDataUsageTest {
|
||||
@Test
|
||||
@Config(shadows = ShadowFragment.class)
|
||||
public void onCreate_notAppUid_shouldGetAppLabelFromUidDetailProvider() {
|
||||
mFragment = spy(new AppDataUsage());
|
||||
mFragment = spy(new AppDataUsage() {
|
||||
@Override
|
||||
public boolean isSimHardwareVisible(Context context) { return true; }
|
||||
});
|
||||
ReflectionHelpers.setField(mFragment, "mDashboardFeatureProvider",
|
||||
FakeFeatureFactory.setupForTest().dashboardFeatureProvider);
|
||||
doReturn(Robolectric.setupActivity(FragmentActivity.class)).when(mFragment).getActivity();
|
||||
@@ -167,7 +173,10 @@ public class AppDataUsageTest {
|
||||
|
||||
@Test
|
||||
public void bindAppHeader_allWorkApps_shouldNotShowAppInfoLink() {
|
||||
mFragment = spy(new AppDataUsage());
|
||||
mFragment = spy(new AppDataUsage() {
|
||||
@Override
|
||||
public boolean isSimHardwareVisible(Context context) { return true; }
|
||||
});
|
||||
|
||||
when(mFragment.getPreferenceManager())
|
||||
.thenReturn(mock(PreferenceManager.class, RETURNS_DEEP_STUBS));
|
||||
@@ -184,7 +193,10 @@ public class AppDataUsageTest {
|
||||
throws PackageManager.NameNotFoundException {
|
||||
final int fakeUserId = 100;
|
||||
|
||||
mFragment = spy(new AppDataUsage());
|
||||
mFragment = spy(new AppDataUsage() {
|
||||
@Override
|
||||
public boolean isSimHardwareVisible(Context context) { return true; }
|
||||
});
|
||||
final ArraySet<String> packages = new ArraySet<>();
|
||||
packages.add("pkg");
|
||||
final AppItem appItem = new AppItem(123456789);
|
||||
@@ -210,7 +222,10 @@ public class AppDataUsageTest {
|
||||
|
||||
@Test
|
||||
public void changePreference_backgroundData_shouldUpdateUI() {
|
||||
mFragment = spy(new AppDataUsage());
|
||||
mFragment = spy(new AppDataUsage() {
|
||||
@Override
|
||||
public boolean isSimHardwareVisible(Context context) { return true; }
|
||||
});
|
||||
final AppItem appItem = new AppItem(123456789);
|
||||
final RestrictedSwitchPreference pref = mock(RestrictedSwitchPreference.class);
|
||||
final DataSaverBackend dataSaverBackend = mock(DataSaverBackend.class);
|
||||
@@ -227,7 +242,10 @@ public class AppDataUsageTest {
|
||||
|
||||
@Test
|
||||
public void updatePrefs_restrictedByAdmin_shouldDisablePreference() {
|
||||
mFragment = spy(new AppDataUsage());
|
||||
mFragment = spy(new AppDataUsage() {
|
||||
@Override
|
||||
public boolean isSimHardwareVisible(Context context) { return true; }
|
||||
});
|
||||
final int testUid = 123123;
|
||||
final AppItem appItem = new AppItem(testUid);
|
||||
final RestrictedSwitchPreference restrictBackgroundPref
|
||||
@@ -255,7 +273,10 @@ public class AppDataUsageTest {
|
||||
|
||||
@Test
|
||||
public void bindData_noAppUsageData_shouldHideCycleSpinner() {
|
||||
mFragment = spy(new AppDataUsage());
|
||||
mFragment = spy(new AppDataUsage() {
|
||||
@Override
|
||||
public boolean isSimHardwareVisible(Context context) { return true; }
|
||||
});
|
||||
final SpinnerPreference cycle = mock(SpinnerPreference.class);
|
||||
ReflectionHelpers.setField(mFragment, "mCycle", cycle);
|
||||
final Preference preference = mock(Preference.class);
|
||||
@@ -271,7 +292,10 @@ public class AppDataUsageTest {
|
||||
|
||||
@Test
|
||||
public void bindData_hasAppUsageData_shouldShowCycleSpinnerAndUpdateUsageSummary() {
|
||||
mFragment = spy(new AppDataUsage());
|
||||
mFragment = spy(new AppDataUsage() {
|
||||
@Override
|
||||
public boolean isSimHardwareVisible(Context context) { return true; }
|
||||
});
|
||||
final Context context = RuntimeEnvironment.application;
|
||||
ReflectionHelpers.setField(mFragment, "mContext", context);
|
||||
final long backgroundBytes = 1234L;
|
||||
@@ -300,7 +324,10 @@ public class AppDataUsageTest {
|
||||
|
||||
@Test
|
||||
public void onCreateLoader_categoryApp_shouldQueryDataUsageUsingAppKey() {
|
||||
mFragment = new AppDataUsage();
|
||||
mFragment = new AppDataUsage() {
|
||||
@Override
|
||||
public boolean isSimHardwareVisible(Context context) { return true; }
|
||||
};
|
||||
final Context context = RuntimeEnvironment.application;
|
||||
final int testUid = 123123;
|
||||
final AppItem appItem = new AppItem(testUid);
|
||||
@@ -323,7 +350,10 @@ public class AppDataUsageTest {
|
||||
|
||||
@Test
|
||||
public void onCreateLoader_categoryUser_shouldQueryDataUsageUsingAssociatedUids() {
|
||||
mFragment = new AppDataUsage();
|
||||
mFragment = new AppDataUsage() {
|
||||
@Override
|
||||
public boolean isSimHardwareVisible(Context context) { return true; }
|
||||
};
|
||||
final Context context = RuntimeEnvironment.application;
|
||||
final int testUserId = 11;
|
||||
final AppItem appItem = new AppItem(testUserId);
|
||||
@@ -360,7 +390,10 @@ public class AppDataUsageTest {
|
||||
appItem.category = AppItem.CATEGORY_APP;
|
||||
appItem.addUid(uid);
|
||||
|
||||
mFragment = new AppDataUsage();
|
||||
mFragment = new AppDataUsage() {
|
||||
@Override
|
||||
public boolean isSimHardwareVisible(Context context) { return true; }
|
||||
};
|
||||
ReflectionHelpers.setField(mFragment, "mContext", RuntimeEnvironment.application);
|
||||
ReflectionHelpers.setField(mFragment, "mCycles", testCycles);
|
||||
ReflectionHelpers.setField(mFragment, "mAppItem", appItem);
|
||||
@@ -393,7 +426,10 @@ public class AppDataUsageTest {
|
||||
builder.setStartTime(tenDaysAgo).setEndTime(now).setTotalUsage(1234L);
|
||||
data.add(builder.build());
|
||||
|
||||
mFragment = new AppDataUsage();
|
||||
mFragment = new AppDataUsage() {
|
||||
@Override
|
||||
public boolean isSimHardwareVisible(Context context) { return true; }
|
||||
};
|
||||
ReflectionHelpers.setField(mFragment, "mContext", RuntimeEnvironment.application);
|
||||
ReflectionHelpers.setField(mFragment, "mCycleAdapter", mock(CycleAdapter.class));
|
||||
ReflectionHelpers.setField(mFragment, "mSelectedCycle", tenDaysAgo);
|
||||
@@ -420,7 +456,10 @@ public class AppDataUsageTest {
|
||||
ShadowDataUsageUtils.HAS_SIM = false;
|
||||
ShadowSubscriptionManager.setDefaultDataSubscriptionId(
|
||||
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
|
||||
mFragment = spy(new AppDataUsage());
|
||||
mFragment = spy(new AppDataUsage() {
|
||||
@Override
|
||||
public boolean isSimHardwareVisible(Context context) { return true; }
|
||||
});
|
||||
doReturn(Robolectric.setupActivity(FragmentActivity.class)).when(mFragment).getActivity();
|
||||
doReturn(RuntimeEnvironment.application).when(mFragment).getContext();
|
||||
final UidDetailProvider uidDetailProvider = mock(UidDetailProvider.class);
|
||||
|
Reference in New Issue
Block a user