Don't ignore exceptions in NsdManagerDownstreamTetheringTest

tryTest{} catches and returns and must be ended with a cleanup{}
block to throw. That is why it's marked with @CheckReturnValue.
The IDE marks the entire block as a huge warning.

Ideally this should really be an error, but that flag only exists
in Kotlin 2.2 and above, which is not out of beta yet, so
add a TODO in the bp file

Test: NsdManagerDownstreamTetheringTest
Flag: EXEMPT test-only
Change-Id: I62a9d0a16926574eb286d45b61d4d5d2e8c870ab
This commit is contained in:
Chalard Jean 2025-05-09 13:20:31 +09:00
commit ebaef1230b
2 changed files with 4 additions and 2 deletions

View file

@ -158,6 +158,7 @@ java_defaults {
// Tests must check a large number of deprecated methods and warning about it
// sends hundreds of warning lines flooding the useful warnings.
kotlincflags: ["-Xsuppress-warning=DEPRECATION"],
// TODO: add "-Xwarning-level=CheckResult:error" when Kotlin 2.2.0 is out
}
// defaults for tests that need to build against framework-connectivity's @hide APIs, but also
@ -184,6 +185,7 @@ java_defaults {
// Tests must check a large number of deprecated methods and warning about it
// sends hundreds of warning lines flooding the useful warnings.
kotlincflags: ["-Xsuppress-warning=DEPRECATION"],
// TODO: add "-Xwarning-level=CheckResult:error" when Kotlin 2.2.0 is out
defaults_visibility: ["//packages/modules/Connectivity/tests:__subpackages__"],
}

View file

@ -104,7 +104,7 @@ class NsdManagerDownstreamTetheringTest : EthernetTetheringTestBase() {
nsdManager.discoverServices(serviceType, NsdManager.PROTOCOL_DNS_SD, discoveryRecord)
discoveryRecord.expectCallback<NsdDiscoveryRecord.DiscoveryEvent.DiscoveryStarted>()
assertNotNull(downstreamReader.pollForQuery("$serviceType.local", 12 /* type PTR */))
} cleanupStep {
} cleanup {
nsdManager.stopServiceDiscovery(discoveryRecord)
discoveryRecord.expectCallback<NsdDiscoveryRecord.DiscoveryEvent.DiscoveryStopped>()
}
@ -137,7 +137,7 @@ class NsdManagerDownstreamTetheringTest : EthernetTetheringTestBase() {
val downstreamReader = downstreamIface.packetReader
assertNotNull(downstreamReader.pollForQuery("$serviceType.local", 12 /* type PTR */))
// TODO: Add another test to check packet reply can trigger serviceFound.
} cleanupStep {
} cleanup {
nsdManager.stopServiceDiscovery(discoveryRecord)
discoveryRecord.expectCallback<NsdDiscoveryRecord.DiscoveryEvent.DiscoveryStopped>()
}