Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/NotificationGroupingUtilTest.kt 0 → 100644 +63 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 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 import android.platform.test.flag.junit.FlagsParameterization import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.statusbar.notification.row.NotificationTestHelper import com.android.systemui.statusbar.notification.shared.NotificationBundleUi import com.google.common.truth.Truth.assertThat import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import platform.test.runner.parameterized.ParameterizedAndroidJunit4 import platform.test.runner.parameterized.Parameters @SmallTest @RunWith(ParameterizedAndroidJunit4::class) class NotificationGroupingUtilTest(flags: FlagsParameterization) : SysuiTestCase() { private lateinit var underTest: NotificationGroupingUtil private lateinit var testHelper: NotificationTestHelper companion object { @JvmStatic @Parameters(name = "{0}") fun getParams(): List<FlagsParameterization> { return FlagsParameterization.allCombinationsOf(NotificationBundleUi.FLAG_NAME) } } init { mSetFlagsRule.setFlagsParameterization(flags) } @Before fun setup() { testHelper = NotificationTestHelper(mContext, mDependency) } @Test fun showsTime() { val row = testHelper.createRow() underTest = NotificationGroupingUtil(row) assertThat(underTest.showsTime(row)).isTrue() } } No newline at end of file packages/SystemUI/src/com/android/systemui/statusbar/NotificationGroupingUtil.java +16 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.app.Flags; import android.app.Notification; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; import android.service.notification.StatusBarNotification; import android.text.TextUtils; import android.util.DisplayMetrics; import android.util.TypedValue; Loading @@ -31,6 +32,8 @@ import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.VisibleForTesting; import com.android.internal.R; import com.android.internal.widget.CachingIconView; import com.android.internal.widget.ConversationLayout; Loading @@ -39,6 +42,7 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow import com.android.systemui.statusbar.notification.row.NotificationContentView; import com.android.systemui.statusbar.notification.row.shared.AsyncGroupHeaderViewInflation; import com.android.systemui.statusbar.notification.row.wrapper.NotificationViewWrapper; import com.android.systemui.statusbar.notification.shared.NotificationBundleUi; import java.util.ArrayList; import java.util.HashSet; Loading Loading @@ -214,7 +218,7 @@ public class NotificationGroupingUtil { } // in case no view is visible we make sure the time is visible int timeVisibility = !hasVisibleText || row.getEntry().getSbn().getNotification().showsTime() || showsTime(row) ? View.VISIBLE : View.GONE; time.setVisibility(timeVisibility); View left = null; Loading Loading @@ -243,6 +247,17 @@ public class NotificationGroupingUtil { } } @VisibleForTesting boolean showsTime(ExpandableNotificationRow row) { StatusBarNotification sbn; if (NotificationBundleUi.isEnabled()) { sbn = row.getEntryAdapter() != null ? row.getEntryAdapter().getSbn() : null; } else { sbn = row.getEntry().getSbn(); } return (sbn != null && sbn.getNotification().showsTime()); } /** * Reset the modifications to this row for removing it from the group. */ Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/NotificationGroupingUtilTest.kt 0 → 100644 +63 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 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 import android.platform.test.flag.junit.FlagsParameterization import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.statusbar.notification.row.NotificationTestHelper import com.android.systemui.statusbar.notification.shared.NotificationBundleUi import com.google.common.truth.Truth.assertThat import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import platform.test.runner.parameterized.ParameterizedAndroidJunit4 import platform.test.runner.parameterized.Parameters @SmallTest @RunWith(ParameterizedAndroidJunit4::class) class NotificationGroupingUtilTest(flags: FlagsParameterization) : SysuiTestCase() { private lateinit var underTest: NotificationGroupingUtil private lateinit var testHelper: NotificationTestHelper companion object { @JvmStatic @Parameters(name = "{0}") fun getParams(): List<FlagsParameterization> { return FlagsParameterization.allCombinationsOf(NotificationBundleUi.FLAG_NAME) } } init { mSetFlagsRule.setFlagsParameterization(flags) } @Before fun setup() { testHelper = NotificationTestHelper(mContext, mDependency) } @Test fun showsTime() { val row = testHelper.createRow() underTest = NotificationGroupingUtil(row) assertThat(underTest.showsTime(row)).isTrue() } } No newline at end of file
packages/SystemUI/src/com/android/systemui/statusbar/NotificationGroupingUtil.java +16 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.app.Flags; import android.app.Notification; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; import android.service.notification.StatusBarNotification; import android.text.TextUtils; import android.util.DisplayMetrics; import android.util.TypedValue; Loading @@ -31,6 +32,8 @@ import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.VisibleForTesting; import com.android.internal.R; import com.android.internal.widget.CachingIconView; import com.android.internal.widget.ConversationLayout; Loading @@ -39,6 +42,7 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow import com.android.systemui.statusbar.notification.row.NotificationContentView; import com.android.systemui.statusbar.notification.row.shared.AsyncGroupHeaderViewInflation; import com.android.systemui.statusbar.notification.row.wrapper.NotificationViewWrapper; import com.android.systemui.statusbar.notification.shared.NotificationBundleUi; import java.util.ArrayList; import java.util.HashSet; Loading Loading @@ -214,7 +218,7 @@ public class NotificationGroupingUtil { } // in case no view is visible we make sure the time is visible int timeVisibility = !hasVisibleText || row.getEntry().getSbn().getNotification().showsTime() || showsTime(row) ? View.VISIBLE : View.GONE; time.setVisibility(timeVisibility); View left = null; Loading Loading @@ -243,6 +247,17 @@ public class NotificationGroupingUtil { } } @VisibleForTesting boolean showsTime(ExpandableNotificationRow row) { StatusBarNotification sbn; if (NotificationBundleUi.isEnabled()) { sbn = row.getEntryAdapter() != null ? row.getEntryAdapter().getSbn() : null; } else { sbn = row.getEntry().getSbn(); } return (sbn != null && sbn.getNotification().showsTime()); } /** * Reset the modifications to this row for removing it from the group. */ Loading