2/ Migrate some common shell classes to use executors

- Remove Handler usage in some (non-feature specific) shell code
(Note: The shell main thread will still be the sysui main thread)
- Add explicit executor for display organizer

Bug: 161979899
Test: atest WMShellUnitTests
Change-Id: I9a354f742167b907c32537eb022e22c0d5bfb97a
This commit is contained in:
Winson Chung
2020-11-11 13:43:54 -08:00
parent 0a398edf5a
commit 68d5d7cdfe
30 changed files with 557 additions and 340 deletions

View File

@@ -27,6 +27,8 @@ import android.testing.TestableLooper;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.SmallTest;
import com.android.wm.shell.common.ShellExecutor;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -44,12 +46,14 @@ public class HideDisplayCutoutControllerTest {
private HideDisplayCutoutController mHideDisplayCutoutController;
@Mock
private HideDisplayCutoutOrganizer mMockDisplayAreaOrganizer;
@Mock
private ShellExecutor mMockMainExecutor;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mHideDisplayCutoutController = new HideDisplayCutoutController(
mContext, mMockDisplayAreaOrganizer);
mContext, mMockDisplayAreaOrganizer, mMockMainExecutor);
}
@Test

View File

@@ -50,6 +50,7 @@ import androidx.test.filters.SmallTest;
import com.android.internal.R;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.ShellExecutor;
import org.junit.Before;
import org.junit.Test;
@@ -72,6 +73,9 @@ public class HideDisplayCutoutOrganizerTest {
private DisplayController mMockDisplayController;
private HideDisplayCutoutOrganizer mOrganizer;
@Mock
private ShellExecutor mMockMainExecutor;
private DisplayAreaInfo mDisplayAreaInfo;
private SurfaceControl mLeash;
@@ -93,7 +97,7 @@ public class HideDisplayCutoutOrganizerTest {
when(mMockDisplayController.getDisplay(anyInt())).thenReturn(mDisplay);
HideDisplayCutoutOrganizer organizer = new HideDisplayCutoutOrganizer(
mContext, mMockDisplayController, Runnable::run);
mContext, mMockDisplayController, mMockMainExecutor);
mOrganizer = Mockito.spy(organizer);
doNothing().when(mOrganizer).unregisterOrganizer();
doNothing().when(mOrganizer).applyBoundsAndOffsets(any(), any(), any(), any());

View File

@@ -73,7 +73,7 @@ public class PipTouchHandlerTest extends ShellTestCase {
private PipUiEventLogger mPipUiEventLogger;
@Mock
private ShellExecutor mShellMainExecutor;
private ShellExecutor mMainExecutor;
private PipBoundsState mPipBoundsState;
private PipBoundsAlgorithm mPipBoundsAlgorithm;
@@ -98,7 +98,7 @@ public class PipTouchHandlerTest extends ShellTestCase {
mPipSnapAlgorithm = new PipSnapAlgorithm();
mPipTouchHandler = new PipTouchHandler(mContext, mPhonePipMenuController,
mPipBoundsAlgorithm, mPipBoundsState, mPipTaskOrganizer,
mFloatingContentCoordinator, mPipUiEventLogger, mShellMainExecutor);
mFloatingContentCoordinator, mPipUiEventLogger, mMainExecutor);
mMotionHelper = Mockito.spy(mPipTouchHandler.getMotionHelper());
mPipResizeGestureHandler = Mockito.spy(mPipTouchHandler.getPipResizeGestureHandler());
mPipTouchHandler.setPipMotionHelper(mMotionHelper);