Loading tests/integration/src/android/net/ip/IpClientIntegrationTestCommon.java +27 −4 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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; Loading @@ -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. * Loading Loading @@ -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()); Loading @@ -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 { Loading Loading
tests/integration/src/android/net/ip/IpClientIntegrationTestCommon.java +27 −4 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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; Loading @@ -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. * Loading Loading @@ -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()); Loading @@ -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 { Loading