diff options
Diffstat (limited to 'tests/robotests')
8 files changed, 93 insertions, 39 deletions
diff --git a/tests/robotests/assets/grandfather_not_implementing_index_provider b/tests/robotests/assets/grandfather_not_implementing_index_provider index c3cb8971b6..a662f2f971 100644 --- a/tests/robotests/assets/grandfather_not_implementing_index_provider +++ b/tests/robotests/assets/grandfather_not_implementing_index_provider @@ -1,8 +1,6 @@ com.android.settings.accessibility.AccessibilitySettingsForSetupWizard com.android.settings.accessibility.CaptionPropertiesFragment com.android.settings.accessibility.ToggleAccessibilityServicePreferenceFragment -com.android.settings.accessibility.ToggleAutoclickPreferenceFragment -com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragmentForSetupWizard com.android.settings.accessibility.ToggleScreenReaderPreferenceFragmentForSetupWizard @@ -24,18 +22,14 @@ com.android.settings.applications.ProcessStatsUi com.android.settings.applications.RunningServices com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureDetails com.android.settings.applications.UsageAccessDetails -com.android.settings.applications.VrListenerSettings com.android.settings.backup.ToggleBackupSettingFragment com.android.settings.biometrics.fingerprint.FingerprintSettings$FingerprintSettingsFragment com.android.settings.bluetooth.BluetoothDeviceDetailsFragment com.android.settings.bluetooth.BluetoothPairingDetail com.android.settings.bluetooth.DevicePickerFragment com.android.settings.datausage.AppDataUsage -com.android.settings.datausage.BillingCycleSettings com.android.settings.datausage.DataUsageList com.android.settings.datetime.timezone.TimeZoneSettings -com.android.settings.development.featureflags.FeatureFlagsDashboard -com.android.settings.development.qstile.DevelopmentTileConfigFragment com.android.settings.deviceinfo.PrivateVolumeSettings com.android.settings.deviceinfo.PublicVolumeSettings com.android.settings.deviceinfo.StorageProfileFragment @@ -53,14 +47,12 @@ com.android.settings.IccLockSettings com.android.settings.inputmethod.InputMethodAndSubtypeEnabler com.android.settings.inputmethod.KeyboardLayoutPickerFragment com.android.settings.inputmethod.SpellCheckersSettings -com.android.settings.inputmethod.UserDictionaryList com.android.settings.localepicker.LocaleListEditor com.android.settings.network.ApnEditor com.android.settings.network.ApnSettings com.android.settings.notification.AppNotificationSettings com.android.settings.notification.ChannelGroupNotificationSettings com.android.settings.notification.ChannelNotificationSettings -com.android.settings.notification.NotificationAccessSettings com.android.settings.notification.NotificationStation com.android.settings.notification.RedactionInterstitial$RedactionInterstitialFragment com.android.settings.notification.ZenModeEventRuleSettings diff --git a/tests/robotests/src/com/android/settings/applications/specialaccess/ZenAccessControllerTest.java b/tests/robotests/src/com/android/settings/applications/specialaccess/ZenAccessControllerTest.java index 205de10f1c..da2bc0a9ed 100644 --- a/tests/robotests/src/com/android/settings/applications/specialaccess/ZenAccessControllerTest.java +++ b/tests/robotests/src/com/android/settings/applications/specialaccess/ZenAccessControllerTest.java @@ -51,6 +51,6 @@ public class ZenAccessControllerTest { @Test public void isAvailable_lowMemory_false() { mActivityManager.setIsLowRamDevice(true); - assertThat(mController.isAvailable()).isTrue(); + assertThat(mController.isAvailable()).isFalse(); } } diff --git a/tests/robotests/src/com/android/settings/applications/specialaccess/EnabledVrListenersControllerTest.java b/tests/robotests/src/com/android/settings/applications/specialaccess/vrlistener/EnabledVrListenersControllerTest.java index 7963fd4a20..3fb9045a66 100644 --- a/tests/robotests/src/com/android/settings/applications/specialaccess/EnabledVrListenersControllerTest.java +++ b/tests/robotests/src/com/android/settings/applications/specialaccess/vrlistener/EnabledVrListenersControllerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,8 +14,10 @@ * limitations under the License. */ -package com.android.settings.applications.specialaccess; +package com.android.settings.applications.specialaccess.vrlistener; +import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE; +import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE; import static com.google.common.truth.Truth.assertThat; import android.content.Context; @@ -45,19 +47,19 @@ public class EnabledVrListenersControllerTest { } @Test - public void isAvailable_byDefault_true() { - assertThat(mController.isAvailable()).isTrue(); + public void getAvailability_byDefault_unsearchable() { + assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE); } @Test - public void isAvailable_lowMemory_false() { + public void getAvailability_lowMemory_unavailable() { mActivityManager.setIsLowRamDevice(true); - assertThat(mController.isAvailable()).isTrue(); + assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE); } @Test @Config(qualifiers = "mcc999") - public void isAvailable_disabled_false() { - assertThat(mController.isAvailable()).isFalse(); + public void getAvailability_disabled_unavailable() { + assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE); } } diff --git a/tests/robotests/src/com/android/settings/applications/specialaccess/vrlistener/VrListenerScreenPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/specialaccess/vrlistener/VrListenerScreenPreferenceControllerTest.java new file mode 100644 index 0000000000..c5734f929c --- /dev/null +++ b/tests/robotests/src/com/android/settings/applications/specialaccess/vrlistener/VrListenerScreenPreferenceControllerTest.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2018 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.applications.specialaccess.vrlistener; + +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 android.content.Context; + +import com.android.settings.testutils.SettingsRobolectricTestRunner; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RuntimeEnvironment; +import org.robolectric.annotation.Config; +import org.robolectric.shadow.api.Shadow; +import org.robolectric.shadows.ShadowActivityManager; + +@RunWith(SettingsRobolectricTestRunner.class) +public class VrListenerScreenPreferenceControllerTest { + + private Context mContext; + private VrListenerScreenPreferenceController mController; + private ShadowActivityManager mActivityManager; + + @Before + public void setUp() { + mContext = RuntimeEnvironment.application; + mController = new VrListenerScreenPreferenceController(mContext, "key"); + mActivityManager = Shadow.extract(mContext.getSystemService(Context.ACTIVITY_SERVICE)); + } + + @Test + public void getAvailability_byDefault_searchable() { + assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE); + } + + @Test + public void getAvailability_lowMemory_unavailable() { + mActivityManager.setIsLowRamDevice(true); + assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE); + } + + @Test + @Config(qualifiers = "mcc999") + public void getAvailability_disabled_unavailable() { + assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE); + } +} diff --git a/tests/robotests/src/com/android/settings/applications/VrListenerSettingsTest.java b/tests/robotests/src/com/android/settings/applications/specialaccess/vrlistener/VrListenerSettingsTest.java index 516d2489b1..4f5b2bbed1 100644 --- a/tests/robotests/src/com/android/settings/applications/VrListenerSettingsTest.java +++ b/tests/robotests/src/com/android/settings/applications/specialaccess/vrlistener/VrListenerSettingsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 The Android Open Source Project + * Copyright (C) 2018 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. @@ -11,10 +11,10 @@ * 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 + * limitations under the License. */ -package com.android.settings.applications; +package com.android.settings.applications.specialaccess.vrlistener; import static org.mockito.ArgumentMatchers.nullable; import static org.mockito.Matchers.eq; diff --git a/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagPreferenceControllerTest.java index 3a9d89a5da..c9c97538de 100644 --- a/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/development/featureflags/FeatureFlagPreferenceControllerTest.java @@ -16,7 +16,7 @@ package com.android.settings.development.featureflags; -import static androidx.lifecycle.Lifecycle.Event.ON_START; +import static com.android.settings.core.BasePreferenceController.AVAILABLE; import static com.google.common.truth.Truth.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Mockito.atLeastOnce; @@ -26,7 +26,6 @@ import static org.mockito.Mockito.when; import android.content.Context; import com.android.settings.testutils.SettingsRobolectricTestRunner; -import com.android.settingslib.core.lifecycle.Lifecycle; import org.junit.Before; import org.junit.Test; @@ -35,7 +34,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.RuntimeEnvironment; -import androidx.lifecycle.LifecycleOwner; +import androidx.preference.PreferenceCategory; import androidx.preference.PreferenceScreen; @RunWith(SettingsRobolectricTestRunner.class) @@ -43,33 +42,31 @@ public class FeatureFlagPreferenceControllerTest { @Mock private PreferenceScreen mScreen; + @Mock + private PreferenceCategory mCategory; private Context mContext; - private LifecycleOwner mLifecycleOwner; - private Lifecycle mLifecycle; private FeatureFlagsPreferenceController mController; @Before public void setUp() { MockitoAnnotations.initMocks(this); mContext = RuntimeEnvironment.application; - mLifecycleOwner = () -> mLifecycle; - mLifecycle = new Lifecycle(mLifecycleOwner); - mController = new FeatureFlagsPreferenceController(mContext, mLifecycle); - when(mScreen.getContext()).thenReturn(mContext); + mController = new FeatureFlagsPreferenceController(mContext, "test_key"); + when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mCategory); + when(mCategory.getContext()).thenReturn(mContext); mController.displayPreference(mScreen); } @Test - public void verifyConstants() { - assertThat(mController.isAvailable()).isTrue(); - assertThat(mController.getPreferenceKey()).isNull(); + public void getAvailability_available() { + assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE); } @Test public void onStart_shouldRefreshFeatureFlags() { - mLifecycle.handleLifecycleEvent(ON_START); + mController.onStart(); - verify(mScreen).removeAll(); - verify(mScreen, atLeastOnce()).addPreference(any(FeatureFlagPreference.class)); + verify(mCategory).removeAll(); + verify(mCategory, atLeastOnce()).addPreference(any(FeatureFlagPreference.class)); } } diff --git a/tests/robotests/src/com/android/settings/development/qstile/DevelopmentTilePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/qstile/DevelopmentTilePreferenceControllerTest.java index 3043019b6d..c42d46c246 100644 --- a/tests/robotests/src/com/android/settings/development/qstile/DevelopmentTilePreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/development/qstile/DevelopmentTilePreferenceControllerTest.java @@ -70,9 +70,7 @@ public class DevelopmentTilePreferenceControllerTest { mShadowPackageManager = Shadows.shadowOf(mContext.getPackageManager()); when(mScreen.getContext()).thenReturn(mContext); - mController = new DevelopmentTilePreferenceController(mContext); - assertThat(mController.getPreferenceKey()).isNull(); - + mController = new DevelopmentTilePreferenceController(mContext, "testkey"); mOnChangeHandler = spy(new DevelopmentTilePreferenceController.OnChangeHandler(mContext)); ReflectionHelpers.setField(mOnChangeHandler, "mStatusBarService", mStatusBarService); } diff --git a/tests/robotests/src/com/android/settings/language/UserDictionaryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/language/UserDictionaryPreferenceControllerTest.java index 0019f4d038..29b5278731 100644 --- a/tests/robotests/src/com/android/settings/language/UserDictionaryPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/language/UserDictionaryPreferenceControllerTest.java @@ -100,7 +100,7 @@ public class UserDictionaryPreferenceControllerTest { } private TestController(Context context) { - super(context); + super(context, "test_key"); } } } |