diff options
| author | 2024-02-26 21:13:41 +0000 | |
|---|---|---|
| committer | 2024-02-27 18:02:43 +0000 | |
| commit | f293548fb12b6a8f1a720b4d717726eddf82df86 (patch) | |
| tree | 91eea7000c983718896a9eb966f85eb7add514aa | |
| parent | 3df1d8540eac258015f4542b726ec004a1b8df12 (diff) | |
Move TestableHeadsUpManager into separate file
Bug: 315362456
Test: BaseHeadsUpManagerTest
Flag: none
Change-Id: I1083ef273f995e813437018d02428354ed027bc5
2 files changed, 138 insertions, 115 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/BaseHeadsUpManagerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/BaseHeadsUpManagerTest.java index b8c6ec4ffc65..6456669c09b6 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/BaseHeadsUpManagerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/BaseHeadsUpManagerTest.java @@ -19,8 +19,6 @@ package com.android.systemui.statusbar.policy; import static android.app.Notification.FLAG_FSI_REQUESTED_BUT_DENIED; import static com.android.systemui.log.LogBufferHelperKt.logcatLogBuffer; -import static com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_CONTRACTED; -import static com.android.systemui.util.concurrency.MockExecutorHandlerKt.mockExecutorHandler; import static com.google.common.truth.Truth.assertThat; @@ -41,31 +39,23 @@ import android.app.ActivityManager; import android.app.Notification; import android.app.PendingIntent; import android.app.Person; -import android.content.Context; import android.content.Intent; -import android.graphics.Region; import android.os.UserHandle; import android.service.notification.StatusBarNotification; import android.testing.TestableLooper; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.test.filters.SmallTest; import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.filters.SmallTest; -import com.android.internal.logging.UiEventLogger; import com.android.internal.logging.testing.UiEventLoggerFake; import com.android.systemui.SysuiTestCase; import com.android.systemui.res.R; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; -import com.android.systemui.util.concurrency.DelayableExecutor; import com.android.systemui.util.concurrency.FakeExecutor; import com.android.systemui.util.settings.FakeGlobalSettings; -import com.android.systemui.util.settings.GlobalSettings; import com.android.systemui.util.time.FakeSystemClock; -import com.android.systemui.util.time.SystemClock; import org.junit.Rule; import org.junit.Test; @@ -83,8 +73,8 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { private static final String TEST_PACKAGE_NAME = "BaseHeadsUpManagerTest"; - private static final int TEST_TOUCH_ACCEPTANCE_TIME = 200; - private static final int TEST_A11Y_AUTO_DISMISS_TIME = 1_000; + static final int TEST_TOUCH_ACCEPTANCE_TIME = 200; + static final int TEST_A11Y_AUTO_DISMISS_TIME = 1_000; private UiEventLoggerFake mUiEventLoggerFake = new UiEventLoggerFake(); private final HeadsUpManagerLogger mLogger = spy(new HeadsUpManagerLogger(logcatLogBuffer())); @@ -110,108 +100,6 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { assertThat(TEST_STICKY_AUTO_DISMISS_TIME).isLessThan(TEST_A11Y_AUTO_DISMISS_TIME); } - private final class TestableHeadsUpManager extends BaseHeadsUpManager { - - private HeadsUpEntry mLastCreatedEntry; - - TestableHeadsUpManager(Context context, - HeadsUpManagerLogger logger, - DelayableExecutor executor, - GlobalSettings globalSettings, - SystemClock systemClock, - AccessibilityManagerWrapper accessibilityManagerWrapper, - UiEventLogger uiEventLogger) { - super(context, logger, mockExecutorHandler(executor), globalSettings, systemClock, - executor, accessibilityManagerWrapper, uiEventLogger); - - mTouchAcceptanceDelay = TEST_TOUCH_ACCEPTANCE_TIME; - mMinimumDisplayTime = TEST_MINIMUM_DISPLAY_TIME; - mAutoDismissTime = TEST_AUTO_DISMISS_TIME; - mStickyForSomeTimeAutoDismissTime = TEST_STICKY_AUTO_DISMISS_TIME; - - } - - @Override - protected HeadsUpEntry createHeadsUpEntry() { - mLastCreatedEntry = spy(super.createHeadsUpEntry()); - return mLastCreatedEntry; - } - - @Override - public int getContentFlag() { - return FLAG_CONTENT_VIEW_CONTRACTED; - } - - // The following are only implemented by HeadsUpManagerPhone. If you need them, use that. - @Override - public void addHeadsUpPhoneListener(@NonNull OnHeadsUpPhoneListenerChange listener) { - throw new UnsupportedOperationException(); - } - - @Override - public void addSwipedOutNotification(@NonNull String key) { - throw new UnsupportedOperationException(); - } - - @Override - public void extendHeadsUp() { - throw new UnsupportedOperationException(); - } - - @Nullable - @Override - public Region getTouchableRegion() { - throw new UnsupportedOperationException(); - } - - @Override - public boolean isHeadsUpGoingAway() { - throw new UnsupportedOperationException(); - } - - @Override - public void onExpandingFinished() { - throw new UnsupportedOperationException(); - } - - @Override - public boolean removeNotification(@NonNull String key, boolean releaseImmediately, - boolean animate) { - throw new UnsupportedOperationException(); - } - - @Override - public void setAnimationStateHandler(@NonNull AnimationStateHandler handler) { - throw new UnsupportedOperationException(); - } - - @Override - public void setGutsShown(@NonNull NotificationEntry entry, boolean gutsShown) { - throw new UnsupportedOperationException(); - } - - @Override - public void setHeadsUpGoingAway(boolean headsUpGoingAway) { - throw new UnsupportedOperationException(); - } - - @Override - public void setRemoteInputActive(@NonNull NotificationEntry entry, - boolean remoteInputActive) { - throw new UnsupportedOperationException(); - } - - @Override - public void setTrackingHeadsUp(boolean tracking) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean shouldSwallowClick(@NonNull String key) { - throw new UnsupportedOperationException(); - } - } - private BaseHeadsUpManager createHeadsUpManager() { return new TestableHeadsUpManager(mContext, mLogger, mExecutor, mGlobalSettings, mSystemClock, mAccessibilityMgr, mUiEventLoggerFake); diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/TestableHeadsUpManager.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/TestableHeadsUpManager.java new file mode 100644 index 000000000000..27476299cf18 --- /dev/null +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/TestableHeadsUpManager.java @@ -0,0 +1,135 @@ +/* + * Copyright (C) 2024 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.systemui.statusbar.policy; + +import static com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_CONTRACTED; +import static com.android.systemui.util.concurrency.MockExecutorHandlerKt.mockExecutorHandler; + +import static org.mockito.Mockito.spy; + +import android.content.Context; +import android.graphics.Region; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.android.internal.logging.UiEventLogger; +import com.android.systemui.statusbar.notification.collection.NotificationEntry; +import com.android.systemui.util.concurrency.DelayableExecutor; +import com.android.systemui.util.settings.GlobalSettings; +import com.android.systemui.util.time.SystemClock; + +class TestableHeadsUpManager extends BaseHeadsUpManager { + + private HeadsUpEntry mLastCreatedEntry; + + TestableHeadsUpManager(Context context, + HeadsUpManagerLogger logger, + DelayableExecutor executor, + GlobalSettings globalSettings, + SystemClock systemClock, + AccessibilityManagerWrapper accessibilityManagerWrapper, + UiEventLogger uiEventLogger) { + super(context, logger, mockExecutorHandler(executor), globalSettings, systemClock, + executor, accessibilityManagerWrapper, uiEventLogger); + + mTouchAcceptanceDelay = BaseHeadsUpManagerTest.TEST_TOUCH_ACCEPTANCE_TIME; + mMinimumDisplayTime = BaseHeadsUpManagerTest.TEST_MINIMUM_DISPLAY_TIME; + mAutoDismissTime = BaseHeadsUpManagerTest.TEST_AUTO_DISMISS_TIME; + mStickyForSomeTimeAutoDismissTime = BaseHeadsUpManagerTest.TEST_STICKY_AUTO_DISMISS_TIME; + } + + @Override + protected HeadsUpEntry createHeadsUpEntry() { + mLastCreatedEntry = spy(super.createHeadsUpEntry()); + return mLastCreatedEntry; + } + + @Override + public int getContentFlag() { + return FLAG_CONTENT_VIEW_CONTRACTED; + } + + // The following are only implemented by HeadsUpManagerPhone. If you need them, use that. + @Override + public void addHeadsUpPhoneListener(@NonNull OnHeadsUpPhoneListenerChange listener) { + throw new UnsupportedOperationException(); + } + + @Override + public void addSwipedOutNotification(@NonNull String key) { + throw new UnsupportedOperationException(); + } + + @Override + public void extendHeadsUp() { + throw new UnsupportedOperationException(); + } + + @Nullable + @Override + public Region getTouchableRegion() { + throw new UnsupportedOperationException(); + } + + @Override + public boolean isHeadsUpGoingAway() { + throw new UnsupportedOperationException(); + } + + @Override + public void onExpandingFinished() { + throw new UnsupportedOperationException(); + } + + @Override + public boolean removeNotification(@NonNull String key, boolean releaseImmediately, + boolean animate) { + throw new UnsupportedOperationException(); + } + + @Override + public void setAnimationStateHandler(@NonNull AnimationStateHandler handler) { + throw new UnsupportedOperationException(); + } + + @Override + public void setGutsShown(@NonNull NotificationEntry entry, boolean gutsShown) { + throw new UnsupportedOperationException(); + } + + @Override + public void setHeadsUpGoingAway(boolean headsUpGoingAway) { + throw new UnsupportedOperationException(); + } + + @Override + public void setRemoteInputActive(@NonNull NotificationEntry entry, + boolean remoteInputActive) { + throw new UnsupportedOperationException(); + } + + @Override + public void setTrackingHeadsUp(boolean tracking) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean shouldSwallowClick(@NonNull String key) { + throw new UnsupportedOperationException(); + } +} |