Merge "Hide ZenMode.getRule() - Settings" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
a8b18f953d
@@ -130,7 +130,7 @@ public final class InterruptionFilterPreferenceControllerTest {
|
||||
verify(mBackend).updateMode(captor.capture());
|
||||
assertThat(captor.getValue().getPolicy().getPriorityCategoryAlarms())
|
||||
.isEqualTo(STATE_DISALLOW);
|
||||
assertThat(captor.getValue().getRule().getInterruptionFilter())
|
||||
assertThat(captor.getValue().getInterruptionFilter())
|
||||
.isEqualTo(INTERRUPTION_FILTER_PRIORITY);
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ public final class InterruptionFilterPreferenceControllerTest {
|
||||
verify(mBackend).updateMode(captor.capture());
|
||||
assertThat(captor.getValue().getPolicy().getPriorityCategoryAlarms())
|
||||
.isEqualTo(STATE_DISALLOW);
|
||||
assertThat(captor.getValue().getRule().getInterruptionFilter())
|
||||
assertThat(captor.getValue().getInterruptionFilter())
|
||||
.isEqualTo(INTERRUPTION_FILTER_ALL);
|
||||
}
|
||||
}
|
@@ -183,7 +183,7 @@ public final class ZenModeAppsPreferenceControllerTest {
|
||||
// NONE is not actually propagated to the backend as an interruption filter;
|
||||
// the filter is set to priority, and sounds and visual effects are disallowed.
|
||||
// See AbstractZenModePreferenceController.
|
||||
assertThat(captor.getValue().getRule().getInterruptionFilter())
|
||||
assertThat(captor.getValue().getInterruptionFilter())
|
||||
.isEqualTo(INTERRUPTION_FILTER_PRIORITY);
|
||||
|
||||
// After screen is refreshed, NONE is now checked; others are unchecked.
|
||||
@@ -217,7 +217,7 @@ public final class ZenModeAppsPreferenceControllerTest {
|
||||
ArgumentCaptor<ZenMode> captor = ArgumentCaptor.forClass(ZenMode.class);
|
||||
verify(mBackend).updateMode(captor.capture());
|
||||
// Checks the policy value for PRIORITY is propagated to the backend.
|
||||
assertThat(captor.getValue().getRule().getInterruptionFilter())
|
||||
assertThat(captor.getValue().getInterruptionFilter())
|
||||
.isEqualTo(INTERRUPTION_FILTER_PRIORITY);
|
||||
|
||||
// After screen is refreshed, PRIORITY is now checked; others are unchecked.
|
||||
|
@@ -124,7 +124,7 @@ public class ZenModeEditNameIconFragmentTest {
|
||||
verify(mBackend).updateMode(captor.capture());
|
||||
ZenMode savedMode = captor.getValue();
|
||||
assertThat(savedMode.getName()).isEqualTo("A newer name");
|
||||
assertThat(savedMode.getRule().getIconResId()).isEqualTo(
|
||||
assertThat(savedMode.getIconKey().resId()).isEqualTo(
|
||||
R.drawable.ic_zen_mode_type_theater);
|
||||
|
||||
assertThat(mActivity.isFinishing()).isTrue();
|
||||
|
@@ -34,6 +34,7 @@ import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settingslib.notification.modes.TestModeBuilder;
|
||||
import com.android.settingslib.notification.modes.ZenMode;
|
||||
import com.android.settingslib.notification.modes.ZenModeSchedules;
|
||||
import com.android.settingslib.notification.modes.ZenModesBackend;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -89,7 +90,7 @@ public class ZenModeExitAtAlarmPreferenceControllerTest {
|
||||
|
||||
// Now update state after changing exitAtAlarm
|
||||
scheduleInfo.exitAtAlarm = true;
|
||||
mode.getRule().setConditionId(ZenModeConfig.toScheduleConditionId(scheduleInfo));
|
||||
mode.setCustomModeConditionId(mContext, ZenModeConfig.toScheduleConditionId(scheduleInfo));
|
||||
|
||||
// now can just call updateState
|
||||
mPrefController.updateState(preference, mode);
|
||||
@@ -117,8 +118,8 @@ public class ZenModeExitAtAlarmPreferenceControllerTest {
|
||||
mPrefController.onPreferenceChange(preference, false);
|
||||
ArgumentCaptor<ZenMode> captor = ArgumentCaptor.forClass(ZenMode.class);
|
||||
verify(mBackend).updateMode(captor.capture());
|
||||
ZenModeConfig.ScheduleInfo newSchedule = ZenModeConfig.tryParseScheduleConditionId(
|
||||
captor.getValue().getRule().getConditionId());
|
||||
ZenModeConfig.ScheduleInfo newSchedule = ZenModeSchedules.getTimeSchedule(
|
||||
captor.getValue());
|
||||
assertThat(newSchedule.exitAtAlarm).isFalse();
|
||||
|
||||
// other properties remain the same
|
||||
|
@@ -41,6 +41,7 @@ import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settingslib.notification.modes.TestModeBuilder;
|
||||
import com.android.settingslib.notification.modes.ZenMode;
|
||||
import com.android.settingslib.notification.modes.ZenModeSchedules;
|
||||
import com.android.settingslib.notification.modes.ZenModesBackend;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -102,10 +103,10 @@ public class ZenModeSetCalendarPreferenceControllerTest {
|
||||
// apply event mode updater to existing mode
|
||||
ZenMode out = mPrefController.updateEventMode(eventInfo).apply(mode);
|
||||
|
||||
assertThat(out.getRule().getOwner()).isEqualTo(ZenModeConfig.getEventConditionProvider());
|
||||
assertThat(out.getRule().getConditionId()).isEqualTo(
|
||||
ZenModeConfig.toEventConditionId(eventInfo));
|
||||
assertThat(out.getRule().getTriggerDescription()).isEqualTo("My events");
|
||||
assertThat(ZenModeSchedules.getCalendarSchedule(out)).isEqualTo(eventInfo);
|
||||
assertThat(out.getOwner().conditionProvider()).isEqualTo(
|
||||
ZenModeConfig.getEventConditionProvider());
|
||||
assertThat(out.getTriggerDescription()).isEqualTo("My events");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -38,6 +38,7 @@ import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settingslib.notification.modes.TestModeBuilder;
|
||||
import com.android.settingslib.notification.modes.ZenMode;
|
||||
import com.android.settingslib.notification.modes.ZenModeSchedules;
|
||||
import com.android.settingslib.notification.modes.ZenModesBackend;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -92,11 +93,10 @@ public class ZenModeSetSchedulePreferenceControllerTest {
|
||||
scheduleInfo.endHour = 2;
|
||||
ZenMode out = mPrefController.updateScheduleMode(scheduleInfo).apply(mode);
|
||||
|
||||
assertThat(out.getRule().getConditionId())
|
||||
.isEqualTo(ZenModeConfig.toScheduleConditionId(scheduleInfo));
|
||||
assertThat(out.getRule().getTriggerDescription()).isNotEmpty();
|
||||
assertThat(out.getRule().getOwner()).isEqualTo(
|
||||
assertThat(ZenModeSchedules.getTimeSchedule(out)).isEqualTo(scheduleInfo);
|
||||
assertThat(out.getOwner().conditionProvider()).isEqualTo(
|
||||
ZenModeConfig.getScheduleConditionProvider());
|
||||
assertThat(out.getTriggerDescription()).isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -44,6 +44,7 @@ import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settingslib.notification.modes.TestModeBuilder;
|
||||
import com.android.settingslib.notification.modes.ZenMode;
|
||||
import com.android.settingslib.notification.modes.ZenModeSchedules;
|
||||
import com.android.settingslib.notification.modes.ZenModesBackend;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -168,9 +169,9 @@ public class ZenModeTriggerAddPreferenceControllerTest {
|
||||
verify(mBackend).updateMode(captor.capture());
|
||||
ZenMode updatedMode = captor.getValue();
|
||||
assertThat(updatedMode.getType()).isEqualTo(TYPE_SCHEDULE_TIME);
|
||||
assertThat(updatedMode.getRule().getConditionId()).isEqualTo(scheduleUri);
|
||||
assertThat(updatedMode.getRule().getTriggerDescription()).isNotEmpty();
|
||||
assertThat(updatedMode.getRule().getOwner()).isEqualTo(
|
||||
assertThat(ZenModeSchedules.getTimeSchedule(updatedMode)).isEqualTo(scheduleInfo);
|
||||
assertThat(updatedMode.getTriggerDescription()).isNotEmpty();
|
||||
assertThat(updatedMode.getOwner().conditionProvider()).isEqualTo(
|
||||
ZenModeConfig.getScheduleConditionProvider());
|
||||
}
|
||||
}
|
||||
|
@@ -161,7 +161,7 @@ public class ZenModeTriggerUpdatePreferenceControllerTest {
|
||||
assertThat(mPreference.getCheckedState()).isFalse();
|
||||
|
||||
// Now with the rule enabled
|
||||
zenMode.getRule().setEnabled(true);
|
||||
zenMode.setEnabled(true);
|
||||
mController.updateZenMode(mPreference, zenMode);
|
||||
assertThat(mPreference.getCheckedState()).isTrue();
|
||||
}
|
||||
@@ -189,7 +189,7 @@ public class ZenModeTriggerUpdatePreferenceControllerTest {
|
||||
// Verify the backend got asked to update the mode to be enabled
|
||||
ArgumentCaptor<ZenMode> captor = ArgumentCaptor.forClass(ZenMode.class);
|
||||
verify(mBackend).updateMode(captor.capture());
|
||||
assertThat(captor.getValue().getRule().isEnabled()).isTrue();
|
||||
assertThat(captor.getValue().isEnabled()).isTrue();
|
||||
assertThat(ShadowAlertDialog.getLatestAlertDialog().isShowing()).isFalse();
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ public class ZenModeTriggerUpdatePreferenceControllerTest {
|
||||
// Verify the backend got asked to update the mode to be disabled
|
||||
ArgumentCaptor<ZenMode> captor = ArgumentCaptor.forClass(ZenMode.class);
|
||||
verify(mBackend).updateMode(captor.capture());
|
||||
assertThat(captor.getValue().getRule().isEnabled()).isFalse();
|
||||
assertThat(captor.getValue().isEnabled()).isFalse();
|
||||
assertThat(ShadowAlertDialog.getLatestAlertDialog().isShowing()).isFalse();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user