Merge "Fix a couple shell unit test regressions" into tm-qpr-dev am: 4cc40c7655
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20811531 Change-Id: Ica68a10832609e3bac2fab7c6a70584e2a5f56a5 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -30,10 +30,13 @@ import static org.mockito.Mockito.times;
|
|||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import static java.lang.Integer.MAX_VALUE;
|
||||||
|
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
import android.graphics.Point;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import android.test.suitebuilder.annotation.SmallTest;
|
||||||
@@ -135,12 +138,12 @@ public class PipControllerTest extends ShellTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void instantiatePipController_addInitCallback() {
|
public void instantiatePipController_addInitCallback() {
|
||||||
verify(mShellInit, times(1)).addInitCallback(any(), any());
|
verify(mShellInit, times(1)).addInitCallback(any(), eq(mPipController));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void instantiateController_registerDumpCallback() {
|
public void instantiateController_registerDumpCallback() {
|
||||||
verify(mMockShellCommandHandler, times(1)).addDumpCallback(any(), any());
|
verify(mMockShellCommandHandler, times(1)).addDumpCallback(any(), eq(mPipController));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -156,7 +159,7 @@ public class PipControllerTest extends ShellTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void instantiatePipController_registerExternalInterface() {
|
public void instantiatePipController_registerExternalInterface() {
|
||||||
verify(mShellController, times(1)).addExternalInterface(
|
verify(mShellController, times(1)).addExternalInterface(
|
||||||
eq(ShellSharedConstants.KEY_EXTRA_SHELL_PIP), any(), any());
|
eq(ShellSharedConstants.KEY_EXTRA_SHELL_PIP), any(), eq(mPipController));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -252,6 +255,10 @@ public class PipControllerTest extends ShellTestCase {
|
|||||||
final int displayId = 1;
|
final int displayId = 1;
|
||||||
final Rect bounds = new Rect(0, 0, 10, 10);
|
final Rect bounds = new Rect(0, 0, 10, 10);
|
||||||
when(mMockPipBoundsAlgorithm.getDefaultBounds()).thenReturn(bounds);
|
when(mMockPipBoundsAlgorithm.getDefaultBounds()).thenReturn(bounds);
|
||||||
|
when(mMockPipBoundsState.getBounds()).thenReturn(bounds);
|
||||||
|
when(mMockPipBoundsState.getMinSize()).thenReturn(new Point(1, 1));
|
||||||
|
when(mMockPipBoundsState.getMaxSize()).thenReturn(new Point(MAX_VALUE, MAX_VALUE));
|
||||||
|
when(mMockPipBoundsState.getBounds()).thenReturn(bounds);
|
||||||
when(mMockPipBoundsState.getDisplayId()).thenReturn(displayId);
|
when(mMockPipBoundsState.getDisplayId()).thenReturn(displayId);
|
||||||
when(mMockPipBoundsState.getDisplayLayout()).thenReturn(mMockDisplayLayout1);
|
when(mMockPipBoundsState.getDisplayLayout()).thenReturn(mMockDisplayLayout1);
|
||||||
when(mMockDisplayController.getDisplayLayout(displayId)).thenReturn(mMockDisplayLayout2);
|
when(mMockDisplayController.getDisplayLayout(displayId)).thenReturn(mMockDisplayLayout2);
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ 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.ShellTestCase;
|
||||||
|
import com.android.wm.shell.TestShellExecutor;
|
||||||
import com.android.wm.shell.common.ExternalInterfaceBinder;
|
import com.android.wm.shell.common.ExternalInterfaceBinder;
|
||||||
import com.android.wm.shell.common.ShellExecutor;
|
import com.android.wm.shell.common.ShellExecutor;
|
||||||
|
|
||||||
@@ -61,10 +62,9 @@ public class ShellControllerTest extends ShellTestCase {
|
|||||||
@Mock
|
@Mock
|
||||||
private ShellCommandHandler mShellCommandHandler;
|
private ShellCommandHandler mShellCommandHandler;
|
||||||
@Mock
|
@Mock
|
||||||
private ShellExecutor mExecutor;
|
|
||||||
@Mock
|
|
||||||
private Context mTestUserContext;
|
private Context mTestUserContext;
|
||||||
|
|
||||||
|
private TestShellExecutor mExecutor;
|
||||||
private ShellController mController;
|
private ShellController mController;
|
||||||
private TestConfigurationChangeListener mConfigChangeListener;
|
private TestConfigurationChangeListener mConfigChangeListener;
|
||||||
private TestKeyguardChangeListener mKeyguardChangeListener;
|
private TestKeyguardChangeListener mKeyguardChangeListener;
|
||||||
@@ -77,6 +77,7 @@ public class ShellControllerTest extends ShellTestCase {
|
|||||||
mKeyguardChangeListener = new TestKeyguardChangeListener();
|
mKeyguardChangeListener = new TestKeyguardChangeListener();
|
||||||
mConfigChangeListener = new TestConfigurationChangeListener();
|
mConfigChangeListener = new TestConfigurationChangeListener();
|
||||||
mUserChangeListener = new TestUserChangeListener();
|
mUserChangeListener = new TestUserChangeListener();
|
||||||
|
mExecutor = new TestShellExecutor();
|
||||||
mController = new ShellController(mShellInit, mShellCommandHandler, mExecutor);
|
mController = new ShellController(mShellInit, mShellCommandHandler, mExecutor);
|
||||||
mController.onConfigurationChanged(getConfigurationCopy());
|
mController.onConfigurationChanged(getConfigurationCopy());
|
||||||
}
|
}
|
||||||
@@ -104,6 +105,7 @@ public class ShellControllerTest extends ShellTestCase {
|
|||||||
|
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
mController.asShell().createExternalInterfaces(b);
|
mController.asShell().createExternalInterfaces(b);
|
||||||
|
mExecutor.flushAll();
|
||||||
assertTrue(b.getIBinder(EXTRA_TEST_BINDER) == callback);
|
assertTrue(b.getIBinder(EXTRA_TEST_BINDER) == callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -936,7 +936,7 @@ public class ShellTransitionTests extends ShellTestCase {
|
|||||||
TransitionInfoBuilder addChange(@WindowManager.TransitionType int mode,
|
TransitionInfoBuilder addChange(@WindowManager.TransitionType int mode,
|
||||||
RunningTaskInfo taskInfo) {
|
RunningTaskInfo taskInfo) {
|
||||||
final TransitionInfo.Change change =
|
final TransitionInfo.Change change =
|
||||||
new TransitionInfo.Change(null /* token */, null /* leash */);
|
new TransitionInfo.Change(null /* token */, createMockSurface(true));
|
||||||
change.setMode(mode);
|
change.setMode(mode);
|
||||||
change.setTaskInfo(taskInfo);
|
change.setTaskInfo(taskInfo);
|
||||||
mInfo.addChange(change);
|
mInfo.addChange(change);
|
||||||
@@ -961,7 +961,7 @@ public class ShellTransitionTests extends ShellTestCase {
|
|||||||
final TransitionInfo.Change mChange;
|
final TransitionInfo.Change mChange;
|
||||||
|
|
||||||
ChangeBuilder(@WindowManager.TransitionType int mode) {
|
ChangeBuilder(@WindowManager.TransitionType int mode) {
|
||||||
mChange = new TransitionInfo.Change(null /* token */, null /* leash */);
|
mChange = new TransitionInfo.Change(null /* token */, createMockSurface(true));
|
||||||
mChange.setMode(mode);
|
mChange.setMode(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -205,6 +205,7 @@ public class DesktopModeWindowDecorViewModelTests extends ShellTestCase {
|
|||||||
"testEventReceiversOnMultipleDisplays", /*width=*/ 400, /*height=*/ 400,
|
"testEventReceiversOnMultipleDisplays", /*width=*/ 400, /*height=*/ 400,
|
||||||
/*densityDpi=*/ 320, surfaceView.getHolder().getSurface(),
|
/*densityDpi=*/ 320, surfaceView.getHolder().getSurface(),
|
||||||
DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY);
|
DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY);
|
||||||
|
try {
|
||||||
int secondaryDisplayId = secondaryDisplay.getDisplay().getDisplayId();
|
int secondaryDisplayId = secondaryDisplay.getDisplay().getDisplayId();
|
||||||
|
|
||||||
final int taskId = 1;
|
final int taskId = 1;
|
||||||
@@ -227,6 +228,9 @@ public class DesktopModeWindowDecorViewModelTests extends ShellTestCase {
|
|||||||
startT, finishT);
|
startT, finishT);
|
||||||
mDesktopModeWindowDecorViewModel.destroyWindowDecoration(thirdTaskInfo);
|
mDesktopModeWindowDecorViewModel.destroyWindowDecoration(thirdTaskInfo);
|
||||||
mDesktopModeWindowDecorViewModel.destroyWindowDecoration(taskInfo);
|
mDesktopModeWindowDecorViewModel.destroyWindowDecoration(taskInfo);
|
||||||
|
} finally {
|
||||||
|
secondaryDisplay.release();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
verify(mMockInputMonitorFactory, times(2)).create(any(), any());
|
verify(mMockInputMonitorFactory, times(2)).create(any(), any());
|
||||||
verify(mInputMonitor, times(1)).dispose();
|
verify(mInputMonitor, times(1)).dispose();
|
||||||
@@ -239,7 +243,7 @@ public class DesktopModeWindowDecorViewModelTests extends ShellTestCase {
|
|||||||
r.run();
|
r.run();
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
});
|
});
|
||||||
latch.await(20, TimeUnit.MILLISECONDS);
|
latch.await(1, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ActivityManager.RunningTaskInfo createTaskInfo(int taskId,
|
private static ActivityManager.RunningTaskInfo createTaskInfo(int taskId,
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import android.view.SurfaceControlViewHost;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewRootImpl;
|
import android.view.ViewRootImpl;
|
||||||
import android.view.WindowManager.LayoutParams;
|
import android.view.WindowManager.LayoutParams;
|
||||||
|
import android.window.TaskConstants;
|
||||||
import android.window.WindowContainerTransaction;
|
import android.window.WindowContainerTransaction;
|
||||||
|
|
||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
@@ -232,7 +233,8 @@ public class WindowDecorationTests extends ShellTestCase {
|
|||||||
verify(mMockSurfaceControlStartT)
|
verify(mMockSurfaceControlStartT)
|
||||||
.setColor(taskBackgroundSurface, new float[] {1.f, 1.f, 0.f});
|
.setColor(taskBackgroundSurface, new float[] {1.f, 1.f, 0.f});
|
||||||
verify(mMockSurfaceControlStartT).setShadowRadius(taskBackgroundSurface, 10);
|
verify(mMockSurfaceControlStartT).setShadowRadius(taskBackgroundSurface, 10);
|
||||||
verify(mMockSurfaceControlStartT).setLayer(taskBackgroundSurface, -1);
|
verify(mMockSurfaceControlStartT).setLayer(taskBackgroundSurface,
|
||||||
|
TaskConstants.TASK_CHILD_LAYER_TASK_BACKGROUND);
|
||||||
verify(mMockSurfaceControlStartT).show(taskBackgroundSurface);
|
verify(mMockSurfaceControlStartT).show(taskBackgroundSurface);
|
||||||
|
|
||||||
verify(captionContainerSurfaceBuilder).setParent(decorContainerSurface);
|
verify(captionContainerSurfaceBuilder).setParent(decorContainerSurface);
|
||||||
|
|||||||
Reference in New Issue
Block a user