DND settings redesign
Test: robotests Change-Id: I7b980218feea28e945994c8b7f8a934df6bc11f9 Bug: 78447976
This commit is contained in:
@@ -20,9 +20,9 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.app.NotificationManager.Policy;
|
||||
import android.content.Context;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
@@ -46,54 +46,140 @@ public class ZenModeSettingsTest {
|
||||
mBuilder = new ZenModeSettings.SummaryBuilder(mContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBehaviorSettingSummary_noSoundsCanBypass() {
|
||||
NotificationManager.Policy policy = new NotificationManager.Policy(0, 0, 0);
|
||||
final String result = mBuilder.getBehaviorSettingSummary(policy,
|
||||
Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
|
||||
|
||||
String totalSilence = mContext.getString(R.string.zen_mode_no_exceptions);
|
||||
assertEquals(totalSilence, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBehaviorSettingSummary_alarmsAndMedia() {
|
||||
NotificationManager.Policy policy = new NotificationManager.Policy(
|
||||
NotificationManager.Policy.PRIORITY_CATEGORY_ALARMS
|
||||
| NotificationManager.Policy.PRIORITY_CATEGORY_MEDIA,
|
||||
0, 0);
|
||||
final String result = mBuilder.getBehaviorSettingSummary(policy,
|
||||
Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
|
||||
|
||||
String alarmsAndMedia = mContext.getString(R.string.join_two_items,
|
||||
mContext.getString(R.string.zen_mode_alarms),
|
||||
mContext.getString(R.string.zen_mode_media).toLowerCase());
|
||||
assertEquals(alarmsAndMedia, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBlockedEffectsSummary_none() {
|
||||
NotificationManager.Policy policy = new NotificationManager.Policy(0, 0, 0, 0);
|
||||
Policy policy = new Policy(0, 0, 0, 0);
|
||||
assertEquals(mContext.getString(R.string.zen_mode_restrict_notifications_summary_muted),
|
||||
mBuilder.getBlockedEffectsSummary(policy));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBlockedEffectsSummary_some() {
|
||||
NotificationManager.Policy policy = new NotificationManager.Policy(
|
||||
0, 0, 0, NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK);
|
||||
Policy policy = new Policy(0, 0, 0, NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK);
|
||||
assertEquals(mContext.getString(R.string.zen_mode_restrict_notifications_summary_custom),
|
||||
mBuilder.getBlockedEffectsSummary(policy));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBlockedEffectsSummary_all() {
|
||||
NotificationManager.Policy policy = new NotificationManager.Policy(
|
||||
0, 0, 0, 511);
|
||||
Policy policy = new Policy(0, 0, 0, 511);
|
||||
assertEquals(mContext.getString(R.string.zen_mode_restrict_notifications_summary_hidden),
|
||||
mBuilder.getBlockedEffectsSummary(policy));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMsgEventReminderSettingSummary_none() {
|
||||
Policy policy = new Policy(0, 0, 0, 0);
|
||||
assertThat(mBuilder.getMsgEventReminderSettingSummary(policy)).isEqualTo("None");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMsgEventReminderSettingSummary_single() {
|
||||
Policy policy = new Policy(
|
||||
Policy.PRIORITY_CATEGORY_ALARMS | Policy.PRIORITY_CATEGORY_EVENTS, 0 , 0 , 0);
|
||||
assertThat(mBuilder.getMsgEventReminderSettingSummary(policy)).isEqualTo("Events");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMsgEventReminderSettingSummary_someMsgs() {
|
||||
Policy policy = new Policy(Policy.PRIORITY_CATEGORY_MESSAGES, 0,
|
||||
Policy.PRIORITY_SENDERS_CONTACTS , 0);
|
||||
assertThat(mBuilder.getMsgEventReminderSettingSummary(policy)).isEqualTo("Some messages");
|
||||
|
||||
policy = new Policy(Policy.PRIORITY_CATEGORY_MESSAGES, 0,
|
||||
Policy.PRIORITY_SENDERS_STARRED , 0);
|
||||
assertThat(mBuilder.getMsgEventReminderSettingSummary(policy)).isEqualTo("Some messages");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMsgEventReminderSettingSummary_msgs() {
|
||||
Policy policy = new Policy(Policy.PRIORITY_CATEGORY_MESSAGES, 0, 0, 0);
|
||||
assertThat(mBuilder.getMsgEventReminderSettingSummary(policy)).isEqualTo("Messages");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMsgEventReminderSettingSummary_someMsgsAndOther() {
|
||||
Policy policy = new Policy(
|
||||
Policy.PRIORITY_CATEGORY_MESSAGES | Policy.PRIORITY_CATEGORY_REMINDERS,
|
||||
0, Policy.PRIORITY_SENDERS_CONTACTS , 0);
|
||||
assertThat(mBuilder.getMsgEventReminderSettingSummary(policy))
|
||||
.isEqualTo("Some messages and reminders");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMsgEventReminderSettingSummary_someMsgsAndAllOthers() {
|
||||
Policy policy = new Policy(Policy.PRIORITY_CATEGORY_EVENTS
|
||||
| Policy.PRIORITY_CATEGORY_MESSAGES | Policy.PRIORITY_CATEGORY_REMINDERS,
|
||||
0, Policy.PRIORITY_SENDERS_CONTACTS , 0);
|
||||
assertThat(mBuilder.getMsgEventReminderSettingSummary(policy))
|
||||
.isEqualTo("Some messages, events, and reminders");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMsgEventReminderSettingSummary_noMsgsAndOther() {
|
||||
Policy policy = new Policy(
|
||||
Policy.PRIORITY_CATEGORY_EVENTS | Policy.PRIORITY_CATEGORY_REMINDERS,
|
||||
0,0, 0);
|
||||
assertThat(mBuilder.getMsgEventReminderSettingSummary(policy))
|
||||
.isEqualTo("Events and reminders");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCallsSettingSummary_none() {
|
||||
Policy policy = new Policy(0, 0, 0, 0);
|
||||
assertThat(mBuilder.getCallsSettingSummary(policy)).isEqualTo("None");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCallsSettingSummary_contacts() {
|
||||
Policy policy = new Policy(Policy.PRIORITY_CATEGORY_ALARMS | Policy.PRIORITY_CATEGORY_CALLS,
|
||||
Policy.PRIORITY_SENDERS_CONTACTS, 0, 0);
|
||||
assertThat(mBuilder.getCallsSettingSummary(policy)).isEqualTo("From contacts only");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCallsSettingSummary_repeatCallers() {
|
||||
Policy policy = new Policy(Policy.PRIORITY_CATEGORY_REPEAT_CALLERS, 0, 0, 0);
|
||||
assertThat(mBuilder.getCallsSettingSummary(policy)).isEqualTo("From repeat callers only");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCallsSettingSummary_starredRepeatCallers() {
|
||||
Policy policy = new Policy(
|
||||
Policy.PRIORITY_CATEGORY_REPEAT_CALLERS | Policy.PRIORITY_CATEGORY_CALLS,
|
||||
Policy.PRIORITY_SENDERS_STARRED, 0, 0);
|
||||
assertThat(mBuilder.getCallsSettingSummary(policy))
|
||||
.isEqualTo("From starred contacts and repeat callers");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSoundSettingSummary_allOff() {
|
||||
Policy policy = new Policy(0, 0, 0, 0);
|
||||
assertThat(mBuilder.getSoundSettingSummary(policy)).isEqualTo("Muted");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSoundSettingSummary_allOn() {
|
||||
Policy policy = new Policy(Policy.PRIORITY_CATEGORY_ALARMS | Policy.PRIORITY_CATEGORY_SYSTEM
|
||||
| Policy.PRIORITY_CATEGORY_MEDIA, 0, 0, 0);
|
||||
assertThat(mBuilder.getSoundSettingSummary(policy))
|
||||
.isEqualTo("Muted, but allow alarms, media, and touch sounds");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSoundSettingSummary_allOffButOne() {
|
||||
Policy policy = new Policy(Policy.PRIORITY_CATEGORY_MEDIA, 0, 0, 0);
|
||||
assertThat(mBuilder.getSoundSettingSummary(policy)).isEqualTo("Muted, but allow media");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSoundSettingSummary_allOffButTwo() {
|
||||
Policy policy = new Policy(Policy.PRIORITY_CATEGORY_SYSTEM
|
||||
| Policy.PRIORITY_CATEGORY_MEDIA, 0, 0, 0);
|
||||
assertThat(mBuilder.getSoundSettingSummary(policy))
|
||||
.isEqualTo("Muted, but allow media and touch sounds");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void searchProvider_shouldIndexDefaultXml() {
|
||||
final List<SearchIndexableResource> sir = ZenModeSettings.SEARCH_INDEX_DATA_PROVIDER
|
||||
|
||||
Reference in New Issue
Block a user