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); }
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); }
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); }
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); }