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

Commit 6e02de9c authored by Brian Isganitis's avatar Brian Isganitis Committed by Android (Google) Code Review
Browse files

Merge "Add more tests for {request,hide}Window." into main

parents cf3a0ef2 a76fcaf5
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import com.android.launcher3.taskbar.TaskbarUnitTestRule
import com.android.launcher3.taskbar.TaskbarUnitTestRule.InjectController
import com.android.launcher3.util.LauncherMultivalentJUnit
import com.android.launcher3.util.LauncherMultivalentJUnit.EmulatedDevices
import com.android.launcher3.views.BaseDragLayer
import com.android.systemui.shared.system.TaskStackChangeListeners
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
@@ -64,6 +65,17 @@ class TaskbarOverlayControllerTest {
        assertThat(context1).isNotSameInstanceAs(context2)
    }

    @Test
    @UiThreadTest
    fun testRequestWindow_afterHidingOverlay_createsNewWindow() {
        val context1 = overlayController.requestWindow()
        TestOverlayView.show(context1)
        overlayController.hideWindow()

        val context2 = overlayController.requestWindow()
        assertThat(context1).isNotSameInstanceAs(context2)
    }

    @Test
    @UiThreadTest
    fun testRequestWindow_addsProxyView() {
@@ -79,6 +91,17 @@ class TaskbarOverlayControllerTest {
        assertThat(overlay.isOpen).isFalse()
    }

    @Test
    fun testRequestWindow_attachesDragLayer() {
        lateinit var dragLayer: BaseDragLayer<*>
        getInstrumentation().runOnMainSync {
            dragLayer = overlayController.requestWindow().dragLayer
        }

        // Allow drag layer to attach before checking.
        getInstrumentation().runOnMainSync { assertThat(dragLayer.isAttachedToWindow).isTrue() }
    }

    @Test
    @UiThreadTest
    fun testHideWindow_closesOverlay() {
@@ -87,6 +110,20 @@ class TaskbarOverlayControllerTest {
        assertThat(overlay.isOpen).isFalse()
    }

    @Test
    fun testHideWindow_detachesDragLayer() {
        lateinit var dragLayer: BaseDragLayer<*>
        getInstrumentation().runOnMainSync {
            dragLayer = overlayController.requestWindow().dragLayer
        }

        // Wait for drag layer to be attached to window before hiding.
        getInstrumentation().runOnMainSync {
            overlayController.hideWindow()
            assertThat(dragLayer.isAttachedToWindow).isFalse()
        }
    }

    @Test
    @UiThreadTest
    fun testTwoOverlays_closeOne_windowStaysOpen() {