Fix a bug where bt name is updated to wrong preference.
Change-Id: Ica0ef6763e8868fc33773f2db917aba29193b632 Fix: 63772093 Test: robotests
This commit is contained in:
@@ -50,9 +50,10 @@ public class BluetoothDeviceNamePreferenceController extends PreferenceControlle
|
||||
|
||||
private final int mAccentColor;
|
||||
|
||||
@VisibleForTesting
|
||||
Preference mPreference;
|
||||
private LocalBluetoothManager mLocalManager;
|
||||
private LocalBluetoothAdapter mLocalAdapter;
|
||||
private Preference mPreference;
|
||||
|
||||
public BluetoothDeviceNamePreferenceController(Context context, Lifecycle lifecycle) {
|
||||
this(context, (LocalBluetoothAdapter) null);
|
||||
@@ -75,7 +76,7 @@ public class BluetoothDeviceNamePreferenceController extends PreferenceControlle
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
mPreference = screen.findPreference(KEY_DEVICE_NAME);
|
||||
mPreference = screen.findPreference(getPreferenceKey());
|
||||
super.displayPreference(screen);
|
||||
}
|
||||
|
||||
|
@@ -24,10 +24,10 @@ import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.app.FragmentManager;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.content.Context;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
@@ -53,9 +53,9 @@ public class BluetoothDeviceRenamePreferenceControllerTest {
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private Fragment mFragment;
|
||||
@Mock
|
||||
private FragmentManager mFragmentManager;
|
||||
@Mock
|
||||
private FragmentTransaction mFragmentTransaction;
|
||||
@Mock
|
||||
private PreferenceScreen mScreen;
|
||||
private Context mContext;
|
||||
private Preference mPreference;
|
||||
private BluetoothDeviceRenamePreferenceController mController;
|
||||
@@ -90,4 +90,13 @@ public class BluetoothDeviceRenamePreferenceControllerTest {
|
||||
verify(mFragmentTransaction).add(any(), anyString());
|
||||
verify(mFragmentTransaction).commit();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void displayPreference_shouldFindPreferenceWithMatchingPrefKey() {
|
||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
assertThat(mController.mPreference.getKey()).isEqualTo(mController.getPreferenceKey());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user