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

Commit 96955cba authored by Ats Jenk's avatar Ats Jenk
Browse files

Remove mock for static method and use resource overrides

For one test case we want to have desktop mode disabled.
Previously this was done via extended mockito and mocking a static
method.
Remove extended mockito and use TestableContext resource override
support instead.

Bug: 390705096
Test: atest com.android.wm.shell.desktopmode.DesktopModeVisualIndicatorTest
Flag: EXEMPT fixing test
Change-Id: I096043c94fe78c9b3d04c011a4f970a9429c4491
parent 225b4dc7
Loading
Loading
Loading
Loading
+8 −9
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import android.testing.TestableLooper.RunWithLooper
import android.view.SurfaceControl
import androidx.test.filters.SmallTest
import com.android.internal.policy.SystemBarUtils
import com.android.modules.utils.testing.ExtendedMockitoRule
import com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE
import com.android.wm.shell.R
import com.android.wm.shell.RootTaskDisplayAreaOrganizer
@@ -35,7 +34,6 @@ import com.android.wm.shell.common.DisplayController
import com.android.wm.shell.common.DisplayLayout
import com.android.wm.shell.common.SyncTransactionQueue
import com.android.wm.shell.shared.bubbles.BubbleDropTargetBoundsProvider
import com.android.wm.shell.shared.desktopmode.DesktopModeStatus
import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Rule
@@ -59,11 +57,6 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() {

    @JvmField @Rule val animatorTestRule = AnimatorTestRule(this)

    @JvmField
    @Rule
    val extendedMockitoRule =
        ExtendedMockitoRule.Builder(this).mockStatic(DesktopModeStatus::class.java).build()!!

    private lateinit var taskInfo: RunningTaskInfo
    @Mock private lateinit var syncQueue: SyncTransactionQueue
    @Mock private lateinit var displayController: DisplayController
@@ -76,7 +69,6 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() {

    @Before
    fun setUp() {
        whenever(DesktopModeStatus.canEnterDesktopMode(any())).thenReturn(true)
        whenever(displayLayout.width()).thenReturn(DISPLAY_BOUNDS.width())
        whenever(displayLayout.height()).thenReturn(DISPLAY_BOUNDS.height())
        whenever(displayLayout.stableInsets()).thenReturn(STABLE_INSETS)
@@ -255,7 +247,14 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() {
        com.android.wm.shell.Flags.FLAG_ENABLE_CREATE_ANY_BUBBLE,
    )
    fun testDefaultIndicatorWithNoDesktop() {
        whenever(DesktopModeStatus.canEnterDesktopMode(any())).thenReturn(false)
        mContext.orCreateTestableResources.addOverride(
            com.android.internal.R.bool.config_isDesktopModeSupported,
            false,
        )
        mContext.orCreateTestableResources.addOverride(
            com.android.internal.R.bool.config_isDesktopModeDevOptionSupported,
            false,
        )

        // Fullscreen to center, no desktop indicator
        createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_FULLSCREEN)