Merge "Autofill Settings: Display the number of saved passwords." into sc-dev

This commit is contained in:
Ahaan Ugale
2021-03-24 18:42:50 +00:00
committed by Android (Google) Code Review
2 changed files with 113 additions and 1 deletions

View File

@@ -21,21 +21,26 @@ import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_U
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.mock;
import android.content.ComponentName;
import android.content.Context;
import android.os.Looper;
import android.service.autofill.AutofillServiceInfo;
import androidx.lifecycle.Lifecycle;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
import androidx.test.annotation.UiThreadTest;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.collect.Lists;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -100,11 +105,15 @@ public class PasswordsPreferenceControllerTest {
assertThat(mPasswordsPreferenceCategory.getPreferenceCount()).isEqualTo(0);
}
@Ignore("TODO: Fix the test to handle the service binding.")
@Test
@UiThreadTest
public void displayPreference_withPasswords_addsPreference() {
AutofillServiceInfo service = createServiceWithPasswords();
PasswordsPreferenceController controller =
createControllerWithServices(Lists.newArrayList(service));
controller.onCreate(() -> mock(Lifecycle.class));
controller.displayPreference(mScreen);
assertThat(mPasswordsPreferenceCategory.getPreferenceCount()).isEqualTo(1);