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:
@@ -202,8 +202,7 @@ public class NetworkStatsManagerTest {
|
||||
assertFalse(stats.hasNextBucket());
|
||||
}
|
||||
|
||||
private void assertBucketMatches(Entry expected,
|
||||
NetworkStats.Bucket actual) {
|
||||
private void assertBucketMatches(Entry expected, NetworkStats.Bucket actual) {
|
||||
assertEquals(expected.uid, actual.getUid());
|
||||
assertEquals(expected.rxBytes, actual.getRxBytes());
|
||||
assertEquals(expected.rxPackets, actual.getRxPackets());
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package android.net;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
@@ -43,7 +43,7 @@ public class IpSecTransformTest {
|
||||
config.setSpiResourceId(1985);
|
||||
IpSecTransform postModification = new IpSecTransform(null, config);
|
||||
|
||||
assertFalse(IpSecTransform.equals(preModification, postModification));
|
||||
assertNotEquals(preModification, postModification);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -57,6 +57,6 @@ public class IpSecTransformTest {
|
||||
IpSecTransform config1 = new IpSecTransform(null, config);
|
||||
IpSecTransform config2 = new IpSecTransform(null, config);
|
||||
|
||||
assertTrue(IpSecTransform.equals(config1, config2));
|
||||
assertEquals(config1, config2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
|
||||
package android.net;
|
||||
|
||||
import static com.android.testutils.ParcelUtilsKt.assertParcelingIsLossless;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import android.net.SocketKeepalive.InvalidPacketException;
|
||||
|
||||
import com.android.internal.util.TestUtils;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -79,7 +79,7 @@ public final class TcpKeepalivePacketDataTest {
|
||||
assertEquals(testInfo.tos, resultData.ipTos);
|
||||
assertEquals(testInfo.ttl, resultData.ipTtl);
|
||||
|
||||
TestUtils.assertParcelingIsLossless(resultData);
|
||||
assertParcelingIsLossless(resultData);
|
||||
|
||||
final byte[] packet = resultData.getPacket();
|
||||
// IP version and IHL
|
||||
|
||||
Reference in New Issue
Block a user