Merge "Add CTS tests for ApfCapabilities static APIs." am: 854b55854b am: 1b7eddd68e
Change-Id: I11555934df4b27cbb6b7ddbb81022d8fb7c25e15
This commit is contained in:
@@ -21,17 +21,31 @@ import static com.android.testutils.ParcelUtilsKt.assertParcelSane;
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.test.InstrumentationRegistry;
|
||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
import androidx.test.runner.AndroidJUnit4;
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public class ApfCapabilitiesTest {
|
public class ApfCapabilitiesTest {
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
mContext = InstrumentationRegistry.getContext();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConstructAndParcel() {
|
public void testConstructAndParcel() {
|
||||||
final ApfCapabilities caps = new ApfCapabilities(123, 456, 789);
|
final ApfCapabilities caps = new ApfCapabilities(123, 456, 789);
|
||||||
@@ -59,4 +73,27 @@ public class ApfCapabilitiesTest {
|
|||||||
caps = new ApfCapabilities(4 /* apfVersionSupported */, 5, 6);
|
caps = new ApfCapabilities(4 /* apfVersionSupported */, 5, 6);
|
||||||
assertTrue(caps.hasDataAccess());
|
assertTrue(caps.hasDataAccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetApfDrop8023Frames() {
|
||||||
|
// Get com.android.internal.R.bool.config_apfDrop802_3Frames. The test cannot directly
|
||||||
|
// use R.bool.config_apfDrop802_3Frames because that is not a stable resource ID.
|
||||||
|
final int resId = mContext.getResources().getIdentifier("config_apfDrop802_3Frames",
|
||||||
|
"bool", "android");
|
||||||
|
final boolean shouldDrop8023Frames = mContext.getResources().getBoolean(resId);
|
||||||
|
final boolean actual = ApfCapabilities.getApfDrop8023Frames();
|
||||||
|
assertEquals(shouldDrop8023Frames, actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetApfEtherTypeBlackList() {
|
||||||
|
// Get com.android.internal.R.array.config_apfEthTypeBlackList. The test cannot directly
|
||||||
|
// use R.array.config_apfEthTypeBlackList because that is not a stable resource ID.
|
||||||
|
final int resId = mContext.getResources().getIdentifier("config_apfEthTypeBlackList",
|
||||||
|
"array", "android");
|
||||||
|
final int[] blacklistedEtherTypeArray = mContext.getResources().getIntArray(resId);
|
||||||
|
final int[] actual = ApfCapabilities.getApfEtherTypeBlackList();
|
||||||
|
assertNotNull(actual);
|
||||||
|
assertTrue(Arrays.equals(blacklistedEtherTypeArray, actual));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user