nus-yam/ex-repair huggingface dataset:
Program: 157284
Project: 157284
Buggy source:
@Test public void testSendsEnterIfNoneAction() throws Exception {
  mAnySoftKeyboardUnderTest.onFinishInputView(true);
  mAnySoftKeyboardUnderTest.onFinishInput();
  EditorInfo editorInfo=TestableAnySoftKeyboard.createEditorInfo(EditorInfo.IME_ACTION_NONE,InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
  mAnySoftKeyboardUnderTest.onStartInput(editorInfo,false);
  mAnySoftKeyboardUnderTest.onStartInputView(editorInfo,false);
  TestInputConnection inputConnection=(TestInputConnection)mAnySoftKeyboardUnderTest.getCurrentInputConnection();
  Assert.assertEquals(0,inputConnection.getLastEditorAction());
  mAnySoftKeyboardUnderTest.simulateKeyPress(KeyCodes.ENTER);
  Assert.assertEquals(0,inputConnection.getLastEditorAction());
}

Fixed version (ground truth):
@Test public void testSendsEnterIfNoneAction() throws Exception {
  mAnySoftKeyboardUnderTest.onFinishInputView(true);
  mAnySoftKeyboardUnderTest.onFinishInput();
  EditorInfo editorInfo=TestableAnySoftKeyboard.createEditorInfo(EditorInfo.IME_ACTION_NONE,InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
  mAnySoftKeyboardUnderTest.onStartInput(editorInfo,false);
  mAnySoftKeyboardUnderTest.onStartInputView(editorInfo,false);
  TestInputConnection inputConnection=(TestInputConnection)mAnySoftKeyboardUnderTest.getCurrentInputConnection();
  Assert.assertEquals(0,inputConnection.getLastEditorAction());
  mAnySoftKeyboardUnderTest.simulateKeyPress(KeyCodes.ENTER);
  Assert.assertEquals(0,inputConnection.getLastEditorAction());
  Assert.assertEquals("String_Node_Str",inputConnection.getCurrentTextInInputConnection());
}
Program: 157285
Project: 157285
Buggy source:
@Test public void testEditorPerformsActionIfImeOptionsSpecified() throws Exception {
  mAnySoftKeyboardUnderTest.onFinishInputView(true);
  mAnySoftKeyboardUnderTest.onFinishInput();
  EditorInfo editorInfo=TestableAnySoftKeyboard.createEditorInfo(EditorInfo.IME_ACTION_DONE,InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
  mAnySoftKeyboardUnderTest.onStartInput(editorInfo,false);
  mAnySoftKeyboardUnderTest.onStartInputView(editorInfo,false);
  TestInputConnection inputConnection=(TestInputConnection)mAnySoftKeyboardUnderTest.getCurrentInputConnection();
  Assert.assertEquals(0,inputConnection.getLastEditorAction());
  mAnySoftKeyboardUnderTest.simulateKeyPress(KeyCodes.ENTER);
  Assert.assertEquals(EditorInfo.IME_ACTION_DONE,inputConnection.getLastEditorAction());
}

Fixed version (ground truth):
@Test public void testEditorPerformsActionIfImeOptionsSpecified() throws Exception {
  mAnySoftKeyboardUnderTest.onFinishInputView(true);
  mAnySoftKeyboardUnderTest.onFinishInput();
  EditorInfo editorInfo=TestableAnySoftKeyboard.createEditorInfo(EditorInfo.IME_ACTION_DONE,InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
  mAnySoftKeyboardUnderTest.onStartInput(editorInfo,false);
  mAnySoftKeyboardUnderTest.onStartInputView(editorInfo,false);
  TestInputConnection inputConnection=(TestInputConnection)mAnySoftKeyboardUnderTest.getCurrentInputConnection();
  Assert.assertEquals(0,inputConnection.getLastEditorAction());
  mAnySoftKeyboardUnderTest.simulateKeyPress(KeyCodes.ENTER);
  Assert.assertEquals(EditorInfo.IME_ACTION_DONE,inputConnection.getLastEditorAction());
  Assert.assertEquals("String_Node_Str",inputConnection.getCurrentTextInInputConnection());
}
Program: 157286
Project: 157286
Buggy source:
@Test public void testSendsENTERKeyEventIfShiftIsNotPressedAndImeDoesNotHaveAction(){
  TestInputConnection inputConnection=(TestInputConnection)mAnySoftKeyboardUnderTest.getCurrentInputConnection();
  mAnySoftKeyboardUnderTest.simulateKeyPress(KeyCodes.ENTER);
  ArgumentCaptor<KeyEvent> keyEventArgumentCaptor=ArgumentCaptor.forClass(KeyEvent.class);
  Mockito.verify(inputConnection,Mockito.times(2)).sendKeyEvent(keyEventArgumentCaptor.capture());
  Assert.assertEquals(2,keyEventArgumentCaptor.getAllValues().size());
  Assert.assertEquals(KeyEvent.KEYCODE_ENTER,keyEventArgumentCaptor.getAllValues().get(0).getKeyCode());
  Assert.assertEquals(KeyEvent.ACTION_DOWN,keyEventArgumentCaptor.getAllValues().get(0).getAction());
  Assert.assertEquals(KeyEvent.KEYCODE_ENTER,keyEventArgumentCaptor.getAllValues().get(1).getKeyCode());
  Assert.assertEquals(KeyEvent.ACTION_UP,keyEventArgumentCaptor.getAllValues().get(1).getAction());
  Mockito.verify(inputConnection,Mockito.never()).commitText("String_Node_Str",1);
}

Fixed version (ground truth):
@Test public void testSendsENTERKeyEventIfShiftIsNotPressedAndImeDoesNotHaveAction(){
  TestInputConnection inputConnection=(TestInputConnection)mAnySoftKeyboardUnderTest.getCurrentInputConnection();
  mAnySoftKeyboardUnderTest.simulateKeyPress(KeyCodes.ENTER);
  ArgumentCaptor<KeyEvent> keyEventArgumentCaptor=ArgumentCaptor.forClass(KeyEvent.class);
  Mockito.verify(inputConnection,Mockito.times(2)).sendKeyEvent(keyEventArgumentCaptor.capture());
  Assert.assertEquals(2,keyEventArgumentCaptor.getAllValues().size());
  Assert.assertEquals(KeyEvent.KEYCODE_ENTER,keyEventArgumentCaptor.getAllValues().get(0).getKeyCode());
  Assert.assertEquals(KeyEvent.ACTION_DOWN,keyEventArgumentCaptor.getAllValues().get(0).getAction());
  Assert.assertEquals(KeyEvent.KEYCODE_ENTER,keyEventArgumentCaptor.getAllValues().get(1).getKeyCode());
  Assert.assertEquals(KeyEvent.ACTION_UP,keyEventArgumentCaptor.getAllValues().get(1).getAction());
  Assert.assertEquals("String_Node_Str",inputConnection.getCurrentTextInInputConnection());
}
Program: 157287
Project: 157287
Buggy source:
@Override public boolean sendKeyEvent(KeyEvent event){
  boolean handled=false;
  if (event.getAction() == KeyEvent.ACTION_UP) {
    if (event.getKeyCode() == KeyEvent.KEYCODE_DEL) {
      if (mSelectionEndPosition == mCursorPosition) {
        handled=true;
        deleteSurroundingText(1,0);
      }
 else {
        handled=true;
        mInputText.delete(mCursorPosition,mSelectionEndPosition);
        notifyTextChange(0);
      }
    }
 else     if (event.getKeyCode() == KeyEvent.KEYCODE_SPACE) {
      handled=true;
      commitText("String_Node_Str",1);
    }
 else     if (event.getKeyCode() >= KeyEvent.KEYCODE_0 || event.getKeyCode() <= KeyEvent.KEYCODE_9) {
      handled=true;
      commitText(Integer.toString(event.getKeyCode() - KeyEvent.KEYCODE_0),1);
    }
 else     if (event.getKeyCode() >= KeyEvent.KEYCODE_A || event.getKeyCode() <= KeyEvent.KEYCODE_Z) {
      handled=true;
      commitText("String_Node_Str" + (char)(event.getKeyCode() - KeyEvent.KEYCODE_A + 'a'),1);
    }
  }
  if (!handled) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
      mIme.onKeyDown(event.getKeyCode(),event);
    }
 else {
      mIme.onKeyUp(event.getKeyCode(),event);
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean sendKeyEvent(KeyEvent event){
  boolean handled=false;
  if (event.getAction() == KeyEvent.ACTION_UP) {
    if (event.getKeyCode() == KeyEvent.KEYCODE_DEL) {
      if (mSelectionEndPosition == mCursorPosition) {
        handled=true;
        deleteSurroundingText(1,0);
      }
 else {
        handled=true;
        mInputText.delete(mCursorPosition,mSelectionEndPosition);
        notifyTextChange(0);
      }
    }
 else     if (event.getKeyCode() == KeyEvent.KEYCODE_SPACE) {
      handled=true;
      commitText("String_Node_Str",1);
    }
 else     if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
      handled=true;
      commitText("String_Node_Str",1);
    }
 else     if (event.getKeyCode() >= KeyEvent.KEYCODE_0 || event.getKeyCode() <= KeyEvent.KEYCODE_9) {
      handled=true;
      commitText(Integer.toString(event.getKeyCode() - KeyEvent.KEYCODE_0),1);
    }
 else     if (event.getKeyCode() >= KeyEvent.KEYCODE_A || event.getKeyCode() <= KeyEvent.KEYCODE_Z) {
      handled=true;
      commitText("String_Node_Str" + (char)(event.getKeyCode() - KeyEvent.KEYCODE_A + 'a'),1);
    }
  }
  if (!handled) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
      mIme.onKeyDown(event.getKeyCode(),event);
    }
 else {
      mIme.onKeyUp(event.getKeyCode(),event);
    }
  }
  return true;
}
Program: 157289
Project: 157289
Buggy source:
private void nextKeyboard(EditorInfo currentEditorInfo,KeyboardSwitcher.NextKeyboardType type){
  getKeyboardSwitcher().nextKeyboard(currentEditorInfo,type);
  setKeyboardFinalStuff();
}

Fixed version (ground truth):
private void nextKeyboard(EditorInfo currentEditorInfo,KeyboardSwitcher.NextKeyboardType type){
  getKeyboardSwitcher().nextKeyboard(currentEditorInfo,type);
}
Program: 157290
Project: 157290
Buggy source:
private void showLanguageSelectionDialog(){
  KeyboardAddOnAndBuilder[] builders=getKeyboardSwitcher().getEnabledKeyboardsBuilders();
  ArrayList<CharSequence> keyboardsIds=new ArrayList<>();
  ArrayList<CharSequence> keyboards=new ArrayList<>();
  for (  KeyboardAddOnAndBuilder keyboardBuilder : builders) {
    keyboardsIds.add(keyboardBuilder.getId());
    String name=keyboardBuilder.getName();
    keyboards.add(name);
  }
  final CharSequence[] ids=new CharSequence[keyboardsIds.size()];
  final CharSequence[] items=new CharSequence[keyboards.size()];
  keyboardsIds.toArray(ids);
  keyboards.toArray(items);
  showOptionsDialogWithData(getText(R.string.select_keyboard_popup_title),R.drawable.ic_keyboard_globe_menu,items,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface di,    int position){
      CharSequence id=ids[position];
      Logger.d(TAG,"String_Node_Str",items[position],id);
      EditorInfo currentEditorInfo=getCurrentInputEditorInfo();
      getKeyboardSwitcher().nextAlphabetKeyboard(currentEditorInfo,id.toString());
      setKeyboardFinalStuff();
    }
  }
);
}

Fixed version (ground truth):
private void showLanguageSelectionDialog(){
  KeyboardAddOnAndBuilder[] builders=getKeyboardSwitcher().getEnabledKeyboardsBuilders();
  ArrayList<CharSequence> keyboardsIds=new ArrayList<>();
  ArrayList<CharSequence> keyboards=new ArrayList<>();
  for (  KeyboardAddOnAndBuilder keyboardBuilder : builders) {
    keyboardsIds.add(keyboardBuilder.getId());
    String name=keyboardBuilder.getName();
    keyboards.add(name);
  }
  final CharSequence[] ids=new CharSequence[keyboardsIds.size()];
  final CharSequence[] items=new CharSequence[keyboards.size()];
  keyboardsIds.toArray(ids);
  keyboards.toArray(items);
  showOptionsDialogWithData(getText(R.string.select_keyboard_popup_title),R.drawable.ic_keyboard_globe_menu,items,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface di,    int position){
      CharSequence id=ids[position];
      Logger.d(TAG,"String_Node_Str",items[position],id);
      EditorInfo currentEditorInfo=getCurrentInputEditorInfo();
      getKeyboardSwitcher().nextAlphabetKeyboard(currentEditorInfo,id.toString());
    }
  }
);
}
Program: 157291
Project: 157291
Buggy source:
void closeDictionaries(){
  mSuggest.closeDictionaries();
  mLastDictionaryRefresh=-1;
}

Fixed version (ground truth):
void closeDictionaries(){
  mSuggest.closeDictionaries();
}
Program: 157293
Project: 157293
Buggy source:
@Override public void onAlphabetKeyboardSet(@NonNull AnyKeyboard keyboard){
  super.onAlphabetKeyboardSet(keyboard);
  setKeyboardForView(keyboard);
}

Fixed version (ground truth):
@Override public void onAlphabetKeyboardSet(@NonNull AnyKeyboard keyboard){
  super.onAlphabetKeyboardSet(keyboard);
  setKeyboardForView(keyboard);
  setKeyboardFinalStuff();
}
Program: 157294
Project: 157294
Buggy source:
@Test public void testDoesNotCloseDictionaryIfInputRestartsQuickly(){
  final EditorInfo editorInfo=TestableAnySoftKeyboard.createEditorInfoTextWithSuggestions();
  mAnySoftKeyboardUnderTest.onStartInput(editorInfo,false);
  mAnySoftKeyboardUnderTest.onCreateInputView();
  mAnySoftKeyboardUnderTest.onStartInputView(editorInfo,false);
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest()).setUserDictionary(Mockito.isNotNull(Dictionary.class));
  Mockito.reset(mAnySoftKeyboardUnderTest.getSpiedSuggest());
  mAnySoftKeyboardUnderTest.onFinishInputView(true);
  mAnySoftKeyboardUnderTest.onFinishInput();
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest(),Mockito.never()).closeDictionaries();
  ShadowSystemClock.sleep(10);
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest(),Mockito.never()).closeDictionaries();
  mAnySoftKeyboardUnderTest.onStartInput(editorInfo,false);
  mAnySoftKeyboardUnderTest.onStartInputView(editorInfo,false);
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest(),Mockito.never()).setUserDictionary(Mockito.any(Dictionary.class));
}

Fixed version (ground truth):
@Test public void testDoesNotCloseDictionaryIfInputRestartsQuickly(){
  final EditorInfo editorInfo=TestableAnySoftKeyboard.createEditorInfoTextWithSuggestions();
  mAnySoftKeyboardUnderTest.onStartInput(editorInfo,false);
  mAnySoftKeyboardUnderTest.onCreateInputView();
  mAnySoftKeyboardUnderTest.onStartInputView(editorInfo,false);
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest()).setUserDictionary(Mockito.isNotNull(Dictionary.class));
  Mockito.reset(mAnySoftKeyboardUnderTest.getSpiedSuggest());
  mAnySoftKeyboardUnderTest.onFinishInputView(true);
  mAnySoftKeyboardUnderTest.onFinishInput();
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest(),Mockito.never()).closeDictionaries();
  ShadowSystemClock.sleep(10);
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest(),Mockito.never()).closeDictionaries();
  mAnySoftKeyboardUnderTest.onStartInput(editorInfo,false);
  mAnySoftKeyboardUnderTest.onStartInputView(editorInfo,false);
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest()).setUserDictionary(Mockito.any(Dictionary.class));
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest(),Mockito.never()).closeDictionaries();
}
Program: 157295
Project: 157295
Buggy source:
@Before public void setUp() throws Exception {
  ServiceController<TestableAnySoftKeyboard> mAnySoftKeyboardController=Robolectric.buildService(TestableAnySoftKeyboard.class);
  mAnySoftKeyboardUnderTest=mAnySoftKeyboardController.attach().create().get();
  Assert.assertNotNull(mAnySoftKeyboardUnderTest.getSpiedSuggest());
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest(),Mockito.never()).setUserDictionary(Mockito.any(Dictionary.class));
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest(),Mockito.never()).setAutoDictionary(Mockito.any(Dictionary.class));
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest(),Mockito.never()).setContactsDictionary(Mockito.any(Context.class),Mockito.anyBoolean());
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest(),Mockito.never()).setMainDictionary(Mockito.any(Context.class),Mockito.any(DictionaryAddOnAndBuilder.class));
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest()).setCorrectionMode(true,true,2,3,2);
  Mockito.reset(mAnySoftKeyboardUnderTest.getSpiedSuggest());
  UserDictionary userDictionary=new UserDictionary(RuntimeEnvironment.application,"String_Node_Str");
  userDictionary.loadDictionary();
  for (int wordIndex=0; wordIndex < DICTIONATY_WORDS.length; wordIndex++) {
    userDictionary.addWord(DICTIONATY_WORDS[wordIndex],DICTIONATY_WORDS.length - wordIndex);
  }
  userDictionary.close();
}

Fixed version (ground truth):
@Before public void setUp() throws Exception {
  ServiceController<TestableAnySoftKeyboard> mAnySoftKeyboardController=Robolectric.buildService(TestableAnySoftKeyboard.class);
  mAnySoftKeyboardUnderTest=mAnySoftKeyboardController.attach().create().get();
  Assert.assertNotNull(mAnySoftKeyboardUnderTest.getSpiedSuggest());
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest(),Mockito.never()).setUserDictionary(Mockito.any(Dictionary.class));
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest(),Mockito.never()).setAutoDictionary(Mockito.any(Dictionary.class));
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest(),Mockito.never()).setContactsDictionary(Mockito.any(Context.class),Mockito.anyBoolean());
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest(),Mockito.never()).setMainDictionary(Mockito.any(Context.class),Mockito.any(DictionaryAddOnAndBuilder.class));
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest()).setCorrectionMode(true,true,2,3,2);
  Mockito.reset(mAnySoftKeyboardUnderTest.getSpiedSuggest());
  UserDictionary userDictionary=new UserDictionary(RuntimeEnvironment.application,"String_Node_Str");
  userDictionary.loadDictionary();
  for (int wordIndex=0; wordIndex < DICTIONATY_WORDS.length; wordIndex++) {
    userDictionary.addWord(DICTIONATY_WORDS[wordIndex],DICTIONATY_WORDS.length - wordIndex);
  }
  userDictionary.close();
  Mockito.reset(mAnySoftKeyboardUnderTest.getSpiedSuggest());
}
Program: 157297
Project: 157297
Buggy source:
private void updateStatistics(SharedPreferences sp,Context context){
  boolean firstAppInstall=false;
  boolean firstVersionInstall=false;
  final String FIRST_APP_VERSION_INSTALL=context.getString(R.string.settings_key_first_app_version_installed);
  if (!sp.contains(FIRST_APP_VERSION_INSTALL)) {
    firstAppInstall=true;
  }
  final String LAST_APP_VERSION_INSTALLED=context.getString(R.string.settings_key_last_app_version_installed);
  if (sp.getInt(LAST_APP_VERSION_INSTALLED,0) != BuildConfig.VERSION_CODE) {
    firstVersionInstall=true;
  }
  if (firstAppInstall || firstVersionInstall) {
    Editor editor=sp.edit();
    final long installTime=System.currentTimeMillis();
    if (firstAppInstall) {
      editor.putInt(FIRST_APP_VERSION_INSTALL,BuildConfig.VERSION_CODE);
      editor.putLong(context.getString(R.string.settings_key_first_time_app_installed),installTime);
    }
    if (firstVersionInstall) {
      editor.putInt(LAST_APP_VERSION_INSTALLED,BuildConfig.VERSION_CODE);
      editor.putLong(context.getString(R.string.settings_key_first_time_current_version_installed),installTime);
    }
    editor.commit();
  }
}

Fixed version (ground truth):
private void updateStatistics(SharedPreferences sp,Context context){
  boolean firstAppInstall=false;
  boolean firstVersionInstall=false;
  final String FIRST_APP_VERSION_INSTALL=context.getString(R.string.settings_key_first_app_version_installed);
  if (!sp.contains(FIRST_APP_VERSION_INSTALL)) {
    firstAppInstall=true;
  }
  final String LAST_APP_VERSION_INSTALLED=context.getString(R.string.settings_key_last_app_version_installed);
  if (sp.getInt(LAST_APP_VERSION_INSTALLED,0) != BuildConfig.VERSION_CODE) {
    firstVersionInstall=true;
  }
  if (firstAppInstall || firstVersionInstall) {
    Editor editor=sp.edit();
    final long installTime=System.currentTimeMillis();
    if (firstAppInstall) {
      editor.putInt(FIRST_APP_VERSION_INSTALL,BuildConfig.VERSION_CODE);
      editor.putLong(context.getString(R.string.settings_key_first_time_app_installed),installTime);
    }
    if (firstVersionInstall) {
      editor.putInt(LAST_APP_VERSION_INSTALLED,BuildConfig.VERSION_CODE);
      editor.putLong(context.getString(R.string.settings_key_first_time_current_version_installed),installTime);
    }
    SharedPreferencesCompat.EditorCompat.getInstance().apply(editor);
  }
}
Program: 157298
Project: 157298
Buggy source:
/** 
 * The purpose of this function is to set in the preferences file the computed values. This is required since the Preferences xml UI elements can not take computed values, only static ones, as default. So, the computed default could be one, and the static default may be another! See https://github.com/AnySoftKeyboard/AnySoftKeyboard/issues/110
 */
private void initializeComputedValues(SharedPreferences sp){
  boolean drawType=sp.getBoolean(mContext.getString(R.string.settings_key_workaround_disable_rtl_fix),getAlwaysUseDrawTextDefault());
  Editor e=sp.edit();
  e.putBoolean(mContext.getString(R.string.settings_key_workaround_disable_rtl_fix),drawType);
  e.commit();
}

Fixed version (ground truth):
/** 
 * The purpose of this function is to set in the preferences file the computed values. This is required since the Preferences xml UI elements can not take computed values, only static ones, as default. So, the computed default could be one, and the static default may be another! See https://github.com/AnySoftKeyboard/AnySoftKeyboard/issues/110
 */
private void initializeComputedValues(SharedPreferences sp){
  boolean drawType=sp.getBoolean(mContext.getString(R.string.settings_key_workaround_disable_rtl_fix),getAlwaysUseDrawTextDefault());
  Editor e=sp.edit();
  e.putBoolean(mContext.getString(R.string.settings_key_workaround_disable_rtl_fix),drawType);
  SharedPreferencesCompat.EditorCompat.getInstance().apply(e);
}
Program: 157301
Project: 157301
Buggy source:
public static List<KeyboardAddOnAndBuilder> getEnabledKeyboards(Context askContext){
  final List<KeyboardAddOnAndBuilder> allAddOns=msInstance.getAllAddOns(askContext);
  Logger.i(TAG,"String_Node_Str" + allAddOns.size() + "String_Node_Str");
  final SharedPreferences sharedPreferences=PreferenceManager.getDefaultSharedPreferences(askContext);
  final ArrayList<KeyboardAddOnAndBuilder> enabledAddOns=new ArrayList<>();
  for (int addOnIndex=0; addOnIndex < allAddOns.size(); addOnIndex++) {
    final KeyboardAddOnAndBuilder addOn=allAddOns.get(addOnIndex);
    final boolean addOnEnabled=sharedPreferences.getBoolean(addOn.getId(),addOn.getKeyboardDefaultEnabled());
    if (addOnEnabled) {
      enabledAddOns.add(addOn);
    }
  }
  if (enabledAddOns.size() == 0) {
    final SharedPreferences.Editor editor=sharedPreferences.edit();
    final KeyboardAddOnAndBuilder addOn=allAddOns.get(0);
    editor.putBoolean(addOn.getId(),true);
    editor.commit();
    enabledAddOns.add(addOn);
  }
  if (BuildConfig.TESTING_BUILD) {
    for (    final KeyboardAddOnAndBuilder addOn : enabledAddOns) {
      Logger.d(TAG,"String_Node_Str",addOn.getId());
    }
  }
  return enabledAddOns;
}

Fixed version (ground truth):
public static List<KeyboardAddOnAndBuilder> getEnabledKeyboards(Context askContext){
  final List<KeyboardAddOnAndBuilder> allAddOns=msInstance.getAllAddOns(askContext);
  Logger.i(TAG,"String_Node_Str" + allAddOns.size() + "String_Node_Str");
  final SharedPreferences sharedPreferences=PreferenceManager.getDefaultSharedPreferences(askContext);
  final ArrayList<KeyboardAddOnAndBuilder> enabledAddOns=new ArrayList<>();
  for (int addOnIndex=0; addOnIndex < allAddOns.size(); addOnIndex++) {
    final KeyboardAddOnAndBuilder addOn=allAddOns.get(addOnIndex);
    final boolean addOnEnabled=sharedPreferences.getBoolean(addOn.getId(),addOn.getKeyboardDefaultEnabled());
    if (addOnEnabled) {
      enabledAddOns.add(addOn);
    }
  }
  if (enabledAddOns.size() == 0) {
    final SharedPreferences.Editor editor=sharedPreferences.edit();
    final KeyboardAddOnAndBuilder addOn=allAddOns.get(0);
    editor.putBoolean(addOn.getId(),true);
    SharedPreferencesCompat.EditorCompat.getInstance().apply(editor);
    enabledAddOns.add(addOn);
  }
  if (BuildConfig.TESTING_BUILD) {
    for (    final KeyboardAddOnAndBuilder addOn : enabledAddOns) {
      Logger.d(TAG,"String_Node_Str",addOn.getId());
    }
  }
  return enabledAddOns;
}
Program: 157302
Project: 157302
Buggy source:
public static void storeOrderedEnabledQuickKeys(Context applicationContext,List<QuickTextKey> orderedKeys){
  SharedPreferences sharedPreferences=PreferenceManager.getDefaultSharedPreferences(applicationContext);
  String settingKey=applicationContext.getString(R.string.settings_key_ordered_active_quick_text_keys);
  Set<String> storedKeys=new HashSet<>();
  List<String> quickKeyIdOrder=new ArrayList<>(orderedKeys.size());
  for (  QuickTextKey key : orderedKeys) {
    final String id=key.getId();
    if (!storedKeys.contains(id))     quickKeyIdOrder.add(id);
    storedKeys.add(id);
  }
  SharedPreferences.Editor editor=sharedPreferences.edit();
  editor.putString(settingKey,TextUtils.join("String_Node_Str",quickKeyIdOrder)).commit();
}

Fixed version (ground truth):
public static void storeOrderedEnabledQuickKeys(Context applicationContext,List<QuickTextKey> orderedKeys){
  SharedPreferences sharedPreferences=PreferenceManager.getDefaultSharedPreferences(applicationContext);
  String settingKey=applicationContext.getString(R.string.settings_key_ordered_active_quick_text_keys);
  Set<String> storedKeys=new HashSet<>();
  List<String> quickKeyIdOrder=new ArrayList<>(orderedKeys.size());
  for (  QuickTextKey key : orderedKeys) {
    final String id=key.getId();
    if (!storedKeys.contains(id))     quickKeyIdOrder.add(id);
    storedKeys.add(id);
  }
  SharedPreferences.Editor editor=sharedPreferences.edit();
  editor.putString(settingKey,TextUtils.join("String_Node_Str",quickKeyIdOrder));
  SharedPreferencesCompat.EditorCompat.getInstance().apply(editor);
}
Program: 157303
Project: 157303
Buggy source:
public void setLastSelectedAddOnId(@Nullable String addOnId){
  mSharedPreferences.edit().putString(KEY_QUICK_TEXT_PREF_LAST_SELECTED_TAB_ADD_ON_ID,addOnId).commit();
}

Fixed version (ground truth):
public void setLastSelectedAddOnId(@Nullable String addOnId){
  final SharedPreferences.Editor editor=mSharedPreferences.edit().putString(KEY_QUICK_TEXT_PREF_LAST_SELECTED_TAB_ADD_ON_ID,addOnId);
  SharedPreferencesCompat.EditorCompat.getInstance().apply(editor);
}
Program: 157304
Project: 157304
Buggy source:
public static KeyboardTheme getCurrentKeyboardTheme(Context appContext){
  SharedPreferences sharedPreferences=PreferenceManager.getDefaultSharedPreferences(appContext);
  String settingKey=appContext.getString(R.string.settings_key_keyboard_theme_key);
  String selectedThemeId=sharedPreferences.getString(settingKey,appContext.getString(R.string.settings_default_keyboard_theme_key));
  KeyboardTheme selectedTheme=null;
  List<KeyboardTheme> themes=msInstance.getAllAddOns(appContext);
  for (  KeyboardTheme aTheme : themes) {
    if (aTheme.getId().equals(selectedThemeId)) {
      selectedTheme=aTheme;
      break;
    }
  }
  if (selectedTheme == null) {
    selectedTheme=themes.get(0);
    SharedPreferences.Editor editor=sharedPreferences.edit();
    editor.putString(settingKey,selectedTheme.getId());
    editor.commit();
  }
  return selectedTheme;
}

Fixed version (ground truth):
public static KeyboardTheme getCurrentKeyboardTheme(Context appContext){
  SharedPreferences sharedPreferences=PreferenceManager.getDefaultSharedPreferences(appContext);
  String settingKey=appContext.getString(R.string.settings_key_keyboard_theme_key);
  String selectedThemeId=sharedPreferences.getString(settingKey,appContext.getString(R.string.settings_default_keyboard_theme_key));
  KeyboardTheme selectedTheme=null;
  List<KeyboardTheme> themes=msInstance.getAllAddOns(appContext);
  for (  KeyboardTheme aTheme : themes) {
    if (aTheme.getId().equals(selectedThemeId)) {
      selectedTheme=aTheme;
      break;
    }
  }
  if (selectedTheme == null) {
    selectedTheme=themes.get(0);
    SharedPreferences.Editor editor=sharedPreferences.edit();
    editor.putString(settingKey,selectedTheme.getId());
    SharedPreferencesCompat.EditorCompat.getInstance().apply(editor);
  }
  return selectedTheme;
}
Program: 157305
Project: 157305
Buggy source:
public static void setTracingRequested(Context applicationContext,boolean enabled){
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(applicationContext);
  Editor e=prefs.edit();
  e.putBoolean(KEY_SDCARD_TRACING_ENABLED,enabled);
  e.commit();
}

Fixed version (ground truth):
public static void setTracingRequested(Context applicationContext,boolean enabled){
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(applicationContext);
  Editor e=prefs.edit();
  e.putBoolean(KEY_SDCARD_TRACING_ENABLED,enabled);
  SharedPreferencesCompat.EditorCompat.getInstance().apply(e);
}
Program: 157306
Project: 157306
Buggy source:
@Override protected final void onEnabledAddOnsChanged(@NonNull List<String> newEnabledAddOns){
  SharedPreferences.Editor editor=PreferenceManager.getDefaultSharedPreferences(getContext()).edit();
  editor.putString(getString(mPrefKeyResourceId),newEnabledAddOns.get(0));
  editor.commit();
}

Fixed version (ground truth):
@Override protected final void onEnabledAddOnsChanged(@NonNull List<String> newEnabledAddOns){
  SharedPreferences.Editor editor=PreferenceManager.getDefaultSharedPreferences(getContext()).edit();
  editor.putString(getString(mPrefKeyResourceId),newEnabledAddOns.get(0));
  SharedPreferencesCompat.EditorCompat.getInstance().apply(editor);
}
Program: 157307
Project: 157307
Buggy source:
private static boolean firstTestersTimeVersionLoaded(Context context){
  final String KEY="String_Node_Str";
  SharedPreferences sp=PreferenceManager.getDefaultSharedPreferences(context);
  final String lastDebugVersionHash=sp.getString(KEY,"String_Node_Str");
  String currentHash=BuildConfig.VERSION_NAME + "String_Node_Str" + BuildConfig.VERSION_CODE;
  Editor e=sp.edit();
  e.putString(KEY,currentHash);
  e.commit();
  return !currentHash.equals(lastDebugVersionHash);
}

Fixed version (ground truth):
private static boolean firstTestersTimeVersionLoaded(Context context){
  final String KEY="String_Node_Str";
  SharedPreferences sp=PreferenceManager.getDefaultSharedPreferences(context);
  final String lastDebugVersionHash=sp.getString(KEY,"String_Node_Str");
  String currentHash=BuildConfig.VERSION_NAME + "String_Node_Str" + BuildConfig.VERSION_CODE;
  Editor e=sp.edit();
  e.putString(KEY,currentHash);
  SharedPreferencesCompat.EditorCompat.getInstance().apply(e);
  return !currentHash.equals(lastDebugVersionHash);
}
Program: 157310
Project: 157310
Buggy source:
@Test public void testAsksToAddToDictionaryWhenTouchingTypedUnknownWordAndAdds(){
  TestInputConnection inputConnection=(TestInputConnection)mAnySoftKeyboardUnderTest.getCurrentInputConnection();
  mAnySoftKeyboardUnderTest.simulateTextTyping("String_Node_Str");
  mAnySoftKeyboardUnderTest.pickSuggestionManually(0,"String_Node_Str");
  Mockito.verify(mAnySoftKeyboardUnderTest.getMockCandidateView()).showAddToDictionaryHint("String_Node_Str");
  Assert.assertEquals("String_Node_Str",inputConnection.getCurrentTextInInputConnection());
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest(),Mockito.never()).addWordToUserDictionary(Mockito.anyString());
  Mockito.verify(mAnySoftKeyboardUnderTest.getMockCandidateView(),Mockito.never()).notifyAboutWordAdded(Mockito.anyString());
  mAnySoftKeyboardUnderTest.addWordToDictionary("String_Node_Str");
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest()).addWordToUserDictionary("String_Node_Str");
  Mockito.verify(mAnySoftKeyboardUnderTest.getMockCandidateView()).notifyAboutWordAdded("String_Node_Str");
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest(),Mockito.never()).removeWordFromUserDictionary(Mockito.anyString());
  mAnySoftKeyboardUnderTest.removeFromUserDictionary("String_Node_Str");
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest()).removeWordFromUserDictionary("String_Node_Str");
}

Fixed version (ground truth):
@Test public void testAsksToAddToDictionaryWhenTouchingTypedUnknownWordAndAdds(){
  TestInputConnection inputConnection=(TestInputConnection)mAnySoftKeyboardUnderTest.getCurrentInputConnection();
  mAnySoftKeyboardUnderTest.simulateTextTyping("String_Node_Str");
  mAnySoftKeyboardUnderTest.pickSuggestionManually(0,"String_Node_Str");
  Mockito.verify(mAnySoftKeyboardUnderTest.getMockCandidateView()).showAddToDictionaryHint("String_Node_Str");
  Assert.assertEquals("String_Node_Str",inputConnection.getCurrentTextInInputConnection());
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest(),Mockito.never()).addWordToUserDictionary(Mockito.anyString());
  Mockito.verify(mAnySoftKeyboardUnderTest.getMockCandidateView(),Mockito.never()).notifyAboutWordAdded(Mockito.anyString());
  Assert.assertTrue(mAnySoftKeyboardUnderTest.isAddToDictionartHintShown());
  mAnySoftKeyboardUnderTest.addWordToDictionary("String_Node_Str");
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest()).addWordToUserDictionary("String_Node_Str");
  Mockito.verify(mAnySoftKeyboardUnderTest.getMockCandidateView()).notifyAboutWordAdded("String_Node_Str");
  Assert.assertFalse(mAnySoftKeyboardUnderTest.isAddToDictionartHintShown());
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest(),Mockito.never()).removeWordFromUserDictionary(Mockito.anyString());
  mAnySoftKeyboardUnderTest.removeFromUserDictionary("String_Node_Str");
  Mockito.verify(mAnySoftKeyboardUnderTest.getSpiedSuggest()).removeWordFromUserDictionary("String_Node_Str");
}
Program: 157311
Project: 157311
Buggy source:
public void resetMockCandidateView(){
  Mockito.reset(mMockCandidateView);
  Mockito.doAnswer(new Answer(){
    @Override public Object answer(    InvocationOnMock invocation) throws Throwable {
      boolean previousState=mCandidateShowsHint;
      mCandidateShowsHint=false;
      return previousState;
    }
  }
).when(mMockCandidateView).dismissAddToDictionaryHint();
  Mockito.doAnswer(new Answer(){
    @Override public Object answer(    InvocationOnMock invocation) throws Throwable {
      mCandidateShowsHint=true;
      return null;
    }
  }
).when(mMockCandidateView).showAddToDictionaryHint(Mockito.any(CharSequence.class));
}

Fixed version (ground truth):
public void resetMockCandidateView(){
  Mockito.reset(mMockCandidateView);
  Mockito.doAnswer(new Answer(){
    @Override public Object answer(    InvocationOnMock invocation) throws Throwable {
      boolean previousState=mCandidateShowsHint;
      mCandidateShowsHint=false;
      return previousState;
    }
  }
).when(mMockCandidateView).dismissAddToDictionaryHint();
  Mockito.doAnswer(new Answer(){
    @Override public Object answer(    InvocationOnMock invocation) throws Throwable {
      mCandidateShowsHint=true;
      return null;
    }
  }
).when(mMockCandidateView).showAddToDictionaryHint(Mockito.any(CharSequence.class));
  Mockito.doAnswer(new Answer(){
    @Override public Object answer(    InvocationOnMock invocation) throws Throwable {
      mCandidateShowsHint=false;
      return null;
    }
  }
).when(mMockCandidateView).notifyAboutWordAdded(Mockito.any(CharSequence.class));
}
Program: 157312
Project: 157312
Buggy source:
@Override public Object answer(InvocationOnMock invocation) throws Throwable {
  mCandidateShowsHint=true;
  return null;
}

Fixed version (ground truth):
@Override public Object answer(InvocationOnMock invocation) throws Throwable {
  mCandidateShowsHint=false;
  return null;
}
Program: 157315
Project: 157315
Buggy source:
private boolean pickDefaultSuggestion(boolean autoCorrectToPreferred){
  if (mKeyboardHandler.hasMessages(KeyboardUIStateHandler.MSG_UPDATE_SUGGESTIONS)) {
    performUpdateSuggestions();
  }
  final CharSequence typedWord=mWord.getTypedWord();
  final CharSequence bestWord=autoCorrectToPreferred ? mWord.getPreferredWord() : typedWord;
  Logger.d(TAG,"String_Node_Str",bestWord,mAutoCorrectOn);
  if (!TextUtils.isEmpty(bestWord)) {
    TextEntryState.acceptedDefault(typedWord);
    final boolean fixed=!typedWord.equals(pickSuggestion(bestWord,!bestWord.equals(typedWord)));
    if (!fixed) {
      checkAddToDictionaryWithAutoDictionary(mWord,mAutoComplete ? AutoDictionary.AdditionType.Picked : AutoDictionary.AdditionType.Typed);
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
private boolean pickDefaultSuggestion(boolean autoCorrectToPreferred){
  if (mKeyboardHandler.hasMessages(KeyboardUIStateHandler.MSG_UPDATE_SUGGESTIONS)) {
    performUpdateSuggestions();
  }
  final CharSequence typedWord=mWord.getTypedWord();
  final CharSequence bestWord=autoCorrectToPreferred ? mWord.getPreferredWord() : typedWord;
  Logger.d(TAG,"String_Node_Str",bestWord,mAutoCorrectOn);
  if (!TextUtils.isEmpty(bestWord)) {
    TextEntryState.acceptedDefault(typedWord);
    final CharSequence outputWord=pickSuggestion(bestWord,!bestWord.equals(typedWord));
    final boolean fixed=!typedWord.equals(outputWord);
    if (!fixed) {
      checkAddToDictionaryWithAutoDictionary(mWord,mAutoComplete ? AutoDictionary.AdditionType.Picked : AutoDictionary.AdditionType.Typed);
    }
    return true;
  }
  return false;
}
Program: 157316
Project: 157316
Buggy source:
public static void typedCharacter(char c,boolean isSeparator){
  final boolean isSpace=c == ' ';
switch (sState) {
case IN_WORD:
    if (isSpace || isSeparator) {
      sState=State.START;
    }
  break;
case ACCEPTED_DEFAULT:
case PICKED_SUGGESTION:
case PICKED_CORRECTION:
case PICKED_TYPED_ADDED_TO_DICTIONARY:
if (isSpace) {
  if (sState == State.ACCEPTED_DEFAULT || sState == State.SPACE_AFTER_PICKED) {
    sState=State.SPACE_AFTER_ACCEPTED;
  }
 else {
    sState=State.SPACE_AFTER_PICKED;
  }
}
 else if (isSeparator) {
  sState=State.PUNCTUATION_AFTER_ACCEPTED;
}
 else {
  sState=State.IN_WORD;
}
break;
case START:
case UNKNOWN:
case SPACE_AFTER_ACCEPTED:
case SPACE_AFTER_PICKED:
case PUNCTUATION_AFTER_ACCEPTED:
case PUNCTUATION_AFTER_WORD:
if (!isSpace && !isSeparator) {
sState=State.IN_WORD;
}
 else {
sState=State.START;
}
break;
case UNDO_COMMIT:
if (isSpace || isSeparator) {
sState=State.ACCEPTED_DEFAULT;
}
 else {
sState=State.IN_WORD;
}
break;
case CORRECTING:
sState=State.START;
break;
}
displayState();
}

Fixed version (ground truth):
public static void typedCharacter(char c,boolean isSeparator){
  final boolean isSpace=c == ' ';
switch (sState) {
case IN_WORD:
    if (isSpace || isSeparator) {
      sState=State.START;
    }
  break;
case ACCEPTED_DEFAULT:
if (isSpace) {
  sState=State.SPACE_AFTER_ACCEPTED;
}
 else if (isSeparator) {
  sState=State.PUNCTUATION_AFTER_ACCEPTED;
}
 else {
  sState=State.IN_WORD;
}
break;
case PICKED_SUGGESTION:
case PICKED_CORRECTION:
case PICKED_TYPED_ADDED_TO_DICTIONARY:
if (isSpace) {
sState=State.SPACE_AFTER_PICKED;
}
 else if (isSeparator) {
sState=State.PUNCTUATION_AFTER_PICKED;
}
 else {
sState=State.IN_WORD;
}
break;
case START:
case UNKNOWN:
case SPACE_AFTER_ACCEPTED:
case SPACE_AFTER_PICKED:
case PUNCTUATION_AFTER_ACCEPTED:
case PUNCTUATION_AFTER_PICKED:
if (!isSpace && !isSeparator) {
sState=State.IN_WORD;
}
 else {
sState=State.START;
}
break;
case UNDO_COMMIT:
if (isSpace || isSeparator) {
sState=State.ACCEPTED_DEFAULT;
}
 else {
sState=State.IN_WORD;
}
break;
case CORRECTING:
sState=State.START;
break;
}
displayState();
}
Program: 157317
Project: 157317
Buggy source:
private static State getNextStateOnBackSpace(State currentState){
switch (currentState) {
case ACCEPTED_DEFAULT:
case SPACE_AFTER_ACCEPTED:
case PUNCTUATION_AFTER_ACCEPTED:
case PICKED_TYPED_ADDED_TO_DICTIONARY:
    return State.UNDO_COMMIT;
case SPACE_AFTER_PICKED:
case PICKED_SUGGESTION:
  return State.UNKNOWN;
case UNDO_COMMIT:
return State.IN_WORD;
default :
return currentState;
}
}

Fixed version (ground truth):
private static State getNextStateOnBackSpace(State currentState){
switch (currentState) {
case ACCEPTED_DEFAULT:
case SPACE_AFTER_ACCEPTED:
case PUNCTUATION_AFTER_ACCEPTED:
    return State.UNDO_COMMIT;
case PICKED_TYPED_ADDED_TO_DICTIONARY:
case SPACE_AFTER_PICKED:
case PICKED_SUGGESTION:
case PUNCTUATION_AFTER_PICKED:
  return State.UNKNOWN;
case UNDO_COMMIT:
return State.IN_WORD;
default :
return currentState;
}
}
Program: 157318
Project: 157318
Buggy source:
public static void acceptedSuggestion(CharSequence typedWord,CharSequence actualWord){
  State oldState=sState;
  if (typedWord.equals(actualWord)) {
    acceptedTyped();
  }
  if (oldState == State.CORRECTING || oldState == State.PICKED_CORRECTION) {
    sState=State.PICKED_CORRECTION;
  }
 else {
    sState=State.PICKED_SUGGESTION;
  }
  displayState();
}

Fixed version (ground truth):
public static void acceptedSuggestion(CharSequence typedWord,CharSequence actualWord){
  State oldState=sState;
  if (typedWord.equals(actualWord)) {
    acceptedTyped();
  }
 else   if (oldState == State.CORRECTING || oldState == State.PICKED_CORRECTION) {
    sState=State.PICKED_CORRECTION;
  }
 else {
    sState=State.PICKED_SUGGESTION;
  }
  displayState();
}
Program: 157319
Project: 157319
Buggy source:
@Test public void testBackSpaceCorrectlyWhenEditingManuallyPickedWord(){
  TestInputConnection inputConnection=(TestInputConnection)mAnySoftKeyboardUnderTest.getCurrentInputConnection();
  verifyNoSuggestionsInteractions();
  mAnySoftKeyboardUnderTest.simulateTextTyping("String_Node_Str");
  verifySuggestions(true,"String_Node_Str","String_Node_Str","String_Node_Str");
  Assert.assertEquals("String_Node_Str",inputConnection.getLastCommitCorrection());
  mAnySoftKeyboardUnderTest.pickSuggestionManually(0,"String_Node_Str");
  Assert.assertEquals("String_Node_Str",inputConnection.getCurrentTextInInputConnection());
  inputConnection.setSelection(2,2);
  Assert.assertEquals("String_Node_Str",inputConnection.getCurrentTextInInputConnection());
  Assert.assertEquals(2,inputConnection.getCurrentStartPosition());
  mAnySoftKeyboardUnderTest.simulateKeyPress(KeyCodes.DELETE,true);
  Assert.assertEquals("String_Node_Str",inputConnection.getCurrentTextInInputConnection());
  Assert.assertEquals(1,inputConnection.getCurrentStartPosition());
}

Fixed version (ground truth):
@Test public void testBackSpaceCorrectlyWhenEditingManuallyPickedWord(){
  TestInputConnection inputConnection=(TestInputConnection)mAnySoftKeyboardUnderTest.getCurrentInputConnection();
  verifyNoSuggestionsInteractions();
  mAnySoftKeyboardUnderTest.simulateTextTyping("String_Node_Str");
  verifySuggestions(true,"String_Node_Str","String_Node_Str","String_Node_Str");
  Assert.assertEquals("String_Node_Str",inputConnection.getLastCommitCorrection());
  mAnySoftKeyboardUnderTest.pickSuggestionManually(0,"String_Node_Str");
  Assert.assertEquals("String_Node_Str",inputConnection.getCurrentTextInInputConnection());
  inputConnection.setSelection(2,2);
  Assert.assertEquals("String_Node_Str",inputConnection.getCurrentTextInInputConnection());
  Assert.assertEquals(2,inputConnection.getCurrentStartPosition());
  mAnySoftKeyboardUnderTest.simulateKeyPress(KeyCodes.DELETE);
  Assert.assertEquals("String_Node_Str",inputConnection.getCurrentTextInInputConnection());
  Assert.assertEquals(1,inputConnection.getCurrentStartPosition());
}
Program: 157321
Project: 157321
Buggy source:
public boolean setShiftLocked(boolean shiftLocked){
  if (keyboardSupportShift()) {
    final int initialState=mShiftState;
    if (shiftLocked) {
      mShiftState=STICKY_KEY_LOCKED;
    }
 else     if (mShiftState == STICKY_KEY_LOCKED) {
      mShiftState=STICKY_KEY_ON;
    }
    setShiftViewAsState();
    return initialState != mShiftState;
  }
  return false;
}

Fixed version (ground truth):
public boolean setShiftLocked(boolean shiftLocked){
  if (keyboardSupportShift()) {
    final int initialState=mShiftState;
    if (shiftLocked) {
      mShiftState=STICKY_KEY_LOCKED;
    }
 else     if (mShiftState == STICKY_KEY_LOCKED) {
      mShiftState=STICKY_KEY_ON;
    }
    return initialState != mShiftState;
  }
  return false;
}
Program: 157324
Project: 157324
Buggy source:
@Override public boolean setShifted(boolean shiftState){
  if (keyboardSupportShift()) {
    final int initialState=mShiftState;
    if (shiftState) {
      if (mShiftState == STICKY_KEY_OFF) {
        mShiftState=STICKY_KEY_ON;
      }
    }
 else {
      mShiftState=STICKY_KEY_OFF;
    }
    setShiftViewAsState();
    return mShiftState != initialState;
  }
 else {
    super.setShifted(shiftState);
    return false;
  }
}

Fixed version (ground truth):
@Override public boolean setShifted(boolean shiftState){
  if (keyboardSupportShift()) {
    final int initialState=mShiftState;
    if (shiftState) {
      if (mShiftState == STICKY_KEY_OFF) {
        mShiftState=STICKY_KEY_ON;
      }
    }
 else {
      mShiftState=STICKY_KEY_OFF;
    }
    return mShiftState != initialState;
  }
 else {
    super.setShifted(shiftState);
    return false;
  }
}
Program: 157325
Project: 157325
Buggy source:
private boolean isAlphabetKey(Key key){
  return (!key.modifier) && (!key.sticky) && (!key.repeatable)&& (key.getPrimaryCode() > 0);
}

Fixed version (ground truth):
private boolean isAlphabetKey(Key key){
  return (!key.repeatable) && (key.getPrimaryCode() > 0);
}
Program: 157326
Project: 157326
Buggy source:
public boolean setControl(boolean control){
  if (mControlKey != null) {
    final int initialState=mControlState;
    if (control) {
      if (mControlState == STICKY_KEY_OFF) {
        mControlState=STICKY_KEY_ON;
      }
    }
 else {
      mControlState=STICKY_KEY_OFF;
    }
    setControlViewAsState();
    return mControlState != initialState;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
public boolean setControl(boolean control){
  if (mControlKey != null) {
    final int initialState=mControlState;
    if (control) {
      if (mControlState == STICKY_KEY_OFF) {
        mControlState=STICKY_KEY_ON;
      }
    }
 else {
      mControlState=STICKY_KEY_OFF;
    }
    return mControlState != initialState;
  }
 else {
    return false;
  }
}
Program: 157327
Project: 157327
Buggy source:
public boolean setShifted(boolean shiftState){
  if (mShiftKey != null) {
    mShiftKey.on=shiftState;
  }
  if (mShifted != shiftState) {
    mShifted=shiftState;
    return true;
  }
  return false;
}

Fixed version (ground truth):
public boolean setShifted(boolean shiftState){
  if (mShifted != shiftState) {
    mShifted=shiftState;
    return true;
  }
  return false;
}
Program: 157328
Project: 157328
Buggy source:
/** 
 * Returns the drawable state for the key, based on the current state and type of the key.
 * @return the drawable state of the key.
 * @see android.graphics.drawable.StateListDrawable#setState(int[])
 */
public int[] getCurrentDrawableState(KeyDrawableStateProvider provider){
  int[] states=provider.KEY_STATE_NORMAL;
  if (on) {
    if (pressed) {
      states=provider.KEY_STATE_PRESSED_ON;
    }
 else {
      states=provider.KEY_STATE_NORMAL_ON;
    }
  }
 else {
    if (sticky) {
      if (pressed) {
        states=provider.KEY_STATE_PRESSED_OFF;
      }
 else {
        states=provider.KEY_STATE_NORMAL_OFF;
      }
    }
 else {
      if (pressed) {
        states=provider.KEY_STATE_PRESSED;
      }
    }
  }
  return states;
}

Fixed version (ground truth):
/** 
 * Returns the drawable state for the key, based on the current state and type of the key.
 * @return the drawable state of the key.
 * @see android.graphics.drawable.StateListDrawable#setState(int[])
 */
public int[] getCurrentDrawableState(KeyDrawableStateProvider provider){
  int[] states=provider.KEY_STATE_NORMAL;
  if (pressed) {
    states=provider.KEY_STATE_PRESSED;
  }
  return states;
}
Program: 157332
Project: 157332
Buggy source:
@Override public void showPreview(int keyIndex,PointerTracker tracker){
  final boolean hidePreviewOrShowSpaceKeyPreview=(tracker == null);
  final Key key=hidePreviewOrShowSpaceKeyPreview ? null : tracker.getKey(keyIndex);
  if (keyIndex != NOT_A_KEY && key != null) {
    Drawable iconToDraw=getIconToDrawForKey(key,true);
    if (iconToDraw != null) {
      mKeyPreviewsManager.showPreviewForKey(key,iconToDraw);
    }
 else {
      CharSequence label=tracker.getPreviewText(key,mKeyboard.isShifted());
      if (TextUtils.isEmpty(label)) {
        label=guessLabelForKey(key.getPrimaryCode());
      }
      mKeyPreviewsManager.showPreviewForKey(key,label);
    }
  }
}

Fixed version (ground truth):
@Override public void showPreview(int keyIndex,PointerTracker tracker){
  final boolean hidePreviewOrShowSpaceKeyPreview=(tracker == null);
  final Key key=hidePreviewOrShowSpaceKeyPreview ? null : tracker.getKey(keyIndex);
  if (keyIndex != NOT_A_KEY && key != null) {
    Drawable iconToDraw=getIconToDrawForKey(key,true);
    if (iconToDraw != null) {
      mKeyPreviewsManager.showPreviewForKey(key,iconToDraw);
    }
 else {
      CharSequence label=tracker.getPreviewText(key);
      if (TextUtils.isEmpty(label)) {
        label=guessLabelForKey(key.getPrimaryCode());
      }
      mKeyPreviewsManager.showPreviewForKey(key,label);
    }
  }
}