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

Commit 85b44c1b authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Do not remove decoration surface on DragResizeInputListener#close" into main

parents ade3b59b 33f0ce08
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -435,7 +435,9 @@ class DragResizeInputListener implements AutoCloseable {
            }
            // Removing this surface on the background thread to ensure that mInitInputChannels has
            // already been finished.
            mSurfaceControlTransactionSupplier.get().remove(mDecorationSurface).apply();
            // Do not |remove| the surface, the decoration might still be needed even if
            // drag-resizing isn't.
            mDecorationSurface.release();
        });
    }

+21 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import com.android.wm.shell.windowdecor.DragResizeInputListener.TaskResizeInputE
import com.google.common.truth.Truth.assertThat
import java.util.function.Consumer
import java.util.function.Supplier
import kotlin.test.assertNotNull
import org.junit.After
import org.junit.Test
import org.junit.runner.RunWith
@@ -69,9 +70,12 @@ class DragResizeInputListenerTest : ShellTestCase() {
    private val sinkInputChannel = mock<InputChannel>()
    private val decorationSurface = SurfaceControl.Builder().setName("decoration surface").build()
    private val createdSurfaces = ArrayList<SurfaceControl>()
    private val removedSurfaces = ArrayList<SurfaceControl>()

    @After
    fun tearDown() {
        createdSurfaces.clear()
        removedSurfaces.clear()
        decorationSurface.release()
    }

@@ -217,6 +221,19 @@ class DragResizeInputListenerTest : ShellTestCase() {
        assertThat(createdSurfaces[1].isValid).isFalse()
    }

    @Test
    fun testClose_releasesDecorationSurfaceWithoutRemoval() {
        val inputListener = create()
        testBgExecutor.flushAll()
        inputListener.close()
        testMainExecutor.flushAll()
        testBgExecutor.flushAll()

        val decorationSurface = assertNotNull(createdSurfaces[0])
        assertThat(decorationSurface.isValid).isFalse()
        assertThat(removedSurfaces.contains(decorationSurface)).isFalse()
    }

    private fun verifyNoInputChannelGrantRequests() {
        verify(mockWindowSession, never())
            .grantInputChannel(
@@ -258,7 +275,10 @@ class DragResizeInputListenerTest : ShellTestCase() {
            {
                object : StubTransaction() {
                    override fun remove(sc: SurfaceControl): SurfaceControl.Transaction {
                        return super.remove(sc).also { sc.release() }
                        return super.remove(sc).also {
                            sc.release()
                            removedSurfaces.add(sc)
                        }
                    }
                }
            },