Merge "Skip testCallbacks when unrestricted interfaces are present" into main
This commit is contained in:
commit
41a8778165
1 changed files with 16 additions and 1 deletions
|
|
@ -324,6 +324,12 @@ class EthernetManagerTest {
|
|||
val cb = events.poll(NO_CALLBACK_TIMEOUT_MS)
|
||||
assertNull(cb, "Expected no callback but got $cb")
|
||||
}
|
||||
|
||||
fun assumeNoCallback() {
|
||||
val cb = events.poll(0 /* timeout */)
|
||||
// Note that assumeNull does not exist.
|
||||
assumeTrue(cb == null)
|
||||
}
|
||||
}
|
||||
|
||||
private class TetheredInterfaceListener : TetheredInterfaceCallback {
|
||||
|
|
@ -617,7 +623,7 @@ class EthernetManagerTest {
|
|||
// check is explicitly *not* using an interface state listener.
|
||||
// Since restricted interfaces cannot be used for tethering,
|
||||
// assumeNoInterfaceForTetheringAvailable() is an okay proxy.
|
||||
assumeNoInterfaceForTetheringAvailable()
|
||||
assumeNoUnrestrictedInterfacesAvailable()
|
||||
|
||||
// If an interface exists when the callback is registered, it is reported on registration.
|
||||
val iface = createInterface()
|
||||
|
|
@ -680,6 +686,15 @@ class EthernetManagerTest {
|
|||
}
|
||||
}
|
||||
|
||||
private fun assumeNoUnrestrictedInterfacesAvailable() {
|
||||
val listener = EthernetStateListener()
|
||||
addInterfaceStateListener(listener)
|
||||
|
||||
// Force interface state listener callbacks to be processed before proceeding.
|
||||
setEthernetEnabled(ethernetEnabled)
|
||||
listener.assumeNoCallback()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCallbacks_forServerModeInterfaces() {
|
||||
// do not run this test if an interface that can be used for tethering already exists.
|
||||
|
|
|
|||
Loading…
Reference in a new issue