Merge "Don't show autofill settings if not enabled"
This commit is contained in:
committed by
Android (Google) Code Review
commit
3d3925f565
@@ -22,10 +22,12 @@ import android.content.pm.PackageManager;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.view.autofill.AutofillManager;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.applications.AutofillManagerWrapper;
|
||||
import com.android.settings.applications.PackageManagerWrapper;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -54,6 +56,8 @@ public class DefaultAutofillPreferenceControllerTest {
|
||||
private UserManager mUserManager;
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private PackageManagerWrapper mPackageManager;
|
||||
@Mock
|
||||
private AutofillManagerWrapper mAutofillManager;
|
||||
|
||||
private DefaultAutofillPreferenceController mController;
|
||||
|
||||
@@ -64,10 +68,23 @@ public class DefaultAutofillPreferenceControllerTest {
|
||||
|
||||
mController = spy(new DefaultAutofillPreferenceController(mContext));
|
||||
ReflectionHelpers.setField(mController, "mPackageManager", mPackageManager);
|
||||
ReflectionHelpers.setField(mController, "mAutofillManager", mAutofillManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAlwaysAvailable() {
|
||||
public void isAvailableIfHasFeatureAndSupported() {
|
||||
when(mContext.getSystemService(AutofillManager.class)).thenReturn(null);
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
|
||||
when(mAutofillManager.hasAutofillFeature()).thenReturn(false);
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
|
||||
when(mAutofillManager.hasAutofillFeature()).thenReturn(true);
|
||||
when(mAutofillManager.isAutofillSupported()).thenReturn(false);
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
|
||||
when(mAutofillManager.hasAutofillFeature()).thenReturn(true);
|
||||
when(mAutofillManager.isAutofillSupported()).thenReturn(true);
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
}
|
||||
|
||||
|
@@ -31,6 +31,7 @@ import android.content.pm.PackageManager;
|
||||
import android.hardware.input.InputManager;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
import android.view.autofill.AutofillManager;
|
||||
import android.view.inputmethod.InputMethodInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.view.textservice.TextServicesManager;
|
||||
@@ -72,6 +73,8 @@ public class LanguageAndInputSettingsTest {
|
||||
private DevicePolicyManager mDpm;
|
||||
@Mock
|
||||
private InputMethodManager mInputMethodManager;
|
||||
@Mock
|
||||
private AutofillManager mAutofillManager;
|
||||
private TestFragment mFragment;
|
||||
|
||||
@Before
|
||||
@@ -84,6 +87,8 @@ public class LanguageAndInputSettingsTest {
|
||||
.thenReturn(mock(TextServicesManager.class));
|
||||
when(mContext.getSystemService(Context.DEVICE_POLICY_SERVICE)).thenReturn(mDpm);
|
||||
when(mContext.getSystemService(Context.INPUT_METHOD_SERVICE)).thenReturn(mImm);
|
||||
when((Object) mContext.getSystemService(AutofillManager.class))
|
||||
.thenReturn(mAutofillManager);
|
||||
mFragment = new TestFragment(mContext);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user