Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5c5a6898 authored by Remi NGUYEN VAN's avatar Remi NGUYEN VAN Committed by Android (Google) Code Review
Browse files

Merge "Finish mocking in finally clause" into rvc-dev

parents a90dec38 cd8b0633
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -95,15 +95,17 @@ class ModuleNetworkStackClientTest {
        // Force NetworkStack.getService() to return null: this cannot be done with
        // setServiceForTest, as passing null just restores default behavior.
        val session = mockitoSession().spyStatic(NetworkStack::class.java).startMocking()
        try {
            doReturn(null).`when` { NetworkStack.getService() }
            ModuleNetworkStackClient.getInstance(mContext).makeIpClient(TEST_IFNAME, mIpClientCb)

            Thread.sleep(TEST_TIMEOUT_MS)
            verify(mConnector, never()).makeIpClient(any(), any())
            NetworkStack.setServiceForTest(mConnectorBinder)

        } finally {
            // Restore behavior of NetworkStack to return what was set in setServiceForTest
            session.finishMocking()
        }

        // Use a longer timeout as polling can cause larger delays
        verify(mConnector, timeout(TEST_TIMEOUT_MS * 4)).makeIpClient(TEST_IFNAME, mIpClientCb)