Support running WMShellUnitTests from studio
- Remove unnecessary @Presubmit annotation - Fix issue with test activity referencing wrong resources - Disable protolog requirement for tests when running under studio (like we do for SysUI studio builds) - Ensure all tests extend ShellTestCase Test: Run tests from studio, and also from atest WMShellUnitTests Bug: 238444377 Change-Id: I60a96dfcbbf119d6736e96193f5a7d41611e2fd1
This commit is contained in:
@@ -28,6 +28,9 @@ android_test {
|
||||
"**/*.java",
|
||||
"**/*.kt",
|
||||
],
|
||||
resource_dirs: [
|
||||
"res",
|
||||
],
|
||||
|
||||
static_libs: [
|
||||
"WindowManager-Shell",
|
||||
@@ -65,4 +68,9 @@ android_test {
|
||||
optimize: {
|
||||
enabled: false,
|
||||
},
|
||||
|
||||
aaptflags: [
|
||||
"--extra-packages",
|
||||
"com.android.wm.shell.tests",
|
||||
],
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ import java.util.Optional;
|
||||
*/
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ShellTaskOrganizerTests {
|
||||
public class ShellTaskOrganizerTests extends ShellTestCase {
|
||||
|
||||
@Mock
|
||||
private ITaskOrganizerController mTaskOrganizerController;
|
||||
|
||||
@@ -24,6 +24,8 @@ import android.testing.TestableContext;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import com.android.internal.protolog.common.ProtoLog;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
@@ -37,6 +39,9 @@ public abstract class ShellTestCase {
|
||||
|
||||
@Before
|
||||
public void shellSetup() {
|
||||
// Disable protolog tool when running the tests from studio
|
||||
ProtoLog.REQUIRE_PROTOLOGTOOL = false;
|
||||
|
||||
MockitoAnnotations.initMocks(this);
|
||||
final Context context =
|
||||
InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
|
||||
@@ -57,6 +57,7 @@ import androidx.test.filters.SmallTest;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import com.android.internal.util.test.FakeSettingsProvider;
|
||||
import com.android.wm.shell.ShellTestCase;
|
||||
import com.android.wm.shell.TestShellExecutor;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -74,7 +75,7 @@ import org.mockito.MockitoAnnotations;
|
||||
@TestableLooper.RunWithLooper
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
public class BackAnimationControllerTest {
|
||||
public class BackAnimationControllerTest extends ShellTestCase {
|
||||
|
||||
private static final String ANIMATION_ENABLED = "1";
|
||||
private final TestShellExecutor mShellExecutor = new TestShellExecutor();
|
||||
|
||||
@@ -20,7 +20,7 @@ import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.android.wm.shell.R;
|
||||
import com.android.wm.shell.tests.R;
|
||||
|
||||
/**
|
||||
* Referenced by NotificationTestHelper#makeBubbleMetadata
|
||||
|
||||
@@ -39,6 +39,7 @@ import android.view.SurfaceControl;
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.internal.view.IInputMethodManager;
|
||||
import com.android.wm.shell.ShellTestCase;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -46,7 +47,7 @@ import org.junit.Test;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@SmallTest
|
||||
public class DisplayImeControllerTest {
|
||||
public class DisplayImeControllerTest extends ShellTestCase {
|
||||
|
||||
private SurfaceControl.Transaction mT;
|
||||
private DisplayImeController.PerDisplay mPerDisplay;
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.view.InsetsVisibilities;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.wm.shell.ShellTestCase;
|
||||
import com.android.wm.shell.TestShellExecutor;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -45,7 +46,7 @@ import org.mockito.MockitoAnnotations;
|
||||
import java.util.List;
|
||||
|
||||
@SmallTest
|
||||
public class DisplayInsetsControllerTest {
|
||||
public class DisplayInsetsControllerTest extends ShellTestCase {
|
||||
|
||||
private static final int SECOND_DISPLAY = DEFAULT_DISPLAY + 10;
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.policy.SystemBarUtils;
|
||||
import com.android.wm.shell.ShellTestCase;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -54,7 +55,7 @@ import org.mockito.MockitoSession;
|
||||
* atest WMShellUnitTests:DisplayLayoutTest
|
||||
*/
|
||||
@SmallTest
|
||||
public class DisplayLayoutTest {
|
||||
public class DisplayLayoutTest extends ShellTestCase {
|
||||
private MockitoSession mMockitoSession;
|
||||
|
||||
@Before
|
||||
|
||||
@@ -35,6 +35,8 @@ import android.window.TaskSnapshot;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.wm.shell.ShellTestCase;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -47,7 +49,7 @@ import org.mockito.MockitoAnnotations;
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
@TestableLooper.RunWithLooper
|
||||
@SmallTest
|
||||
public class TaskStackListenerImplTest {
|
||||
public class TaskStackListenerImplTest extends ShellTestCase {
|
||||
|
||||
@Mock
|
||||
private IActivityTaskManager mActivityTaskManager;
|
||||
|
||||
@@ -44,6 +44,7 @@ import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.internal.logging.UiEventLogger;
|
||||
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.ShellExecutor;
|
||||
import com.android.wm.shell.splitscreen.SplitScreenController;
|
||||
@@ -61,7 +62,7 @@ import java.util.Optional;
|
||||
*/
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class DragAndDropControllerTest {
|
||||
public class DragAndDropControllerTest extends ShellTestCase {
|
||||
|
||||
@Mock
|
||||
private Context mContext;
|
||||
|
||||
@@ -66,6 +66,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.internal.logging.InstanceId;
|
||||
import com.android.wm.shell.ShellTestCase;
|
||||
import com.android.wm.shell.common.DisplayLayout;
|
||||
import com.android.wm.shell.draganddrop.DragAndDropPolicy.Target;
|
||||
import com.android.wm.shell.splitscreen.SplitScreenController;
|
||||
@@ -85,7 +86,7 @@ import java.util.HashSet;
|
||||
*/
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class DragAndDropPolicyTest {
|
||||
public class DragAndDropPolicyTest extends ShellTestCase {
|
||||
|
||||
@Mock
|
||||
private Context mContext;
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.wm.shell.hidedisplaycutout;
|
||||
import static org.mockito.Mockito.reset;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
import android.testing.TestableContext;
|
||||
import android.testing.TestableLooper;
|
||||
@@ -27,6 +26,7 @@ import android.testing.TestableLooper;
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import com.android.wm.shell.ShellTestCase;
|
||||
import com.android.wm.shell.common.ShellExecutor;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -35,11 +35,10 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
@Presubmit
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
@TestableLooper.RunWithLooper
|
||||
public class HideDisplayCutoutControllerTest {
|
||||
public class HideDisplayCutoutControllerTest extends ShellTestCase {
|
||||
private TestableContext mContext = new TestableContext(
|
||||
InstrumentationRegistry.getInstrumentation().getTargetContext(), null);
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ import android.content.res.Configuration;
|
||||
import android.graphics.Insets;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Binder;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
import android.testing.TestableContext;
|
||||
import android.testing.TestableLooper;
|
||||
@@ -48,6 +47,7 @@ import android.window.WindowContainerToken;
|
||||
import androidx.test.filters.SmallTest;
|
||||
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.DisplayLayout;
|
||||
import com.android.wm.shell.common.ShellExecutor;
|
||||
@@ -61,11 +61,10 @@ import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Presubmit
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
@TestableLooper.RunWithLooper
|
||||
public class HideDisplayCutoutOrganizerTest {
|
||||
public class HideDisplayCutoutOrganizerTest extends ShellTestCase {
|
||||
private TestableContext mContext = new TestableContext(
|
||||
InstrumentationRegistry.getInstrumentation().getTargetContext(), null);
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ import android.window.WindowContainerTransaction;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.wm.shell.ShellTestCase;
|
||||
import com.android.wm.shell.common.DisplayController;
|
||||
import com.android.wm.shell.common.DisplayInsetsController;
|
||||
import com.android.wm.shell.common.ShellExecutor;
|
||||
@@ -61,7 +62,7 @@ import java.util.Optional;
|
||||
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class KidsModeTaskOrganizerTest {
|
||||
public class KidsModeTaskOrganizerTest extends ShellTestCase {
|
||||
@Mock private ITaskOrganizerController mTaskOrganizerController;
|
||||
@Mock private Context mContext;
|
||||
@Mock private Handler mHandler;
|
||||
|
||||
@@ -30,6 +30,8 @@ import android.view.WindowManager;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import com.android.wm.shell.ShellTestCase;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.mockito.Answers;
|
||||
@@ -38,7 +40,7 @@ import org.mockito.Mock;
|
||||
/**
|
||||
* Base class that does One Handed specific setup.
|
||||
*/
|
||||
public abstract class OneHandedTestCase {
|
||||
public abstract class OneHandedTestCase extends ShellTestCase {
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
protected Context mContext;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.graphics.Rect;
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.wm.shell.ShellTestCase;
|
||||
import com.android.wm.shell.util.SplitBounds;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -17,7 +18,7 @@ import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@SmallTest
|
||||
public class SplitBoundsTest {
|
||||
public class SplitBoundsTest extends ShellTestCase {
|
||||
private static final int DEVICE_WIDTH = 100;
|
||||
private static final int DEVICE_LENGTH = 200;
|
||||
private static final int DIVIDER_SIZE = 20;
|
||||
|
||||
@@ -73,6 +73,7 @@ import androidx.test.filters.SmallTest;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
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.ShellExecutor;
|
||||
import com.android.wm.shell.common.TransactionPool;
|
||||
@@ -91,7 +92,7 @@ import java.util.function.IntSupplier;
|
||||
*/
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class StartingSurfaceDrawerTests {
|
||||
public class StartingSurfaceDrawerTests extends ShellTestCase {
|
||||
@Mock
|
||||
private IBinder mBinder;
|
||||
@Mock
|
||||
|
||||
@@ -47,6 +47,7 @@ import android.window.TaskSnapshot;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.wm.shell.ShellTestCase;
|
||||
import com.android.wm.shell.TestShellExecutor;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -58,7 +59,7 @@ import org.junit.runner.RunWith;
|
||||
*/
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class TaskSnapshotWindowTest {
|
||||
public class TaskSnapshotWindowTest extends ShellTestCase {
|
||||
|
||||
private TaskSnapshotWindow mWindow;
|
||||
|
||||
|
||||
@@ -18,13 +18,13 @@ package com.android.wm.shell.tasksurfacehelper;
|
||||
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
import android.view.SurfaceControl;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.wm.shell.ShellTaskOrganizer;
|
||||
import com.android.wm.shell.ShellTestCase;
|
||||
import com.android.wm.shell.common.ShellExecutor;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -33,10 +33,9 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
@Presubmit
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
@SmallTest
|
||||
public class TaskSurfaceHelperControllerTest {
|
||||
public class TaskSurfaceHelperControllerTest extends ShellTestCase {
|
||||
private TaskSurfaceHelperController mTaskSurfaceHelperController;
|
||||
@Mock
|
||||
private ShellTaskOrganizer mMockTaskOrganizer;
|
||||
|
||||
@@ -79,6 +79,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import com.android.wm.shell.ShellTestCase;
|
||||
import com.android.wm.shell.TestShellExecutor;
|
||||
import com.android.wm.shell.common.DisplayController;
|
||||
import com.android.wm.shell.common.ShellExecutor;
|
||||
@@ -98,7 +99,7 @@ import java.util.ArrayList;
|
||||
*/
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ShellTransitionTests {
|
||||
public class ShellTransitionTests extends ShellTestCase {
|
||||
|
||||
private final WindowOrganizer mOrganizer = mock(WindowOrganizer.class);
|
||||
private final TransactionPool mTransactionPool = mock(TransactionPool.class);
|
||||
|
||||
Reference in New Issue
Block a user