Fix a bug where bt name is updated to wrong preference. am: f6e6ae2441
am: c1d04860d5
Change-Id: I42525051bd0471dece01807c87adb0f2a38af1d1
This commit is contained in:
@@ -51,9 +51,10 @@ public class BluetoothDeviceNamePreferenceController extends AbstractPreferenceC
|
||||
|
||||
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);
|
||||
@@ -76,7 +77,7 @@ public class BluetoothDeviceNamePreferenceController extends AbstractPreferenceC
|
||||
|
||||
@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