Initial TaskbarUnitTestRule with example overlay controller tests.

Flag: TEST_ONLY
Bug: 230027385
Test: TaskbarOverlayControllerTest
Change-Id: I858906ece7e67677962ec8b4432bfcca5ec30283
This commit is contained in:
Brian Isganitis
2024-06-03 23:20:07 +00:00
parent d141b3094d
commit 9eaae4b6a4
5 changed files with 387 additions and 11 deletions

View File

@@ -1605,4 +1605,9 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
boolean canToggleHomeAllApps() {
return mControllers.uiController.canToggleHomeAllApps();
}
@VisibleForTesting
public TaskbarControllers getControllers() {
return mControllers;
}
}

View File

@@ -611,7 +611,8 @@ public class TaskbarManager {
}
}
private void addTaskbarRootViewToWindow() {
@VisibleForTesting
void addTaskbarRootViewToWindow() {
if (enableTaskbarNoRecreate() && !mAddedWindow && mTaskbarActivityContext != null) {
mWindowManager.addView(mTaskbarRootLayout,
mTaskbarActivityContext.getWindowLayoutParams());
@@ -619,7 +620,8 @@ public class TaskbarManager {
}
}
private void removeTaskbarRootViewFromWindow() {
@VisibleForTesting
void removeTaskbarRootViewFromWindow() {
if (enableTaskbarNoRecreate() && mAddedWindow) {
mWindowManager.removeViewImmediate(mTaskbarRootLayout);
mAddedWindow = false;

View File

@@ -133,16 +133,19 @@ public final class TaskbarOverlayController {
* <p>
* This method should be called after an exit animation finishes, if applicable.
*/
@SuppressLint("WrongConstant")
void maybeCloseWindow() {
if (mOverlayContext != null && (AbstractFloatingView.hasOpenView(mOverlayContext, TYPE_ALL)
|| mOverlayContext.getDragController().isSystemDragInProgress())) {
return;
}
if (!canCloseWindow()) return;
mProxyView.close(false);
onDestroy();
}
@SuppressLint("WrongConstant")
private boolean canCloseWindow() {
if (mOverlayContext == null) return true;
if (AbstractFloatingView.hasOpenView(mOverlayContext, TYPE_ALL)) return false;
return !mOverlayContext.getDragController().isSystemDragInProgress();
}
/** Destroys the controller and any overlay window if present. */
public void onDestroy() {
TaskStackChangeListeners.getInstance().unregisterTaskStackListener(mTaskStackListener);
@@ -212,10 +215,17 @@ public final class TaskbarOverlayController {
@Override
protected void handleClose(boolean animate) {
if (mIsOpen) {
mTaskbarContext.getDragLayer().removeView(this);
Optional.ofNullable(mOverlayContext).ifPresent(c -> closeAllOpenViews(c, animate));
}
if (!mIsOpen) return;
mTaskbarContext.getDragLayer().removeView(this);
Optional.ofNullable(mOverlayContext).ifPresent(c -> {
if (canCloseWindow()) {
onDestroy(); // Window is already ready to be destroyed.
} else {
// Close window's AFVs before destroying it. Its drag layer will attempt to
// close the proxy view again once its children are removed.
closeAllOpenViews(c, animate);
}
});
}
@Override