Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f67d1a8c authored by Jack Yu's avatar Jack Yu
Browse files

Fixed flaky data unit tests

Test: Telephony unit tests
Bug: 29579544
Change-Id: Ifda4c8ef8390c253215c02abeb22fa099c40837a
parent 2bb9e708
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import static org.mockito.Mockito.eq;

import android.app.ActivityManager;
import android.app.IActivityManager;
import android.content.ContentResolver;
import android.content.Context;
import android.content.IIntentSender;
import android.content.Intent;
@@ -41,6 +42,7 @@ import android.os.IDeviceIdleController;
import android.os.RegistrantList;
import android.os.ServiceManager;
import android.provider.BlockedNumberContract;
import android.provider.Settings;
import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@@ -441,6 +443,14 @@ public abstract class TelephonyTest {
        //SIM
        doReturn(1).when(mTelephonyManager).getSimCount();

        //Data
        //Initial state is: userData enabled, provisioned.
        ContentResolver resolver = mContext.getContentResolver();
        Settings.Global.putInt(resolver, Settings.Global.MOBILE_DATA, 1);
        Settings.Global.putInt(resolver, Settings.Global.DEVICE_PROVISIONED, 1);
        Settings.Global.putInt(resolver,
                Settings.Global.DEVICE_PROVISIONING_MOBILE_DATA_ENABLED, 1);

        //Use reflection to mock singletons
        replaceInstance(CallManager.class, "INSTANCE", null, mCallManager);
        replaceInstance(TelephonyComponentFactory.class, "sInstance", null,
+0 −5
Original line number Diff line number Diff line
@@ -1247,12 +1247,7 @@ public class DcTrackerTest extends TelephonyTest {
    @Test
    @SmallTest
    public void testDataEnableInProvisioning() throws Exception {
        // Initial state is: userData enabled, provisioned.
        ContentResolver resolver = mContext.getContentResolver();
        Settings.Global.putInt(resolver, Settings.Global.MOBILE_DATA, 1);
        Settings.Global.putInt(resolver, Settings.Global.DEVICE_PROVISIONED, 1);
        Settings.Global.putInt(resolver,
                Settings.Global.DEVICE_PROVISIONING_MOBILE_DATA_ENABLED, 1);

        assertEquals(1, Settings.Global.getInt(resolver, Settings.Global.MOBILE_DATA));
        assertTrue(mDct.isDataEnabled());