Merge "Remove the xml entry when the system language is removed" into main

This commit is contained in:
Allen Su
2024-01-03 08:29:07 +00:00
committed by Android (Google) Code Review
7 changed files with 66 additions and 18 deletions

View File

@@ -369,7 +369,7 @@ public class AppLocalePickerActivityTest {
// In the proto file, en-US's uid list contains 103, the notificationCount equals 1, and
// LastNotificationTime > 0.
NotificationInfo info = mDataManager.getNotificationInfo(EN_US);
assertThat(info.getUidCollection().contains(sUid)).isTrue();
assertThat(info.getUidCollection()).contains(sUid);
assertThat(info.getNotificationCount()).isEqualTo(1);
assertThat(info.getDismissCount()).isEqualTo(0);
assertThat(info.getLastNotificationTimeMs()).isNotEqualTo(0);
@@ -440,7 +440,7 @@ public class AppLocalePickerActivityTest {
@Test
@RequiresFlagsEnabled(Flags.FLAG_LOCALE_NOTIFICATION_ENABLED)
public void testEvaluateLocaleNotification_localeUpdateReachThreshold_uidAddedNoNotification()
public void testEvaluateLocaleNotification_localeUpdateReachThreshold_noUidNorNotification()
throws Exception {
// App with uid 106 changed its locale from System to en-US.
sUid = 106;
@@ -460,7 +460,7 @@ public class AppLocalePickerActivityTest {
// In the proto file, en-US's uid list contains 106, the notificationCount equals 2, and
// LastNotificationTime > 0.
NotificationInfo info = mDataManager.getNotificationInfo(EN_US);
assertThat(info.getUidCollection()).contains(sUid);
assertThat(info.getUidCollection().contains(sUid)).isFalse();
assertThat(info.getNotificationCount()).isEqualTo(2);
assertThat(info.getDismissCount()).isEqualTo(0);
assertThat(info.getLastNotificationTimeMs()).isEqualTo(lastNotificationTime);

View File

@@ -68,6 +68,18 @@ public class LocaleNotificationDataManagerTest {
info.getLastNotificationTimeMs());
}
@Test
public void testRemoveNotificationInfo() {
String locale = "en-US";
Set<Integer> uidSet = Set.of(101);
NotificationInfo info = new NotificationInfo(uidSet, 1, 1, 100L, 1000);
mDataManager.putNotificationInfo(locale, info);
assertThat(mDataManager.getNotificationInfo(locale)).isEqualTo(info);
mDataManager.removeNotificationInfo(locale);
assertThat(mDataManager.getNotificationInfo(locale)).isNull();
}
@Test
public void testGetNotificationMap() {
String enUS = "en-US";

View File

@@ -71,6 +71,19 @@ public class NotificationControllerTest {
assertThat(result.getNotificationId()).isEqualTo(id);
}
@Test
public void testRemoveNotificationInfo_removed() throws Exception {
String enUS = "en-US";
Set<Integer> uidSet = Set.of(100, 101);
long lastNotificationTime = Calendar.getInstance().getTimeInMillis();
int id = (int) SystemClock.uptimeMillis();
initSharedPreference(enUS, uidSet, 0, 1, lastNotificationTime, id);
mNotificationController.removeNotificationInfo(enUS);
assertThat(mDataManager.getNotificationInfo(enUS)).isNull();
}
@Test
public void testShouldTriggerNotification_inSystemLocale_returnFalse() throws Exception {
int uid = 102;