Codebase list mozc / 51242df
Fix #374: Duplicate candidates after Undo For all platforms, config.use_cascading_window is true by default. For some platforms such as Android Session class does overwrite the setting whether we actually show cascading window to ImeContext. So the candidate list is not the same among the platforms. Here, for Windows/Mac, full-width "!" is not in the candidate list, but in the cascading window. BUG=#374 TEST= REF_BUG=28285701 REF_CL=124801184,125129727 REF_TIME=2016-06-14T13:01:13+09:00 REF_TIME_RAW=1465876873 +0900 Toshiyuki Hanaoka 7 years ago
3 changed file(s) with 88 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
00 MAJOR=2
11 MINOR=18
2 BUILD=2574
2 BUILD=2575
33 REVISION=102
44 # CAUTION: NACL_DICTIONARY_VERSION is going to be migrated to ENGINE_VERSION.
55 # NACL_DICTIONARY_VERSION is the target version of the system dictionary to be
11831183 session_converter->previous_suggestions_.CopyFrom(previous_suggestions_);
11841184 session_converter->conversion_preferences_ = conversion_preferences();
11851185 session_converter->result_->CopyFrom(*result_);
1186 session_converter->request_ = request_;
1187 session_converter->config_ = config_;
1188 session_converter->use_cascading_window_ = use_cascading_window_;
1189 session_converter->selected_candidate_indices_ = selected_candidate_indices_;
11861190
11871191 if (session_converter->CheckState(SUGGESTION | PREDICTION | CONVERSION)) {
1192 // UpdateCandidateList() is not simple setter and it uses some members.
11881193 session_converter->UpdateCandidateList();
11891194 session_converter->candidate_list_->MoveToId(candidate_list_->focused_id());
11901195 session_converter->SetCandidateListVisible(candidate_list_visible_);
11911196 }
1192
1193 session_converter->request_ = request_;
1194 session_converter->config_ = config_;
1195 session_converter->selected_candidate_indices_ = selected_candidate_indices_;
11961197
11971198 return session_converter;
11981199 }
76317631 return false;
76327632 }
76337633
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
76347648 TEST_F(SessionTest, CommitCandidate_T13N) {
76357649 std::unique_ptr<Session> session(new Session(engine_.get()));
76367650 InitSessionToPrecomposition(session.get(), *mobile_request_);
85608574 }
85618575 }
85628576
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
85638645 TEST_F(SessionTest, TemporaryKeyMapChange) {
85648646 config::Config config(config::ConfigHandler::DefaultConfig());
85658647 config.set_session_keymap(config::Config::ATOK);