Merge "Fix refresh in Gestures, not reflecting the changes after toggling on/off one-handed mode" into sc-dev

This commit is contained in:
Jason Chang
2021-03-24 15:15:52 +00:00
committed by Android (Google) Code Review
12 changed files with 85 additions and 84 deletions

View File

@@ -51,14 +51,16 @@ public class OneHandedEnablePreferenceControllerTest {
public void setChecked_setBoolean_checkIsTrueOrFalse() {
mController.setChecked(false);
assertThat(OneHandedSettingsUtils.isOneHandedModeEnabled(mContext)).isFalse();
assertThat(OneHandedSettingsUtils.isSwipeDownNotificationEnabled(mContext)).isTrue();
mController.setChecked(true);
assertThat(OneHandedSettingsUtils.isOneHandedModeEnabled(mContext)).isTrue();
assertThat(OneHandedSettingsUtils.isSwipeDownNotificationEnabled(mContext)).isFalse();
}
@Test
public void getAvailabilityStatus_setSupportOneHandedModeProperty_shouldAvailable() {
SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "true");
SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "true");
assertThat(mController.getAvailabilityStatus())
.isEqualTo(BasePreferenceController.AVAILABLE);
@@ -66,7 +68,7 @@ public class OneHandedEnablePreferenceControllerTest {
@Test
public void getAvailabilityStatus_unsetSupportOneHandedModeProperty_shouldUnsupported() {
SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "false");
SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "false");
assertThat(mController.getAvailabilityStatus())
.isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);

View File

@@ -55,7 +55,7 @@ public class OneHandedSettingsTest {
@Test
public void isPageSearchEnabled_setSupportOneHandedModeProperty_shouldReturnTrue() {
SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "true");
SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "true");
final Object obj = ReflectionHelpers.callInstanceMethod(
OneHandedSettings.SEARCH_INDEX_DATA_PROVIDER, "isPageSearchEnabled",
@@ -66,7 +66,7 @@ public class OneHandedSettingsTest {
@Test
public void isPageSearchEnabled_unsetSupportOneHandedModeProperty_shouldReturnFalse() {
SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "false");
SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "false");
final Object obj = ReflectionHelpers.callInstanceMethod(
OneHandedSettings.SEARCH_INDEX_DATA_PROVIDER, "isPageSearchEnabled",

View File

@@ -16,10 +16,7 @@
package com.android.settings.gestures;
import static android.provider.Settings.Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
import static com.android.settings.core.BasePreferenceController.DISABLED_DEPENDENT_SETTING;
import static com.google.common.truth.Truth.assertThat;
@@ -28,6 +25,7 @@ import android.os.SystemProperties;
import android.provider.Settings;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import org.junit.Before;
import org.junit.Test;
@@ -57,43 +55,32 @@ public class SwipeBottomToNotificationPreferenceControllerTest {
public void setChecked_toggledOn_enablesSwipeBottomToNotification() {
mController.setChecked(true);
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, 0)).isEqualTo(1);
assertThat(OneHandedSettingsUtils.isSwipeDownNotificationEnabled(mContext)).isTrue();
assertThat(OneHandedSettingsUtils.isOneHandedModeEnabled(mContext)).isFalse();
}
@Test
public void setChecked_toggledOff_disablesSwipeBottomToNotification() {
mController.setChecked(false);
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, 0)).isEqualTo(0);
assertThat(OneHandedSettingsUtils.isSwipeDownNotificationEnabled(mContext)).isFalse();
}
@Test
public void getAvailabilityStatus_oneHandedUnsupported_returnsAvailable() {
SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "false");
public void getAvailabilityStatus_oneHandedUnsupported_returnsUnsupport() {
SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "false");
assertThat(mController.getAvailabilityStatus()).isEqualTo(
BasePreferenceController.UNSUPPORTED_ON_DEVICE);
}
@Test
public void getAvailabilityStatus_oneHandedSupported_returnsAvailable() {
SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "true");
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test
public void getAvailabilityStatus_oneHandedDisabled_returnsAvailable() {
SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "true");
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.ONE_HANDED_MODE_ENABLED, 0);
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test
public void getAvailabilityStatus_oneHandedEnabled_returnsDisabled() {
SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "true");
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.ONE_HANDED_MODE_ENABLED, 1);
assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_DEPENDENT_SETTING);
}
@Test
public void getSummary_gestureEnabled_returnsOnSummary() {
mController.setChecked(true);
@@ -111,8 +98,8 @@ public class SwipeBottomToNotificationPreferenceControllerTest {
}
@Test
public void getDefaultConfig_returnsOffState() {
SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "false");
public void isChecked_getDefaultConfig_returnFalse() {
SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "false");
Settings.Secure.resetToDefaults(mContext.getContentResolver(),
Settings.Secure.ONE_HANDED_MODE_ENABLED);

View File

@@ -21,7 +21,6 @@ import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import android.os.SystemProperties;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
import com.android.settings.R;
@@ -64,22 +63,21 @@ public class SwipeBottomToNotificationSettingsTest {
}
@Test
public void isPageSearchEnabled_oneHandedUnsupported_shouldReturnTrue() {
SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "false");
public void isPageSearchEnabled_oneHandedUnsupported_shouldReturnFalse() {
SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "false");
final Object obj = ReflectionHelpers.callInstanceMethod(
SwipeBottomToNotificationSettings.SEARCH_INDEX_DATA_PROVIDER, "isPageSearchEnabled",
ReflectionHelpers.ClassParameter.from(Context.class, mContext));
final boolean isEnabled = (Boolean) obj;
assertThat(isEnabled).isTrue();
assertThat(isEnabled).isFalse();
}
@Test
public void isPageSearchEnabled_oneHandedDisabled_shouldReturnTrue() {
SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "true");
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.ONE_HANDED_MODE_ENABLED, 0);
SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "true");
OneHandedSettingsUtils.setSettingsOneHandedModeEnabled(mContext, false);
final Object obj = ReflectionHelpers.callInstanceMethod(
SwipeBottomToNotificationSettings.SEARCH_INDEX_DATA_PROVIDER, "isPageSearchEnabled",
@@ -91,9 +89,8 @@ public class SwipeBottomToNotificationSettingsTest {
@Test
public void isPageSearchEnabled_oneHandedEnabled_shouldReturnFalse() {
SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "true");
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.ONE_HANDED_MODE_ENABLED, 1);
SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "true");
OneHandedSettingsUtils.setSettingsOneHandedModeEnabled(mContext, true);
final Object obj = ReflectionHelpers.callInstanceMethod(
SwipeBottomToNotificationSettings.SEARCH_INDEX_DATA_PROVIDER, "isPageSearchEnabled",