Both device controls and wallet have moved to new areas outside of the power menu. In step 1, we are removing the device controls settings, as the user can now fully control availability within the new Quick Settings device controls tile. Bug: 185597511 Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.gestures Change-Id: Ib9a8c36c0532c095e58bc0ec085b788fc84945d7
117 lines
4.6 KiB
Java
117 lines
4.6 KiB
Java
/*
|
|
* Copyright (C) 2020 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 com.google.common.truth.Truth.assertThat;
|
|
|
|
import static org.mockito.ArgumentMatchers.anyInt;
|
|
import static org.mockito.Mockito.when;
|
|
|
|
import android.content.ContentResolver;
|
|
import android.content.Context;
|
|
import android.content.pm.PackageManager;
|
|
import android.provider.Settings;
|
|
|
|
import com.android.internal.widget.LockPatternUtils;
|
|
import com.android.settings.core.BasePreferenceController;
|
|
import com.android.settings.testutils.FakeFeatureFactory;
|
|
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
import org.junit.runner.RunWith;
|
|
import org.mockito.Mock;
|
|
import org.mockito.MockitoAnnotations;
|
|
import org.robolectric.ParameterizedRobolectricTestRunner;
|
|
import org.robolectric.RuntimeEnvironment;
|
|
import org.robolectric.Shadows;
|
|
import org.robolectric.shadows.ShadowPackageManager;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.Collection;
|
|
|
|
@RunWith(ParameterizedRobolectricTestRunner.class)
|
|
public class PowerMenuPrivacyPreferenceControllerAvailabilityTest {
|
|
|
|
private static final String CONTROLS_FEATURE = PackageManager.FEATURE_CONTROLS;
|
|
private static final String CARDS_ENABLED = Settings.Secure.GLOBAL_ACTIONS_PANEL_ENABLED;
|
|
private static final String CARDS_AVAILABLE = Settings.Secure.GLOBAL_ACTIONS_PANEL_AVAILABLE;
|
|
|
|
@ParameterizedRobolectricTestRunner.Parameters(
|
|
name = "ctrls available={0} cards available={1}, cards enabled={2}")
|
|
public static Collection data() {
|
|
return Arrays.asList(new Object[][]{
|
|
// controls available, cards available, cards enabled, available
|
|
{false, false, false, BasePreferenceController.DISABLED_DEPENDENT_SETTING},
|
|
{false, false, true, BasePreferenceController.DISABLED_DEPENDENT_SETTING},
|
|
{false, true, false, BasePreferenceController.DISABLED_DEPENDENT_SETTING},
|
|
{false, true, true, BasePreferenceController.AVAILABLE},
|
|
{true, false, false, BasePreferenceController.AVAILABLE},
|
|
{true, false, true, BasePreferenceController.AVAILABLE},
|
|
{true, true, false, BasePreferenceController.AVAILABLE},
|
|
{true, true, true, BasePreferenceController.AVAILABLE}
|
|
});
|
|
}
|
|
|
|
private Context mContext;
|
|
private PowerMenuPrivacyPreferenceController mController;
|
|
private ShadowPackageManager mShadowPackageManager;
|
|
|
|
@Mock
|
|
private LockPatternUtils mLockPatternUtils;
|
|
|
|
private boolean mControlsAvailable;
|
|
private boolean mCardsAvailable;
|
|
private boolean mCardsEnabled;
|
|
private int mAvailable;
|
|
|
|
public PowerMenuPrivacyPreferenceControllerAvailabilityTest(
|
|
boolean controlsAvailable,
|
|
boolean cardsAvailable,
|
|
boolean cardsEnabled,
|
|
int available) {
|
|
mControlsAvailable = controlsAvailable;
|
|
mCardsAvailable = cardsAvailable;
|
|
mCardsEnabled = cardsEnabled;
|
|
mAvailable = available;
|
|
}
|
|
|
|
@Before
|
|
public void setUp() {
|
|
MockitoAnnotations.initMocks(this);
|
|
mContext = RuntimeEnvironment.application;
|
|
mShadowPackageManager = Shadows.shadowOf(mContext.getPackageManager());
|
|
FakeFeatureFactory featureFactory = FakeFeatureFactory.setupForTest();
|
|
|
|
// For these tests we assume the device has a secure lock.
|
|
when(featureFactory.securityFeatureProvider.getLockPatternUtils(mContext))
|
|
.thenReturn(mLockPatternUtils);
|
|
when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
|
|
|
|
mController = new PowerMenuPrivacyPreferenceController(mContext, "TEST_KEY");
|
|
}
|
|
|
|
@Test
|
|
public void getAvailabilityStatus_possiblyAvailableAndEnabled() {
|
|
mShadowPackageManager.setSystemFeature(CONTROLS_FEATURE, mControlsAvailable);
|
|
ContentResolver cr = mContext.getContentResolver();
|
|
Settings.Secure.putInt(cr, CARDS_AVAILABLE, mCardsAvailable ? 1 : 0);
|
|
Settings.Secure.putInt(cr, CARDS_ENABLED, mCardsEnabled ? 1 : 0);
|
|
|
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(mAvailable);
|
|
}
|
|
}
|