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:
committed by
Android (Google) Code Review
commit
cfcef072d9
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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 {
|
||||
|
@@ -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;
|
||||
|
@@ -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 {
|
||||
|
@@ -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;
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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 {
|
||||
|
@@ -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)
|
||||
|
@@ -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();
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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)
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user