Fix kotlin nullable errors in Connectivity tests
Fix kotlin nullable errors that were exposed by setting the retention of android.annotation.NonNull and android.annotation.Nullable to class retention. Bug: 294110802 Test: builds Change-Id: Id49e4a2ee0b7b463d99bce6eb22919b84c21443a
This commit is contained in:
@@ -50,9 +50,9 @@ class KeepalivePacketDataTest {
|
||||
|
||||
// Add for test because constructor of KeepalivePacketData is protected.
|
||||
private inner class TestKeepalivePacketData(
|
||||
srcAddress: InetAddress? = TEST_SRC_ADDRV4,
|
||||
srcAddress: InetAddress = TEST_SRC_ADDRV4,
|
||||
srcPort: Int = TEST_SRC_PORT,
|
||||
dstAddress: InetAddress? = TEST_DST_ADDRV4,
|
||||
dstAddress: InetAddress = TEST_DST_ADDRV4,
|
||||
dstPort: Int = TEST_DST_PORT,
|
||||
data: ByteArray = TESTBYTES
|
||||
) : KeepalivePacketData(srcAddress, srcPort, dstAddress, dstPort, data)
|
||||
@@ -62,20 +62,6 @@ class KeepalivePacketDataTest {
|
||||
fun testConstructor() {
|
||||
var data: TestKeepalivePacketData
|
||||
|
||||
try {
|
||||
data = TestKeepalivePacketData(srcAddress = null)
|
||||
fail("Null src address should cause exception")
|
||||
} catch (e: InvalidPacketException) {
|
||||
assertEquals(e.error, ERROR_INVALID_IP_ADDRESS)
|
||||
}
|
||||
|
||||
try {
|
||||
data = TestKeepalivePacketData(dstAddress = null)
|
||||
fail("Null dst address should cause exception")
|
||||
} catch (e: InvalidPacketException) {
|
||||
assertEquals(e.error, ERROR_INVALID_IP_ADDRESS)
|
||||
}
|
||||
|
||||
try {
|
||||
data = TestKeepalivePacketData(dstAddress = TEST_ADDRV6)
|
||||
fail("Ip family mismatched should cause exception")
|
||||
@@ -117,4 +103,4 @@ class KeepalivePacketDataTest {
|
||||
@Test
|
||||
@IgnoreUpTo(Build.VERSION_CODES.Q)
|
||||
fun testPacket() = assertTrue(Arrays.equals(TESTBYTES, TestKeepalivePacketData().packet))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user