Make Settings robotest work with tot Robolectric
Bug: 116278591 Test: make -j RunSettingsRoboTests Change-Id: I32cb2fcf6094675f79d2fc24702ef6298a9691e4
This commit is contained in:
@@ -82,7 +82,7 @@ public class DoubleTapPowerPreferenceControllerTest {
|
||||
@Test
|
||||
public void testIsChecked_configIsNotSet_shouldReturnTrue() {
|
||||
// Set the setting to be enabled.
|
||||
Settings.System.putInt(mContentResolver, CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, ON);
|
||||
Settings.Secure.putInt(mContentResolver, CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, ON);
|
||||
mController = new DoubleTapPowerPreferenceController(mContext, KEY_DOUBLE_TAP_POWER);
|
||||
|
||||
assertThat(mController.isChecked()).isTrue();
|
||||
@@ -91,7 +91,7 @@ public class DoubleTapPowerPreferenceControllerTest {
|
||||
@Test
|
||||
public void testIsChecked_configIsSet_shouldReturnFalse() {
|
||||
// Set the setting to be disabled.
|
||||
Settings.System.putInt(mContentResolver, CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, OFF);
|
||||
Settings.Secure.putInt(mContentResolver, CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, OFF);
|
||||
mController = new DoubleTapPowerPreferenceController(mContext, KEY_DOUBLE_TAP_POWER);
|
||||
|
||||
assertThat(mController.isChecked()).isFalse();
|
||||
|
@@ -139,7 +139,7 @@ public class DoubleTwistPreferenceControllerTest {
|
||||
public void testIsChecked_configIsSet_shouldReturnTrue() {
|
||||
// Set the setting to be enabled.
|
||||
final Context context = RuntimeEnvironment.application;
|
||||
Settings.System.putInt(context.getContentResolver(),
|
||||
Settings.Secure.putInt(context.getContentResolver(),
|
||||
Settings.Secure.CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, 1);
|
||||
mController = new DoubleTwistPreferenceController(context, KEY_DOUBLE_TWIST);
|
||||
|
||||
@@ -150,7 +150,7 @@ public class DoubleTwistPreferenceControllerTest {
|
||||
public void testIsChecked_configIsNotSet_shouldReturnFalse() {
|
||||
// Set the setting to be disabled.
|
||||
final Context context = RuntimeEnvironment.application;
|
||||
Settings.System.putInt(context.getContentResolver(),
|
||||
Settings.Secure.putInt(context.getContentResolver(),
|
||||
Settings.Secure.CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, 0);
|
||||
mController = new DoubleTwistPreferenceController(context, KEY_DOUBLE_TWIST);
|
||||
|
||||
|
@@ -100,7 +100,7 @@ public class SwipeToNotificationPreferenceControllerTest {
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
// Set the setting to be enabled.
|
||||
final Context context = RuntimeEnvironment.application;
|
||||
Settings.System.putInt(context.getContentResolver(), SYSTEM_NAVIGATION_KEYS_ENABLED, 1);
|
||||
Settings.Secure.putInt(context.getContentResolver(), SYSTEM_NAVIGATION_KEYS_ENABLED, 1);
|
||||
mController = new SwipeToNotificationPreferenceController(context, KEY_SWIPE_DOWN);
|
||||
|
||||
assertThat(mController.isChecked()).isTrue();
|
||||
@@ -112,7 +112,7 @@ public class SwipeToNotificationPreferenceControllerTest {
|
||||
when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
|
||||
// Set the setting to be disabled.
|
||||
final Context context = RuntimeEnvironment.application;
|
||||
Settings.System.putInt(context.getContentResolver(), SYSTEM_NAVIGATION_KEYS_ENABLED, 0);
|
||||
Settings.Secure.putInt(context.getContentResolver(), SYSTEM_NAVIGATION_KEYS_ENABLED, 0);
|
||||
mController = new SwipeToNotificationPreferenceController(context, KEY_SWIPE_DOWN);
|
||||
|
||||
assertThat(mController.isChecked()).isFalse();
|
||||
|
@@ -21,7 +21,9 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.ServiceInfo;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
@@ -69,7 +71,14 @@ public class SwipeUpPreferenceControllerTest {
|
||||
mContext.getString(com.android.internal.R.string.config_recentsComponentName));
|
||||
final Intent quickStepIntent = new Intent(ACTION_QUICKSTEP)
|
||||
.setPackage(recentsComponentName.getPackageName());
|
||||
mPackageManager.addResolveInfoForIntent(quickStepIntent, new ResolveInfo());
|
||||
final ResolveInfo info = new ResolveInfo();
|
||||
info.serviceInfo = new ServiceInfo();
|
||||
info.resolvePackageName = recentsComponentName.getPackageName();
|
||||
info.serviceInfo.packageName = info.resolvePackageName;
|
||||
info.serviceInfo.name = recentsComponentName.getClassName();
|
||||
info.serviceInfo.applicationInfo = new ApplicationInfo();
|
||||
info.serviceInfo.applicationInfo.flags = ApplicationInfo.FLAG_SYSTEM;
|
||||
mPackageManager.addResolveInfoForIntent(quickStepIntent, info);
|
||||
|
||||
assertThat(SwipeUpPreferenceController.isGestureAvailable(mContext)).isTrue();
|
||||
}
|
||||
@@ -121,7 +130,7 @@ public class SwipeUpPreferenceControllerTest {
|
||||
@Test
|
||||
public void isSliceableCorrectKey_returnsTrue() {
|
||||
final SwipeUpPreferenceController controller =
|
||||
new SwipeUpPreferenceController(mContext,"gesture_swipe_up");
|
||||
new SwipeUpPreferenceController(mContext, "gesture_swipe_up");
|
||||
assertThat(controller.isSliceable()).isTrue();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user