Revert "Settings for skip and silence gestures"
This reverts commit d5428a5cd4
.
Test: manual, builds
Reason for revert: moving to SettingsGoogle
Change-Id: Iad954e22c9484c2bc059b52e5f17a244be461394
This commit is contained in:
@@ -10541,12 +10541,6 @@
|
|||||||
<!-- String for talkback on the account avatar of the search bar. [CHAR LIMIT=NONE] -->
|
<!-- String for talkback on the account avatar of the search bar. [CHAR LIMIT=NONE] -->
|
||||||
<string name="search_bar_account_avatar_content_description"></string>
|
<string name="search_bar_account_avatar_content_description"></string>
|
||||||
|
|
||||||
<!-- Preference title text for skip media gesture [CHAR LIMIT=60]-->
|
|
||||||
<string name="gesture_skip_title">Skip gesture</string>
|
|
||||||
|
|
||||||
<!-- Preference title text for silence gesture [CHAR LIMIT=60]-->
|
|
||||||
<string name="gesture_silence_title">Silence alerts gesture</string>
|
|
||||||
|
|
||||||
<!-- Text to display when no app used permission. [CHAR LIMIT=NONE] -->
|
<!-- Text to display when no app used permission. [CHAR LIMIT=NONE] -->
|
||||||
<string name="permission_bar_chart_empty_text">0 apps used permissions</string>
|
<string name="permission_bar_chart_empty_text">0 apps used permissions</string>
|
||||||
|
|
||||||
|
@@ -27,18 +27,6 @@
|
|||||||
android:fragment="com.android.settings.gestures.AssistGestureSettings"
|
android:fragment="com.android.settings.gestures.AssistGestureSettings"
|
||||||
settings:controller="com.android.settings.gestures.AssistGestureSettingsPreferenceController" />
|
settings:controller="com.android.settings.gestures.AssistGestureSettingsPreferenceController" />
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:key="gesture_skip_summary"
|
|
||||||
android:title="@string/gesture_skip_title"
|
|
||||||
android:fragment="com.android.settings.gestures.SkipGestureSettings"
|
|
||||||
settings:controller="com.android.settings.gestures.SkipGesturePreferenceController" />
|
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:key="gesture_silence_summary"
|
|
||||||
android:title="@string/gesture_silence_title"
|
|
||||||
android:fragment="com.android.settings.gestures.SilenceGestureSettings"
|
|
||||||
settings:controller="com.android.settings.gestures.SilenceGesturePreferenceController" />
|
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="gesture_wake_screen_input_summary"
|
android:key="gesture_wake_screen_input_summary"
|
||||||
android:title="@string/ambient_display_wake_screen_title"
|
android:title="@string/ambient_display_wake_screen_title"
|
||||||
|
@@ -1,26 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Copyright (C) 2019 The Android Open Source Project
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
-->
|
|
||||||
<PreferenceScreen
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:key="silence_gesture"
|
|
||||||
android:title="@string/gesture_silence_title">
|
|
||||||
|
|
||||||
<com.android.settings.widget.VideoPreference
|
|
||||||
android:key="gesture_silence_video"
|
|
||||||
app:animation="@raw/gesture_silence"
|
|
||||||
app:preview="@drawable/gesture_silence"/>
|
|
||||||
</PreferenceScreen>
|
|
@@ -1,26 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Copyright (C) 2019 The Android Open Source Project
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
-->
|
|
||||||
<PreferenceScreen
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:key="skip_gesture"
|
|
||||||
android:title="@string/gesture_skip_title">
|
|
||||||
|
|
||||||
<com.android.settings.widget.VideoPreference
|
|
||||||
android:key="gesture_skip_video"
|
|
||||||
app:animation="@raw/gesture_skip"
|
|
||||||
app:preview="@drawable/gesture_skip"/>
|
|
||||||
</PreferenceScreen>
|
|
@@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2019 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.settings.gestures;
|
|
||||||
|
|
||||||
import static android.provider.Settings.Secure.SILENCE_GESTURE;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.provider.Settings;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
public class SilenceGesturePreferenceController extends GesturePreferenceController {
|
|
||||||
|
|
||||||
private static final int ON = 1;
|
|
||||||
private static final int OFF = 0;
|
|
||||||
|
|
||||||
private static final String PREF_KEY_VIDEO = "gesture_silence_video";
|
|
||||||
|
|
||||||
public SilenceGesturePreferenceController(Context context, String key) {
|
|
||||||
super(context, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAvailabilityStatus() {
|
|
||||||
return mContext.getResources()
|
|
||||||
.getBoolean(com.android.internal.R.bool.config_silenceSensorAvailable)
|
|
||||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSliceable() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getVideoPrefKey() {
|
|
||||||
return PREF_KEY_VIDEO;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isChecked() {
|
|
||||||
return Settings.Secure.getInt(mContext.getContentResolver(), SILENCE_GESTURE, ON) == ON;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setChecked(boolean isChecked) {
|
|
||||||
return Settings.Secure.putInt(mContext.getContentResolver(), SILENCE_GESTURE,
|
|
||||||
isChecked ? ON : OFF);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2019 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.settings.gestures;
|
|
||||||
|
|
||||||
import android.app.settings.SettingsEnums;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.provider.SearchIndexableResource;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
|
||||||
import com.android.settingslib.search.SearchIndexable;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@SearchIndexable
|
|
||||||
public class SilenceGestureSettings extends DashboardFragment {
|
|
||||||
|
|
||||||
private static final String TAG = "SilenceGestureSettings";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMetricsCategory() {
|
|
||||||
return SettingsEnums.SETTINGS_GESTURE_SILENCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getLogTag() {
|
|
||||||
return TAG;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getPreferenceScreenResId() {
|
|
||||||
return R.xml.silence_gesture_settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
|
||||||
new BaseSearchIndexProvider() {
|
|
||||||
@Override
|
|
||||||
public List<SearchIndexableResource> getXmlResourcesToIndex(
|
|
||||||
Context context, boolean enabled) {
|
|
||||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
|
||||||
sir.xmlResId = R.xml.silence_gesture_settings;
|
|
||||||
return Arrays.asList(sir);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
@@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2019 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.settings.gestures;
|
|
||||||
|
|
||||||
import static android.provider.Settings.Secure.SKIP_GESTURE;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.provider.Settings;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
public class SkipGesturePreferenceController extends GesturePreferenceController {
|
|
||||||
|
|
||||||
private static final int ON = 1;
|
|
||||||
private static final int OFF = 0;
|
|
||||||
|
|
||||||
private static final String PREF_KEY_VIDEO = "gesture_silence_video";
|
|
||||||
|
|
||||||
public SkipGesturePreferenceController(Context context, String key) {
|
|
||||||
super(context, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAvailabilityStatus() {
|
|
||||||
return mContext.getResources()
|
|
||||||
.getBoolean(com.android.internal.R.bool.config_skipSensorAvailable) ? AVAILABLE
|
|
||||||
: UNSUPPORTED_ON_DEVICE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSliceable() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getVideoPrefKey() {
|
|
||||||
return PREF_KEY_VIDEO;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isChecked() {
|
|
||||||
return Settings.Secure.getInt(mContext.getContentResolver(), SKIP_GESTURE, ON) == ON;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setChecked(boolean isChecked) {
|
|
||||||
return Settings.Secure.putInt(mContext.getContentResolver(), SKIP_GESTURE,
|
|
||||||
isChecked ? ON : OFF);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2019 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.settings.gestures;
|
|
||||||
|
|
||||||
import android.app.settings.SettingsEnums;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.provider.SearchIndexableResource;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
|
||||||
import com.android.settingslib.search.SearchIndexable;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@SearchIndexable
|
|
||||||
public class SkipGestureSettings extends DashboardFragment {
|
|
||||||
|
|
||||||
private static final String TAG = "SkipGestureSettings";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMetricsCategory() {
|
|
||||||
return SettingsEnums.SETTINGS_GESTURE_SKIP;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getLogTag() {
|
|
||||||
return TAG;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getPreferenceScreenResId() {
|
|
||||||
return R.xml.skip_gesture_settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
|
||||||
new BaseSearchIndexProvider() {
|
|
||||||
@Override
|
|
||||||
public List<SearchIndexableResource> getXmlResourcesToIndex(
|
|
||||||
Context context, boolean enabled) {
|
|
||||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
|
||||||
sir.xmlResId = R.xml.skip_gesture_settings;
|
|
||||||
return Arrays.asList(sir);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@@ -1,94 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2019 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.settings.gestures;
|
|
||||||
|
|
||||||
import static android.provider.Settings.Secure.SILENCE_GESTURE;
|
|
||||||
|
|
||||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
|
||||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.provider.Settings;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.mockito.Answers;
|
|
||||||
import org.mockito.Mock;
|
|
||||||
import org.mockito.MockitoAnnotations;
|
|
||||||
import org.robolectric.RobolectricTestRunner;
|
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
|
||||||
public class SilenceGesturePreferenceControllerTest {
|
|
||||||
|
|
||||||
private static final String KEY_SILENCE = "gesture_silence";
|
|
||||||
|
|
||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
|
||||||
private Context mContext;
|
|
||||||
@Mock
|
|
||||||
private Resources mResources;
|
|
||||||
|
|
||||||
private SilenceGesturePreferenceController mController;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
when(mContext.getResources()).thenReturn(mResources);
|
|
||||||
mController = new SilenceGesturePreferenceController(mContext, KEY_SILENCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getAvailabilityStatus_gestureNotSupported_UNSUPPORTED_ON_DEVICE() {
|
|
||||||
when(mResources.getBoolean(
|
|
||||||
com.android.internal.R.bool.config_silenceSensorAvailable))
|
|
||||||
.thenReturn(false);
|
|
||||||
final int availabilityStatus = mController.getAvailabilityStatus();
|
|
||||||
|
|
||||||
assertThat(availabilityStatus).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getAvailabilityStatus_gestureSupported_AVAILABLE() {
|
|
||||||
when(mResources.getBoolean(
|
|
||||||
com.android.internal.R.bool.config_silenceSensorAvailable)).thenReturn(true);
|
|
||||||
final int availabilityStatus = mController.getAvailabilityStatus();
|
|
||||||
|
|
||||||
assertThat(availabilityStatus).isEqualTo(AVAILABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isSliceableCorrectKey_returnsTrue() {
|
|
||||||
assertThat(mController.isSliceable()).isTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isChecked_testTrue() {
|
|
||||||
Settings.Secure.putInt(mContext.getContentResolver(), SILENCE_GESTURE, 1);
|
|
||||||
assertThat(mController.isChecked()).isTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isChecked_testFalse() {
|
|
||||||
Settings.Secure.putInt(mContext.getContentResolver(), SILENCE_GESTURE, 0);
|
|
||||||
assertThat(mController.isChecked()).isFalse();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,94 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2019 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.settings.gestures;
|
|
||||||
|
|
||||||
import static android.provider.Settings.Secure.SKIP_GESTURE;
|
|
||||||
|
|
||||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
|
||||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.provider.Settings;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.mockito.Answers;
|
|
||||||
import org.mockito.Mock;
|
|
||||||
import org.mockito.MockitoAnnotations;
|
|
||||||
import org.robolectric.RobolectricTestRunner;
|
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
|
||||||
public class SkipGesturePreferenceControllerTest {
|
|
||||||
|
|
||||||
private static final String KEY_SKIP = "gesture_skip";
|
|
||||||
|
|
||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
|
||||||
private Context mContext;
|
|
||||||
@Mock
|
|
||||||
private Resources mResources;
|
|
||||||
|
|
||||||
private SkipGesturePreferenceController mController;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
when(mContext.getResources()).thenReturn(mResources);
|
|
||||||
mController = new SkipGesturePreferenceController(mContext, KEY_SKIP);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getAvailabilityStatus_gestureNotSupported_UNSUPPORTED_ON_DEVICE() {
|
|
||||||
when(mResources.getBoolean(
|
|
||||||
com.android.internal.R.bool.config_skipSensorAvailable))
|
|
||||||
.thenReturn(false);
|
|
||||||
final int availabilityStatus = mController.getAvailabilityStatus();
|
|
||||||
|
|
||||||
assertThat(availabilityStatus).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getAvailabilityStatus_gestureSupported_AVAILABLE() {
|
|
||||||
when(mResources.getBoolean(
|
|
||||||
com.android.internal.R.bool.config_skipSensorAvailable)).thenReturn(true);
|
|
||||||
final int availabilityStatus = mController.getAvailabilityStatus();
|
|
||||||
|
|
||||||
assertThat(availabilityStatus).isEqualTo(AVAILABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isSliceableCorrectKey_returnsTrue() {
|
|
||||||
assertThat(mController.isSliceable()).isTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isChecked_testTrue() {
|
|
||||||
Settings.Secure.putInt(mContext.getContentResolver(), SKIP_GESTURE, 1);
|
|
||||||
assertThat(mController.isChecked()).isTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isChecked_testFalse() {
|
|
||||||
Settings.Secure.putInt(mContext.getContentResolver(), SKIP_GESTURE, 0);
|
|
||||||
assertThat(mController.isChecked()).isFalse();
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user