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.content.SharedPreferences;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
|
import android.support.annotation.VisibleForTesting;
|
||||||
|
|
||||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -55,8 +56,13 @@ public class DoubleTapScreenPreferenceController extends GesturePreferenceContro
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSuggestionComplete(Context context, SharedPreferences prefs) {
|
public static boolean isSuggestionComplete(Context context, SharedPreferences prefs) {
|
||||||
AmbientDisplayConfiguration ambientConfig = new AmbientDisplayConfiguration(context);
|
return isSuggestionComplete(new AmbientDisplayConfiguration(context), prefs);
|
||||||
return !ambientConfig.pulseOnDoubleTapAvailable()
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
static boolean isSuggestionComplete(AmbientDisplayConfiguration config,
|
||||||
|
SharedPreferences prefs) {
|
||||||
|
return !config.pulseOnDoubleTapAvailable()
|
||||||
|| prefs.getBoolean(DoubleTapScreenSettings.PREF_KEY_SUGGESTION_COMPLETE, false);
|
|| prefs.getBoolean(DoubleTapScreenSettings.PREF_KEY_SUGGESTION_COMPLETE, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,6 +24,7 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
|
import android.support.annotation.VisibleForTesting;
|
||||||
|
|
||||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -90,7 +91,7 @@ public class PickupGesturePreferenceController extends GesturePreferenceControll
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canHandleClicks() {
|
public boolean canHandleClicks() {
|
||||||
return mAmbientConfig.pulseOnPickupCanBeModified(mUserId);
|
return pulseOnPickupCanBeModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -102,4 +103,9 @@ public class PickupGesturePreferenceController extends GesturePreferenceControll
|
|||||||
return new InlineSwitchPayload(SECURE_KEY, ResultPayload.SettingsSource.SECURE,
|
return new InlineSwitchPayload(SECURE_KEY, ResultPayload.SettingsSource.SECURE,
|
||||||
ON /* onValue */, intent, isAvailable(), ON /* defaultValue */);
|
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)
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
@Config(
|
@Config(
|
||||||
manifest = TestConfig.MANIFEST_PATH,
|
manifest = TestConfig.MANIFEST_PATH,
|
||||||
sdk = TestConfig.SDK_VERSION,
|
sdk = TestConfig.SDK_VERSION_O,
|
||||||
shadows = ShadowSecureSettings.class
|
shadows = ShadowSecureSettings.class
|
||||||
)
|
)
|
||||||
public class AssistGestureSettingsPreferenceControllerTest {
|
public class AssistGestureSettingsPreferenceControllerTest {
|
||||||
|
@@ -41,7 +41,7 @@ import org.robolectric.shadows.ShadowApplication;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@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 {
|
public class AssistGestureSettingsTest {
|
||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
@@ -48,7 +48,7 @@ import org.robolectric.RuntimeEnvironment;
|
|||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@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
|
SettingsShadowResources.class
|
||||||
})
|
})
|
||||||
public class DoubleTapPowerPreferenceControllerTest {
|
public class DoubleTapPowerPreferenceControllerTest {
|
||||||
|
@@ -32,7 +32,7 @@ import java.util.List;
|
|||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@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 {
|
public class DoubleTapPowerSettingsTest {
|
||||||
|
|
||||||
private DoubleTapPowerSettings mSettings;
|
private DoubleTapPowerSettings mSettings;
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
package com.android.settings.gestures;
|
package com.android.settings.gestures;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.Matchers.anyInt;
|
import static org.mockito.Matchers.anyInt;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@@ -46,9 +47,7 @@ import org.robolectric.RuntimeEnvironment;
|
|||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows = {
|
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||||
SettingsShadowResources.class
|
|
||||||
})
|
|
||||||
public class DoubleTapScreenPreferenceControllerTest {
|
public class DoubleTapScreenPreferenceControllerTest {
|
||||||
|
|
||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||||
@@ -139,25 +138,19 @@ public class DoubleTapScreenPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isSuggestionCompleted_ambientDisplay_falseWhenNotVisited() {
|
public void isSuggestionCompleted_ambientDisplay_falseWhenNotVisited() {
|
||||||
SettingsShadowResources.overrideResource(
|
when(mAmbientDisplayConfiguration.pulseOnDoubleTapAvailable()).thenReturn(true);
|
||||||
com.android.internal.R.string.config_dozeComponent, "foo");
|
|
||||||
SettingsShadowResources.overrideResource(
|
|
||||||
com.android.internal.R.string.config_dozeDoubleTapSensorType, "bar");
|
|
||||||
// No stored value in shared preferences if not visited yet.
|
// No stored value in shared preferences if not visited yet.
|
||||||
final Context context = RuntimeEnvironment.application;
|
final Context context = RuntimeEnvironment.application;
|
||||||
final SharedPreferences prefs = new SuggestionFeatureProviderImpl(context)
|
final SharedPreferences prefs = new SuggestionFeatureProviderImpl(context)
|
||||||
.getSharedPrefs(context);
|
.getSharedPrefs(context);
|
||||||
|
|
||||||
assertThat(DoubleTapScreenPreferenceController.isSuggestionComplete(context, prefs))
|
assertThat(DoubleTapScreenPreferenceController.isSuggestionComplete(
|
||||||
.isFalse();
|
mAmbientDisplayConfiguration, prefs)).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isSuggestionCompleted_ambientDisplay_trueWhenVisited() {
|
public void isSuggestionCompleted_ambientDisplay_trueWhenVisited() {
|
||||||
SettingsShadowResources.overrideResource(
|
when(mAmbientDisplayConfiguration.pulseOnDoubleTapAvailable()).thenReturn(false);
|
||||||
com.android.internal.R.string.config_dozeComponent, "foo");
|
|
||||||
SettingsShadowResources.overrideResource(
|
|
||||||
com.android.internal.R.string.config_dozeDoubleTapSensorType, "bar");
|
|
||||||
final Context context = RuntimeEnvironment.application;
|
final Context context = RuntimeEnvironment.application;
|
||||||
final SharedPreferences prefs = new SuggestionFeatureProviderImpl(context)
|
final SharedPreferences prefs = new SuggestionFeatureProviderImpl(context)
|
||||||
.getSharedPrefs(context);
|
.getSharedPrefs(context);
|
||||||
@@ -165,7 +158,7 @@ public class DoubleTapScreenPreferenceControllerTest {
|
|||||||
prefs.edit().putBoolean(
|
prefs.edit().putBoolean(
|
||||||
DoubleTapScreenSettings.PREF_KEY_SUGGESTION_COMPLETE, true).commit();
|
DoubleTapScreenSettings.PREF_KEY_SUGGESTION_COMPLETE, true).commit();
|
||||||
|
|
||||||
assertThat(DoubleTapScreenPreferenceController.isSuggestionComplete(context, prefs))
|
assertThat(DoubleTapScreenPreferenceController.isSuggestionComplete(
|
||||||
.isTrue();
|
mAmbientDisplayConfiguration, prefs)).isTrue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -32,7 +32,7 @@ import java.util.List;
|
|||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@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 {
|
public class DoubleTapScreenSettingsTest {
|
||||||
|
|
||||||
private DoubleTapScreenSettings mSettings;
|
private DoubleTapScreenSettings mSettings;
|
||||||
|
@@ -32,7 +32,7 @@ import java.util.List;
|
|||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@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 {
|
public class DoubleTwistGestureSettingsTest {
|
||||||
|
|
||||||
private DoubleTwistGestureSettings mSettings;
|
private DoubleTwistGestureSettings mSettings;
|
||||||
|
@@ -51,7 +51,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@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
|
SettingsShadowResources.class
|
||||||
})
|
})
|
||||||
public class DoubleTwistPreferenceControllerTest {
|
public class DoubleTwistPreferenceControllerTest {
|
||||||
|
@@ -48,7 +48,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@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 {
|
public class GesturesSettingsPreferenceControllerTest {
|
||||||
|
|
||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
@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 com.google.common.truth.Truth.assertThat;
|
||||||
import static org.mockito.Matchers.anyInt;
|
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 static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
@@ -46,7 +48,7 @@ import org.robolectric.RuntimeEnvironment;
|
|||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@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
|
SettingsShadowResources.class
|
||||||
})
|
})
|
||||||
public class PickupGesturePreferenceControllerTest {
|
public class PickupGesturePreferenceControllerTest {
|
||||||
@@ -105,14 +107,16 @@ public class PickupGesturePreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCanHandleClicks_configIsSet_shouldReturnTrue() {
|
public void testCanHandleClicks_configIsSet_shouldReturnTrue() {
|
||||||
when(mAmbientDisplayConfiguration.pulseOnPickupCanBeModified(anyInt())).thenReturn(true);
|
mController = spy(mController);
|
||||||
|
doReturn(true).when(mController).pulseOnPickupCanBeModified();
|
||||||
|
|
||||||
assertThat(mController.canHandleClicks()).isTrue();
|
assertThat(mController.canHandleClicks()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCanHandleClicks_configIsNotSet_shouldReturnFalse() {
|
public void testCanHandleClicks_configIsNotSet_shouldReturnFalse() {
|
||||||
when(mAmbientDisplayConfiguration.pulseOnPickupCanBeModified(anyInt())).thenReturn(false);
|
mController = spy(mController);
|
||||||
|
doReturn(false).when(mController).pulseOnPickupCanBeModified();
|
||||||
|
|
||||||
assertThat(mController.canHandleClicks()).isFalse();
|
assertThat(mController.canHandleClicks()).isFalse();
|
||||||
}
|
}
|
||||||
|
@@ -32,7 +32,7 @@ import java.util.List;
|
|||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@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 {
|
public class PickupGestureSettingsTest {
|
||||||
|
|
||||||
private PickupGestureSettings mSettings;
|
private PickupGestureSettings mSettings;
|
||||||
|
@@ -41,7 +41,7 @@ import org.robolectric.annotation.Config;
|
|||||||
import org.robolectric.shadows.ShadowApplication;
|
import org.robolectric.shadows.ShadowApplication;
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@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 {
|
public class SwipeToNotificationPreferenceControllerTest {
|
||||||
|
|
||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||||
|
@@ -37,7 +37,7 @@ import org.robolectric.shadows.ShadowApplication;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@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 {
|
public class SwipeToNotificationSettingsTest {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
|
Reference in New Issue
Block a user