Search in sources :

Example 16 with UidDetailProvider

use of com.android.settingslib.net.UidDetailProvider in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AppDataUsageTest method onCreate_noNetworkTemplateAndInvalidDataSubscription_shouldUseWifiTemplate.

@Test
@Config(shadows = { ShadowDataUsageUtils.class, ShadowSubscriptionManager.class })
public void onCreate_noNetworkTemplateAndInvalidDataSubscription_shouldUseWifiTemplate() {
    ShadowDataUsageUtils.IS_MOBILE_DATA_SUPPORTED = true;
    ShadowDataUsageUtils.IS_WIFI_SUPPORTED = true;
    ShadowDataUsageUtils.HAS_SIM = false;
    ShadowSubscriptionManager.setDefaultDataSubscriptionId(SubscriptionManager.INVALID_SUBSCRIPTION_ID);
    mFragment = spy(new AppDataUsage());
    doReturn(Robolectric.setupActivity(FragmentActivity.class)).when(mFragment).getActivity();
    doReturn(RuntimeEnvironment.application).when(mFragment).getContext();
    final UidDetailProvider uidDetailProvider = mock(UidDetailProvider.class);
    doReturn(uidDetailProvider).when(mFragment).getUidDetailProvider();
    doReturn(new UidDetail()).when(uidDetailProvider).getUidDetail(anyInt(), anyBoolean());
    ReflectionHelpers.setField(mFragment, "mDashboardFeatureProvider", FakeFeatureFactory.setupForTest().dashboardFeatureProvider);
    final Bundle args = new Bundle();
    args.putInt(AppInfoBase.ARG_PACKAGE_UID, 123123);
    mFragment.setArguments(args);
    mFragment.onCreate(Bundle.EMPTY);
    assertThat(mFragment.mTemplate.getMatchRule()).isEqualTo(NetworkTemplate.MATCH_WIFI_WILDCARD);
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) UidDetail(com.android.settingslib.net.UidDetail) Bundle(android.os.Bundle) UidDetailProvider(com.android.settingslib.net.UidDetailProvider) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Aggregations

UidDetailProvider (com.android.settingslib.net.UidDetailProvider)16 Bundle (android.os.Bundle)15 Context (android.content.Context)13 RemoteException (android.os.RemoteException)12 UidDetail (com.android.settingslib.net.UidDetail)9 AppItem (com.android.settingslib.AppItem)8 Intent (android.content.Intent)7 ApplicationInfo (android.content.pm.ApplicationInfo)7 PackageManager (android.content.pm.PackageManager)7 NetworkTemplate (android.net.NetworkTemplate)7 PackageManagerWrapperImpl (com.android.settings.applications.PackageManagerWrapperImpl)6 FragmentActivity (androidx.fragment.app.FragmentActivity)2 Test (org.junit.Test)2 Activity (android.app.Activity)1 TelephonyManager (android.telephony.TelephonyManager)1 ArrayList (java.util.ArrayList)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 Config (org.robolectric.annotation.Config)1