Add ability to show/hide assist_and_voice_input preference.

This adds a new boolean flag, config_show_assist_and_voice_input, which
when set to false will hide the assist_and_voice_input preference item.

Bug: 62379282
Test: make RunSettingsRoboTests
ROBOTEST_FILTER=DefaultAssistPreferenceControllerTest
Change-Id: I3bfc84f0fba07cd52679269daadbdcfccd205ff1
This commit is contained in:
Ben Lin
2017-12-19 14:56:52 -08:00
parent ac870bed2f
commit 69084b3a8d
4 changed files with 19 additions and 5 deletions

View File

@@ -50,6 +50,7 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.util.ReflectionHelpers;
import java.util.ArrayList;
@@ -61,26 +62,33 @@ public class DefaultAssistPreferenceControllerTest {
private static final String TEST_KEY = "test_pref_key";
@Mock
private Context mContext;
@Mock
private SearchManager mSearchManager;
@Mock
private PackageManager mPackageManager;
private Context mContext;
private DefaultAssistPreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
mController = new DefaultAssistPreferenceController(mContext, TEST_KEY,
true /* showSetting */);
}
@Test
public void isAlwaysAvailable() {
public void testAssistAndVoiceInput_byDefault_shouldBeShown() {
assertThat(mController.isAvailable()).isTrue();
}
@Test
@Config(qualifiers = "mcc999")
public void testAssistAndVoiceInput_ifDisabled_shouldNotBeShown() {
assertThat(mController.isAvailable()).isFalse();
}
@Test
public void getPrefKey_shouldReturnKey() {
assertThat(mController.getPreferenceKey())
@@ -91,7 +99,8 @@ public class DefaultAssistPreferenceControllerTest {
@Config(shadows = {ShadowSecureSettings.class})
public void getDefaultAppInfo_hasDefaultAssist_shouldReturnKey() {
final String flattenKey = "com.android.settings/assist";
Settings.Secure.putString(null, Settings.Secure.ASSISTANT, flattenKey);
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.ASSISTANT,
flattenKey);
DefaultAppInfo appInfo = mController.getDefaultAppInfo();
assertThat(appInfo.getKey()).isEqualTo(flattenKey);