Remove unused file and test case

- Remove AutoCompleteEditTextPreference & NameAutoCompletePreference.
- Remove unused test case.

Test: make RunEmergencyInfoRoboTests

Bug: 112168722
Bug: 111967295

Change-Id: I675c6bd283856f084df90c6f4213fbf20382d6aa
Merged-In: I675c6bd283856f084df90c6f4213fbf20382d6aa
diff --git a/src/com/android/emergency/preferences/AutoCompleteEditTextPreference.java b/src/com/android/emergency/preferences/AutoCompleteEditTextPreference.java
deleted file mode 100644
index ab3c6b4..0000000
--- a/src/com/android/emergency/preferences/AutoCompleteEditTextPreference.java
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.emergency.preferences;
-
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.SharedPreferences;
-import android.content.res.TypedArray;
-import android.graphics.Rect;
-import android.os.Bundle;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.support.v14.preference.PreferenceDialogFragment;
-import android.text.TextUtils;
-import android.util.AttributeSet;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.ViewParent;
-import android.view.Window;
-import android.view.WindowManager;
-import android.view.inputmethod.EditorInfo;
-import android.widget.AutoCompleteTextView;
-import android.widget.TextView;
-
-import com.android.emergency.R;
-import com.android.internal.annotations.VisibleForTesting;
-import com.android.settingslib.CustomDialogPreference;
-
-/**
- * Almost a copy of EditTextPreference that shows a {@link AutoCompleteTextView} instead of the
- * basic EditText. It always show the suggested options.
- * TODO: an EditTextPreference always shows the soft input keyboard, whereas this class does not,
- * and it should, to mimic EditTextPreference better.
- */
-public class AutoCompleteEditTextPreference extends CustomDialogPreference {
-    /**
-     * The edit text shown in the dialog.
-     */
-    private AutoCompleteTextView mAutoCompleteTextView;
-
-    private String mText;
-    private boolean mTextSet;
-
-    public AutoCompleteEditTextPreference(Context context, AttributeSet attrs, int defStyleAttr,
-            int defStyleRes) {
-        super(context, attrs, defStyleAttr, defStyleRes);
-
-        mAutoCompleteTextView = new InstantAutoCompleteTextView(context, attrs);
-
-        // Give it an ID so it can be saved/restored
-        mAutoCompleteTextView.setId(R.id.edit);
-
-        /*
-         * The preference framework and view framework both have an 'enabled'
-         * attribute. Most likely, the 'enabled' specified in this XML is for
-         * the preference framework, but it was also given to the view framework.
-         * We reset the enabled state.
-         */
-        mAutoCompleteTextView.setEnabled(true);
-
-        mAutoCompleteTextView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
-            @Override
-            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
-                if (actionId == EditorInfo.IME_ACTION_DONE) {
-                    onClick(getDialog(), DialogInterface.BUTTON_POSITIVE);
-                    getDialog().dismiss();
-                    return true;
-                }
-                return false;
-            }
-        });
-        setDialogLayoutResource(R.layout.preference_dialog_autocomplete_edittext);
-    }
-
-    public AutoCompleteEditTextPreference(Context context, AttributeSet attrs, int defStyleAttr) {
-        this(context, attrs, defStyleAttr, 0);
-    }
-
-    public AutoCompleteEditTextPreference(Context context, AttributeSet attrs) {
-        this(context, attrs, R.attr.dialogPreferenceStyle);
-    }
-
-    public AutoCompleteEditTextPreference(Context context) {
-        this(context, null);
-    }
-
-    public AutoCompleteTextView getAutoCompleteTextView() {
-        return mAutoCompleteTextView;
-    }
-
-    /**
-     * Saves the text to the {@link SharedPreferences}.
-     *
-     * @param text The text to save
-     */
-    public void setText(String text) {
-        // Always persist/notify the first time.
-        final boolean changed = !TextUtils.equals(mText, text);
-        if (changed || !mTextSet) {
-            mText = text;
-            mTextSet = true;
-            persistString(text);
-            if (changed) {
-                notifyDependencyChange(shouldDisableDependents());
-                notifyChanged();
-            }
-        }
-    }
-
-    @VisibleForTesting
-    @Override
-    public void onClick() {
-        super.onClick();
-    }
-
-    /**
-     * Gets the text from the {@link SharedPreferences}.
-     *
-     * @return The current preference value.
-     */
-    public String getText() {
-        return mText;
-    }
-
-    @Override
-    protected void onBindDialogView(View view) {
-        super.onBindDialogView(view);
-
-        AutoCompleteTextView editText = mAutoCompleteTextView;
-        editText.setText(getText());
-        editText.requestFocus();
-
-        ViewParent oldParent = editText.getParent();
-        if (oldParent != view) {
-            if (oldParent != null) {
-                ((ViewGroup) oldParent).removeView(editText);
-            }
-            onAddEditTextToDialogView(view, editText);
-        }
-        editText.setSelection(editText.getText().length());
-    }
-
-    /**
-     * Adds the AutoCompleteTextView widget of this preference to the dialog's view.
-     *
-     * @param dialogView The dialog view.
-     */
-    protected void onAddEditTextToDialogView(View dialogView, AutoCompleteTextView editText) {
-        ViewGroup container = (ViewGroup) dialogView
-                .findViewById(R.id.autocomplete_edittext_container);
-        if (container != null) {
-            container.addView(editText, ViewGroup.LayoutParams.MATCH_PARENT,
-                    ViewGroup.LayoutParams.WRAP_CONTENT);
-        }
-    }
-
-    @Override
-    protected void onDialogClosed(boolean positiveResult) {
-        super.onDialogClosed(positiveResult);
-
-        if (positiveResult) {
-            String value = mAutoCompleteTextView.getText().toString();
-            if (callChangeListener(value)) {
-                setText(value);
-            }
-        }
-    }
-
-    @Override
-    protected Object onGetDefaultValue(TypedArray a, int index) {
-        return a.getString(index);
-    }
-
-    @Override
-    protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
-        setText(restoreValue ? getPersistedString(mText) : (String) defaultValue);
-    }
-
-    @Override
-    public boolean shouldDisableDependents() {
-        return TextUtils.isEmpty(mText) || super.shouldDisableDependents();
-    }
-
-    @Override
-    protected Parcelable onSaveInstanceState() {
-        final Parcelable superState = super.onSaveInstanceState();
-        if (isPersistent()) {
-            // No need to save instance state since it's persistent
-            return superState;
-        }
-
-        final SavedState myState = new SavedState(superState);
-        myState.text = getText();
-        return myState;
-    }
-
-    @Override
-    protected void onRestoreInstanceState(Parcelable state) {
-        if (state == null || !state.getClass().equals(SavedState.class)) {
-            // Didn't save state for us in onSaveInstanceState
-            super.onRestoreInstanceState(state);
-            return;
-        }
-
-        SavedState myState = (SavedState) state;
-        super.onRestoreInstanceState(myState.getSuperState());
-        setText(myState.text);
-    }
-
-    private static class SavedState extends BaseSavedState {
-        String text;
-
-        public SavedState(Parcel source) {
-            super(source);
-            text = source.readString();
-        }
-
-        @Override
-        public void writeToParcel(Parcel dest, int flags) {
-            super.writeToParcel(dest, flags);
-            dest.writeString(text);
-        }
-
-        public SavedState(Parcelable superState) {
-            super(superState);
-        }
-
-        public static final Parcelable.Creator<SavedState> CREATOR =
-                new Parcelable.Creator<SavedState>() {
-                    public SavedState createFromParcel(Parcel in) {
-                        return new SavedState(in);
-                    }
-
-                    public SavedState[] newArray(int size) {
-                        return new SavedState[size];
-                    }
-                };
-    }
-
-    /** {@link AutoCompleteTextView} that always shows the suggestions. */
-    private class InstantAutoCompleteTextView extends AutoCompleteTextView {
-        public InstantAutoCompleteTextView(Context context, AttributeSet attrs) {
-            super(context, attrs);
-        }
-
-        @Override
-        public boolean enoughToFilter() {
-            return true;
-        }
-
-        @Override
-        protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
-            super.onFocusChanged(focused, direction, previouslyFocusedRect);
-
-            showDropDownIfFocused();
-        }
-
-        @Override
-        protected void onAttachedToWindow() {
-            super.onAttachedToWindow();
-            showDropDownIfFocused();
-        }
-
-        private void showDropDownIfFocused() {
-            if (isFocused() && getWindowVisibility() == View.VISIBLE) {
-                showDropDown();
-            }
-        }
-    }
-
-    public static class AutoCompleteEditTextPreferenceDialogFragment
-            extends CustomDialogPreference.CustomPreferenceDialogFragment {
-        public static CustomDialogPreference.CustomPreferenceDialogFragment
-                newInstance(String key) {
-            return CustomDialogPreference.CustomPreferenceDialogFragment.newInstance(key);
-        }
-    }
-}
diff --git a/src/com/android/emergency/preferences/NameAutoCompletePreference.java b/src/com/android/emergency/preferences/NameAutoCompletePreference.java
deleted file mode 100644
index 7af25e5..0000000
--- a/src/com/android/emergency/preferences/NameAutoCompletePreference.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.emergency.preferences;
-
-import android.content.Context;
-import android.os.UserManager;
-import android.support.annotation.Nullable;
-import android.text.TextUtils;
-import android.util.AttributeSet;
-import android.widget.ArrayAdapter;
-
-import com.android.emergency.ReloadablePreferenceInterface;
-import com.android.internal.annotations.VisibleForTesting;
-
-/**
- * {@link AutoCompleteEditTextPreference} that prepopulates the edit text view with the name of the
- * user provided in settings.
- */
-public class NameAutoCompletePreference extends AutoCompleteEditTextPreference implements
-        ReloadablePreferenceInterface {
-    private static final String[] EMPTY_STRING_ARRAY = new String[] {};
-
-    private final SuggestionProvider mSuggestionProvider;
-
-    public NameAutoCompletePreference(Context context, AttributeSet attrs) {
-        this(context, attrs, new SuggestionProvider() {
-            private final UserManager mUserManager =
-                    (UserManager) context.getSystemService(Context.USER_SERVICE);
-
-            @Override
-            public boolean hasNameToSuggest() {
-                return mUserManager.isUserNameSet();
-            }
-
-            @Override
-            public String getNameSuggestion() {
-                if (!hasNameToSuggest()) {
-                    return null;
-                }
-                return mUserManager.getUserName();
-            }
-        });
-    }
-
-    @VisibleForTesting
-    public NameAutoCompletePreference(Context context, AttributeSet attrs,
-            SuggestionProvider suggestionProvider) {
-        super(context, attrs);
-        mSuggestionProvider = suggestionProvider;
-        getAutoCompleteTextView().setAdapter(createAdapter());
-    }
-
-    @VisibleForTesting
-    public String[] createAutocompleteSuggestions() {
-        if (!mSuggestionProvider.hasNameToSuggest()) {
-            return EMPTY_STRING_ARRAY;
-        }
-        return new String[] {mSuggestionProvider.getNameSuggestion()};
-    }
-
-    private ArrayAdapter createAdapter() {
-        UserManager userManager =
-                (UserManager) getContext().getSystemService(Context.USER_SERVICE);
-        String[] autocompleteSuggestions = createAutocompleteSuggestions();
-        return new ArrayAdapter<String>(getContext(),
-                android.R.layout.simple_dropdown_item_1line, autocompleteSuggestions);
-    }
-
-
-    @Override
-    public void reloadFromPreference() {
-        setText(getPersistedString(""));
-    }
-
-    @Override
-    public boolean isNotSet() {
-        return TextUtils.isEmpty(getText());
-    }
-
-    @Override
-    public CharSequence getSummary() {
-        String text = getText();
-        return TextUtils.isEmpty(text) ? super.getSummary() : text;
-    }
-
-    /**
-     * Interface for suggesting a name.
-     */
-    public interface SuggestionProvider {
-        /** @return whether this class has a name to suggest. */
-        boolean hasNameToSuggest();
-
-        /**
-         * Gets a suggested name.
-         * @return a suggest name, or {@code null} if there is no name to suggest.
-         */
-        @Nullable
-        String getNameSuggestion();
-    }
-}
diff --git a/tests/robolectric/src/com/android/emergency/preferences/NameAutoCompletePreferenceTest.java b/tests/robolectric/src/com/android/emergency/preferences/NameAutoCompletePreferenceTest.java
deleted file mode 100644
index 2ca499e..0000000
--- a/tests/robolectric/src/com/android/emergency/preferences/NameAutoCompletePreferenceTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.emergency.preferences;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.nullable;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.support.v7.preference.PreferenceGroup;
-import android.support.v7.preference.PreferenceManager;
-import android.support.v7.preference.PreferenceScreen;
-import android.text.Editable;
-import android.view.View;
-import android.widget.AutoCompleteTextView;
-
-import com.android.emergency.PreferenceKeys;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.util.ReflectionHelpers;
-
-/** Unit tests for {@link NameAutoCompletePreference}. */
-@RunWith(RobolectricTestRunner.class)
-public class NameAutoCompletePreferenceTest {
-    @Mock private PreferenceManager mPreferenceManager;
-    @Mock private SharedPreferences mSharedPreferences;
-    @Mock private NameAutoCompletePreference.SuggestionProvider mAutoCompleteSuggestionProvider;
-    private NameAutoCompletePreference mPreference;
-
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
-        when(mPreferenceManager.getSharedPreferences()).thenReturn(mSharedPreferences);
-
-        Context context = RuntimeEnvironment.application;
-
-        mPreference =
-            spy(new NameAutoCompletePreference(context, null, mAutoCompleteSuggestionProvider));
-
-        PreferenceGroup prefRoot = spy(new PreferenceScreen(context, null));
-        when(prefRoot.getPreferenceManager()).thenReturn(mPreferenceManager);
-        prefRoot.addPreference(mPreference);
-    }
-
-    @Test
-    public void testProperties() {
-        assertThat(mPreference).isNotNull();
-        assertThat(mPreference.isEnabled()).isTrue();
-        assertThat(mPreference.isPersistent()).isTrue();
-        assertThat(mPreference.isSelectable()).isTrue();
-        assertThat(mPreference.isNotSet()).isTrue();
-    }
-
-    @Test
-    public void testReloadFromPreference() throws Throwable {
-        mPreference.setKey(PreferenceKeys.KEY_NAME);
-
-        String name = "John";
-        when(mSharedPreferences.getString(eq(mPreference.getKey()), nullable(String.class)))
-                .thenReturn(name);
-
-        mPreference.reloadFromPreference();
-        assertThat(mPreference.getText()).isEqualTo(name);
-        assertThat(mPreference.isNotSet()).isFalse();
-    }
-
-    @Test
-    public void testSetText() throws Throwable {
-        final String name = "John";
-        mPreference.setText(name);
-        assertThat(mPreference.getText()).isEqualTo(name);
-        assertThat(mPreference.getSummary()).isEqualTo(name);
-    }
-
-    @Test
-    public void testGetAutoCompleteTextView() {
-        AutoCompleteTextView autoCompleteTextView = mPreference.getAutoCompleteTextView();
-        assertThat(autoCompleteTextView).isNotNull();
-    }
-
-    @Test
-    public void testCreateAutocompleteSuggestions_noNameToSuggest() {
-        when(mAutoCompleteSuggestionProvider.hasNameToSuggest()).thenReturn(false);
-        assertThat(mPreference.createAutocompleteSuggestions()).isEqualTo(new String[] {});
-    }
-
-    @Test
-    public void testCreateAutocompleteSuggestions_nameToSuggest() {
-        final String name = "Jane";
-        when(mAutoCompleteSuggestionProvider.hasNameToSuggest()).thenReturn(true);
-        when(mAutoCompleteSuggestionProvider.getNameSuggestion()).thenReturn(name);
-        assertThat(mPreference.createAutocompleteSuggestions()).isEqualTo(new String[] {name});
-    }
-
-    @Test
-    public void testBindDialog_shouldFocusOnEditText() {
-        final AutoCompleteTextView editText = mock(AutoCompleteTextView.class);
-        final Editable text = mock(Editable.class);
-        when(editText.getText()).thenReturn(text);
-        when(text.length()).thenReturn(0);
-        ReflectionHelpers.setField(mPreference, "mAutoCompleteTextView", editText);
-
-        mPreference.onBindDialogView(mock(View.class));
-
-        verify(editText).requestFocus();
-    }
-}
diff --git a/tests/unit/src/com/android/emergency/edit/EditInfoActivityTest.java b/tests/unit/src/com/android/emergency/edit/EditInfoActivityTest.java
index e0049b6..5a5f463 100644
--- a/tests/unit/src/com/android/emergency/edit/EditInfoActivityTest.java
+++ b/tests/unit/src/com/android/emergency/edit/EditInfoActivityTest.java
@@ -43,7 +43,6 @@
 import com.android.emergency.preferences.EmergencyContactsPreference;
 import com.android.emergency.preferences.EmergencyEditTextPreference;
 import com.android.emergency.preferences.EmergencyListPreference;
-import com.android.emergency.preferences.NameAutoCompletePreference;
 import com.android.emergency.util.PreferenceUtils;
 
 import java.util.ArrayList;
@@ -102,8 +101,6 @@
     @Test
     public void testClearAllPreferences() {
         PreferenceManager.getDefaultSharedPreferences(mTargetContext).edit().putString(
-                PreferenceKeys.KEY_NAME, "John").commit();
-        PreferenceManager.getDefaultSharedPreferences(mTargetContext).edit().putString(
                 PreferenceKeys.KEY_ADDRESS, "Home").commit();
         PreferenceManager.getDefaultSharedPreferences(mTargetContext).edit().putString(
                 PreferenceKeys.KEY_BLOOD_TYPE, "A+").commit();
@@ -134,9 +131,6 @@
         EditInfoActivity activity = startEditInfoActivity();
         EditInfoFragment fragment = (EditInfoFragment) activity.getFragment();
 
-        final NameAutoCompletePreference namePreference =
-                (NameAutoCompletePreference) fragment.getMedicalInfoPreference(
-                        PreferenceKeys.KEY_NAME);
         final EmergencyEditTextPreference addressPreference =
                 (EmergencyEditTextPreference) fragment.getMedicalInfoPreference(
                         PreferenceKeys.KEY_ADDRESS);
@@ -159,7 +153,6 @@
                 (EmergencyContactsPreference) fragment.findPreference(
                         PreferenceKeys.KEY_EMERGENCY_CONTACTS);
 
-        String unknownName = activity.getResources().getString(R.string.unknown_name);
         String unknownAddress = activity.getResources().getString(R.string.unknown_address);
         String unknownBloodType = activity.getResources().getString(R.string.unknown_blood_type);
         String unknownAllergies = activity.getResources().getString(R.string.unknown_allergies);
@@ -168,7 +161,6 @@
                 activity.getResources().getString(R.string.unknown_medical_conditions);
         String unknownOrganDonor = activity.getResources().getString(R.string.unknown_organ_donor);
 
-        assertThat(namePreference.getSummary()).isNotEqualTo(unknownName);
         assertThat(addressPreference.getSummary()).isNotEqualTo(unknownAddress);
         assertThat(bloodTypePreference.getSummary()).isNotEqualTo(unknownBloodType);
         assertThat(allergiesPreference.getSummary()).isNotEqualTo(unknownAllergies);
@@ -199,7 +191,6 @@
 
         // After the clear all the preferences dialog is confirmed, the preferences values are
         // reloaded, and the existing object references are updated in-place.
-        assertThat(namePreference.getSummary()).isNull();
         assertThat(addressPreference.getSummary()).isNull();
         assertThat(bloodTypePreference.getSummary().toString()).isEqualTo(unknownBloodType);
         assertThat(allergiesPreference.getSummary()).isNull();
diff --git a/tests/unit/src/com/android/emergency/preferences/NameAutoCompletePreferenceTest.java b/tests/unit/src/com/android/emergency/preferences/NameAutoCompletePreferenceTest.java
deleted file mode 100644
index c4422be..0000000
--- a/tests/unit/src/com/android/emergency/preferences/NameAutoCompletePreferenceTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.emergency.preferences;
-
-import static android.support.test.espresso.Espresso.onView;
-import static android.support.test.espresso.action.ViewActions.click;
-import static android.support.test.espresso.assertion.ViewAssertions.matches;
-import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
-import static android.support.test.espresso.matcher.ViewMatchers.withText;
-import static com.google.common.truth.Truth.assertThat;
-import static org.hamcrest.Matchers.allOf;
-import static org.hamcrest.Matchers.any;
-import static org.hamcrest.Matchers.not;
-
-import android.app.Instrumentation;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Looper;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
-import android.view.View;
-
-import com.android.emergency.PreferenceKeys;
-import com.android.emergency.R;
-import com.android.emergency.edit.EditMedicalInfoActivity;
-import com.android.emergency.edit.EditMedicalInfoFragment;
-
-import org.hamcrest.Matcher;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/** Unit tests for {@link NameAutoCompletePreference}. */
-@RunWith(AndroidJUnit4.class)
-public final class NameAutoCompletePreferenceTest {
-    private NameAutoCompletePreference mNameAutoCompletePreference;
-
-    @BeforeClass
-    public static void oneTimeSetup() {
-        if (Looper.myLooper() == null) {
-            Looper.prepare();
-        }
-    }
-
-    @Before
-    public void setUp() {
-        Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
-
-        final Intent editActivityIntent = new Intent(
-                instrumentation.getTargetContext(), EditMedicalInfoActivity.class);
-        EditMedicalInfoActivity activity =
-                (EditMedicalInfoActivity) instrumentation.startActivitySync(editActivityIntent);
-        EditMedicalInfoFragment fragment = activity.getFragment();
-
-        mNameAutoCompletePreference =
-                (NameAutoCompletePreference) fragment.findPreference(PreferenceKeys.KEY_NAME);
-    }
-
-    @Test
-    public void testDialogShow() {
-        onView(withText(R.string.name)).perform(click());
-
-        onView(withText(android.R.string.ok))
-                .check(matches(isDisplayed()));
-        onView(withText(android.R.string.cancel))
-                .check(matches(isDisplayed()));
-    }
-}