diff --git a/tests/cts/net/src/android/net/cts/NsdManagerTest.kt b/tests/cts/net/src/android/net/cts/NsdManagerTest.kt index db4f937f04..4c63cb07ae 100644 --- a/tests/cts/net/src/android/net/cts/NsdManagerTest.kt +++ b/tests/cts/net/src/android/net/cts/NsdManagerTest.kt @@ -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() + assertEquals(NsdManager.FAILURE_OPERATION_NOT_RUNNING, failedCb.errorCode) + } + /** * Register a service and return its registration record. */