Merge "Add CTS test for resolution stop failed"

This commit is contained in:
Paul Hu
2023-03-29 05:32:28 +00:00
committed by Gerrit Code Review

View File

@@ -314,6 +314,7 @@ class NsdManagerTest {
}
override fun onStopResolutionFailed(si: NsdServiceInfo, err: Int) {
super.onStopResolutionFailed(si, err)
add(StopResolutionFailed(si, err))
}
}
@@ -985,6 +986,24 @@ class NsdManagerTest {
}
}
@Test
fun testStopServiceResolutionFailedCallback() {
// This test requires shims supporting U+ APIs (NsdManager.stopServiceResolution)
assumeTrue(TestUtils.shouldTestUApis())
// It's not possible to make ResolutionListener#onStopResolutionFailed callback sending
// because it is only sent in very edge-case scenarios when the legacy implementation is
// used, and the legacy implementation is never used in the current AOSP builds. Considering
// that this callback isn't expected to be sent at all at the moment, and this is just an
// interface with no implementation. To verify this callback, just call
// onStopResolutionFailed on the record directly then verify it is received.
val resolveRecord = NsdResolveRecord()
resolveRecord.onStopResolutionFailed(
NsdServiceInfo(), NsdManager.FAILURE_OPERATION_NOT_RUNNING)
val failedCb = resolveRecord.expectCallback<StopResolutionFailed>()
assertEquals(NsdManager.FAILURE_OPERATION_NOT_RUNNING, failedCb.errorCode)
}
/**
* Register a service and return its registration record.
*/