Search in sources :

Example 1 with Event

use of com.android.inputmethod.event.Event in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class InputLogicTestsDeadKeys method testDeadAcuteLetterBackspace.

public void testDeadAcuteLetterBackspace() {
    final int MODIFIER_LETTER_ACUTE = 0xB4;
    final String EXPECTED_RESULT1 = "aá";
    final String EXPECTED_RESULT2 = "a";
    final EventList events = new EventList().addCodePoint('a', false).addCodePoint(MODIFIER_LETTER_ACUTE, true).addCodePoint('a', false);
    for (final Event event : events) {
        mLatinIME.onEvent(event);
    }
    assertEquals("dead acute on a typed", EXPECTED_RESULT1, mEditText.getText().toString());
    mLatinIME.onEvent(Event.createSoftwareKeypressEvent(Event.NOT_A_CODE_POINT, Constants.CODE_DELETE, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, false));
    assertEquals("a with acute deleted", EXPECTED_RESULT2, mEditText.getText().toString());
}
Also used : Event(com.android.inputmethod.event.Event)

Example 2 with Event

use of com.android.inputmethod.event.Event in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class InputLogicTestsDeadKeys method testDeadDiaeresisSpace.

public void testDeadDiaeresisSpace() {
    final int MODIFIER_LETTER_DIAERESIS = 0xA8;
    final String EXPECTED_RESULT = "a¨e¨i";
    final EventList events = new EventList().addCodePoint('a', false).addCodePoint(MODIFIER_LETTER_DIAERESIS, true).addCodePoint(Constants.CODE_SPACE, false).addCodePoint('e', false).addCodePoint(MODIFIER_LETTER_DIAERESIS, true).addCodePoint(Constants.CODE_ENTER, false).addCodePoint('i', false);
    for (final Event event : events) {
        mLatinIME.onEvent(event);
    }
    assertEquals("dead diaeresis space commits the dead char", EXPECTED_RESULT, mEditText.getText().toString());
}
Also used : Event(com.android.inputmethod.event.Event)

Example 3 with Event

use of com.android.inputmethod.event.Event in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class InputLogicTestsDeadKeys method testDeadCircumflexSimple.

public void testDeadCircumflexSimple() {
    final int MODIFIER_LETTER_CIRCUMFLEX_ACCENT = 0x02C6;
    final String EXPECTED_RESULT = "aê";
    final EventList events = new EventList().addCodePoint('a', false).addCodePoint(MODIFIER_LETTER_CIRCUMFLEX_ACCENT, true).addCodePoint('e', false);
    for (final Event event : events) {
        mLatinIME.onEvent(event);
    }
    assertEquals("simple dead circumflex", EXPECTED_RESULT, mEditText.getText().toString());
}
Also used : Event(com.android.inputmethod.event.Event)

Example 4 with Event

use of com.android.inputmethod.event.Event in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class InputLogicTestsDeadKeys method testDeadCircumflexDeadDiaeresisBackspace.

public void testDeadCircumflexDeadDiaeresisBackspace() {
    final int MODIFIER_LETTER_CIRCUMFLEX_ACCENT = 0x02C6;
    final int MODIFIER_LETTER_DIAERESIS = 0xA8;
    final String EXPECTED_RESULT = "û";
    final EventList events = new EventList().addCodePoint(MODIFIER_LETTER_CIRCUMFLEX_ACCENT, true).addCodePoint(MODIFIER_LETTER_DIAERESIS, true).addKey(Constants.CODE_DELETE).addCodePoint('u', false);
    for (final Event event : events) {
        mLatinIME.onEvent(event);
    }
    assertEquals("dead circumflex, dead diaeresis, backspace, u", EXPECTED_RESULT, mEditText.getText().toString());
}
Also used : Event(com.android.inputmethod.event.Event)

Example 5 with Event

use of com.android.inputmethod.event.Event in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class InputTestsBase method typeInternal.

// type(int) and type(String): helper methods to send a code point resp. a string to LatinIME.
protected void typeInternal(final int codePoint, final boolean isKeyRepeat) {
    // onPressKey and onReleaseKey are explicitly deactivated here, but they do happen in the
    // code (although multitouch/slide input and other factors make the sequencing complicated).
    // They are supposed to be entirely deconnected from the input logic from LatinIME point of
    // view and only delegates to the parts of the code that care. So we don't include them here
    // to keep these tests as pinpoint as possible and avoid bringing it too many dependencies,
    // but keep them in mind if something breaks. Commenting them out as is should work.
    //mLatinIME.onPressKey(codePoint, 0 /* repeatCount */, true /* isSinglePointer */);
    final Key key = mKeyboard.getKey(codePoint);
    final Event event;
    if (key == null) {
        event = Event.createSoftwareKeypressEvent(codePoint, Event.NOT_A_KEY_CODE, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, isKeyRepeat);
    } else {
        final int x = key.getX() + key.getWidth() / 2;
        final int y = key.getY() + key.getHeight() / 2;
        event = LatinIME.createSoftwareKeypressEvent(codePoint, x, y, isKeyRepeat);
    }
    mLatinIME.onEvent(event);
// Also see the comment at the top of this function about onReleaseKey
//mLatinIME.onReleaseKey(codePoint, false /* withSliding */);
}
Also used : Event(com.android.inputmethod.event.Event) Key(com.android.inputmethod.keyboard.Key) Point(android.graphics.Point)

Aggregations

Event (com.android.inputmethod.event.Event)21 KeyEvent (android.view.KeyEvent)6 InputTransaction (com.android.inputmethod.event.InputTransaction)3 Point (android.graphics.Point)1 SpannableString (android.text.SpannableString)1 Key (com.android.inputmethod.keyboard.Key)1 MainKeyboardView (com.android.inputmethod.keyboard.MainKeyboardView)1 SuggestedWords (com.android.inputmethod.latin.SuggestedWords)1 Nonnull (javax.annotation.Nonnull)1