From 57fdd00cc73ba2c895c590a9433e4f9213dab36a Mon Sep 17 00:00:00 2001 From: Junyu Lai Date: Tue, 1 Jul 2025 20:32:56 +0800 Subject: [PATCH] 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 --- .../android/net/cts/EthernetManagerTest.kt | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/tests/cts/net/src/android/net/cts/EthernetManagerTest.kt b/tests/cts/net/src/android/net/cts/EthernetManagerTest.kt index 778bd6e34b..291ffc10ad 100644 --- a/tests/cts/net/src/android/net/cts/EthernetManagerTest.kt +++ b/tests/cts/net/src/android/net/cts/EthernetManagerTest.kt @@ -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