Support "Add account" search indexing

Implement a default getRawDataToIndex method of preference controller
base for indexing preference's raw data.

Test: manual, robotest
Fix: 243899250
Change-Id: I3fb4f88c881edcbaa3c5bfc7f78cc2e169b0380f
This commit is contained in:
Jason Chiu
2023-12-28 18:44:26 +08:00
parent dd61b6bb3d
commit 01f992a698
3 changed files with 41 additions and 15 deletions

View File

@@ -254,25 +254,26 @@ public class AccountPreferenceControllerTest {
}
@Test
public void updateRawDataToIndex_ManagedProfile_shouldNotUpdate() {
public void updateRawDataToIndex_noManagedProfile_shouldContainAddAccount() {
final List<SearchIndexableRaw> data = new ArrayList<>();
when(mUserManager.isManagedProfile()).thenReturn(false);
mController.updateRawDataToIndex(data);
assertThat(data).hasSize(1);
assertThat(data.get(0).key).isEqualTo("add_account");
}
@Test
public void updateRawDataToIndex_ManagedProfile_shouldContainAddAccount() {
final List<SearchIndexableRaw> data = new ArrayList<>();
when(mUserManager.isManagedProfile()).thenReturn(true);
mController.updateRawDataToIndex(data);
assertThat(data).isEmpty();
}
@Test
public void updateRawDataToIndex_DisabledUser_shouldNotUpdate() {
final List<SearchIndexableRaw> data = new ArrayList<>();
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(1, "user 1", UserInfo.FLAG_DISABLED));
when(mUserManager.isManagedProfile()).thenReturn(false);
when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
mController.updateRawDataToIndex(data);
assertThat(data).isEmpty();
assertThat(data).hasSize(1);
assertThat(data.get(0).key).isEqualTo("add_account");
}
@Test