Merge "Fix the test failures for the new lock screen notifications settings page" into main
This commit is contained in:
@@ -17,6 +17,10 @@
|
|||||||
package com.android.settings.notification;
|
package com.android.settings.notification;
|
||||||
|
|
||||||
import static android.provider.Settings.Secure.LOCK_SCREEN_NOTIFICATION_MINIMALISM;
|
import static android.provider.Settings.Secure.LOCK_SCREEN_NOTIFICATION_MINIMALISM;
|
||||||
|
import static android.provider.Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS;
|
||||||
|
|
||||||
|
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||||
|
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
@@ -34,6 +38,8 @@ import android.provider.Settings;
|
|||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
|
import com.android.server.notification.Flags;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -44,9 +50,15 @@ import org.mockito.MockitoAnnotations;
|
|||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS because this toggle will be replaced by the new
|
||||||
|
* settings page.
|
||||||
|
*/
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
@DisableFlags(Flags.FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS)
|
||||||
public class LockscreenNotificationMinimalismPreferenceControllerTest {
|
public class LockscreenNotificationMinimalismPreferenceControllerTest {
|
||||||
|
@Rule
|
||||||
|
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||||
@@ -56,8 +68,6 @@ public class LockscreenNotificationMinimalismPreferenceControllerTest {
|
|||||||
private Preference mPreference;
|
private Preference mPreference;
|
||||||
static final int ON = 1;
|
static final int ON = 1;
|
||||||
static final int OFF = 0;
|
static final int OFF = 0;
|
||||||
@Rule
|
|
||||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
@@ -72,17 +82,33 @@ public class LockscreenNotificationMinimalismPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@DisableFlags(com.android.server.notification.Flags.FLAG_NOTIFICATION_MINIMALISM)
|
@DisableFlags(Flags.FLAG_NOTIFICATION_MINIMALISM)
|
||||||
public void display_featureFlagOff_shouldNotDisplay() {
|
public void display_featureFlagOff_shouldNotDisplay() {
|
||||||
|
// Given: lockscreen show notifications, FLAG_NOTIFICATION_MINIMALISM is disabled
|
||||||
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_NOTIFICATIONS, ON);
|
||||||
|
|
||||||
|
// When: displayPreference
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
|
|
||||||
|
// Then: The controller is CONDITIONALLY_UNAVAILABLE, preference is not visible
|
||||||
assertThat(mPreference.isVisible()).isFalse();
|
assertThat(mPreference.isVisible()).isFalse();
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@EnableFlags(com.android.server.notification.Flags.FLAG_NOTIFICATION_MINIMALISM)
|
@EnableFlags(com.android.server.notification.Flags.FLAG_NOTIFICATION_MINIMALISM)
|
||||||
public void display_featureFlagOn_shouldDisplay() {
|
public void display_featureFlagOn_shouldDisplay() {
|
||||||
|
// Given: lockscreen show notifications, FLAG_NOTIFICATION_MINIMALISM is enabled
|
||||||
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
|
LOCK_SCREEN_SHOW_NOTIFICATIONS, ON);
|
||||||
|
|
||||||
|
// When: displayPreference
|
||||||
mController.displayPreference(mScreen);
|
mController.displayPreference(mScreen);
|
||||||
|
|
||||||
|
// Then: The controller is AVAILABLE, preference is visible
|
||||||
assertThat(mPreference.isVisible()).isTrue();
|
assertThat(mPreference.isVisible()).isTrue();
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -37,11 +37,14 @@ import android.content.Context;
|
|||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
import android.platform.test.annotations.DisableFlags;
|
||||||
|
import android.platform.test.flag.junit.SetFlagsRule;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.internal.widget.LockPatternUtils;
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
|
import com.android.server.notification.Flags;
|
||||||
import com.android.settings.testutils.FakeFeatureFactory;
|
import com.android.settings.testutils.FakeFeatureFactory;
|
||||||
import com.android.settings.testutils.shadow.ShadowRestrictedLockUtilsInternal;
|
import com.android.settings.testutils.shadow.ShadowRestrictedLockUtilsInternal;
|
||||||
import com.android.settings.testutils.shadow.ShadowUtils;
|
import com.android.settings.testutils.shadow.ShadowUtils;
|
||||||
@@ -49,6 +52,7 @@ import com.android.settingslib.RestrictedSwitchPreference;
|
|||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
@@ -59,13 +63,19 @@ import org.robolectric.annotation.Config;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS because this toggle will be replaced by the new
|
||||||
|
* settings page.
|
||||||
|
*/
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@Config(shadows = {
|
@Config(shadows = {
|
||||||
ShadowUtils.class,
|
ShadowUtils.class,
|
||||||
ShadowRestrictedLockUtilsInternal.class,
|
ShadowRestrictedLockUtilsInternal.class,
|
||||||
})
|
})
|
||||||
|
@DisableFlags(Flags.FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS)
|
||||||
public class RedactNotificationPreferenceControllerTest {
|
public class RedactNotificationPreferenceControllerTest {
|
||||||
|
@Rule
|
||||||
|
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||||
@Mock
|
@Mock
|
||||||
private DevicePolicyManager mDpm;
|
private DevicePolicyManager mDpm;
|
||||||
@Mock
|
@Mock
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ import android.provider.Settings;
|
|||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
|
import com.android.server.notification.Flags;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -47,9 +49,15 @@ import org.mockito.MockitoAnnotations;
|
|||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS because this toggle will be replaced by the new
|
||||||
|
* settings page.
|
||||||
|
*/
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
@DisableFlags(Flags.FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS)
|
||||||
public class ShowOnlyUnseenNotificationsOnLockscreenPreferenceControllerTest {
|
public class ShowOnlyUnseenNotificationsOnLockscreenPreferenceControllerTest {
|
||||||
|
@Rule
|
||||||
|
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||||
@@ -57,8 +65,6 @@ public class ShowOnlyUnseenNotificationsOnLockscreenPreferenceControllerTest {
|
|||||||
|
|
||||||
private ShowOnlyUnseenNotificationsOnLockscreenPreferenceController mController;
|
private ShowOnlyUnseenNotificationsOnLockscreenPreferenceController mController;
|
||||||
private Preference mPreference;
|
private Preference mPreference;
|
||||||
@Rule
|
|
||||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
|
|||||||
Reference in New Issue
Block a user