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

Commit ec4f546c authored by Liran Binyamin's avatar Liran Binyamin
Browse files

Updates bubble drag zones for bubble bar

Also fixes a minor issue where bubble drag zones weren't added for
dragging the expanded view and fixed the test to make sure it
correctly checks the type.

Change-Id: Ib1c3069a77915d6061d02f321008317136269e9d
Flag: EXEMPT not wired
Bug: 393172431
Test: atest DragZoneFactoryTest
parent a53c941b
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -58,11 +58,11 @@ class DragZoneFactory(
        when (draggedObject) {
            is DraggedObject.BubbleBar -> {
                dragZones.add(createDismissDragZone())
                dragZones.addAll(createBubbleDragZones())
                dragZones.addAll(createBubbleHalfScreenDragZones())
            }
            is DraggedObject.Bubble -> {
                dragZones.add(createDismissDragZone())
                dragZones.addAll(createBubbleDragZones())
                dragZones.addAll(createBubbleCornerDragZones())
                dragZones.add(createFullScreenDragZone())
                if (shouldShowDesktopWindowDragZones()) {
                    dragZones.add(createDesktopWindowDragZoneForBubble())
@@ -80,7 +80,7 @@ class DragZoneFactory(
                } else {
                    dragZones.addAll(createSplitScreenDragZonesForExpandedViewOnTablet())
                }
                createBubbleDragZonesForExpandedView()
                dragZones.addAll(createBubbleHalfScreenDragZones())
            }
        }
        return dragZones
@@ -98,7 +98,7 @@ class DragZoneFactory(
        )
    }

    private fun createBubbleDragZones(): List<DragZone> {
    private fun createBubbleCornerDragZones(): List<DragZone> {
        val dragZoneSize =
            if (deviceConfig.isSmallTablet) {
                bubbleDragZoneFoldableSize
@@ -124,7 +124,7 @@ class DragZoneFactory(
        )
    }

    private fun createBubbleDragZonesForExpandedView(): List<DragZone> {
    private fun createBubbleHalfScreenDragZones(): List<DragZone> {
        return listOf(
            DragZone.Bubble.Left(
                bounds = Rect(0, 0, windowBounds.right / 2, windowBounds.bottom),
+88 −91
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import com.google.common.truth.Truth.assertThat
import org.junit.Test
import org.junit.runner.RunWith

private typealias DragZoneVerifier = (dragZone: DragZone) -> Unit

@SmallTest
@RunWith(AndroidJUnit4::class)
/** Unit tests for [DragZoneFactory]. */
@@ -58,15 +60,14 @@ class DragZoneFactoryTest {
            DragZoneFactory(tabletPortrait, splitScreenModeChecker, desktopWindowModeChecker)
        val dragZones =
            dragZoneFactory.createSortedDragZones(DraggedObject.BubbleBar(BubbleBarLocation.LEFT))
        val expectedZones: List<Class<out DragZone>> =
        val expectedZones: List<DragZoneVerifier> =
            listOf(
                DragZone.Dismiss::class.java,
                DragZone.Bubble::class.java,
                DragZone.Bubble::class.java,
                verifyInstance<DragZone.Dismiss>(),
                verifyInstance<DragZone.Bubble.Left>(),
                verifyInstance<DragZone.Bubble.Right>(),
            )
        dragZones.zip(expectedZones).forEach { (zone, expectedType) ->
            assertThat(zone).isInstanceOf(expectedType)
        }
        assertThat(dragZones).hasSize(expectedZones.size)
        dragZones.zip(expectedZones).forEach { (zone, instanceVerifier) -> instanceVerifier(zone) }
    }

    @Test
@@ -75,19 +76,18 @@ class DragZoneFactoryTest {
            DragZoneFactory(tabletPortrait, splitScreenModeChecker, desktopWindowModeChecker)
        val dragZones =
            dragZoneFactory.createSortedDragZones(DraggedObject.Bubble(BubbleBarLocation.LEFT))
        val expectedZones: List<Class<out DragZone>> =
        val expectedZones: List<DragZoneVerifier> =
            listOf(
                DragZone.Dismiss::class.java,
                DragZone.Bubble.Left::class.java,
                DragZone.Bubble.Right::class.java,
                DragZone.FullScreen::class.java,
                DragZone.DesktopWindow::class.java,
                DragZone.Split.Top::class.java,
                DragZone.Split.Bottom::class.java,
                verifyInstance<DragZone.Dismiss>(),
                verifyInstance<DragZone.Bubble.Left>(),
                verifyInstance<DragZone.Bubble.Right>(),
                verifyInstance<DragZone.FullScreen>(),
                verifyInstance<DragZone.DesktopWindow>(),
                verifyInstance<DragZone.Split.Top>(),
                verifyInstance<DragZone.Split.Bottom>(),
            )
        dragZones.zip(expectedZones).forEach { (zone, expectedType) ->
            assertThat(zone).isInstanceOf(expectedType)
        }
        assertThat(dragZones).hasSize(expectedZones.size)
        dragZones.zip(expectedZones).forEach { (zone, instanceVerifier) -> instanceVerifier(zone) }
    }

    @Test
@@ -95,19 +95,18 @@ class DragZoneFactoryTest {
        dragZoneFactory = DragZoneFactory(tabletLandscape, splitScreenModeChecker, desktopWindowModeChecker)
        val dragZones =
            dragZoneFactory.createSortedDragZones(DraggedObject.Bubble(BubbleBarLocation.LEFT))
        val expectedZones: List<Class<out DragZone>> =
        val expectedZones: List<DragZoneVerifier> =
            listOf(
                DragZone.Dismiss::class.java,
                DragZone.Bubble.Left::class.java,
                DragZone.Bubble.Right::class.java,
                DragZone.FullScreen::class.java,
                DragZone.DesktopWindow::class.java,
                DragZone.Split.Left::class.java,
                DragZone.Split.Right::class.java,
                verifyInstance<DragZone.Dismiss>(),
                verifyInstance<DragZone.Bubble.Left>(),
                verifyInstance<DragZone.Bubble.Right>(),
                verifyInstance<DragZone.FullScreen>(),
                verifyInstance<DragZone.DesktopWindow>(),
                verifyInstance<DragZone.Split.Left>(),
                verifyInstance<DragZone.Split.Right>(),
            )
        dragZones.zip(expectedZones).forEach { (zone, expectedType) ->
            assertThat(zone).isInstanceOf(expectedType)
        }
        assertThat(dragZones).hasSize(expectedZones.size)
        dragZones.zip(expectedZones).forEach { (zone, instanceVerifier) -> instanceVerifier(zone) }
    }

    @Test
@@ -115,18 +114,17 @@ class DragZoneFactoryTest {
        dragZoneFactory = DragZoneFactory(foldablePortrait, splitScreenModeChecker, desktopWindowModeChecker)
        val dragZones =
            dragZoneFactory.createSortedDragZones(DraggedObject.Bubble(BubbleBarLocation.LEFT))
        val expectedZones: List<Class<out DragZone>> =
        val expectedZones: List<DragZoneVerifier> =
            listOf(
                DragZone.Dismiss::class.java,
                DragZone.Bubble.Left::class.java,
                DragZone.Bubble.Right::class.java,
                DragZone.FullScreen::class.java,
                DragZone.Split.Left::class.java,
                DragZone.Split.Right::class.java,
                verifyInstance<DragZone.Dismiss>(),
                verifyInstance<DragZone.Bubble.Left>(),
                verifyInstance<DragZone.Bubble.Right>(),
                verifyInstance<DragZone.FullScreen>(),
                verifyInstance<DragZone.Split.Left>(),
                verifyInstance<DragZone.Split.Right>(),
            )
        dragZones.zip(expectedZones).forEach { (zone, expectedType) ->
            assertThat(zone).isInstanceOf(expectedType)
        }
        assertThat(dragZones).hasSize(expectedZones.size)
        dragZones.zip(expectedZones).forEach { (zone, instanceVerifier) -> instanceVerifier(zone) }
    }

    @Test
@@ -134,18 +132,17 @@ class DragZoneFactoryTest {
        dragZoneFactory = DragZoneFactory(foldableLandscape, splitScreenModeChecker, desktopWindowModeChecker)
        val dragZones =
            dragZoneFactory.createSortedDragZones(DraggedObject.Bubble(BubbleBarLocation.LEFT))
        val expectedZones: List<Class<out DragZone>> =
        val expectedZones: List<DragZoneVerifier> =
            listOf(
                DragZone.Dismiss::class.java,
                DragZone.Bubble.Left::class.java,
                DragZone.Bubble.Right::class.java,
                DragZone.FullScreen::class.java,
                DragZone.Split.Top::class.java,
                DragZone.Split.Bottom::class.java,
                verifyInstance<DragZone.Dismiss>(),
                verifyInstance<DragZone.Bubble.Left>(),
                verifyInstance<DragZone.Bubble.Right>(),
                verifyInstance<DragZone.FullScreen>(),
                verifyInstance<DragZone.Split.Top>(),
                verifyInstance<DragZone.Split.Bottom>(),
            )
        dragZones.zip(expectedZones).forEach { (zone, expectedType) ->
            assertThat(zone).isInstanceOf(expectedType)
        }
        assertThat(dragZones).hasSize(expectedZones.size)
        dragZones.zip(expectedZones).forEach { (zone, instanceVerifier) -> instanceVerifier(zone) }
    }

    @Test
@@ -156,19 +153,18 @@ class DragZoneFactoryTest {
            dragZoneFactory.createSortedDragZones(
                DraggedObject.ExpandedView(BubbleBarLocation.LEFT)
            )
        val expectedZones: List<Class<out DragZone>> =
        val expectedZones: List<DragZoneVerifier> =
            listOf(
                DragZone.Dismiss::class.java,
                DragZone.FullScreen::class.java,
                DragZone.DesktopWindow::class.java,
                DragZone.Split.Top::class.java,
                DragZone.Split.Bottom::class.java,
                DragZone.Bubble.Left::class.java,
                DragZone.Bubble.Right::class.java,
                verifyInstance<DragZone.Dismiss>(),
                verifyInstance<DragZone.FullScreen>(),
                verifyInstance<DragZone.DesktopWindow>(),
                verifyInstance<DragZone.Split.Top>(),
                verifyInstance<DragZone.Split.Bottom>(),
                verifyInstance<DragZone.Bubble.Left>(),
                verifyInstance<DragZone.Bubble.Right>(),
            )
        dragZones.zip(expectedZones).forEach { (zone, expectedType) ->
            assertThat(zone).isInstanceOf(expectedType)
        }
        assertThat(dragZones).hasSize(expectedZones.size)
        dragZones.zip(expectedZones).forEach { (zone, instanceVerifier) -> instanceVerifier(zone) }
    }

    @Test
@@ -176,19 +172,18 @@ class DragZoneFactoryTest {
        dragZoneFactory = DragZoneFactory(tabletLandscape, splitScreenModeChecker, desktopWindowModeChecker)
        val dragZones =
            dragZoneFactory.createSortedDragZones(DraggedObject.ExpandedView(BubbleBarLocation.LEFT))
        val expectedZones: List<Class<out DragZone>> =
        val expectedZones: List<DragZoneVerifier> =
            listOf(
                DragZone.Dismiss::class.java,
                DragZone.FullScreen::class.java,
                DragZone.DesktopWindow::class.java,
                DragZone.Split.Left::class.java,
                DragZone.Split.Right::class.java,
                DragZone.Bubble.Left::class.java,
                DragZone.Bubble.Right::class.java,
                verifyInstance<DragZone.Dismiss>(),
                verifyInstance<DragZone.FullScreen>(),
                verifyInstance<DragZone.DesktopWindow>(),
                verifyInstance<DragZone.Split.Left>(),
                verifyInstance<DragZone.Split.Right>(),
                verifyInstance<DragZone.Bubble.Left>(),
                verifyInstance<DragZone.Bubble.Right>(),
            )
        dragZones.zip(expectedZones).forEach { (zone, expectedType) ->
            assertThat(zone).isInstanceOf(expectedType)
        }
        assertThat(dragZones).hasSize(expectedZones.size)
        dragZones.zip(expectedZones).forEach { (zone, instanceVerifier) -> instanceVerifier(zone) }
    }

    @Test
@@ -196,18 +191,17 @@ class DragZoneFactoryTest {
        dragZoneFactory = DragZoneFactory(foldablePortrait, splitScreenModeChecker, desktopWindowModeChecker)
        val dragZones =
            dragZoneFactory.createSortedDragZones(DraggedObject.ExpandedView(BubbleBarLocation.LEFT))
        val expectedZones: List<Class<out DragZone>> =
        val expectedZones: List<DragZoneVerifier> =
            listOf(
                DragZone.Dismiss::class.java,
                DragZone.FullScreen::class.java,
                DragZone.Split.Left::class.java,
                DragZone.Split.Right::class.java,
                DragZone.Bubble.Left::class.java,
                DragZone.Bubble.Right::class.java,
                verifyInstance<DragZone.Dismiss>(),
                verifyInstance<DragZone.FullScreen>(),
                verifyInstance<DragZone.Split.Left>(),
                verifyInstance<DragZone.Split.Right>(),
                verifyInstance<DragZone.Bubble.Left>(),
                verifyInstance<DragZone.Bubble.Right>(),
            )
        dragZones.zip(expectedZones).forEach { (zone, expectedType) ->
            assertThat(zone).isInstanceOf(expectedType)
        }
        assertThat(dragZones).hasSize(expectedZones.size)
        dragZones.zip(expectedZones).forEach { (zone, instanceVerifier) -> instanceVerifier(zone) }
    }

    @Test
@@ -215,18 +209,17 @@ class DragZoneFactoryTest {
        dragZoneFactory = DragZoneFactory(foldableLandscape, splitScreenModeChecker, desktopWindowModeChecker)
        val dragZones =
            dragZoneFactory.createSortedDragZones(DraggedObject.ExpandedView(BubbleBarLocation.LEFT))
        val expectedZones: List<Class<out DragZone>> =
        val expectedZones: List<DragZoneVerifier> =
            listOf(
                DragZone.Dismiss::class.java,
                DragZone.FullScreen::class.java,
                DragZone.Split.Top::class.java,
                DragZone.Split.Bottom::class.java,
                DragZone.Bubble.Left::class.java,
                DragZone.Bubble.Right::class.java,
                verifyInstance<DragZone.Dismiss>(),
                verifyInstance<DragZone.FullScreen>(),
                verifyInstance<DragZone.Split.Top>(),
                verifyInstance<DragZone.Split.Bottom>(),
                verifyInstance<DragZone.Bubble.Left>(),
                verifyInstance<DragZone.Bubble.Right>(),
            )
        dragZones.zip(expectedZones).forEach { (zone, expectedType) ->
            assertThat(zone).isInstanceOf(expectedType)
        }
        assertThat(dragZones).hasSize(expectedZones.size)
        dragZones.zip(expectedZones).forEach { (zone, instanceVerifier) -> instanceVerifier(zone) }
    }

    @Test
@@ -246,4 +239,8 @@ class DragZoneFactoryTest {
            dragZoneFactory.createSortedDragZones(DraggedObject.ExpandedView(BubbleBarLocation.LEFT))
        assertThat(dragZones.filterIsInstance<DragZone.DesktopWindow>()).isEmpty()
    }

    private inline fun <reified T> verifyInstance(): DragZoneVerifier = { dragZone ->
        assertThat(dragZone).isInstanceOf(T::class.java)
    }
}