Fix EthernetManagerTest

This patch fixes EthernetManagerTest as follows:
(1) testEnableDisableInterface_disableEnableEthernet
    Fix the test error when USB interface is present and treated as
    ethernet interfaces.
(2) testRemoveInterface_disableEnableEthernet
    Fix the error When tethering interface already presents.

Bug: 427055553
Test: atest ConnectivityCoverageTests
Flag: EXEMPT mainline

Change-Id: I2a31f3f0434b35e9ebe96b4f7003e5a9be0d3e81
This commit is contained in:
Chuwei He 2025-07-02 14:45:26 +09:00
commit e9dcc62d2d

View file

@ -843,6 +843,7 @@ class EthernetManagerTest {
@Test
fun testEnableDisableInterface_disableEnableEthernet() {
assumeFalse(restoreEthernetRule.isAdbOverEthernet())
val iface = createInterface()
val listener = TestInterfaceStateListener()
addInterfaceStateListener(listener)
@ -854,7 +855,6 @@ class EthernetManagerTest {
listener.eventuallyExpectInterfaceStateChanged(iface.name, STATE_LINK_DOWN, ROLE_CLIENT)
enableInterface(iface).expectError()
disableInterface(iface).expectError()
listener.assertNoCallback()
// When ethernet is enabled, enable/disableInterface() should succeed.
restoreEthernetRule.setEthernetEnabled(true)
@ -1006,6 +1006,8 @@ class EthernetManagerTest {
@Test
fun testRemoveInterface_disableEnableEthernet() {
assumeNoInterfaceForTetheringAvailable()
// Set up 2 interfaces for testing
val iface1 = createInterface()
val listener = TestInterfaceStateListener()