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

Commit c8f2c148 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

Fix missing WindowTestBase.tearDown call

Bug: 116449554
Test: tradefed.sh run commandAndExit FrameworksServicesTests \
    --include-filter com.android.server.wm \
    --include-annotation android.platform.test.annotations.Presubmit \
    --exclude-annotation androidx.test.filters.FlakyTest

Change-Id: I5cb699f0f2d4e762d8712eea02577195fbaa124c
parent a9e320bb
Loading
Loading
Loading
Loading
+12 −12
Original line number Original line Diff line number Diff line
@@ -40,27 +40,25 @@ import android.view.SurfaceControl;
import android.view.SurfaceSession;
import android.view.SurfaceSession;
import android.view.View;
import android.view.View;


import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.GuardedBy;
import com.android.server.LocalServices;
import com.android.server.LocalServices;


import org.junit.After;
import org.junit.After;
import org.junit.Before;
import org.junit.Before;
import org.junit.Test;
import org.junit.Test;
import org.junit.runner.RunWith;


import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeUnit;


import androidx.test.filters.SmallTest;

/**
/**
 * Tests for the {@link DragDropController} class.
 * Tests for the {@link DragDropController} class.
 *
 *
 * Build/Install/Run:
 *  atest FrameworksServicesTests:com.android.server.wm.DragDropControllerTests
 *  atest FrameworksServicesTests:com.android.server.wm.DragDropControllerTests
 */
 */
@SmallTest
@SmallTest
@RunWith(AndroidJUnit4.class)
@Presubmit
@Presubmit
public class DragDropControllerTests extends WindowTestsBase {
public class DragDropControllerTests extends WindowTestsBase {
    private static final int TIMEOUT_MS = 3000;
    private static final int TIMEOUT_MS = 3000;
@@ -109,6 +107,7 @@ public class DragDropControllerTests extends WindowTestsBase {
        return window;
        return window;
    }
    }


    @Override
    @Before
    @Before
    public void setUp() throws Exception {
    public void setUp() throws Exception {
        final UserManagerInternal userManager = mock(UserManagerInternal.class);
        final UserManagerInternal userManager = mock(UserManagerInternal.class);
@@ -127,6 +126,7 @@ public class DragDropControllerTests extends WindowTestsBase {
        }
        }
    }
    }


    @Override
    @After
    @After
    public void tearDown() throws Exception {
    public void tearDown() throws Exception {
        LocalServices.removeServiceForTest(UserManagerInternal.class);
        LocalServices.removeServiceForTest(UserManagerInternal.class);
@@ -139,25 +139,25 @@ public class DragDropControllerTests extends WindowTestsBase {
                mTarget.cancelDragAndDrop(mToken);
                mTarget.cancelDragAndDrop(mToken);
            }
            }
            latch = new CountDownLatch(1);
            latch = new CountDownLatch(1);
            mTarget.setOnClosedCallbackLocked(() -> {
            mTarget.setOnClosedCallbackLocked(latch::countDown);
                latch.countDown();
            });
        }
        }
        assertTrue(latch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
        assertTrue(latch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));

        super.tearDown();
    }
    }


    @Test
    @Test
    public void testDragFlow() throws Exception {
    public void testDragFlow() {
        dragFlow(0, ClipData.newPlainText("label", "Test"), 0, 0);
        dragFlow(0, ClipData.newPlainText("label", "Test"), 0, 0);
    }
    }


    @Test
    @Test
    public void testPerformDrag_NullDataWithGrantUri() throws Exception {
    public void testPerformDrag_NullDataWithGrantUri() {
        dragFlow(View.DRAG_FLAG_GLOBAL | View.DRAG_FLAG_GLOBAL_URI_READ, null, 0, 0);
        dragFlow(View.DRAG_FLAG_GLOBAL | View.DRAG_FLAG_GLOBAL_URI_READ, null, 0, 0);
    }
    }


    @Test
    @Test
    public void testPerformDrag_NullDataToOtherUser() throws Exception {
    public void testPerformDrag_NullDataToOtherUser() {
        final WindowState otherUsersWindow =
        final WindowState otherUsersWindow =
                createDropTargetWindow("Other user's window", 1 * UserHandle.PER_USER_RANGE);
                createDropTargetWindow("Other user's window", 1 * UserHandle.PER_USER_RANGE);
        doReturn(otherUsersWindow).when(mDisplayContent).getTouchableWinAtPointLocked(10, 10);
        doReturn(otherUsersWindow).when(mDisplayContent).getTouchableWinAtPointLocked(10, 10);
+7 −2
Original line number Original line Diff line number Diff line
@@ -29,14 +29,14 @@ import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.Rect;
import android.os.UserManager;
import android.os.UserManager;


import androidx.test.InstrumentationRegistry;

import org.junit.After;
import org.junit.After;
import org.junit.Before;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.BeforeClass;


import java.io.File;
import java.io.File;


import androidx.test.InstrumentationRegistry;

/**
/**
 * Base class for tests that use a {@link TaskSnapshotPersister}.
 * Base class for tests that use a {@link TaskSnapshotPersister}.
 */
 */
@@ -54,9 +54,11 @@ class TaskSnapshotPersisterTestBase extends WindowTestsBase {
        sFilesDir = InstrumentationRegistry.getContext().getFilesDir();
        sFilesDir = InstrumentationRegistry.getContext().getFilesDir();
    }
    }


    @Override
    @Before
    @Before
    public void setUp() throws Exception {
    public void setUp() throws Exception {
        super.setUp();
        super.setUp();

        final UserManager um = UserManager.get(InstrumentationRegistry.getContext());
        final UserManager um = UserManager.get(InstrumentationRegistry.getContext());
        mTestUserId = um.getUserHandle();
        mTestUserId = um.getUserHandle();
        mPersister = new TaskSnapshotPersister(userId -> sFilesDir);
        mPersister = new TaskSnapshotPersister(userId -> sFilesDir);
@@ -64,9 +66,12 @@ class TaskSnapshotPersisterTestBase extends WindowTestsBase {
        mPersister.start();
        mPersister.start();
    }
    }


    @Override
    @After
    @After
    public void tearDown() throws Exception {
    public void tearDown() throws Exception {
        cleanDirectory();
        cleanDirectory();

        super.tearDown();
    }
    }


    private void cleanDirectory() {
    private void cleanDirectory() {
+8 −6
Original line number Original line Diff line number Diff line
@@ -25,30 +25,29 @@ import static org.junit.Assert.assertTrue;


import android.platform.test.annotations.Presubmit;
import android.platform.test.annotations.Presubmit;


import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;

import org.junit.After;
import org.junit.After;
import org.junit.Before;
import org.junit.Before;
import org.junit.Test;
import org.junit.Test;
import org.junit.runner.RunWith;

import androidx.test.filters.SmallTest;


/**
/**
 * Tests for the {@link DisplayContent.TaskStackContainers} container in {@link DisplayContent}.
 * Tests for the {@link DisplayContent.TaskStackContainers} container in {@link DisplayContent}.
 *
 *
 * Build/Install/Run:
 * Build/Install/Run:
 *  bit FrameworksServicesTests:com.android.server.wm.TaskStackContainersTests
 *  atest FrameworksServicesTests:com.android.server.wm.TaskStackContainersTests
 */
 */
@SmallTest
@SmallTest
@Presubmit
@Presubmit
@RunWith(AndroidJUnit4.class)
public class TaskStackContainersTests extends WindowTestsBase {
public class TaskStackContainersTests extends WindowTestsBase {


    private TaskStack mPinnedStack;
    private TaskStack mPinnedStack;


    @Override
    @Before
    @Before
    public void setUp() throws Exception {
    public void setUp() throws Exception {
        super.setUp();
        super.setUp();

        mPinnedStack = createStackControllerOnStackOnDisplay(
        mPinnedStack = createStackControllerOnStackOnDisplay(
                WINDOWING_MODE_PINNED, ACTIVITY_TYPE_STANDARD, mDisplayContent).mContainer;
                WINDOWING_MODE_PINNED, ACTIVITY_TYPE_STANDARD, mDisplayContent).mContainer;
        // Stack should contain visible app window to be considered visible.
        // Stack should contain visible app window to be considered visible.
@@ -60,9 +59,12 @@ public class TaskStackContainersTests extends WindowTestsBase {
        assertTrue(mPinnedStack.isVisible());
        assertTrue(mPinnedStack.isVisible());
    }
    }


    @Override
    @After
    @After
    public void tearDown() throws Exception {
    public void tearDown() throws Exception {
        mPinnedStack.removeImmediately();
        mPinnedStack.removeImmediately();

        super.tearDown();
    }
    }


    @Test
    @Test