Codebase list mozc / 9fb365c
Set correct key and config for testing. With the previous implementation, preedit text was transliterated to get the query for prediction (half width ascii to full width) and this was not the expected behavior. By this change, we will be able to test the suggestion result of ascii preedit text. TODO(toshiyuki): - Use new method(Composer::SetPreeditTextForTestOnly) for other test modules or - Modify the implementation of InsertCharacterPreedit() and remove SetPreeditTextForTestOnly() if we can confirm that that will not cause any problems. REF_BUG=67485370 REF_CL=173622500 REF_TIME=2017-10-27T11:01:19+09:00 REF_TIME_RAW=1509069679 +0900 Toshiyuki Hanaoka 6 years ago
5 changed file(s) with 33 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
437437 begin += mblen;
438438 }
439439 DCHECK_EQ(begin, end);
440 }
441
442 // Note: This method is only for test.
443 void Composer::SetPreeditTextForTestOnly(const string &input) {
444 SetTemporaryInputMode(transliteration::HALF_ASCII);
445 InsertCharacterPreedit(input);
440446 }
441447
442448 void Composer::InsertCharacterPreeditForProbableKeyEvents(
139139 void DeleteRange(size_t pos, size_t length);
140140
141141 void InsertCharacter(const string &input);
142
143 // Set preedit text to composer.
144 //
145 // If you want to set preedit text for testing
146 // (to convert from HIRAGANA string rather than key input),
147 // you should use SetPreeditTextForTestOnly().
148 // With the current implementation, prediction queries can be transliterated
149 // and you will not be able to get right candidates.
142150 void InsertCharacterPreedit(const string &input);
151
152 // TEST ONLY: Set preedit text to composer.
153 //
154 // The |input| will be used in as-is form for conversion/suggestion query
155 // and will not be transliterated.
156 // For example, when the |input| will be set as "mo", suggestion will be
157 // triggered by "mo", rather than "も", or "mo", etc.
158 void SetPreeditTextForTestOnly(const string &input);
159
143160 bool InsertCharacterKeyAndPreedit(const string &key, const string &preedit);
144161 void InsertCharacterForProbableKeyEvents(
145162 const string &input,
5454 #include "protocol/commands.pb.h"
5555 #include "protocol/config.pb.h"
5656 #include "request/conversion_request.h"
57 #include "session/request_test_util.h"
5758
5859 DEFINE_int32(max_conversion_candidates_size, 200, "maximum candidates size");
5960 DEFINE_string(user_profile_dir, "", "path to user profile directory");
270271 CHECK_FIELDS_LENGTH(2);
271272 Table table;
272273 Composer composer(&table, &request, &config);
273 composer.InsertCharacterPreedit(fields[1]);
274 composer.SetPreeditTextForTestOnly(fields[1]);
274275 ConversionRequest conversion_request(&composer, &request, &config);
275276 return converter.StartConversionForRequest(conversion_request, segments);
276277 } else if (func == "convertwithnodeinfo" || func == "cn") {
289290 Table table;
290291 Composer composer(&table, &request, &config);
291292 if (fields.size() >= 2) {
292 composer.InsertCharacterPreedit(fields[1]);
293 composer.SetPreeditTextForTestOnly(fields[1]);
293294 ConversionRequest conversion_request(&composer, &request, &config);
294295 return converter.StartPredictionForRequest(conversion_request, segments);
295296 } else {
300301 Table table;
301302 Composer composer(&table, &request, &config);
302303 if (fields.size() >= 2) {
303 composer.InsertCharacterPreedit(fields[1]);
304 composer.SetPreeditTextForTestOnly(fields[1]);
304305 ConversionRequest conversion_request(&composer, &request, &config);
305306 return converter.StartSuggestionForRequest(conversion_request, segments);
306307 } else {
453454 FLAGS_magic);
454455 CHECK_EQ(status, mozc::DataManager::Status::OK);
455456
457 mozc::commands::Request request;
456458 std::unique_ptr<mozc::EngineInterface> engine;
457459 if (FLAGS_engine_type == "desktop") {
458460 engine = mozc::Engine::CreateDesktopEngine(std::move(data_manager));
459461 } else if (FLAGS_engine_type == "mobile") {
460462 engine = mozc::Engine::CreateMobileEngine(std::move(data_manager));
463 mozc::commands::RequestForUnitTest::FillMobileRequest(&request);
461464 } else {
462465 LOG(FATAL) << "Invalid type: --engine_type=" << FLAGS_engine_type;
463466 return 0;
466469 mozc::ConverterInterface *converter = engine->GetConverter();
467470 CHECK(converter);
468471
469 const mozc::commands::Request request;
470472 mozc::Segments segments;
471473 string line;
472474
202202 if (command == kConversionExpect ||
203203 command == kConversionNotExpect) {
204204 composer::Composer composer(&table, request_.get(), config_.get());
205 composer.InsertCharacterPreedit(key);
205 composer.SetPreeditTextForTestOnly(key);
206206 ConversionRequest request(&composer, request_.get(), config_.get());
207207 converter_->StartConversionForRequest(request, segments_.get());
208208 } else if (command == kReverseConversionExpect ||
211211 } else if (command == kPredictionExpect ||
212212 command == kPredictionNotExpect) {
213213 composer::Composer composer(&table, request_.get(), config_.get());
214 composer.InsertCharacterPreedit(key);
214 composer.SetPreeditTextForTestOnly(key);
215215 ConversionRequest request(&composer, request_.get(), config_.get());
216216 converter_->StartPredictionForRequest(request, segments_.get());
217217 } else if (command == kSuggestionExpect ||
218218 command == kSuggestionNotExpect) {
219219 composer::Composer composer(&table, request_.get(), config_.get());
220 composer.InsertCharacterPreedit(key);
220 composer.SetPreeditTextForTestOnly(key);
221221 ConversionRequest request(&composer, request_.get(), config_.get());
222222 converter_->StartSuggestionForRequest(request, segments_.get());
223223 } else {
2929
3030 MAJOR=2
3131 MINOR=23
32 BUILD=2754
32 BUILD=2755
3333 REVISION=102
3434 # This version represents the version of Mozc IME engine (converter, predictor,
3535 # etc.). This version info is included both in the Mozc server and in the Mozc