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

Commit 7ecdb8e4 authored by paulhu's avatar paulhu
Browse files

Fix FrameworksNetIntegrationTests failure

The test is broken because CS is using
sendStickyBroadcast with all users context instead of
sendStickyBroadcastAsUser to send sticky broadcast. So update
related code on ConnectivityServiceIntegrationTest.

Bug: 178367782
Test: atest FrameworksNetIntegrationTests
      atest FrameworksNetTests
Change-Id: I7ad94fa31ea16025e6ad62d41235978f45be5d99
parent 7166f0b4
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.net.metrics.IpConnectivityLog
import android.os.ConditionVariable
import android.os.IBinder
import android.os.INetworkManagementService
import android.os.UserHandle
import android.testing.TestableContext
import android.util.Log
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -55,10 +56,13 @@ import org.junit.Before
import org.junit.BeforeClass
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.AdditionalAnswers
import org.mockito.Mock
import org.mockito.Mockito.any
import org.mockito.Mockito.anyInt
import org.mockito.Mockito.doNothing
import org.mockito.Mockito.doReturn
import org.mockito.Mockito.eq
import org.mockito.Mockito.mock
import org.mockito.Mockito.spy
import org.mockito.MockitoAnnotations
@@ -143,7 +147,10 @@ class ConnectivityServiceIntegrationTest {
    @Before
    fun setUp() {
        MockitoAnnotations.initMocks(this)
        doNothing().`when`(context).sendStickyBroadcastAsUser(any(), any(), any())
        val asUserCtx = mock(Context::class.java, AdditionalAnswers.delegatesTo<Context>(context))
        doReturn(UserHandle.ALL).`when`(asUserCtx).user
        doReturn(asUserCtx).`when`(context).createContextAsUser(eq(UserHandle.ALL), anyInt())
        doNothing().`when`(context).sendStickyBroadcast(any(), any())

        networkStackClient = TestNetworkStackClient(realContext)
        networkStackClient.init()