Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +2 −1 Original line number Diff line number Diff line Loading @@ -618,7 +618,8 @@ public class BubbleController { } /** Contains information to help position things on the screen. */ BubblePositioner getPositioner() { @VisibleForTesting public BubblePositioner getPositioner() { return mBubblePositioner; } Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java +4 −2 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ import android.widget.LinearLayout; import androidx.annotation.Nullable; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.policy.ScreenDecorationsUtils; import com.android.wm.shell.R; import com.android.wm.shell.TaskView; Loading Loading @@ -418,8 +419,9 @@ public class BubbleExpandedView extends LinearLayout { mPointerView.setBackground(mCurrentPointer); } private String getBubbleKey() { return mBubble != null ? mBubble.getKey() : "null"; @VisibleForTesting public String getBubbleKey() { return mBubble != null ? mBubble.getKey() : mIsOverflow ? BubbleOverflow.KEY : null; } /** Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflow.kt +9 −6 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ class BubbleOverflow( /** Call before use and again if cleanUpExpandedState was called. */ fun initialize(controller: BubbleController) { createExpandedView() getExpandedView()?.initialize(controller, controller.stackView, true /* isOverflow */) } Loading Loading @@ -123,13 +124,15 @@ class BubbleOverflow( overflowBtn?.updateDotVisibility(true /* animate */) } override fun getExpandedView(): BubbleExpandedView? { if (expandedView == null) { fun createExpandedView(): BubbleExpandedView? { expandedView = inflater.inflate(R.layout.bubble_expanded_view, null /* root */, false /* attachToRoot */) as BubbleExpandedView expandedView?.applyThemeAttrs() updateResources() return expandedView } override fun getExpandedView(): BubbleExpandedView? { return expandedView } Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java +1 −2 Original line number Diff line number Diff line Loading @@ -787,7 +787,7 @@ public class BubbleStackView extends FrameLayout ta.recycle(); final Runnable onBubbleAnimatedOut = () -> { if (getBubbleCount() == 0 && !mBubbleData.isShowingOverflow()) { if (getBubbleCount() == 0) { mBubbleController.onAllBubblesAnimatedOut(); } }; Loading Loading @@ -1651,7 +1651,6 @@ public class BubbleStackView extends FrameLayout } else { bubble.cleanupViews(); } updatePointerPosition(false /* forIme */); updateExpandedView(); logBubbleEvent(bubble, FrameworkStatsLog.BUBBLE_UICHANGED__ACTION__DISMISSED); return; Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/BubbleOverflowTest.java 0 → 100644 +85 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.wm.shell; import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.view.WindowManager; import androidx.test.filters.SmallTest; import com.android.wm.shell.bubbles.BubbleController; import com.android.wm.shell.bubbles.BubbleOverflow; import com.android.wm.shell.bubbles.BubbleStackView; import com.android.wm.shell.bubbles.TestableBubblePositioner; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; /** * Unit tests for {@link com.android.wm.shell.bubbles.BubbleOverflow}. */ @SmallTest @RunWith(AndroidTestingRunner.class) @TestableLooper.RunWithLooper(setAsMainLooper = true) public class BubbleOverflowTest extends ShellTestCase { private TestableBubblePositioner mPositioner; private BubbleOverflow mOverflow; @Mock private BubbleController mBubbleController; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); mPositioner = new TestableBubblePositioner(mContext, mock(WindowManager.class)); when(mBubbleController.getPositioner()).thenReturn(mPositioner); when(mBubbleController.getStackView()).thenReturn(mock(BubbleStackView.class)); mOverflow = new BubbleOverflow(mContext, mPositioner); } @Test public void test_initialize() { assertThat(mOverflow.getExpandedView()).isNull(); mOverflow.initialize(mBubbleController); assertThat(mOverflow.getExpandedView()).isNotNull(); assertThat(mOverflow.getExpandedView().getBubbleKey()).isEqualTo(BubbleOverflow.KEY); } @Test public void test_cleanUpExpandedState() { mOverflow.createExpandedView(); assertThat(mOverflow.getExpandedView()).isNotNull(); mOverflow.cleanUpExpandedState(); assertThat(mOverflow.getExpandedView()).isNull(); } } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +2 −1 Original line number Diff line number Diff line Loading @@ -618,7 +618,8 @@ public class BubbleController { } /** Contains information to help position things on the screen. */ BubblePositioner getPositioner() { @VisibleForTesting public BubblePositioner getPositioner() { return mBubblePositioner; } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java +4 −2 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ import android.widget.LinearLayout; import androidx.annotation.Nullable; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.policy.ScreenDecorationsUtils; import com.android.wm.shell.R; import com.android.wm.shell.TaskView; Loading Loading @@ -418,8 +419,9 @@ public class BubbleExpandedView extends LinearLayout { mPointerView.setBackground(mCurrentPointer); } private String getBubbleKey() { return mBubble != null ? mBubble.getKey() : "null"; @VisibleForTesting public String getBubbleKey() { return mBubble != null ? mBubble.getKey() : mIsOverflow ? BubbleOverflow.KEY : null; } /** Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleOverflow.kt +9 −6 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ class BubbleOverflow( /** Call before use and again if cleanUpExpandedState was called. */ fun initialize(controller: BubbleController) { createExpandedView() getExpandedView()?.initialize(controller, controller.stackView, true /* isOverflow */) } Loading Loading @@ -123,13 +124,15 @@ class BubbleOverflow( overflowBtn?.updateDotVisibility(true /* animate */) } override fun getExpandedView(): BubbleExpandedView? { if (expandedView == null) { fun createExpandedView(): BubbleExpandedView? { expandedView = inflater.inflate(R.layout.bubble_expanded_view, null /* root */, false /* attachToRoot */) as BubbleExpandedView expandedView?.applyThemeAttrs() updateResources() return expandedView } override fun getExpandedView(): BubbleExpandedView? { return expandedView } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java +1 −2 Original line number Diff line number Diff line Loading @@ -787,7 +787,7 @@ public class BubbleStackView extends FrameLayout ta.recycle(); final Runnable onBubbleAnimatedOut = () -> { if (getBubbleCount() == 0 && !mBubbleData.isShowingOverflow()) { if (getBubbleCount() == 0) { mBubbleController.onAllBubblesAnimatedOut(); } }; Loading Loading @@ -1651,7 +1651,6 @@ public class BubbleStackView extends FrameLayout } else { bubble.cleanupViews(); } updatePointerPosition(false /* forIme */); updateExpandedView(); logBubbleEvent(bubble, FrameworkStatsLog.BUBBLE_UICHANGED__ACTION__DISMISSED); return; Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/BubbleOverflowTest.java 0 → 100644 +85 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.wm.shell; import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.view.WindowManager; import androidx.test.filters.SmallTest; import com.android.wm.shell.bubbles.BubbleController; import com.android.wm.shell.bubbles.BubbleOverflow; import com.android.wm.shell.bubbles.BubbleStackView; import com.android.wm.shell.bubbles.TestableBubblePositioner; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; /** * Unit tests for {@link com.android.wm.shell.bubbles.BubbleOverflow}. */ @SmallTest @RunWith(AndroidTestingRunner.class) @TestableLooper.RunWithLooper(setAsMainLooper = true) public class BubbleOverflowTest extends ShellTestCase { private TestableBubblePositioner mPositioner; private BubbleOverflow mOverflow; @Mock private BubbleController mBubbleController; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); mPositioner = new TestableBubblePositioner(mContext, mock(WindowManager.class)); when(mBubbleController.getPositioner()).thenReturn(mPositioner); when(mBubbleController.getStackView()).thenReturn(mock(BubbleStackView.class)); mOverflow = new BubbleOverflow(mContext, mPositioner); } @Test public void test_initialize() { assertThat(mOverflow.getExpandedView()).isNull(); mOverflow.initialize(mBubbleController); assertThat(mOverflow.getExpandedView()).isNotNull(); assertThat(mOverflow.getExpandedView().getBubbleKey()).isEqualTo(BubbleOverflow.KEY); } @Test public void test_cleanUpExpandedState() { mOverflow.createExpandedView(); assertThat(mOverflow.getExpandedView()).isNotNull(); mOverflow.cleanUpExpandedState(); assertThat(mOverflow.getExpandedView()).isNull(); } }