Merge "Support running WMShellUnitTests from studio" into tm-qpr-dev am: d69a267b95

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19221969

Change-Id: I85fef8d8468458e50b020a2c2f6f1bf526959d1d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Winson Chung
2022-07-09 02:54:08 +00:00
committed by Automerger Merge Worker
20 changed files with 49 additions and 24 deletions

View File

@@ -28,6 +28,9 @@ android_test {
"**/*.java", "**/*.java",
"**/*.kt", "**/*.kt",
], ],
resource_dirs: [
"res",
],
static_libs: [ static_libs: [
"WindowManager-Shell", "WindowManager-Shell",
@@ -65,4 +68,9 @@ android_test {
optimize: { optimize: {
enabled: false, enabled: false,
}, },
aaptflags: [
"--extra-packages",
"com.android.wm.shell.tests",
],
} }

View File

@@ -77,7 +77,7 @@ import java.util.Optional;
*/ */
@SmallTest @SmallTest
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public class ShellTaskOrganizerTests { public class ShellTaskOrganizerTests extends ShellTestCase {
@Mock @Mock
private ITaskOrganizerController mTaskOrganizerController; private ITaskOrganizerController mTaskOrganizerController;

View File

@@ -24,6 +24,8 @@ import android.testing.TestableContext;
import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.platform.app.InstrumentationRegistry;
import com.android.internal.protolog.common.ProtoLog;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;
@@ -37,6 +39,9 @@ public abstract class ShellTestCase {
@Before @Before
public void shellSetup() { public void shellSetup() {
// Disable protolog tool when running the tests from studio
ProtoLog.REQUIRE_PROTOLOGTOOL = false;
MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this);
final Context context = final Context context =
InstrumentationRegistry.getInstrumentation().getTargetContext(); InstrumentationRegistry.getInstrumentation().getTargetContext();

View File

@@ -57,6 +57,7 @@ import androidx.test.filters.SmallTest;
import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.platform.app.InstrumentationRegistry;
import com.android.internal.util.test.FakeSettingsProvider; import com.android.internal.util.test.FakeSettingsProvider;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.TestShellExecutor; import com.android.wm.shell.TestShellExecutor;
import org.junit.Before; import org.junit.Before;
@@ -74,7 +75,7 @@ import org.mockito.MockitoAnnotations;
@TestableLooper.RunWithLooper @TestableLooper.RunWithLooper
@SmallTest @SmallTest
@RunWith(AndroidTestingRunner.class) @RunWith(AndroidTestingRunner.class)
public class BackAnimationControllerTest { public class BackAnimationControllerTest extends ShellTestCase {
private static final String ANIMATION_ENABLED = "1"; private static final String ANIMATION_ENABLED = "1";
private final TestShellExecutor mShellExecutor = new TestShellExecutor(); private final TestShellExecutor mShellExecutor = new TestShellExecutor();

View File

@@ -20,7 +20,7 @@ import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import com.android.wm.shell.R; import com.android.wm.shell.tests.R;
/** /**
* Referenced by NotificationTestHelper#makeBubbleMetadata * Referenced by NotificationTestHelper#makeBubbleMetadata

View File

@@ -39,6 +39,7 @@ import android.view.SurfaceControl;
import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest;
import com.android.internal.view.IInputMethodManager; import com.android.internal.view.IInputMethodManager;
import com.android.wm.shell.ShellTestCase;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@@ -46,7 +47,7 @@ import org.junit.Test;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
@SmallTest @SmallTest
public class DisplayImeControllerTest { public class DisplayImeControllerTest extends ShellTestCase {
private SurfaceControl.Transaction mT; private SurfaceControl.Transaction mT;
private DisplayImeController.PerDisplay mPerDisplay; private DisplayImeController.PerDisplay mPerDisplay;

View File

@@ -34,6 +34,7 @@ import android.view.InsetsVisibilities;
import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.TestShellExecutor; import com.android.wm.shell.TestShellExecutor;
import org.junit.Before; import org.junit.Before;
@@ -45,7 +46,7 @@ import org.mockito.MockitoAnnotations;
import java.util.List; import java.util.List;
@SmallTest @SmallTest
public class DisplayInsetsControllerTest { public class DisplayInsetsControllerTest extends ShellTestCase {
private static final int SECOND_DISPLAY = DEFAULT_DISPLAY + 10; private static final int SECOND_DISPLAY = DEFAULT_DISPLAY + 10;

View File

@@ -41,6 +41,7 @@ import androidx.test.filters.SmallTest;
import com.android.internal.R; import com.android.internal.R;
import com.android.internal.policy.SystemBarUtils; import com.android.internal.policy.SystemBarUtils;
import com.android.wm.shell.ShellTestCase;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
@@ -54,7 +55,7 @@ import org.mockito.MockitoSession;
* atest WMShellUnitTests:DisplayLayoutTest * atest WMShellUnitTests:DisplayLayoutTest
*/ */
@SmallTest @SmallTest
public class DisplayLayoutTest { public class DisplayLayoutTest extends ShellTestCase {
private MockitoSession mMockitoSession; private MockitoSession mMockitoSession;
@Before @Before

View File

@@ -35,6 +35,8 @@ import android.window.TaskSnapshot;
import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest;
import com.android.wm.shell.ShellTestCase;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@@ -47,7 +49,7 @@ import org.mockito.MockitoAnnotations;
@RunWith(AndroidTestingRunner.class) @RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper @TestableLooper.RunWithLooper
@SmallTest @SmallTest
public class TaskStackListenerImplTest { public class TaskStackListenerImplTest extends ShellTestCase {
@Mock @Mock
private IActivityTaskManager mActivityTaskManager; private IActivityTaskManager mActivityTaskManager;

View File

@@ -44,6 +44,7 @@ import androidx.test.filters.SmallTest;
import com.android.internal.logging.UiEventLogger; import com.android.internal.logging.UiEventLogger;
import com.android.launcher3.icons.IconProvider; import com.android.launcher3.icons.IconProvider;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.splitscreen.SplitScreenController; import com.android.wm.shell.splitscreen.SplitScreenController;
@@ -61,7 +62,7 @@ import java.util.Optional;
*/ */
@SmallTest @SmallTest
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public class DragAndDropControllerTest { public class DragAndDropControllerTest extends ShellTestCase {
@Mock @Mock
private Context mContext; private Context mContext;

View File

@@ -66,6 +66,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest;
import com.android.internal.logging.InstanceId; import com.android.internal.logging.InstanceId;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.common.DisplayLayout; import com.android.wm.shell.common.DisplayLayout;
import com.android.wm.shell.draganddrop.DragAndDropPolicy.Target; import com.android.wm.shell.draganddrop.DragAndDropPolicy.Target;
import com.android.wm.shell.splitscreen.SplitScreenController; import com.android.wm.shell.splitscreen.SplitScreenController;
@@ -85,7 +86,7 @@ import java.util.HashSet;
*/ */
@SmallTest @SmallTest
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public class DragAndDropPolicyTest { public class DragAndDropPolicyTest extends ShellTestCase {
@Mock @Mock
private Context mContext; private Context mContext;

View File

@@ -19,7 +19,6 @@ package com.android.wm.shell.hidedisplaycutout;
import static org.mockito.Mockito.reset; import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import android.platform.test.annotations.Presubmit;
import android.testing.AndroidTestingRunner; import android.testing.AndroidTestingRunner;
import android.testing.TestableContext; import android.testing.TestableContext;
import android.testing.TestableLooper; import android.testing.TestableLooper;
@@ -27,6 +26,7 @@ import android.testing.TestableLooper;
import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest;
import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.platform.app.InstrumentationRegistry;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.common.ShellExecutor;
import org.junit.Before; import org.junit.Before;
@@ -35,11 +35,10 @@ import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;
@Presubmit
@SmallTest @SmallTest
@RunWith(AndroidTestingRunner.class) @RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper @TestableLooper.RunWithLooper
public class HideDisplayCutoutControllerTest { public class HideDisplayCutoutControllerTest extends ShellTestCase {
private TestableContext mContext = new TestableContext( private TestableContext mContext = new TestableContext(
InstrumentationRegistry.getInstrumentation().getTargetContext(), null); InstrumentationRegistry.getInstrumentation().getTargetContext(), null);

View File

@@ -32,7 +32,6 @@ import android.content.res.Configuration;
import android.graphics.Insets; import android.graphics.Insets;
import android.graphics.Rect; import android.graphics.Rect;
import android.os.Binder; import android.os.Binder;
import android.platform.test.annotations.Presubmit;
import android.testing.AndroidTestingRunner; import android.testing.AndroidTestingRunner;
import android.testing.TestableContext; import android.testing.TestableContext;
import android.testing.TestableLooper; import android.testing.TestableLooper;
@@ -48,6 +47,7 @@ import android.window.WindowContainerToken;
import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest;
import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.platform.app.InstrumentationRegistry;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.DisplayLayout; import com.android.wm.shell.common.DisplayLayout;
import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.common.ShellExecutor;
@@ -61,11 +61,10 @@ import org.mockito.MockitoAnnotations;
import java.util.ArrayList; import java.util.ArrayList;
@Presubmit
@SmallTest @SmallTest
@RunWith(AndroidTestingRunner.class) @RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper @TestableLooper.RunWithLooper
public class HideDisplayCutoutOrganizerTest { public class HideDisplayCutoutOrganizerTest extends ShellTestCase {
private TestableContext mContext = new TestableContext( private TestableContext mContext = new TestableContext(
InstrumentationRegistry.getInstrumentation().getTargetContext(), null); InstrumentationRegistry.getInstrumentation().getTargetContext(), null);

View File

@@ -44,6 +44,7 @@ import android.window.WindowContainerTransaction;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.DisplayInsetsController; import com.android.wm.shell.common.DisplayInsetsController;
import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.common.ShellExecutor;
@@ -61,7 +62,7 @@ import java.util.Optional;
@SmallTest @SmallTest
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public class KidsModeTaskOrganizerTest { public class KidsModeTaskOrganizerTest extends ShellTestCase {
@Mock private ITaskOrganizerController mTaskOrganizerController; @Mock private ITaskOrganizerController mTaskOrganizerController;
@Mock private Context mContext; @Mock private Context mContext;
@Mock private Handler mHandler; @Mock private Handler mHandler;

View File

@@ -30,6 +30,8 @@ import android.view.WindowManager;
import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.platform.app.InstrumentationRegistry;
import com.android.wm.shell.ShellTestCase;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.mockito.Answers; import org.mockito.Answers;
@@ -38,7 +40,7 @@ import org.mockito.Mock;
/** /**
* Base class that does One Handed specific setup. * Base class that does One Handed specific setup.
*/ */
public abstract class OneHandedTestCase { public abstract class OneHandedTestCase extends ShellTestCase {
@Mock(answer = Answers.RETURNS_DEEP_STUBS) @Mock(answer = Answers.RETURNS_DEEP_STUBS)
protected Context mContext; protected Context mContext;

View File

@@ -9,6 +9,7 @@ import android.graphics.Rect;
import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4; import androidx.test.runner.AndroidJUnit4;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.util.SplitBounds; import com.android.wm.shell.util.SplitBounds;
import org.junit.Before; import org.junit.Before;
@@ -17,7 +18,7 @@ import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
@SmallTest @SmallTest
public class SplitBoundsTest { public class SplitBoundsTest extends ShellTestCase {
private static final int DEVICE_WIDTH = 100; private static final int DEVICE_WIDTH = 100;
private static final int DEVICE_LENGTH = 200; private static final int DEVICE_LENGTH = 200;
private static final int DIVIDER_SIZE = 20; private static final int DIVIDER_SIZE = 20;

View File

@@ -73,6 +73,7 @@ import androidx.test.filters.SmallTest;
import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.platform.app.InstrumentationRegistry;
import com.android.launcher3.icons.IconProvider; import com.android.launcher3.icons.IconProvider;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.common.HandlerExecutor; import com.android.wm.shell.common.HandlerExecutor;
import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.TransactionPool; import com.android.wm.shell.common.TransactionPool;
@@ -91,7 +92,7 @@ import java.util.function.IntSupplier;
*/ */
@SmallTest @SmallTest
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public class StartingSurfaceDrawerTests { public class StartingSurfaceDrawerTests extends ShellTestCase {
@Mock @Mock
private IBinder mBinder; private IBinder mBinder;
@Mock @Mock

View File

@@ -47,6 +47,7 @@ import android.window.TaskSnapshot;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.TestShellExecutor; import com.android.wm.shell.TestShellExecutor;
import org.junit.Test; import org.junit.Test;
@@ -58,7 +59,7 @@ import org.junit.runner.RunWith;
*/ */
@SmallTest @SmallTest
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public class TaskSnapshotWindowTest { public class TaskSnapshotWindowTest extends ShellTestCase {
private TaskSnapshotWindow mWindow; private TaskSnapshotWindow mWindow;

View File

@@ -18,13 +18,13 @@ package com.android.wm.shell.tasksurfacehelper;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import android.platform.test.annotations.Presubmit;
import android.testing.AndroidTestingRunner; import android.testing.AndroidTestingRunner;
import android.view.SurfaceControl; import android.view.SurfaceControl;
import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest;
import com.android.wm.shell.ShellTaskOrganizer; import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.common.ShellExecutor;
import org.junit.Before; import org.junit.Before;
@@ -33,10 +33,9 @@ import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;
@Presubmit
@RunWith(AndroidTestingRunner.class) @RunWith(AndroidTestingRunner.class)
@SmallTest @SmallTest
public class TaskSurfaceHelperControllerTest { public class TaskSurfaceHelperControllerTest extends ShellTestCase {
private TaskSurfaceHelperController mTaskSurfaceHelperController; private TaskSurfaceHelperController mTaskSurfaceHelperController;
@Mock @Mock
private ShellTaskOrganizer mMockTaskOrganizer; private ShellTaskOrganizer mMockTaskOrganizer;

View File

@@ -79,6 +79,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest;
import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.platform.app.InstrumentationRegistry;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.TestShellExecutor; import com.android.wm.shell.TestShellExecutor;
import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.common.ShellExecutor;
@@ -98,7 +99,7 @@ import java.util.ArrayList;
*/ */
@SmallTest @SmallTest
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public class ShellTransitionTests { public class ShellTransitionTests extends ShellTestCase {
private final WindowOrganizer mOrganizer = mock(WindowOrganizer.class); private final WindowOrganizer mOrganizer = mock(WindowOrganizer.class);
private final TransactionPool mTransactionPool = mock(TransactionPool.class); private final TransactionPool mTransactionPool = mock(TransactionPool.class);