From d44df344534d8d154565d8c76990426fc0a0fceb Mon Sep 17 00:00:00 2001 From: jasonwshsu Date: Sat, 20 Jan 2024 23:36:48 +0800 Subject: [Drag To Hide] Fix test case fail Root Cause: onDetachedFromWindow_menuIsGone will fail due to menuView is visible with no content under drag to hide feature enabled Solution: Don't need to show menuView if there is no content contains Bug: 298718415 Flag: ACONFIG com.android.systemui.floating_menu_drag_to_hide DEVELOPMENT Test: atest MenuViewLayerTest Change-Id: Id5abc9965fe468bd2c2c0890bd1256009dbd9473 --- .../android/systemui/accessibility/floatingmenu/MenuViewLayer.java | 4 +++- .../systemui/accessibility/floatingmenu/MenuViewLayerTest.java | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayer.java b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayer.java index 6869bbaedcf3..97999cc19dc8 100644 --- a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayer.java +++ b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayer.java @@ -240,7 +240,9 @@ class MenuViewLayer extends FrameLayout implements mMenuView.setOnTargetFeaturesChangeListener(newTargetFeatures -> { if (Flags.floatingMenuDragToHide()) { dismissNotification(); - undo(); + if (newTargetFeatures.size() > 0) { + undo(); + } } else { if (newTargetFeatures.size() < 1) { return; diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerTest.java index 68879a54cfe4..7b8394fc759e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerTest.java @@ -187,16 +187,16 @@ public class MenuViewLayerTest extends SysuiTestCase { @Test public void onAttachedToWindow_menuIsVisible() { mMenuViewLayer.onAttachedToWindow(); - final View menuView = mMenuViewLayer.getChildAt(LayerIndex.MENU_VIEW); + final View menuView = mMenuViewLayer.getChildAt(LayerIndex.MENU_VIEW); assertThat(menuView.getVisibility()).isEqualTo(VISIBLE); } @Test - public void onAttachedToWindow_menuIsGone() { + public void onDetachedFromWindow_menuIsGone() { mMenuViewLayer.onDetachedFromWindow(); - final View menuView = mMenuViewLayer.getChildAt(LayerIndex.MENU_VIEW); + final View menuView = mMenuViewLayer.getChildAt(LayerIndex.MENU_VIEW); assertThat(menuView.getVisibility()).isEqualTo(GONE); } -- cgit v1.2.3-59-g8ed1b