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

Commit ceef58fe authored by Remi NGUYEN VAN's avatar Remi NGUYEN VAN
Browse files

Remove usage of setDefaultImpl in test

This is the only usage of setDefaultImpl on the interface. Removing this
usage allows not generating all the code managing default
implementations in the aidl interface, as it will soon not be generated
by default.

Bug: 206006915
Test: atest NetworkStackServiceTest
Change-Id: I969740122eb4496a919678f94a4eb1848b6b2b16
parent 2d82fb2b
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.net.dhcp.IDhcpServer
import android.net.dhcp.IDhcpServerCallbacks
import android.net.ip.IIpClientCallbacks
import android.net.ip.IpClient
import android.os.Binder
import android.os.Build
import android.os.IBinder
import android.os.Process
@@ -48,6 +49,7 @@ import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentMatchers.any
import org.mockito.ArgumentMatchers.anyInt
import org.mockito.Mockito.doReturn
import org.mockito.Mockito.eq
import org.mockito.Mockito.mock
@@ -170,11 +172,14 @@ class NetworkStackServiceTest {
        // Call makeNetworkMonitor
        // Use a spy of INetworkMonitorCallbacks and not a mock, as mockito can't create a mock on Q
        // because of the missing CaptivePortalData class that is an argument of one of the methods
        val mockNetworkMonitorCb = spy(INetworkMonitorCallbacks.Stub.asInterface(
                mock(IBinder::class.java)))
        val mockBinder = mock(IBinder::class.java)
        val mockNetworkMonitorCb = spy(INetworkMonitorCallbacks.Stub.asInterface(mockBinder))
        doReturn(9990003).`when`(mockNetworkMonitorCb).interfaceVersion
        doReturn("networkmonitor_hash").`when`(mockNetworkMonitorCb).interfaceHash
        INetworkMonitorCallbacks.Stub.setDefaultImpl(INetworkMonitorCallbacks.Default())
        // Oneway transactions are always successful (return true). INetworkMonitorCallbacks is a
        // oneway interface. This avoids the stub throwing because the method is not implemented by
        // the (mock) remote.
        doReturn(true).`when`(mockBinder).transact(anyInt(), any(), any(), eq(Binder.FLAG_ONEWAY))

        connector.makeNetworkMonitor(Network(123), "test_nm", mockNetworkMonitorCb)