Merge "Don't add the "Events" mode anymore, and delete it if disabled" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
a78f2b834c
@@ -458,7 +458,7 @@ public class ZenModeBackend {
|
||||
}
|
||||
|
||||
private static List<String> getDefaultRuleIds() {
|
||||
return ZenModeConfig.DEFAULT_RULE_IDS;
|
||||
return ZenModeConfig.getDefaultRuleIds();
|
||||
}
|
||||
|
||||
NotificationManager.Policy toNotificationPolicy(ZenPolicy policy) {
|
||||
|
@@ -23,14 +23,18 @@ import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.AutomaticZenRule;
|
||||
import android.app.Flags;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.NotificationManager.Policy;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.provider.Settings;
|
||||
import android.service.notification.ZenModeConfig;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
@@ -53,12 +57,15 @@ public class ZenModeBackendTest {
|
||||
private NotificationManager mNotificationManager;
|
||||
|
||||
private static final String GENERIC_RULE_NAME = "test";
|
||||
private static final String DEFAULT_ID_1 = ZenModeConfig.EVENTS_DEFAULT_RULE_ID;
|
||||
private static final String DEFAULT_ID_1 = ZenModeConfig.EVENTS_OBSOLETE_RULE_ID;
|
||||
private static final String DEFAULT_ID_2 = ZenModeConfig.EVERY_NIGHT_DEFAULT_RULE_ID;
|
||||
|
||||
private Context mContext;
|
||||
private ZenModeBackend mBackend;
|
||||
|
||||
@Rule
|
||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
@@ -161,6 +168,10 @@ public class ZenModeBackendTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
// With MODES_UI the Events rule is not default and is sorted differently. Most likely this
|
||||
// whole test class should be disabled since ZenModeBackend should never be used with
|
||||
// MODES_UI. However the other tests pass, so...
|
||||
@DisableFlags(Flags.FLAG_MODES_UI)
|
||||
public void updateState_checkRuleOrderingDescending_withDefaultRules() {
|
||||
final int NUM_RULES = 4;
|
||||
|
||||
@@ -168,8 +179,8 @@ public class ZenModeBackendTest {
|
||||
true);
|
||||
Arrays.sort(rules, ZenModeBackend.RULE_COMPARATOR);
|
||||
|
||||
assertEquals(rules[0].getKey(), DEFAULT_ID_1);
|
||||
assertEquals(rules[1].getKey(), DEFAULT_ID_2);
|
||||
assertEquals(DEFAULT_ID_1, rules[0].getKey());
|
||||
assertEquals(DEFAULT_ID_2, rules[1].getKey());
|
||||
// NON-DEFAULT RULES check ordering, most recent at the bottom/end
|
||||
for (int i = 0; i < NUM_RULES; i++) {
|
||||
assertEquals(GENERIC_RULE_NAME + (NUM_RULES - 1 - i), rules[i + 2].getKey());
|
||||
|
Reference in New Issue
Block a user