7631 | 7631 |
return false;
|
7632 | 7632 |
}
|
7633 | 7633 |
|
|
7634 |
void FindCandidateIDs(const commands::Candidates &candidates,
|
|
7635 |
const string &value, vector<int> *ids) {
|
|
7636 |
CHECK(ids);
|
|
7637 |
ids->clear();
|
|
7638 |
for (size_t i = 0; i < candidates.candidate_size(); ++i) {
|
|
7639 |
const commands::Candidates::Candidate &candidate =
|
|
7640 |
candidates.candidate(i);
|
|
7641 |
LOG(INFO) << candidate.value();
|
|
7642 |
if (candidate.value() == value) {
|
|
7643 |
ids->push_back(candidate.id());
|
|
7644 |
}
|
|
7645 |
}
|
|
7646 |
}
|
|
7647 |
|
7634 | 7648 |
TEST_F(SessionTest, CommitCandidate_T13N) {
|
7635 | 7649 |
std::unique_ptr<Session> session(new Session(engine_.get()));
|
7636 | 7650 |
InitSessionToPrecomposition(session.get(), *mobile_request_);
|
|
8560 | 8574 |
}
|
8561 | 8575 |
}
|
8562 | 8576 |
|
|
8577 |
TEST_F(SessionTest, DedupAfterUndo) {
|
|
8578 |
commands::Command command;
|
|
8579 |
{
|
|
8580 |
Session session(mock_data_engine_.get());
|
|
8581 |
InitSessionToPrecomposition(&session, *mobile_request_);
|
|
8582 |
|
|
8583 |
// Undo requires capability DELETE_PRECEDING_TEXT.
|
|
8584 |
commands::Capability capability;
|
|
8585 |
capability.set_text_deletion(commands::Capability::DELETE_PRECEDING_TEXT);
|
|
8586 |
session.set_client_capability(capability);
|
|
8587 |
|
|
8588 |
SwitchInputMode(commands::HIRAGANA, &session);
|
|
8589 |
|
|
8590 |
commands::Request request(*mobile_request_);
|
|
8591 |
request.set_special_romanji_table(
|
|
8592 |
commands::Request::TWELVE_KEYS_TO_HIRAGANA);
|
|
8593 |
session.SetRequest(&request);
|
|
8594 |
|
|
8595 |
composer::Table table;
|
|
8596 |
table.InitializeWithRequestAndConfig(
|
|
8597 |
request, config::ConfigHandler::DefaultConfig());
|
|
8598 |
session.SetTable(&table);
|
|
8599 |
|
|
8600 |
// Type "!" to produce "!".
|
|
8601 |
SetSendKeyCommand("!", &command);
|
|
8602 |
session.SendKey(&command);
|
|
8603 |
EXPECT_EQ(ImeContext::COMPOSITION, session.context().state());
|
|
8604 |
// "!"
|
|
8605 |
EXPECT_EQ("\xef\xbc\x81", GetComposition(command));
|
|
8606 |
|
|
8607 |
ASSERT_TRUE(command.output().has_candidates());
|
|
8608 |
|
|
8609 |
vector<int> ids;
|
|
8610 |
// "!"
|
|
8611 |
FindCandidateIDs(
|
|
8612 |
command.output().candidates(), "\xef\xbc\x81", &ids);
|
|
8613 |
EXPECT_GE(1, ids.size());
|
|
8614 |
|
|
8615 |
FindCandidateIDs(command.output().candidates(), "!", &ids);
|
|
8616 |
EXPECT_GE(1, ids.size());
|
|
8617 |
|
|
8618 |
const int candidate_size_before_undo =
|
|
8619 |
command.output().candidates().candidate_size();
|
|
8620 |
|
|
8621 |
command.Clear();
|
|
8622 |
session.CommitFirstSuggestion(&command);
|
|
8623 |
EXPECT_FALSE(command.output().has_preedit());
|
|
8624 |
EXPECT_EQ(ImeContext::PRECOMPOSITION, session.context().state());
|
|
8625 |
|
|
8626 |
command.Clear();
|
|
8627 |
session.Undo(&command);
|
|
8628 |
EXPECT_EQ(ImeContext::COMPOSITION, session.context().state());
|
|
8629 |
EXPECT_TRUE(command.output().has_deletion_range());
|
|
8630 |
ASSERT_TRUE(command.output().has_candidates());
|
|
8631 |
|
|
8632 |
// "!"
|
|
8633 |
FindCandidateIDs(
|
|
8634 |
command.output().candidates(), "\xef\xbc\x81", &ids);
|
|
8635 |
EXPECT_GE(1, ids.size());
|
|
8636 |
|
|
8637 |
FindCandidateIDs(command.output().candidates(), "!", &ids);
|
|
8638 |
EXPECT_GE(1, ids.size());
|
|
8639 |
|
|
8640 |
EXPECT_EQ(command.output().candidates().candidate_size(),
|
|
8641 |
candidate_size_before_undo);
|
|
8642 |
}
|
|
8643 |
}
|
|
8644 |
|
8563 | 8645 |
TEST_F(SessionTest, TemporaryKeyMapChange) {
|
8564 | 8646 |
config::Config config(config::ConfigHandler::DefaultConfig());
|
8565 | 8647 |
config.set_session_keymap(config::Config::ATOK);
|