Merge "Accept new bluetooth device name on enter press." into main
This commit is contained in:
@@ -132,7 +132,7 @@ abstract class BluetoothNameDialogFragment extends InstrumentedDialogFragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_NULL) {
|
||||||
setDeviceName(v.getText().toString());
|
setDeviceName(v.getText().toString());
|
||||||
if (mAlertDialog != null && mAlertDialog.isShowing()) {
|
if (mAlertDialog != null && mAlertDialog.isShowing()) {
|
||||||
mAlertDialog.dismiss();
|
mAlertDialog.dismiss();
|
||||||
|
@@ -33,6 +33,8 @@ public class BluetoothNameDialogFragmentTest {
|
|||||||
private TestBluetoothNameDialogFragment mBluetoothNameDialogFragment;
|
private TestBluetoothNameDialogFragment mBluetoothNameDialogFragment;
|
||||||
private TextView mTextView;
|
private TextView mTextView;
|
||||||
|
|
||||||
|
private static final String NAME_FOR_TEST = "test_device_name";
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
@@ -51,12 +53,24 @@ public class BluetoothNameDialogFragmentTest {
|
|||||||
null)).isTrue();
|
null)).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onEditorAction_ImeNull_setsDeviceName() {
|
||||||
|
|
||||||
|
|
||||||
|
mTextView.setText(NAME_FOR_TEST);
|
||||||
|
assertThat(
|
||||||
|
mBluetoothNameDialogFragment.onEditorAction(mTextView, EditorInfo.IME_NULL,
|
||||||
|
null)).isTrue();
|
||||||
|
assertThat(mBluetoothNameDialogFragment.getDeviceName()).isEqualTo(NAME_FOR_TEST);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test fragment for {@link BluetoothNameDialogFragment} to test common methods
|
* Test fragment for {@link BluetoothNameDialogFragment} to test common methods
|
||||||
*/
|
*/
|
||||||
public static class TestBluetoothNameDialogFragment extends BluetoothNameDialogFragment {
|
public static class TestBluetoothNameDialogFragment extends BluetoothNameDialogFragment {
|
||||||
|
|
||||||
|
private String mName;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getDialogTitle() {
|
protected int getDialogTitle() {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -64,12 +78,12 @@ public class BluetoothNameDialogFragmentTest {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getDeviceName() {
|
protected String getDeviceName() {
|
||||||
return null;
|
return mName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setDeviceName(String deviceName) {
|
protected void setDeviceName(String deviceName) {
|
||||||
|
mName = deviceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user