Merge "Updates to use flash notification settings keys in settings provider" into udc-dev am: ccb009c34f
am: 4efb1f47f9
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/21507358 Change-Id: I1d0711035c54f4a80eade62cc1d06c8f31c13d45 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -16,7 +16,8 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import static com.android.settings.accessibility.FlashNotificationsUtil.SETTING_KEY_CAMERA_FLASH_NOTIFICATION;
|
||||
import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
|
||||
import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
|
||||
@@ -81,28 +82,30 @@ public class CameraFlashNotificationPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void isChecked_setOff_assertFalse() {
|
||||
Settings.System.putInt(mContentResolver, SETTING_KEY_CAMERA_FLASH_NOTIFICATION, 0);
|
||||
Settings.System.putInt(mContentResolver, Settings.System.CAMERA_FLASH_NOTIFICATION, OFF);
|
||||
assertThat(mController.isChecked()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isChecked_setOn_assertTrue() {
|
||||
Settings.System.putInt(mContentResolver, SETTING_KEY_CAMERA_FLASH_NOTIFICATION, 1);
|
||||
Settings.System.putInt(mContentResolver, Settings.System.CAMERA_FLASH_NOTIFICATION, ON);
|
||||
assertThat(mController.isChecked()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_setTrue_assertNotZero() {
|
||||
public void setChecked_setTrue_assertNotOff() {
|
||||
mController.setChecked(true);
|
||||
assertThat(Settings.System.getInt(mContentResolver, SETTING_KEY_CAMERA_FLASH_NOTIFICATION,
|
||||
0)).isNotEqualTo(0);
|
||||
assertThat(
|
||||
Settings.System.getInt(mContentResolver, Settings.System.CAMERA_FLASH_NOTIFICATION,
|
||||
OFF)).isNotEqualTo(OFF);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_setFalse_assertNotOne() {
|
||||
public void setChecked_setFalse_assertNotOn() {
|
||||
mController.setChecked(false);
|
||||
assertThat(Settings.System.getInt(mContentResolver, SETTING_KEY_CAMERA_FLASH_NOTIFICATION,
|
||||
1)).isNotEqualTo(1);
|
||||
assertThat(
|
||||
Settings.System.getInt(mContentResolver, Settings.System.CAMERA_FLASH_NOTIFICATION,
|
||||
OFF)).isNotEqualTo(ON);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -18,8 +18,6 @@ package com.android.settings.accessibility;
|
||||
|
||||
import static com.android.settings.accessibility.FlashNotificationsUtil.ACTION_FLASH_NOTIFICATION_START_PREVIEW;
|
||||
import static com.android.settings.accessibility.FlashNotificationsUtil.EXTRA_FLASH_NOTIFICATION_PREVIEW_TYPE;
|
||||
import static com.android.settings.accessibility.FlashNotificationsUtil.SETTING_KEY_CAMERA_FLASH_NOTIFICATION;
|
||||
import static com.android.settings.accessibility.FlashNotificationsUtil.SETTING_KEY_SCREEN_FLASH_NOTIFICATION;
|
||||
import static com.android.settings.accessibility.FlashNotificationsUtil.TYPE_LONG_PREVIEW;
|
||||
import static com.android.settings.accessibility.FlashNotificationsUtil.TYPE_SHORT_PREVIEW;
|
||||
import static com.android.settings.accessibility.ShadowFlashNotificationsUtils.setFlashNotificationsState;
|
||||
@@ -48,7 +46,6 @@ import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -131,7 +128,6 @@ public class FlashNotificationsPreviewPreferenceControllerTest {
|
||||
verify(mPreference).setEnabled(eq(true));
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testHandlePreferenceTreeClick_invalidPreference() {
|
||||
mController.handlePreferenceTreeClick(mock(Preference.class));
|
||||
@@ -165,16 +161,16 @@ public class FlashNotificationsPreviewPreferenceControllerTest {
|
||||
public void onStateChanged_onResume_cameraUri_verifyRegister() {
|
||||
mController.onStateChanged(mock(LifecycleOwner.class), Lifecycle.Event.ON_RESUME);
|
||||
verify(mContentResolver).registerContentObserver(
|
||||
eq(Settings.System.getUriFor(SETTING_KEY_CAMERA_FLASH_NOTIFICATION)), anyBoolean(),
|
||||
eq(mController.mContentObserver));
|
||||
eq(Settings.System.getUriFor(Settings.System.CAMERA_FLASH_NOTIFICATION)),
|
||||
anyBoolean(), eq(mController.mContentObserver));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onStateChanged_onResume_screenUri_verifyRegister() {
|
||||
mController.onStateChanged(mock(LifecycleOwner.class), Lifecycle.Event.ON_RESUME);
|
||||
verify(mContentResolver).registerContentObserver(
|
||||
eq(Settings.System.getUriFor(SETTING_KEY_SCREEN_FLASH_NOTIFICATION)), anyBoolean(),
|
||||
eq(mController.mContentObserver));
|
||||
eq(Settings.System.getUriFor(Settings.System.SCREEN_FLASH_NOTIFICATION)),
|
||||
anyBoolean(), eq(mController.mContentObserver));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -21,8 +21,8 @@ import static android.hardware.camera2.CameraCharacteristics.LENS_FACING;
|
||||
import static android.hardware.camera2.CameraCharacteristics.LENS_FACING_BACK;
|
||||
import static android.hardware.camera2.CameraMetadata.LENS_FACING_FRONT;
|
||||
|
||||
import static com.android.settings.accessibility.FlashNotificationsUtil.SETTING_KEY_CAMERA_FLASH_NOTIFICATION;
|
||||
import static com.android.settings.accessibility.FlashNotificationsUtil.SETTING_KEY_SCREEN_FLASH_NOTIFICATION;
|
||||
import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
|
||||
import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
|
||||
import static com.android.settings.accessibility.FlashNotificationsUtil.getColorDescriptionText;
|
||||
import static com.android.settings.accessibility.FlashNotificationsUtil.getFlashNotificationsState;
|
||||
import static com.android.settings.accessibility.FlashNotificationsUtil.getScreenColor;
|
||||
@@ -156,8 +156,8 @@ public class FlashNotificationsUtilTest {
|
||||
@Test
|
||||
public void getFlashNotificationsState_torchPresent_cameraOff_screenOff_assertOff() {
|
||||
setTorchPresent();
|
||||
Settings.System.putInt(mContentResolver, SETTING_KEY_CAMERA_FLASH_NOTIFICATION, 0);
|
||||
Settings.System.putInt(mContentResolver, SETTING_KEY_SCREEN_FLASH_NOTIFICATION, 0);
|
||||
Settings.System.putInt(mContentResolver, Settings.System.CAMERA_FLASH_NOTIFICATION, OFF);
|
||||
Settings.System.putInt(mContentResolver, Settings.System.SCREEN_FLASH_NOTIFICATION, OFF);
|
||||
|
||||
assertThat(getFlashNotificationsState(mContext))
|
||||
.isEqualTo(FlashNotificationsUtil.State.OFF);
|
||||
@@ -166,8 +166,8 @@ public class FlashNotificationsUtilTest {
|
||||
@Test
|
||||
public void getFlashNotificationsState_torchNotPresent_cameraOn_screenOff_assertOff() {
|
||||
setTorchNotPresent();
|
||||
Settings.System.putInt(mContentResolver, SETTING_KEY_CAMERA_FLASH_NOTIFICATION, 1);
|
||||
Settings.System.putInt(mContentResolver, SETTING_KEY_SCREEN_FLASH_NOTIFICATION, 0);
|
||||
Settings.System.putInt(mContentResolver, Settings.System.CAMERA_FLASH_NOTIFICATION, ON);
|
||||
Settings.System.putInt(mContentResolver, Settings.System.SCREEN_FLASH_NOTIFICATION, OFF);
|
||||
|
||||
assertThat(getFlashNotificationsState(mContext))
|
||||
.isEqualTo(FlashNotificationsUtil.State.OFF);
|
||||
@@ -176,8 +176,8 @@ public class FlashNotificationsUtilTest {
|
||||
@Test
|
||||
public void getFlashNotificationsState_torchPresent_cameraOn_screenOff_assertCamera() {
|
||||
setTorchPresent();
|
||||
Settings.System.putInt(mContentResolver, SETTING_KEY_CAMERA_FLASH_NOTIFICATION, 1);
|
||||
Settings.System.putInt(mContentResolver, SETTING_KEY_SCREEN_FLASH_NOTIFICATION, 0);
|
||||
Settings.System.putInt(mContentResolver, Settings.System.CAMERA_FLASH_NOTIFICATION, ON);
|
||||
Settings.System.putInt(mContentResolver, Settings.System.SCREEN_FLASH_NOTIFICATION, OFF);
|
||||
|
||||
assertThat(getFlashNotificationsState(mContext))
|
||||
.isEqualTo(FlashNotificationsUtil.State.CAMERA);
|
||||
@@ -186,8 +186,8 @@ public class FlashNotificationsUtilTest {
|
||||
@Test
|
||||
public void getFlashNotificationsState_torchPresent_cameraOff_screenOn_assertScreen() {
|
||||
setTorchPresent();
|
||||
Settings.System.putInt(mContentResolver, SETTING_KEY_CAMERA_FLASH_NOTIFICATION, 0);
|
||||
Settings.System.putInt(mContentResolver, SETTING_KEY_SCREEN_FLASH_NOTIFICATION, 1);
|
||||
Settings.System.putInt(mContentResolver, Settings.System.CAMERA_FLASH_NOTIFICATION, OFF);
|
||||
Settings.System.putInt(mContentResolver, Settings.System.SCREEN_FLASH_NOTIFICATION, ON);
|
||||
|
||||
assertThat(getFlashNotificationsState(mContext))
|
||||
.isEqualTo(FlashNotificationsUtil.State.SCREEN);
|
||||
@@ -196,8 +196,8 @@ public class FlashNotificationsUtilTest {
|
||||
@Test
|
||||
public void testGetFlashNotificationsState_torchPresent_cameraOn_screenOn_assertCameraScreen() {
|
||||
setTorchPresent();
|
||||
Settings.System.putInt(mContentResolver, SETTING_KEY_CAMERA_FLASH_NOTIFICATION, 1);
|
||||
Settings.System.putInt(mContentResolver, SETTING_KEY_SCREEN_FLASH_NOTIFICATION, 1);
|
||||
Settings.System.putInt(mContentResolver, Settings.System.CAMERA_FLASH_NOTIFICATION, ON);
|
||||
Settings.System.putInt(mContentResolver, Settings.System.SCREEN_FLASH_NOTIFICATION, ON);
|
||||
|
||||
assertThat(getFlashNotificationsState(mContext))
|
||||
.isEqualTo(FlashNotificationsUtil.State.CAMERA_SCREEN);
|
||||
|
@@ -16,9 +16,9 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
|
||||
import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
|
||||
import static com.android.settings.accessibility.FlashNotificationsUtil.DEFAULT_SCREEN_FLASH_COLOR;
|
||||
import static com.android.settings.accessibility.FlashNotificationsUtil.SETTING_KEY_SCREEN_FLASH_NOTIFICATION;
|
||||
import static com.android.settings.accessibility.FlashNotificationsUtil.SETTING_KEY_SCREEN_FLASH_NOTIFICATION_COLOR;
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
@@ -114,48 +114,50 @@ public class ScreenFlashNotificationPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void isChecked_setOff_assertFalse() {
|
||||
Settings.System.putInt(mContentResolver, SETTING_KEY_SCREEN_FLASH_NOTIFICATION, 0);
|
||||
Settings.System.putInt(mContentResolver, Settings.System.SCREEN_FLASH_NOTIFICATION, OFF);
|
||||
assertThat(mController.isChecked()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isChecked_setOn_assertTrue() {
|
||||
Settings.System.putInt(mContentResolver, SETTING_KEY_SCREEN_FLASH_NOTIFICATION, 1);
|
||||
Settings.System.putInt(mContentResolver, Settings.System.SCREEN_FLASH_NOTIFICATION, ON);
|
||||
assertThat(mController.isChecked()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_whenTransparentColor_setTrue_assertNotTransparentColor() {
|
||||
Settings.System.putInt(mContentResolver,
|
||||
SETTING_KEY_SCREEN_FLASH_NOTIFICATION_COLOR, Color.TRANSPARENT);
|
||||
Settings.System.SCREEN_FLASH_NOTIFICATION_COLOR, Color.TRANSPARENT);
|
||||
mController.setChecked(true);
|
||||
assertThat(Settings.System.getInt(mContentResolver,
|
||||
SETTING_KEY_SCREEN_FLASH_NOTIFICATION_COLOR, 0))
|
||||
.isEqualTo(DEFAULT_SCREEN_FLASH_COLOR);
|
||||
Settings.System.SCREEN_FLASH_NOTIFICATION_COLOR, 0)).isEqualTo(
|
||||
DEFAULT_SCREEN_FLASH_COLOR);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_whenNotTransparent_setTrue_assertSameColor() {
|
||||
Settings.System.putInt(mContentResolver,
|
||||
SETTING_KEY_SCREEN_FLASH_NOTIFICATION_COLOR, 0x4D0000FF);
|
||||
Settings.System.SCREEN_FLASH_NOTIFICATION_COLOR, 0x4D0000FF);
|
||||
mController.setChecked(true);
|
||||
assertThat(Settings.System.getInt(mContentResolver,
|
||||
SETTING_KEY_SCREEN_FLASH_NOTIFICATION_COLOR, 0))
|
||||
Settings.System.SCREEN_FLASH_NOTIFICATION_COLOR, 0))
|
||||
.isEqualTo(0x4D0000FF);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_setTrue_assertOn() {
|
||||
mController.setChecked(true);
|
||||
assertThat(Settings.System.getInt(mContentResolver, SETTING_KEY_SCREEN_FLASH_NOTIFICATION,
|
||||
0)).isEqualTo(1);
|
||||
assertThat(
|
||||
Settings.System.getInt(mContentResolver, Settings.System.SCREEN_FLASH_NOTIFICATION,
|
||||
OFF)).isEqualTo(ON);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_setFalse_assertOff() {
|
||||
mController.setChecked(false);
|
||||
assertThat(Settings.System.getInt(mContentResolver, SETTING_KEY_SCREEN_FLASH_NOTIFICATION,
|
||||
1)).isEqualTo(0);
|
||||
assertThat(
|
||||
Settings.System.getInt(mContentResolver, Settings.System.SCREEN_FLASH_NOTIFICATION,
|
||||
OFF)).isEqualTo(OFF);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user