Refactor: Fix lint errors in EthernetManagerTest
This is a no-op, test-only change. Flag: EXEMPT refactor Test: atest CtsNetTestCases:android.net.cts.EthernetManagerTest Bug: 410731080 Change-Id: I98e6df5b1733b548a2515bab66ac9609c9394f85
This commit is contained in:
parent
7e5665ae44
commit
57fdd00cc7
1 changed files with 22 additions and 10 deletions
|
|
@ -70,12 +70,12 @@ import com.android.testutils.DevSdkIgnoreRule
|
|||
import com.android.testutils.DevSdkIgnoreRunner
|
||||
import com.android.testutils.DeviceInfoUtils.isKernelVersionAtLeast
|
||||
import com.android.testutils.NdResponder
|
||||
import com.android.testutils.PollPacketReader
|
||||
import com.android.testutils.TestableNetworkCallback
|
||||
import com.android.testutils.TestableNetworkCallback.Event.Available
|
||||
import com.android.testutils.TestableNetworkCallback.Event.CapabilitiesChanged
|
||||
import com.android.testutils.TestableNetworkCallback.Event.LinkPropertiesChanged
|
||||
import com.android.testutils.TestableNetworkCallback.Event.Lost
|
||||
import com.android.testutils.PollPacketReader
|
||||
import com.android.testutils.TestableNetworkCallback
|
||||
import com.android.testutils.assertThrows
|
||||
import com.android.testutils.runAsShell
|
||||
import com.android.testutils.waitForIdle
|
||||
|
|
@ -104,17 +104,23 @@ import org.junit.Test
|
|||
import org.junit.runner.RunWith
|
||||
|
||||
private const val TAG = "EthernetManagerTest"
|
||||
|
||||
// This timeout does not affect the test duration for passing tests. It needs to be long enough to
|
||||
// account for RS delay (and potentially the first retry interval (4s)). There have been failures
|
||||
// where the interface did not gain provisioning within the allotted timeout.
|
||||
private const val TIMEOUT_MS = 10_000L
|
||||
|
||||
// Timeout used to confirm no callbacks matching given criteria are received. Must be long enough to
|
||||
// process all callbacks including ip provisioning when using the updateConfiguration API.
|
||||
// Note that increasing this timeout increases the test duration.
|
||||
private const val NO_CALLBACK_TIMEOUT_MS = 500L
|
||||
|
||||
private val DEFAULT_IP_CONFIGURATION = IpConfiguration(IpConfiguration.IpAssignment.DHCP,
|
||||
IpConfiguration.ProxySettings.NONE, null, null)
|
||||
private val DEFAULT_IP_CONFIGURATION = IpConfiguration(
|
||||
IpConfiguration.IpAssignment.DHCP,
|
||||
IpConfiguration.ProxySettings.NONE,
|
||||
null,
|
||||
null
|
||||
)
|
||||
private val ETH_REQUEST: NetworkRequest = NetworkRequest.Builder()
|
||||
.addTransportType(TRANSPORT_TEST)
|
||||
.addTransportType(TRANSPORT_ETHERNET)
|
||||
|
|
@ -287,8 +293,12 @@ class EthernetManagerTest {
|
|||
}
|
||||
|
||||
private fun createChangeEvent(iface: String, state: Int, role: Int) =
|
||||
InterfaceStateChanged(iface, state, role,
|
||||
if (state != STATE_ABSENT) DEFAULT_IP_CONFIGURATION else null)
|
||||
InterfaceStateChanged(
|
||||
iface,
|
||||
state,
|
||||
role,
|
||||
if (state != STATE_ABSENT) DEFAULT_IP_CONFIGURATION else null
|
||||
)
|
||||
|
||||
fun eventuallyExpect(expected: Event) {
|
||||
val cb = events.poll(TIMEOUT_MS) { it == expected }
|
||||
|
|
@ -468,7 +478,8 @@ class EthernetManagerTest {
|
|||
private fun requestNetwork(request: NetworkRequest): TestableNetworkCallback {
|
||||
return TestableNetworkCallback(
|
||||
timeoutMs = TIMEOUT_MS,
|
||||
noCallbackTimeoutMs = NO_CALLBACK_TIMEOUT_MS).also {
|
||||
noCallbackTimeoutMs = NO_CALLBACK_TIMEOUT_MS
|
||||
).also {
|
||||
cm.requestNetwork(request, it)
|
||||
registeredCallbacks.add(it)
|
||||
}
|
||||
|
|
@ -477,7 +488,8 @@ class EthernetManagerTest {
|
|||
private fun registerNetworkListener(request: NetworkRequest): TestableNetworkCallback {
|
||||
return TestableNetworkCallback(
|
||||
timeoutMs = TIMEOUT_MS,
|
||||
noCallbackTimeoutMs = NO_CALLBACK_TIMEOUT_MS).also {
|
||||
noCallbackTimeoutMs = NO_CALLBACK_TIMEOUT_MS
|
||||
).also {
|
||||
cm.registerNetworkCallback(request, it)
|
||||
registeredCallbacks.add(it)
|
||||
}
|
||||
|
|
@ -525,7 +537,8 @@ class EthernetManagerTest {
|
|||
.setIpConfiguration(ipConfig)
|
||||
.setNetworkCapabilities(capabilities).build(),
|
||||
handler::post,
|
||||
it)
|
||||
it
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1112,7 +1125,6 @@ class EthernetManagerTest {
|
|||
listener.eventuallyExpect(iface, STATE_LINK_UP, ROLE_CLIENT)
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun testRemoveInterface_disableEnableEthernet() {
|
||||
// Set up 2 interfaces for testing
|
||||
|
|
|
|||
Loading…
Reference in a new issue