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

Commit eafcccbf authored by Xiao Ma's avatar Xiao Ma Committed by Automerger Merge Worker
Browse files

Merge "Run NetworkStackIntegrationTest with Parameterized.class." am: 2ac4d2b8 am: 0547467e

Original change: https://android-review.googlesource.com/c/platform/packages/modules/NetworkStack/+/1824574

Change-Id: I8efe0623871b590cb8da6bca196d915bf1932d80
parents cf6edbe2 0547467e
Loading
Loading
Loading
Loading
+27 −4
Original line number Diff line number Diff line
@@ -146,7 +146,6 @@ import android.system.Os;
import androidx.annotation.NonNull;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;

import com.android.internal.util.HexDump;
import com.android.internal.util.StateMachine;
@@ -181,6 +180,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.mockito.ArgumentCaptor;
import org.mockito.InOrder;
import org.mockito.Mock;
@@ -224,7 +224,7 @@ import kotlin.LazyKt;
 *
 * Tests in this class can either be run with signature permissions, or with root access.
 */
@RunWith(AndroidJUnit4.class)
@RunWith(Parameterized.class)
@SmallTest
public abstract class IpClientIntegrationTestCommon {
    private static final int DATA_BUFFER_LEN = 4096;
@@ -247,6 +247,17 @@ public abstract class IpClientIntegrationTestCommon {
    @Rule
    public final TestName mTestNameRule = new TestName();

    // Indicate whether the flag of parsing netlink event is enabled or not. If it's disabled,
    // integration test still covers the old codepath(i.e. using NetworkObserver), otherwise,
    // test goes through the new codepath(i.e. processRtNetlinkxxx).
    @Parameterized.Parameter(0)
    public boolean mIsNetlinkEventParseEnabled;

    @Parameterized.Parameters
    public static Iterable<? extends Object> data() {
        return Arrays.asList(Boolean.valueOf("false"), Boolean.valueOf("true"));
    }

    /**
     * Indicates that a test requires signature permissions to run.
     *
@@ -553,8 +564,14 @@ public abstract class IpClientIntegrationTestCommon {

    @Before
    public void setUp() throws Exception {
        final Method testMethod = IpClientIntegrationTestCommon.class.getMethod(
                mTestNameRule.getMethodName());
        // Suffix "[0]" or "[1]" is added to the end of test method name after running with
        // Parameterized.class, that's intended behavior, to iterate each test method with the
        // parameterize value. However, Class#getMethod() throws NoSuchMethodException when
        // searching the target test method name due to this change. Just keep the original test
        // method name to fix NoSuchMethodException, and find the correct annotation associated
        // to test method.
        final String testMethodName = mTestNameRule.getMethodName().split("\\[")[0];
        final Method testMethod = IpClientIntegrationTestCommon.class.getMethod(testMethodName);
        mIsSignatureRequiredTest = testMethod.getAnnotation(SignatureRequiredTest.class) != null;
        assumeFalse(testSkipped());

@@ -567,6 +584,12 @@ public abstract class IpClientIntegrationTestCommon {
        }

        mIIpClient = makeIIpClient(mIfaceName, mCb);

        // Depend on the parameterized value to enable/disable netlink message refactor flag.
        // Make sure both of the old codepath(rely on the INetdUnsolicitedEventListener aidl)
        // and new codepath(parse netlink event from kernel) will be executed.
        setFeatureEnabled(NetworkStackUtils.IPCLIENT_PARSE_NETLINK_EVENTS_VERSION,
                mIsNetlinkEventParseEnabled /* default value */);
    }

    protected void setUpMocks() throws Exception {