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
This commit is contained in:
Tadashi G. Takaoka
2018-10-11 16:30:28 +09:00
parent a9e320bb13
commit c8f2c1485f
3 changed files with 27 additions and 20 deletions

View File

@@ -40,27 +40,25 @@ import android.view.SurfaceControl;
import android.view.SurfaceSession;
import android.view.View;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
import com.android.internal.annotations.GuardedBy;
import com.android.server.LocalServices;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import androidx.test.filters.SmallTest;
/**
* Tests for the {@link DragDropController} class.
*
* atest FrameworksServicesTests:com.android.server.wm.DragDropControllerTests
* Build/Install/Run:
* atest FrameworksServicesTests:com.android.server.wm.DragDropControllerTests
*/
@SmallTest
@RunWith(AndroidJUnit4.class)
@Presubmit
public class DragDropControllerTests extends WindowTestsBase {
private static final int TIMEOUT_MS = 3000;
@@ -109,6 +107,7 @@ public class DragDropControllerTests extends WindowTestsBase {
return window;
}
@Override
@Before
public void setUp() throws Exception {
final UserManagerInternal userManager = mock(UserManagerInternal.class);
@@ -127,6 +126,7 @@ public class DragDropControllerTests extends WindowTestsBase {
}
}
@Override
@After
public void tearDown() throws Exception {
LocalServices.removeServiceForTest(UserManagerInternal.class);
@@ -139,25 +139,25 @@ public class DragDropControllerTests extends WindowTestsBase {
mTarget.cancelDragAndDrop(mToken);
}
latch = new CountDownLatch(1);
mTarget.setOnClosedCallbackLocked(() -> {
latch.countDown();
});
mTarget.setOnClosedCallbackLocked(latch::countDown);
}
assertTrue(latch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
super.tearDown();
}
@Test
public void testDragFlow() throws Exception {
public void testDragFlow() {
dragFlow(0, ClipData.newPlainText("label", "Test"), 0, 0);
}
@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);
}
@Test
public void testPerformDrag_NullDataToOtherUser() throws Exception {
public void testPerformDrag_NullDataToOtherUser() {
final WindowState otherUsersWindow =
createDropTargetWindow("Other user's window", 1 * UserHandle.PER_USER_RANGE);
doReturn(otherUsersWindow).when(mDisplayContent).getTouchableWinAtPointLocked(10, 10);

View File

@@ -29,14 +29,14 @@ import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.os.UserManager;
import androidx.test.InstrumentationRegistry;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import java.io.File;
import androidx.test.InstrumentationRegistry;
/**
* Base class for tests that use a {@link TaskSnapshotPersister}.
*/
@@ -54,9 +54,11 @@ class TaskSnapshotPersisterTestBase extends WindowTestsBase {
sFilesDir = InstrumentationRegistry.getContext().getFilesDir();
}
@Override
@Before
public void setUp() throws Exception {
super.setUp();
final UserManager um = UserManager.get(InstrumentationRegistry.getContext());
mTestUserId = um.getUserHandle();
mPersister = new TaskSnapshotPersister(userId -> sFilesDir);
@@ -64,9 +66,12 @@ class TaskSnapshotPersisterTestBase extends WindowTestsBase {
mPersister.start();
}
@Override
@After
public void tearDown() throws Exception {
cleanDirectory();
super.tearDown();
}
private void cleanDirectory() {

View File

@@ -25,30 +25,29 @@ import static org.junit.Assert.assertTrue;
import android.platform.test.annotations.Presubmit;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import androidx.test.filters.SmallTest;
/**
* Tests for the {@link DisplayContent.TaskStackContainers} container in {@link DisplayContent}.
*
* Build/Install/Run:
* bit FrameworksServicesTests:com.android.server.wm.TaskStackContainersTests
* atest FrameworksServicesTests:com.android.server.wm.TaskStackContainersTests
*/
@SmallTest
@Presubmit
@RunWith(AndroidJUnit4.class)
public class TaskStackContainersTests extends WindowTestsBase {
private TaskStack mPinnedStack;
@Override
@Before
public void setUp() throws Exception {
super.setUp();
mPinnedStack = createStackControllerOnStackOnDisplay(
WINDOWING_MODE_PINNED, ACTIVITY_TYPE_STANDARD, mDisplayContent).mContainer;
// Stack should contain visible app window to be considered visible.
@@ -60,9 +59,12 @@ public class TaskStackContainersTests extends WindowTestsBase {
assertTrue(mPinnedStack.isVisible());
}
@Override
@After
public void tearDown() throws Exception {
mPinnedStack.removeImmediately();
super.tearDown();
}
@Test