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

Commit c414ee60 authored by Chen Xu's avatar Chen Xu Committed by Gerrit Code Review
Browse files

Merge "flaky unit test"

parents 2b76694a ca30a3cb
Loading
Loading
Loading
Loading
+2 −24
Original line number Diff line number Diff line
@@ -24,12 +24,10 @@ import static org.mockito.Mockito.verify;

import android.database.ContentObserver;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.provider.Settings;
import android.test.mock.MockContentProvider;
import android.test.mock.MockContentResolver;
import android.test.suitebuilder.annotation.SmallTest;

@@ -42,7 +40,6 @@ import org.mockito.Mock;
public class CarrierActionAgentTest extends TelephonyTest {
    private CarrierActionAgent mCarrierActionAgentUT;
    private FakeContentResolver mFakeContentResolver;
    private FakeContentProvider mFakeContentProvider;
    private static int DATA_CARRIER_ACTION_EVENT = 0;
    private static int RADIO_CARRIER_ACTION_EVENT = 1;
    private CarrierActionAgentHandler mCarrierActionAgentHandler;
@@ -64,23 +61,6 @@ public class CarrierActionAgentTest extends TelephonyTest {
        }
    }

    private class FakeContentProvider extends MockContentProvider {
        private int mExpectedValue;
        public void simulateChange(Uri uri) {
            mFakeContentResolver.notifyChange(uri, null);
        }
        @Override
        public Bundle call(String method, String request, Bundle args) {
            Bundle result = new Bundle();
            if (Settings.CALL_METHOD_GET_GLOBAL.equals(method)) {
                result.putString(Settings.NameValueTable.VALUE, Integer.toString(mExpectedValue));
            } else {
                mExpectedValue = Integer.parseInt(args.getString(Settings.NameValueTable.VALUE));
            }
            return result;
        }
    }

    private class CarrierActionAgentHandler extends HandlerThread {

        private CarrierActionAgentHandler(String name) {
@@ -105,8 +85,6 @@ public class CarrierActionAgentTest extends TelephonyTest {
        logd("CarrierActionAgentTest +Setup!");
        super.setUp(getClass().getSimpleName());
        mFakeContentResolver = new FakeContentResolver();
        mFakeContentProvider = new FakeContentProvider();
        mFakeContentResolver.addProvider(Settings.AUTHORITY, mFakeContentProvider);
        doReturn(mFakeContentResolver).when(mContext).getContentResolver();
        mCarrierActionAgentHandler = new CarrierActionAgentHandler(getClass().getSimpleName());
        mCarrierActionAgentHandler.start();
@@ -118,8 +96,8 @@ public class CarrierActionAgentTest extends TelephonyTest {
    @SmallTest
    public void testCarrierActionResetOnAPM() {
        Settings.Global.putInt(mFakeContentResolver, Settings.Global.AIRPLANE_MODE_ON, 1);
        mFakeContentProvider.simulateChange(
                Settings.Global.getUriFor(Settings.Global.AIRPLANE_MODE_ON));
        mFakeContentResolver.notifyChange(
                Settings.Global.getUriFor(Settings.Global.AIRPLANE_MODE_ON), null);
        waitForMs(200);
        ArgumentCaptor<Message> message = ArgumentCaptor.forClass(Message.class);

+3 −0
Original line number Diff line number Diff line
@@ -534,6 +534,9 @@ public class ContextFixture implements TestFixture<Context> {
        doReturn(mConfiguration).when(mResources).getConfiguration();

        mContentResolver.addProvider(Settings.AUTHORITY, mContentProvider);
        // Settings caches the provider after first get/set call, this is needed to make sure
        // Settings is using mContentProvider as the cached provider across all tests.
        Settings.Global.getInt(mContentResolver, Settings.Global.AIRPLANE_MODE_ON, 0);
        mContentResolver.addProvider(ServiceStateTable.AUTHORITY, mContentProvider);
        mPermissionTable.add(PERMISSION_ENABLE_ALL);
    }
+0 −4
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@ 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;
@@ -442,9 +441,6 @@ public abstract class TelephonyTest {
        mSST.mSS = mServiceState;
        mServiceManagerMockedServices.put("connectivity_metrics_logger", mConnMetLoggerBinder);

        Settings.Global.putInt(mContext.getContentResolver(),
                Settings.Global.ENABLE_CELLULAR_ON_BOOT, 1);

        setReady(false);
    }

+0 −4
Original line number Diff line number Diff line
@@ -288,10 +288,6 @@ public class DcTrackerTest extends TelephonyTest {

    @Before
    public void setUp() throws Exception {
        // set the lazy cp to the real content provider in order to use the real settings
        ContentResolver realContentResolver = TestApplication.getAppContext().getContentResolver();
        Settings.Global.getInt(realContentResolver, Settings.Global.MOBILE_DATA, 1);

        logd("DcTrackerTest +Setup!");
        super.setUp(getClass().getSimpleName());