Set return value for mock(IWindow).asBinder() to prevent exception
In TestWindowManagerPolicy#addSplashScreen(), mock(IWindow) is created and it's passed to the constructor of WindowState. In the constructor, c.asBinder().linkToDeath() is called, but currently, c.asBinder() returns null, which ends up throwing an exception. This CL sets a proper return value for c.asBinder(). With this CL, all the tests in AppWindowContainerControllerTests pass in ARC. Bug: 110906840 Test: atest AppWindowContainerControllerTests Change-Id: I5cacd6635eb11f174d14c7c2a3873dc648d43527
This commit is contained in:
@@ -19,6 +19,7 @@ package com.android.server.wm;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR;
|
||||
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
@@ -159,9 +160,11 @@ class TestWindowManagerPolicy implements WindowManagerPolicy {
|
||||
final WindowManagerService wm = mWmSupplier.get();
|
||||
synchronized (wm.mWindowMap) {
|
||||
atoken = wm.mRoot.getAppWindowToken(appToken);
|
||||
IWindow iWindow = mock(IWindow.class);
|
||||
doReturn(mock(IBinder.class)).when(iWindow).asBinder();
|
||||
window = WindowTestsBase.createWindow(null, TYPE_APPLICATION_STARTING, atoken,
|
||||
"Starting window", 0 /* ownerId */, false /* internalWindows */, wm,
|
||||
mock(Session.class), mock(IWindow.class));
|
||||
mock(Session.class), iWindow);
|
||||
atoken.startingWindow = window;
|
||||
}
|
||||
if (mRunnableWhenAddingSplashScreen != null) {
|
||||
|
||||
Reference in New Issue
Block a user