Hide password for wifi tether

Add summaryPassword variable in ValidatedEditTextPreference. If it
is true, set the summary textview with password flag.

Bug: 65413204
Test: RunSettingsRoboTests
Change-Id: Ia0f1e3ab50e81d8f7f9fc0fb34b35c3041200a4e
This commit is contained in:
Lei Yu
2018-03-20 17:22:24 -07:00
parent 048b71a67c
commit 4c8c4b27fc
3 changed files with 40 additions and 0 deletions

View File

@@ -17,6 +17,7 @@
package com.android.settings.widget;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.never;
@@ -24,10 +25,12 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.support.v7.preference.PreferenceViewHolder;
import android.text.InputType;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
@@ -37,6 +40,7 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
public class ValidatedEditTextPreferenceTest {
@@ -46,11 +50,15 @@ public class ValidatedEditTextPreferenceTest {
@Mock
private ValidatedEditTextPreference.Validator mValidator;
private PreferenceViewHolder mViewHolder;
private ValidatedEditTextPreference mPreference;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mViewHolder = spy(PreferenceViewHolder.createInstanceForTests(
new View(RuntimeEnvironment.application)));
mPreference = new ValidatedEditTextPreference(RuntimeEnvironment.application);
}
@@ -111,4 +119,17 @@ public class ValidatedEditTextPreferenceTest {
& (InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_CLASS_TEXT))
.isNotEqualTo(0);
}
@Test
public void bindViewHolder_isPassword_shouldSetInputType() {
final TextView textView = spy(new TextView(RuntimeEnvironment.application));
when(mViewHolder.findViewById(android.R.id.summary)).thenReturn(textView);
mPreference.setIsSummaryPassword(true);
mPreference.onBindViewHolder(mViewHolder);
assertThat(textView.getInputType()
& (InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_CLASS_TEXT))
.isNotEqualTo(0);
}
}