Beispiel #1
0
static void test_TextField_cursor()
{
    const char* text = "Hello";
    TextField* t = createTextField();
    t->setText(text);

    t->deleteCharacter();
    EXPECT_STR_EQ("Hell", t->getText());
    t->insertCharacter('o');
    EXPECT_STR_EQ("Hello", t->getText());

    for (size_t i = 0; i < strlen(text); i++) {
        t->backward();
    }
    t->backward();

    for (size_t i = 0; i < strlen(text); i++) {
        t->forward();
    }
    t->forward();

    t->insertCharacter('Z');
    EXPECT_STR_EQ("HelloZ", t->getText());
    destroyTextField(t);
}
Beispiel #2
0
static void test_TextField_ime_on()
{
    TextField* t = createTextField();
    EXPECT_EQ(false, t->isImeOn());
    toggleIme(t);
    EXPECT_TRUE(t->isImeOn());

    keyPress(t, 'a');
    keyPress(t, KeyEvent::VKEY_ENTER);
    EXPECT_STR_EQ("あ", t->getText()); // japanese hiragana A

    keyPress(t, 'i');
    keyPress(t, 'u');
    keyPress(t, KeyEvent::VKEY_ENTER);
    EXPECT_STR_EQ("あいう", t->getText()); // japanese hiragana A I U
    destroyTextField(t);
}
Beispiel #3
0
static void test_TextField_backspace_empty_ime_on()
{
    TextField* t = createTextField();
    keyPress(t, 'a');
    keyPress(t, 'b');
    toggleIme(t);
    keyPress(t, 'a');

    keyPress(t, KeyEvent::VKEY_BACKSPACE);
    EXPECT_EQ(2, t->getCursor());
    EXPECT_STR_EQ("ab", t->getText());

    // When ime buffer is empty, backspace goes to Textfield
    keyPress(t, KeyEvent::VKEY_BACKSPACE);
    EXPECT_EQ(1, t->getCursor());
    EXPECT_STR_EQ("a", t->getText());
    destroyTextField(t);
}
Beispiel #4
0
static void test_TextField_backspace_ime_on()
{
    TextField* t = createTextField();
    toggleIme(t);
    keyPress(t, 'a');
    keyPress(t, 'i');

    keyPress(t, KeyEvent::VKEY_BACKSPACE);
    EXPECT_EQ(0, t->getCursor());
    EXPECT_STR_EQ("", t->getText());

    keyPress(t, KeyEvent::VKEY_ENTER);
    EXPECT_EQ_TEXT_FIELD("あ", 1, t);
    destroyTextField(t);
}
Beispiel #5
0
static void test_TextField_remove_multi_byte_backspace()
{
    TextField* t = createTextField();
    toggleIme(t);
    keyPress(t, 'a');
    keyPress(t, 'i');

    keyPress(t, KeyEvent::VKEY_ENTER);
    EXPECT_EQ_TEXT_FIELD("あい", 2, t);
    toggleIme(t);
    keyPress(t, KeyEvent::VKEY_BACKSPACE);
    EXPECT_EQ(1, t->getCursor());
    EXPECT_STR_EQ("あ", t->getText());
    // keyPress(t, KeyEvent::VKEY_BACKSPACE);
    // EXPECT_EQ(0, t->getCursor());
    // EXPECT_STR_EQ("", t->getText());

    destroyTextField(t);
}
Beispiel #6
0
static void test_TextField_ime_off()
{
    TextField* t = createTextField();
    keyPress(t, 'a');
    EXPECT_STR_EQ("a", t->getText());

    keyPress(t, 'i');
    EXPECT_EQ_TEXT_FIELD("ai", 2, t);

    keyPress(t, KeyEvent::VKEY_BACKSPACE);
    EXPECT_EQ_TEXT_FIELD("a", 1, t);

    keyPress(t, KeyEvent::VKEY_LEFT);
    EXPECT_EQ_TEXT_FIELD("a", 0, t);

    keyPress(t, 'c');
    EXPECT_EQ_TEXT_FIELD("ca", 1, t);

    keyPress(t, KeyEvent::VKEY_RIGHT);
    EXPECT_EQ(2, t->getCursor());
    keyPress(t, 'b');
    EXPECT_EQ_TEXT_FIELD("cab", 3, t);
    destroyTextField(t);
}