Search in sources :

Example 11 with UidDetail

use of com.android.settingslib.net.UidDetail 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)

Example 12 with UidDetail

use of com.android.settingslib.net.UidDetail in project android_packages_apps_Settings by omnirom.

the class AppDataUsagePreferenceTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mAppItem = new AppItem(123);
    mUidDetail = new UidDetail();
    mUidDetail.icon = new ColorDrawable(Color.BLUE);
    mUidDetail.label = "title";
}
Also used : UidDetail(com.android.settingslib.net.UidDetail) ColorDrawable(android.graphics.drawable.ColorDrawable) AppItem(com.android.settingslib.AppItem) Before(org.junit.Before)

Example 13 with UidDetail

use of com.android.settingslib.net.UidDetail in project android_packages_apps_Settings by omnirom.

the class AppDataUsageTest method onCreate_noNetworkTemplateAndInvalidDataSubscription_shouldUseWifiTemplate.

@Test
@Config(shadows = { ShadowDataUsageUtils.class, ShadowSubscriptionManager.class, ShadowFragment.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);
    assertNull(mFragment.mTemplate.getSubscriberId());
    assertThat(mFragment.mTemplate.getNetworkId()).isEqualTo(NetworkTemplate.WIFI_NETWORKID_ALL);
}
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

UidDetail (com.android.settingslib.net.UidDetail)13 Bundle (android.os.Bundle)11 AppItem (com.android.settingslib.AppItem)11 UidDetailProvider (com.android.settingslib.net.UidDetailProvider)11 Context (android.content.Context)7 Intent (android.content.Intent)7 ApplicationInfo (android.content.pm.ApplicationInfo)7 PackageManager (android.content.pm.PackageManager)7 NetworkTemplate (android.net.NetworkTemplate)7 RemoteException (android.os.RemoteException)5 PackageManagerWrapperImpl (com.android.settings.applications.PackageManagerWrapperImpl)5 FragmentActivity (androidx.fragment.app.FragmentActivity)4 Test (org.junit.Test)4 Config (org.robolectric.annotation.Config)3 ColorDrawable (android.graphics.drawable.ColorDrawable)2 ArrayList (java.util.ArrayList)2 Before (org.junit.Before)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2