Merge "Add the "Smart Lock" item to dynamic index." into rvc-dev am: 37d5ed5073
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/11544230 Change-Id: I2fdd9c2227b798376fa3036de82f82843392e02e
This commit is contained in:
@@ -44,6 +44,7 @@ import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.security.SecuritySettings;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.search.SearchIndexableRaw;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -111,10 +112,20 @@ public class TrustAgentListPreferenceControllerTest {
|
||||
@Test
|
||||
public void onResume_shouldClearOldAgents() {
|
||||
final Preference oldAgent = new Preference(mActivity);
|
||||
oldAgent.setKey(PREF_KEY_TRUST_AGENT);
|
||||
when(mCategory.findPreference(PREF_KEY_TRUST_AGENT))
|
||||
oldAgent.setKey(PREF_KEY_TRUST_AGENT + 0);
|
||||
when(mCategory.findPreference(PREF_KEY_TRUST_AGENT + 0))
|
||||
.thenReturn(oldAgent)
|
||||
.thenReturn(null);
|
||||
final List<TrustAgentManager.TrustAgentComponentInfo> agents = new ArrayList<>();
|
||||
final TrustAgentManager.TrustAgentComponentInfo agent =
|
||||
mock(TrustAgentManager.TrustAgentComponentInfo.class);
|
||||
agent.title = "Test_title";
|
||||
agent.summary = "test summary";
|
||||
agent.componentName = new ComponentName("pkg", "agent");
|
||||
agent.admin = null;
|
||||
agents.add(agent);
|
||||
when(mTrustAgentManager.getActiveTrustAgents(mActivity, mLockPatternUtils))
|
||||
.thenReturn(agents);
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
mController.onResume();
|
||||
@@ -160,4 +171,24 @@ public class TrustAgentListPreferenceControllerTest {
|
||||
|
||||
verify(mCategory, never()).addPreference(any(Preference.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateDynamicRawDataToIndex_shouldIndexAgents() {
|
||||
final List<TrustAgentManager.TrustAgentComponentInfo> agents = new ArrayList<>();
|
||||
final TrustAgentManager.TrustAgentComponentInfo agent =
|
||||
mock(TrustAgentManager.TrustAgentComponentInfo.class);
|
||||
agent.title = "Test_title";
|
||||
agent.summary = "test summary";
|
||||
agent.componentName = new ComponentName("pkg", "agent");
|
||||
agent.admin = null;
|
||||
agents.add(agent);
|
||||
when(mTrustAgentManager.getActiveTrustAgents(mActivity, mLockPatternUtils))
|
||||
.thenReturn(agents);
|
||||
final List<SearchIndexableRaw> indexRaws = new ArrayList<>();
|
||||
|
||||
mController.updateDynamicRawDataToIndex(indexRaws);
|
||||
|
||||
assertThat(indexRaws).hasSize(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user