Fix settings robotest

am: 4e34839a1e

Change-Id: I46d6dd639b779f993bc2088608a52165139967fb
This commit is contained in:
Fan Zhang
2017-06-30 03:49:57 +00:00
committed by android-build-merger

View File

@@ -21,6 +21,7 @@ import android.app.admin.DevicePolicyManager;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.hardware.input.InputManager; import android.hardware.input.InputManager;
import android.os.UserManager; import android.os.UserManager;
import android.provider.Settings; import android.provider.Settings;
@@ -191,10 +192,14 @@ public class LanguageAndInputSettingsTest {
@Test @Test
public void testNonIndexableKeys_existInXmlLayout() { public void testNonIndexableKeys_existInXmlLayout() {
final Context context = spy(RuntimeEnvironment.application); final Context context = spy(RuntimeEnvironment.application);
final Resources res = spy(RuntimeEnvironment.application.getResources());
//(InputManager) context.getSystemService(Context.INPUT_SERVICE); //(InputManager) context.getSystemService(Context.INPUT_SERVICE);
InputManager manager = mock(InputManager.class); InputManager manager = mock(InputManager.class);
when(manager.getInputDeviceIds()).thenReturn(new int[]{}); when(manager.getInputDeviceIds()).thenReturn(new int[]{});
doReturn(manager).when(context).getSystemService(Context.INPUT_SERVICE); doReturn(manager).when(context).getSystemService(Context.INPUT_SERVICE);
doReturn(res).when(context).getResources();
doReturn(false).when(res)
.getBoolean(com.android.internal.R.bool.config_supportSystemNavigationKeys);
final List<String> niks = LanguageAndInputSettings.SEARCH_INDEX_DATA_PROVIDER final List<String> niks = LanguageAndInputSettings.SEARCH_INDEX_DATA_PROVIDER
.getNonIndexableKeys(context); .getNonIndexableKeys(context);
final int xmlId = (new LanguageAndInputSettings()).getPreferenceScreenResId(); final int xmlId = (new LanguageAndInputSettings()).getPreferenceScreenResId();