Factorize custom asserts.

Also a few utilities that were in the way, and some opportunistic
cleanups.

Test: FrameworksNetTest NetworkStackTest
Change-Id: I385070e2044fd967cb18f1ffea9a86a4627b742e
This commit is contained in:
Chalard Jean
2019-05-30 17:11:14 +09:00
parent c961e03526
commit af718367c2
24 changed files with 181 additions and 395 deletions

View File

@@ -16,12 +16,12 @@
package android.net;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static com.android.testutils.ParcelUtilsKt.assertParcelSane;
import static com.android.testutils.ParcelUtilsKt.assertParcelingIsLossless;
import android.os.Parcel;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import androidx.test.filters.SmallTest;
@@ -89,23 +89,15 @@ public class IpSecConfigTest {
IpSecConfig original = getSampleConfig();
IpSecConfig copy = new IpSecConfig(original);
assertTrue(IpSecConfig.equals(original, copy));
assertFalse(original == copy);
assertEquals(original, copy);
assertNotSame(original, copy);
}
@Test
public void testParcelUnparcel() throws Exception {
public void testParcelUnparcel() {
assertParcelingIsLossless(new IpSecConfig());
IpSecConfig c = getSampleConfig();
assertParcelingIsLossless(c);
}
private void assertParcelingIsLossless(IpSecConfig ci) throws Exception {
Parcel p = Parcel.obtain();
ci.writeToParcel(p, 0);
p.setDataPosition(0);
IpSecConfig co = IpSecConfig.CREATOR.createFromParcel(p);
assertTrue(IpSecConfig.equals(co, ci));
assertParcelSane(c, 15);
}
}