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

Commit f9599b4d authored by Mady Mellor's avatar Mady Mellor
Browse files

Mock BubbleStackView in BubbleViewInfoTest

The optional bubble overflow flag had to be rolled back, this
uncovers an issue in this test that was added after that flag had
been in trunkfood, so the overflow is added immediately when stack
view is created. This results in an error in robolectric's handling
of bitmaps.

It might take some time to fix the cause of the optional overflow
flag being rolled back, so to fix this test, use a mock of stack
view instead as the test really just needs the view for inflation,
it's not testing anything about the view.

Flag: EXEMPT test fix
Test: atest WMShellRobolectricTests com.android.wm.shell.bubbles.BubbleViewInfoTaskTest
Bug: 375513387
Change-Id: I5ce2d7008289cb4601c0606b1c861a55d9034b77
parent ac9181e1
Loading
Loading
Loading
Loading
+20 −12
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.os.Handler
import android.os.UserManager
import android.view.IWindowManager
import android.view.WindowManager
import android.widget.FrameLayout
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
@@ -56,7 +57,9 @@ import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.any
import org.mockito.kotlin.mock
import org.mockito.kotlin.whenever

/** Test inflating bubbles with [BubbleViewInfoTask]. */
@SmallTest
@@ -158,18 +161,23 @@ class BubbleViewInfoTaskTest {
                mock<BubbleProperties>()
            )

        val bubbleStackViewManager = BubbleStackViewManager.fromBubbleController(bubbleController)
        bubbleStackView =
            BubbleStackView(
                context,
                bubbleStackViewManager,
                bubblePositioner,
                bubbleData,
                surfaceSynchronizer,
                FloatingContentCoordinator(),
                bubbleController,
                mainExecutor
            )
        // TODO: (b/371829099) - when optional overflow is no longer flagged we can enable this
        //  again, something about the overflow being added uncovers an issue with Robolectric and
        //  bitmaps; this is switched to a mock to work around that (b/375513387).
//        val bubbleStackViewManager = BubbleStackViewManager.fromBubbleController(bubbleController)
//        bubbleStackView = BubbleStackView(
//                context,
//                bubbleStackViewManager,
//                bubblePositioner,
//                bubbleData,
//                surfaceSynchronizer,
//                FloatingContentCoordinator(),
//                bubbleController,
//                mainExecutor
//            )
        bubbleStackView = mock<BubbleStackView>()
        whenever(bubbleStackView.generateLayoutParams(any()))
            .thenReturn(FrameLayout.LayoutParams(1000, 1000))
        expandedViewManager = BubbleExpandedViewManager.fromBubbleController(bubbleController)
    }