Merge changes I7925482b,Ia4ed8863,Ia322a8c9

* changes:
  move gestures package to sdk 26
  Update DoubleTapScreenPrefCtrl to sdk 26
  Update PickupGesturePrefCtrlTest to sdk 26
This commit is contained in:
TreeHugger Robot
2017-11-30 22:08:40 +00:00
committed by Android (Google) Code Review
15 changed files with 41 additions and 32 deletions

View File

@@ -22,6 +22,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.provider.Settings;
import android.support.v7.preference.Preference;
import android.support.annotation.VisibleForTesting;
import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.settings.R;
@@ -55,8 +56,13 @@ public class DoubleTapScreenPreferenceController extends GesturePreferenceContro
}
public static boolean isSuggestionComplete(Context context, SharedPreferences prefs) {
AmbientDisplayConfiguration ambientConfig = new AmbientDisplayConfiguration(context);
return !ambientConfig.pulseOnDoubleTapAvailable()
return isSuggestionComplete(new AmbientDisplayConfiguration(context), prefs);
}
@VisibleForTesting
static boolean isSuggestionComplete(AmbientDisplayConfiguration config,
SharedPreferences prefs) {
return !config.pulseOnDoubleTapAvailable()
|| prefs.getBoolean(DoubleTapScreenSettings.PREF_KEY_SUGGESTION_COMPLETE, false);
}

View File

@@ -24,6 +24,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.provider.Settings;
import android.support.v7.preference.Preference;
import android.support.annotation.VisibleForTesting;
import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.settings.R;
@@ -90,7 +91,7 @@ public class PickupGesturePreferenceController extends GesturePreferenceControll
@Override
public boolean canHandleClicks() {
return mAmbientConfig.pulseOnPickupCanBeModified(mUserId);
return pulseOnPickupCanBeModified();
}
@Override
@@ -102,4 +103,9 @@ public class PickupGesturePreferenceController extends GesturePreferenceControll
return new InlineSwitchPayload(SECURE_KEY, ResultPayload.SettingsSource.SECURE,
ON /* onValue */, intent, isAvailable(), ON /* defaultValue */);
}
@VisibleForTesting
boolean pulseOnPickupCanBeModified() {
return mAmbientConfig.pulseOnPickupCanBeModified(mUserId);
}
}

View File

@@ -45,7 +45,7 @@ import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(
manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION,
sdk = TestConfig.SDK_VERSION_O,
shadows = ShadowSecureSettings.class
)
public class AssistGestureSettingsPreferenceControllerTest {

View File

@@ -41,7 +41,7 @@ import org.robolectric.shadows.ShadowApplication;
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AssistGestureSettingsTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext;

View File

@@ -48,7 +48,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows = {
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O, shadows = {
SettingsShadowResources.class
})
public class DoubleTapPowerPreferenceControllerTest {

View File

@@ -32,7 +32,7 @@ import java.util.List;
import static com.google.common.truth.Truth.assertThat;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DoubleTapPowerSettingsTest {
private DoubleTapPowerSettings mSettings;

View File

@@ -17,6 +17,7 @@
package com.android.settings.gestures;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.when;
@@ -46,9 +47,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows = {
SettingsShadowResources.class
})
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DoubleTapScreenPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
@@ -139,25 +138,19 @@ public class DoubleTapScreenPreferenceControllerTest {
@Test
public void isSuggestionCompleted_ambientDisplay_falseWhenNotVisited() {
SettingsShadowResources.overrideResource(
com.android.internal.R.string.config_dozeComponent, "foo");
SettingsShadowResources.overrideResource(
com.android.internal.R.string.config_dozeDoubleTapSensorType, "bar");
when(mAmbientDisplayConfiguration.pulseOnDoubleTapAvailable()).thenReturn(true);
// No stored value in shared preferences if not visited yet.
final Context context = RuntimeEnvironment.application;
final SharedPreferences prefs = new SuggestionFeatureProviderImpl(context)
.getSharedPrefs(context);
assertThat(DoubleTapScreenPreferenceController.isSuggestionComplete(context, prefs))
.isFalse();
assertThat(DoubleTapScreenPreferenceController.isSuggestionComplete(
mAmbientDisplayConfiguration, prefs)).isFalse();
}
@Test
public void isSuggestionCompleted_ambientDisplay_trueWhenVisited() {
SettingsShadowResources.overrideResource(
com.android.internal.R.string.config_dozeComponent, "foo");
SettingsShadowResources.overrideResource(
com.android.internal.R.string.config_dozeDoubleTapSensorType, "bar");
when(mAmbientDisplayConfiguration.pulseOnDoubleTapAvailable()).thenReturn(false);
final Context context = RuntimeEnvironment.application;
final SharedPreferences prefs = new SuggestionFeatureProviderImpl(context)
.getSharedPrefs(context);
@@ -165,7 +158,7 @@ public class DoubleTapScreenPreferenceControllerTest {
prefs.edit().putBoolean(
DoubleTapScreenSettings.PREF_KEY_SUGGESTION_COMPLETE, true).commit();
assertThat(DoubleTapScreenPreferenceController.isSuggestionComplete(context, prefs))
.isTrue();
assertThat(DoubleTapScreenPreferenceController.isSuggestionComplete(
mAmbientDisplayConfiguration, prefs)).isTrue();
}
}

View File

@@ -32,7 +32,7 @@ import java.util.List;
import static com.google.common.truth.Truth.assertThat;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DoubleTapScreenSettingsTest {
private DoubleTapScreenSettings mSettings;

View File

@@ -32,7 +32,7 @@ import java.util.List;
import static com.google.common.truth.Truth.assertThat;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DoubleTwistGestureSettingsTest {
private DoubleTwistGestureSettings mSettings;

View File

@@ -51,7 +51,7 @@ import java.util.ArrayList;
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows = {
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O, shadows = {
SettingsShadowResources.class
})
public class DoubleTwistPreferenceControllerTest {

View File

@@ -48,7 +48,7 @@ import java.util.ArrayList;
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class GesturesSettingsPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)

View File

@@ -18,6 +18,8 @@ package com.android.settings.gestures;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import android.content.ContentResolver;
@@ -46,7 +48,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows = {
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O, shadows = {
SettingsShadowResources.class
})
public class PickupGesturePreferenceControllerTest {
@@ -105,14 +107,16 @@ public class PickupGesturePreferenceControllerTest {
@Test
public void testCanHandleClicks_configIsSet_shouldReturnTrue() {
when(mAmbientDisplayConfiguration.pulseOnPickupCanBeModified(anyInt())).thenReturn(true);
mController = spy(mController);
doReturn(true).when(mController).pulseOnPickupCanBeModified();
assertThat(mController.canHandleClicks()).isTrue();
}
@Test
public void testCanHandleClicks_configIsNotSet_shouldReturnFalse() {
when(mAmbientDisplayConfiguration.pulseOnPickupCanBeModified(anyInt())).thenReturn(false);
mController = spy(mController);
doReturn(false).when(mController).pulseOnPickupCanBeModified();
assertThat(mController.canHandleClicks()).isFalse();
}

View File

@@ -32,7 +32,7 @@ import java.util.List;
import static com.google.common.truth.Truth.assertThat;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class PickupGestureSettingsTest {
private PickupGestureSettings mSettings;

View File

@@ -41,7 +41,7 @@ import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SwipeToNotificationPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)

View File

@@ -37,7 +37,7 @@ import org.robolectric.shadows.ShadowApplication;
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SwipeToNotificationSettingsTest {
@Mock