58 | 58 |
#include "usage_stats/usage_stats.h"
|
59 | 59 |
#include "usage_stats/usage_stats_testing_util.h"
|
60 | 60 |
|
|
61 |
namespace mozc {
|
|
62 |
|
|
63 |
class ConverterInterface;
|
|
64 |
class PredictorInterface;
|
|
65 |
|
|
66 |
namespace dictionary { class SuppressionDictionary; }
|
|
67 |
|
|
68 |
namespace session {
|
|
69 |
namespace {
|
|
70 |
|
61 | 71 |
using ::mozc::commands::Request;
|
62 | 72 |
using ::mozc::usage_stats::UsageStats;
|
63 | |
|
64 | |
namespace mozc {
|
65 | |
|
66 | |
class ConverterInterface;
|
67 | |
class PredictorInterface;
|
68 | |
|
69 | |
namespace dictionary { class SuppressionDictionary; }
|
70 | |
|
71 | |
namespace session {
|
72 | |
namespace {
|
73 | |
|
74 | |
// "あいうえお"
|
75 | |
const char kAiueo[] =
|
76 | |
"\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86\xE3\x81\x88\xE3\x81\x8A";
|
77 | |
// " "
|
78 | |
const char kFullWidthSpace[] = "\xE3\x80\x80";
|
79 | |
// "アイウエオ"
|
80 | |
const char kKatakanaAiueo[] =
|
81 | |
"\xe3\x82\xa2\xe3\x82\xa4\xe3\x82\xa6\xe3\x82\xa8\xe3\x82\xaa";
|
82 | |
// "あ"
|
83 | |
const char kHiraganaA[] = "\xE3\x81\x82";
|
84 | |
// "a"
|
85 | |
const char kFullWidthSmallA[] = "\xEF\xBD\x81";
|
86 | 73 |
|
87 | 74 |
void SetSendKeyCommandWithKeyString(const string &key_string,
|
88 | 75 |
commands::Command *command) {
|
|
609 | 596 |
Segment::Candidate *candidate;
|
610 | 597 |
|
611 | 598 |
segment = segments->add_segment();
|
612 | |
// "あいうえお"
|
613 | |
segment->set_key(kAiueo);
|
|
599 |
segment->set_key("あいうえお");
|
614 | 600 |
candidate = segment->add_candidate();
|
615 | |
// "あいうえお"
|
616 | |
candidate->key = kAiueo;
|
617 | |
candidate->content_key = kAiueo;
|
618 | |
candidate->value = kAiueo;
|
|
601 |
candidate->key = "あいうえお";
|
|
602 |
candidate->content_key = "あいうえお";
|
|
603 |
candidate->value = "あいうえお";
|
619 | 604 |
candidate = segment->add_candidate();
|
620 | |
// "アイウエオ"
|
621 | |
candidate->key = kAiueo;
|
622 | |
candidate->content_key = kAiueo;
|
623 | |
candidate->value = kKatakanaAiueo;
|
|
605 |
candidate->key = "あいうえお";
|
|
606 |
candidate->content_key = "あいうえお";
|
|
607 |
candidate->value = "アイウエオ";
|
624 | 608 |
}
|
625 | 609 |
|
626 | 610 |
void InitSessionToDirect(Session* session) {
|
|
686 | 670 |
segments->Clear();
|
687 | 671 |
segment = segments->add_segment();
|
688 | 672 |
|
689 | |
// "ぃ"
|
690 | |
segment->set_key("\xE3\x81\x83");
|
|
673 |
segment->set_key("ぃ");
|
691 | 674 |
candidate = segment->add_candidate();
|
692 | |
// "ぃ"
|
693 | |
candidate->value = "\xE3\x81\x83";
|
|
675 |
candidate->value = "ぃ";
|
694 | 676 |
|
695 | 677 |
candidate = segment->add_candidate();
|
696 | |
// "ィ"
|
697 | |
candidate->value = "\xE3\x82\xA3";
|
|
678 |
candidate->value = "ィ";
|
698 | 679 |
|
699 | 680 |
segment = segments->add_segment();
|
700 | |
// "け"
|
701 | |
segment->set_key("\xE3\x81\x91");
|
|
681 |
segment->set_key("け");
|
702 | 682 |
candidate = segment->add_candidate();
|
703 | |
// "家"
|
704 | |
candidate->value = "\xE5\xAE\xB6";
|
|
683 |
candidate->value = "家";
|
705 | 684 |
candidate = segment->add_candidate();
|
706 | |
// "け"
|
707 | |
candidate->value = "\xE3\x81\x91";
|
|
685 |
candidate->value = "け";
|
708 | 686 |
}
|
709 | 687 |
|
710 | 688 |
void FillT13Ns(const ConversionRequest &request, Segments *segments) {
|
|
816 | 794 |
command.Clear();
|
817 | 795 |
session->Convert(&command);
|
818 | 796 |
EXPECT_FALSE(command.output().has_result());
|
819 | |
// "あいうえお"
|
820 | |
EXPECT_PREEDIT(kAiueo, command);
|
|
797 |
EXPECT_PREEDIT("あいうえお", command);
|
821 | 798 |
|
822 | 799 |
GetConverterMock()->SetCommitSegmentValue(&segments, true);
|
823 | 800 |
command.Clear();
|
824 | 801 |
|
825 | 802 |
session->Commit(&command);
|
826 | 803 |
EXPECT_FALSE(command.output().has_preedit());
|
827 | |
// "あいうえお"
|
828 | |
EXPECT_RESULT(kAiueo, command);
|
|
804 |
EXPECT_RESULT("あいうえお", command);
|
829 | 805 |
}
|
830 | 806 |
}
|
831 | 807 |
|
|
869 | 845 |
InitSessionToPrecomposition(session.get());
|
870 | 846 |
commands::Command command;
|
871 | 847 |
SendKey("a", session.get(), &command);
|
872 | |
// "あ"
|
873 | |
EXPECT_SINGLE_SEGMENT(kHiraganaA, command)
|
|
848 |
EXPECT_SINGLE_SEGMENT("あ", command)
|
874 | 849 |
<< "Global Romaji table should be initialized for each test fixture.";
|
875 | 850 |
}
|
876 | 851 |
}
|
|
929 | 904 |
InsertCharacterChars("k", session.get(), &command);
|
930 | 905 |
SendCommand(commands::SessionCommand::SUBMIT, session.get(), &command);
|
931 | 906 |
EXPECT_TRUE(command.output().consumed());
|
932 | |
// "k"
|
933 | |
EXPECT_RESULT("\xef\xbd\x8b", command);
|
|
907 |
EXPECT_RESULT("k", command);
|
934 | 908 |
EXPECT_FALSE(command.output().has_preedit());
|
935 | 909 |
EXPECT_FALSE(command.output().has_candidates());
|
936 | 910 |
|
937 | 911 |
// SWITCH_INPUT_MODE
|
938 | 912 |
SendKey("a", session.get(), &command);
|
939 | |
EXPECT_SINGLE_SEGMENT(kHiraganaA, command);
|
|
913 |
EXPECT_SINGLE_SEGMENT("あ", command);
|
940 | 914 |
|
941 | 915 |
SwitchInputMode(commands::FULL_ASCII, session.get());
|
942 | 916 |
|
943 | 917 |
SendKey("a", session.get(), &command);
|
944 | |
// "あa"
|
945 | |
EXPECT_SINGLE_SEGMENT("\xE3\x81\x82\xEF\xBD\x81", command);
|
|
918 |
EXPECT_SINGLE_SEGMENT("あa", command);
|
946 | 919 |
|
947 | 920 |
// GET_STATUS
|
948 | 921 |
SendCommand(commands::SessionCommand::GET_STATUS, session.get(), &command);
|
|
981 | 954 |
|
982 | 955 |
// SWITCH_INPUT_MODE
|
983 | 956 |
SendKey("a", session.get(), &command);
|
984 | |
EXPECT_SINGLE_SEGMENT(kHiraganaA, command);
|
|
957 |
EXPECT_SINGLE_SEGMENT("あ", command);
|
985 | 958 |
|
986 | 959 |
SwitchInputMode(commands::FULL_ASCII, session.get());
|
987 | 960 |
|
988 | 961 |
SendKey("a", session.get(), &command);
|
989 | |
// "あa"
|
990 | |
EXPECT_SINGLE_SEGMENT("\xE3\x81\x82\xEF\xBD\x81", command);
|
|
962 |
EXPECT_SINGLE_SEGMENT("あa", command);
|
991 | 963 |
|
992 | 964 |
// GET_STATUS
|
993 | 965 |
SendCommand(commands::SessionCommand::GET_STATUS, session.get(), &command);
|
|
1017 | 989 |
EXPECT_EQ(commands::HIRAGANA, command.output().mode());
|
1018 | 990 |
|
1019 | 991 |
SendKey("a", session.get(), &command);
|
1020 | |
// "あ"
|
1021 | |
EXPECT_SINGLE_SEGMENT(kHiraganaA, command);
|
|
992 |
EXPECT_SINGLE_SEGMENT("あ", command);
|
1022 | 993 |
|
1023 | 994 |
// GET_STATUS
|
1024 | 995 |
SendCommand(commands::SessionCommand::GET_STATUS, session.get(), &command);
|
|
1052 | 1023 |
EXPECT_FALSE(command.output().has_candidates());
|
1053 | 1024 |
|
1054 | 1025 |
SendKey("a", session.get(), &command);
|
1055 | |
EXPECT_SINGLE_SEGMENT(kHiraganaA, command);
|
|
1026 |
EXPECT_SINGLE_SEGMENT("あ", command);
|
1056 | 1027 |
}
|
1057 | 1028 |
|
1058 | 1029 |
TEST_F(SessionTest, InputMode) {
|
|
1100 | 1071 |
session->SendCommand(&command);
|
1101 | 1072 |
EXPECT_TRUE(command.output().consumed());
|
1102 | 1073 |
EXPECT_FALSE(command.output().has_result());
|
1103 | |
// "アイウエオ"
|
1104 | |
EXPECT_PREEDIT(
|
1105 | |
"\xEF\xBD\xB1\xEF\xBD\xB2\xEF\xBD\xB3\xEF\xBD\xB4\xEF\xBD\xB5", command);
|
|
1074 |
EXPECT_PREEDIT("アイウエオ", command);
|
1106 | 1075 |
EXPECT_FALSE(command.output().has_candidates());
|
1107 | 1076 |
}
|
1108 | 1077 |
|
|
1124 | 1093 |
|
1125 | 1094 |
command.Clear();
|
1126 | 1095 |
session->ConvertNext(&command);
|
1127 | |
// "アイウエオ"
|
1128 | |
EXPECT_SINGLE_SEGMENT(
|
1129 | |
"\xE3\x82\xA2\xE3\x82\xA4\xE3\x82\xA6\xE3\x82\xA8\xE3\x82\xAA", command);
|
|
1096 |
EXPECT_SINGLE_SEGMENT("アイウエオ", command);
|
1130 | 1097 |
|
1131 | 1098 |
SetSendCommandCommand(commands::SessionCommand::HIGHLIGHT_CANDIDATE,
|
1132 | 1099 |
&command);
|
|
1135 | 1102 |
session->SendCommand(&command);
|
1136 | 1103 |
EXPECT_TRUE(command.output().consumed());
|
1137 | 1104 |
EXPECT_FALSE(command.output().has_result());
|
1138 | |
// "アイウエオ"
|
1139 | |
EXPECT_SINGLE_SEGMENT(
|
1140 | |
"\xEF\xBD\xB1\xEF\xBD\xB2\xEF\xBD\xB3\xEF\xBD\xB4\xEF\xBD\xB5", command);
|
|
1105 |
EXPECT_SINGLE_SEGMENT("アイウエオ", command);
|
1141 | 1106 |
EXPECT_TRUE(command.output().has_candidates());
|
1142 | 1107 |
}
|
1143 | 1108 |
|
|
1154 | 1119 |
FillT13Ns(request, &segments);
|
1155 | 1120 |
GetConverterMock()->SetStartConversionForRequest(&segments, true);
|
1156 | 1121 |
|
1157 | |
// "あいうえお"
|
1158 | |
EXPECT_SINGLE_SEGMENT_AND_KEY(kAiueo, kAiueo, command);
|
|
1122 |
EXPECT_SINGLE_SEGMENT_AND_KEY("あいうえお", "あいうえお", command);
|
1159 | 1123 |
|
1160 | 1124 |
command.Clear();
|
1161 | 1125 |
session->Convert(&command);
|
|
1169 | 1133 |
EXPECT_TRUE(command.output().preedit().segment(i).has_key());
|
1170 | 1134 |
key += command.output().preedit().segment(i).key();
|
1171 | 1135 |
}
|
1172 | |
// "あいうえお"
|
1173 | |
EXPECT_EQ(kAiueo, key);
|
|
1136 |
EXPECT_EQ("あいうえお", key);
|
1174 | 1137 |
}
|
1175 | 1138 |
|
1176 | 1139 |
TEST_F(SessionTest, SegmentWidthShrink) {
|
|
1235 | 1198 |
// "わたしのなまえはなかのです[]"
|
1236 | 1199 |
|
1237 | 1200 |
segment = segments.add_segment();
|
1238 | |
// "わたしの"
|
1239 | |
segment->set_key("\xe3\x82\x8f\xe3\x81\x9f\xe3\x81\x97\xe3\x81\xae");
|
|
1201 |
segment->set_key("わたしの");
|
1240 | 1202 |
candidate = segment->add_candidate();
|
1241 | |
// "私の"
|
1242 | |
candidate->value = "\xe7\xa7\x81\xe3\x81\xae";
|
|
1203 |
candidate->value = "私の";
|
1243 | 1204 |
candidate = segment->add_candidate();
|
1244 | |
// "わたしの"
|
1245 | |
candidate->value = "\xe3\x82\x8f\xe3\x81\x9f\xe3\x81\x97\xe3\x81\xae";
|
|
1205 |
candidate->value = "わたしの";
|
1246 | 1206 |
candidate = segment->add_candidate();
|
1247 | |
// "渡しの"
|
1248 | |
candidate->value = "\xe6\xb8\xa1\xe3\x81\x97\xe3\x81\xae";
|
|
1207 |
candidate->value = "渡しの";
|
1249 | 1208 |
|
1250 | 1209 |
segment = segments.add_segment();
|
1251 | |
// "なまえは"
|
1252 | |
segment->set_key("\xe3\x81\xaa\xe3\x81\xbe\xe3\x81\x88\xe3\x81\xaf");
|
|
1210 |
segment->set_key("なまえは");
|
1253 | 1211 |
candidate = segment->add_candidate();
|
1254 | |
// "名前は"
|
1255 | |
candidate->value = "\xe5\x90\x8d\xe5\x89\x8d\xe3\x81\xaf";
|
|
1212 |
candidate->value = "名前は";
|
1256 | 1213 |
candidate = segment->add_candidate();
|
1257 | |
// "ナマエは"
|
1258 | |
candidate->value = "\xe3\x83\x8a\xe3\x83\x9e\xe3\x82\xa8\xe3\x81\xaf";
|
|
1214 |
candidate->value = "ナマエは";
|
1259 | 1215 |
|
1260 | 1216 |
segment = segments.add_segment();
|
1261 | |
// "なかのです"
|
1262 | |
segment->set_key(
|
1263 | |
"\xe3\x81\xaa\xe3\x81\x8b\xe3\x81\xae\xe3\x81\xa7\xe3\x81\x99");
|
|
1217 |
segment->set_key("なかのです");
|
1264 | 1218 |
candidate = segment->add_candidate();
|
1265 | |
// "中野です"
|
1266 | |
candidate->value = "\xe4\xb8\xad\xe9\x87\x8e\xe3\x81\xa7\xe3\x81\x99";
|
|
1219 |
candidate->value = "中野です";
|
1267 | 1220 |
candidate = segment->add_candidate();
|
1268 | |
// "なかのです"
|
1269 | |
candidate->value
|
1270 | |
= "\xe3\x81\xaa\xe3\x81\x8b\xe3\x81\xae\xe3\x81\xa7\xe3\x81\x99";
|
|
1221 |
candidate->value = "なかのです";
|
1271 | 1222 |
SetComposer(session.get(), &request);
|
1272 | 1223 |
FillT13Ns(request, &segments);
|
1273 | 1224 |
GetConverterMock()->SetStartConversionForRequest(&segments, true);
|
|
1312 | 1263 |
|
1313 | 1264 |
segments.Clear();
|
1314 | 1265 |
segment = segments.add_segment();
|
1315 | |
// "あ"
|
1316 | |
segment->set_key(kHiraganaA);
|
|
1266 |
segment->set_key("あ");
|
1317 | 1267 |
candidate = segment->add_candidate();
|
1318 | |
// "阿"
|
1319 | |
candidate->value = "\xe9\x98\xbf";
|
|
1268 |
candidate->value = "阿";
|
1320 | 1269 |
candidate = segment->add_candidate();
|
1321 | |
// "亜"
|
1322 | |
candidate->value = "\xe4\xba\x9c";
|
|
1270 |
candidate->value = "亜";
|
1323 | 1271 |
|
1324 | 1272 |
SetComposer(session.get(), &request);
|
1325 | 1273 |
FillT13Ns(request, &segments);
|
|
1348 | 1296 |
InsertCharacterChars("ai", session.get(), &command);
|
1349 | 1297 |
|
1350 | 1298 |
segment = segments.add_segment();
|
1351 | |
// "あい"
|
1352 | |
segment->set_key("\xe3\x81\x82\xe3\x81\x84");
|
|
1299 |
segment->set_key("あい");
|
1353 | 1300 |
candidate = segment->add_candidate();
|
1354 | |
// "愛"
|
1355 | |
candidate->value = "\xe6\x84\x9b";
|
|
1301 |
candidate->value = "愛";
|
1356 | 1302 |
candidate = segment->add_candidate();
|
1357 | |
// "相"
|
1358 | |
candidate->value = "\xe7\x9b\xb8";
|
|
1303 |
candidate->value = "相";
|
1359 | 1304 |
ConversionRequest request;
|
1360 | 1305 |
SetComposer(session.get(), &request);
|
1361 | 1306 |
FillT13Ns(request, &segments);
|
|
1368 | 1313 |
|
1369 | 1314 |
segments.Clear();
|
1370 | 1315 |
segment = segments.add_segment();
|
1371 | |
// "あ"
|
1372 | |
segment->set_key(kHiraganaA);
|
|
1316 |
segment->set_key("あ");
|
1373 | 1317 |
candidate = segment->add_candidate();
|
1374 | |
// "あ"
|
1375 | |
candidate->value = kHiraganaA;
|
|
1318 |
candidate->value = "あ";
|
1376 | 1319 |
segment = segments.add_segment();
|
1377 | |
// "い"
|
1378 | |
segment->set_key("\xe3\x81\x84");
|
|
1320 |
segment->set_key("い");
|
1379 | 1321 |
candidate = segment->add_candidate();
|
1380 | |
// "い"
|
1381 | |
candidate->value = "\xe3\x81\x84";
|
|
1322 |
candidate->value = "い";
|
1382 | 1323 |
candidate = segment->add_candidate();
|
1383 | |
// "位"
|
1384 | |
candidate->value = "\xe4\xbd\x8d";
|
|
1324 |
candidate->value = "位";
|
1385 | 1325 |
GetConverterMock()->SetResizeSegment1(&segments, true);
|
1386 | 1326 |
|
1387 | 1327 |
command.Clear();
|
|
1406 | 1346 |
|
1407 | 1347 |
segments.Clear();
|
1408 | 1348 |
segment = segments.add_segment();
|
1409 | |
// "あい"
|
1410 | |
segment->set_key("\xe3\x81\x82\xe3\x81\x84");
|
|
1349 |
segment->set_key("あい");
|
1411 | 1350 |
candidate = segment->add_candidate();
|
1412 | |
// "愛"
|
1413 | |
candidate->value = "\xe6\x84\x9b";
|
|
1351 |
candidate->value = "愛";
|
1414 | 1352 |
candidate = segment->add_candidate();
|
1415 | |
// "相"
|
1416 | |
candidate->value = "\xe7\x9b\xb8";
|
|
1353 |
candidate->value = "相";
|
1417 | 1354 |
SetComposer(session.get(), &request);
|
1418 | 1355 |
FillT13Ns(request, &segments);
|
1419 | 1356 |
GetConverterMock()->SetStartConversionForRequest(&segments, true);
|
|
1427 | 1364 |
session->Convert(&command);
|
1428 | 1365 |
// "[相]"
|
1429 | 1366 |
}
|
1430 | |
|
1431 | 1367 |
|
1432 | 1368 |
TEST_F(SessionTest, KeepFixedCandidateAfterSegmentWidthExpand) {
|
1433 | 1369 |
// Issue#1271099
|
|
1442 | 1378 |
// "ばりにりょこうにいった[]"
|
1443 | 1379 |
|
1444 | 1380 |
segment = segments.add_segment();
|
1445 | |
// "ばりに"
|
1446 | |
segment->set_key("\xe3\x81\xb0\xe3\x82\x8a\xe3\x81\xab");
|
|
1381 |
segment->set_key("ばりに");
|
1447 | 1382 |
candidate = segment->add_candidate();
|
1448 | |
// "バリに"
|
1449 | |
candidate->value = "\xe3\x83\x90\xe3\x83\xaa\xe3\x81\xab";
|
|
1383 |
candidate->value = "バリに";
|
1450 | 1384 |
candidate = segment->add_candidate();
|
1451 | |
// "針に"
|
1452 | |
candidate->value = "\xe9\x87\x9d\xe3\x81\xab";
|
|
1385 |
candidate->value = "針に";
|
1453 | 1386 |
|
1454 | 1387 |
segment = segments.add_segment();
|
1455 | |
// "りょこうに"
|
1456 | |
segment->set_key(
|
1457 | |
"\xe3\x82\x8a\xe3\x82\x87\xe3\x81\x93\xe3\x81\x86\xe3\x81\xab");
|
|
1388 |
segment->set_key("りょこうに");
|
1458 | 1389 |
candidate = segment->add_candidate();
|
1459 | |
// "旅行に"
|
1460 | |
candidate->value = "\xe6\x97\x85\xe8\xa1\x8c\xe3\x81\xab";
|
|
1390 |
candidate->value = "旅行に";
|
1461 | 1391 |
|
1462 | 1392 |
segment = segments.add_segment();
|
1463 | |
// "いった"
|
1464 | |
segment->set_key("\xe3\x81\x84\xe3\x81\xa3\xe3\x81\x9f");
|
|
1393 |
segment->set_key("いった");
|
1465 | 1394 |
candidate = segment->add_candidate();
|
1466 | |
// "行った"
|
1467 | |
candidate->value = "\xe8\xa1\x8c\xe3\x81\xa3\xe3\x81\x9f";
|
|
1395 |
candidate->value = "行った";
|
1468 | 1396 |
|
1469 | 1397 |
ConversionRequest request;
|
1470 | 1398 |
SetComposer(session.get(), &request);
|
|
1474 | 1402 |
command.Clear();
|
1475 | 1403 |
session->Convert(&command);
|
1476 | 1404 |
// ex. "[バリに]旅行に行った"
|
1477 | |
EXPECT_EQ("\xE3\x83\x90\xE3\x83\xAA\xE3\x81\xAB\xE6\x97\x85\xE8\xA1\x8C\xE3"
|
1478 | |
"\x81\xAB\xE8\xA1\x8C\xE3\x81\xA3\xE3\x81\x9F", GetComposition(command));
|
|
1405 |
EXPECT_EQ("バリに旅行に行った", GetComposition(command));
|
1479 | 1406 |
command.Clear();
|
1480 | 1407 |
session->ConvertNext(&command);
|
1481 | 1408 |
// ex. "[針に]旅行に行った"
|
|
1494 | 1421 |
EXPECT_EQ(first_segment, command.output().preedit().segment(0).value());
|
1495 | 1422 |
|
1496 | 1423 |
segment = segments.mutable_segment(1);
|
1497 | |
// "りょこうにい"
|
1498 | |
segment->set_key("\xe3\x82\x8a\xe3\x82\x87\xe3\x81\x93"
|
1499 | |
"\xe3\x81\x86\xe3\x81\xab\xe3\x81\x84");
|
|
1424 |
segment->set_key("りょこうにい");
|
1500 | 1425 |
candidate = segment->mutable_candidate(0);
|
1501 | |
// "旅行に行"
|
1502 | |
candidate->value = "\xe6\x97\x85\xe8\xa1\x8c\xe3\x81\xab\xe8\xa1\x8c";
|
|
1426 |
candidate->value = "旅行に行";
|
1503 | 1427 |
|
1504 | 1428 |
segment = segments.mutable_segment(2);
|
1505 | |
// "った"
|
1506 | |
segment->set_key("\xe3\x81\xa3\xe3\x81\x9f");
|
|
1429 |
segment->set_key("った");
|
1507 | 1430 |
candidate = segment->mutable_candidate(0);
|
1508 | |
// "った"
|
1509 | |
candidate->value = "\xe3\x81\xa3\xe3\x81\x9f";
|
|
1431 |
candidate->value = "った";
|
1510 | 1432 |
|
1511 | 1433 |
GetConverterMock()->SetResizeSegment1(&segments, true);
|
1512 | 1434 |
|
|
1533 | 1455 |
// "わたしのなまえ[]"
|
1534 | 1456 |
|
1535 | 1457 |
segment = segments.add_segment();
|
1536 | |
// "わたしの"
|
1537 | |
segment->set_key("\xe3\x82\x8f\xe3\x81\x9f\xe3\x81\x97\xe3\x81\xae");
|
|
1458 |
segment->set_key("わたしの");
|
1538 | 1459 |
candidate = segment->add_candidate();
|
1539 | |
// "私の"
|
1540 | |
candidate->value = "\xe7\xa7\x81\xe3\x81\xae";
|
|
1460 |
candidate->value = "私の";
|
1541 | 1461 |
candidate = segment->add_candidate();
|
1542 | |
// "わたしの"
|
1543 | |
candidate->value = "\xe3\x82\x8f\xe3\x81\x9f\xe3\x81\x97\xe3\x81\xae";
|
|
1462 |
candidate->value = "わたしの";
|
1544 | 1463 |
candidate = segment->add_candidate();
|
1545 | |
// "渡しの"
|
1546 | |
candidate->value = "\xe6\xb8\xa1\xe3\x81\x97\xe3\x81\xae";
|
|
1464 |
candidate->value = "渡しの";
|
1547 | 1465 |
|
1548 | 1466 |
segment = segments.add_segment();
|
1549 | |
// "なまえ"
|
1550 | |
segment->set_key("\xe3\x81\xaa\xe3\x81\xbe\xe3\x81\x88");
|
|
1467 |
segment->set_key("なまえ");
|
1551 | 1468 |
candidate = segment->add_candidate();
|
1552 | |
// "名前"
|
1553 | |
candidate->value = "\xe5\x90\x8d\xe5\x89\x8d";
|
|
1469 |
candidate->value = "名前";
|
1554 | 1470 |
|
1555 | 1471 |
ConversionRequest request;
|
1556 | 1472 |
SetComposer(session.get(), &request);
|
|
1559 | 1475 |
|
1560 | 1476 |
command.Clear();
|
1561 | 1477 |
session->Convert(&command);
|
|
1478 |
EXPECT_EQ(0, command.output().candidates().focused_index());
|
1562 | 1479 |
// "[私の]名前"
|
1563 | |
EXPECT_EQ(0, command.output().candidates().focused_index());
|
1564 | 1480 |
|
1565 | 1481 |
command.Clear();
|
1566 | 1482 |
session->ConvertNext(&command);
|
|
1483 |
EXPECT_EQ(1, command.output().candidates().focused_index());
|
1567 | 1484 |
// "[わたしの]名前"
|
1568 | |
EXPECT_EQ(1, command.output().candidates().focused_index());
|
1569 | 1485 |
|
1570 | 1486 |
command.Clear();
|
1571 | 1487 |
session->ConvertNext(&command);
|
|
1596 | 1512 |
// "わたしのはは[]"
|
1597 | 1513 |
|
1598 | 1514 |
segment = segments.add_segment();
|
1599 | |
// "わたしの"
|
1600 | |
segment->set_key("\xe3\x82\x8f\xe3\x81\x9f\xe3\x81\x97\xe3\x81\xae");
|
|
1515 |
segment->set_key("わたしの");
|
1601 | 1516 |
candidate = segment->add_candidate();
|
1602 | |
// "私の"
|
1603 | |
candidate->value = "\xe7\xa7\x81\xe3\x81\xae";
|
|
1517 |
candidate->value = "私の";
|
1604 | 1518 |
segment = segments.add_segment();
|
1605 | |
// "はは"
|
1606 | |
segment->set_key("\xe3\x81\xaf\xe3\x81\xaf");
|
|
1519 |
segment->set_key("はは");
|
1607 | 1520 |
candidate = segment->add_candidate();
|
1608 | |
// "母"
|
1609 | |
candidate->value = "\xe6\xaf\x8d";
|
|
1521 |
candidate->value = "母";
|
1610 | 1522 |
|
1611 | 1523 |
ConversionRequest request;
|
1612 | 1524 |
SetComposer(session.get(), &request);
|
|
1629 | 1541 |
session->CommitSegment(&command);
|
1630 | 1542 |
// "私の" + "[母]"
|
1631 | 1543 |
|
1632 | |
// "は"
|
1633 | |
segment->set_key("\xe3\x81\xaf");
|
1634 | |
// "葉"
|
1635 | |
candidate->value = "\xe8\x91\x89";
|
|
1544 |
segment->set_key("は");
|
|
1545 |
candidate->value = "葉";
|
1636 | 1546 |
segment = segments.add_segment();
|
1637 | |
// "は"
|
1638 | |
segment->set_key("\xe3\x81\xaf");
|
|
1547 |
segment->set_key("は");
|
1639 | 1548 |
candidate = segment->add_candidate();
|
1640 | |
// "は"
|
1641 | |
candidate->value = "\xe3\x81\xaf";
|
|
1549 |
candidate->value = "は";
|
1642 | 1550 |
segments.pop_front_segment();
|
1643 | 1551 |
GetConverterMock()->SetResizeSegment1(&segments, true);
|
1644 | 1552 |
|
|
1658 | 1566 |
InsertCharacterChars("jishin", session.get(), &command);
|
1659 | 1567 |
|
1660 | 1568 |
segment = segments.add_segment();
|
1661 | |
// "じしん"
|
1662 | |
segment->set_key("\xe3\x81\x98\xe3\x81\x97\xe3\x82\x93");
|
|
1569 |
segment->set_key("じしん");
|
1663 | 1570 |
candidate = segment->add_candidate();
|
1664 | |
// "自信"
|
1665 | |
candidate->value = "\xe8\x87\xaa\xe4\xbf\xa1";
|
|
1571 |
candidate->value = "自信";
|
1666 | 1572 |
candidate = segment->add_candidate();
|
1667 | |
// "自身"
|
1668 | |
candidate->value = "\xe8\x87\xaa\xe8\xba\xab";
|
|
1573 |
candidate->value = "自身";
|
1669 | 1574 |
|
1670 | 1575 |
ConversionRequest request;
|
1671 | 1576 |
SetComposer(session.get(), &request);
|
|
1706 | 1611 |
InsertCharacterChars("jishin", session.get(), &command);
|
1707 | 1612 |
|
1708 | 1613 |
segment = segments.add_segment();
|
1709 | |
// "じしん"
|
1710 | |
segment->set_key("\xe3\x81\x98\xe3\x81\x97\xe3\x82\x93");
|
|
1614 |
segment->set_key("じしん");
|
1711 | 1615 |
candidate = segment->add_candidate();
|
1712 | |
// "自信"
|
1713 | |
candidate->value = "\xe8\x87\xaa\xe4\xbf\xa1";
|
|
1616 |
candidate->value = "自信";
|
1714 | 1617 |
candidate = segment->add_candidate();
|
1715 | |
// "自身"
|
1716 | |
candidate->value = "\xe8\x87\xaa\xe8\xba\xab";
|
|
1618 |
candidate->value = "自身";
|
1717 | 1619 |
|
1718 | 1620 |
ConversionRequest request;
|
1719 | 1621 |
SetComposer(session.get(), &request);
|
|
1762 | 1664 |
|
1763 | 1665 |
const commands::Preedit &conversion = output.preedit();
|
1764 | 1666 |
EXPECT_EQ(2, conversion.segment_size());
|
1765 | |
// "ぃ"
|
1766 | |
EXPECT_EQ("\xE3\x81\x83", conversion.segment(0).value());
|
1767 | |
// "家"
|
1768 | |
EXPECT_EQ("\xE5\xAE\xB6", conversion.segment(1).value());
|
|
1667 |
EXPECT_EQ("ぃ", conversion.segment(0).value());
|
|
1668 |
EXPECT_EQ("家", conversion.segment(1).value());
|
1769 | 1669 |
}
|
1770 | 1670 |
|
1771 | 1671 |
// TranslateHalfASCII
|
|
1792 | 1692 |
Segments segments;
|
1793 | 1693 |
{ // Initialize segments.
|
1794 | 1694 |
Segment *segment = segments.add_segment();
|
1795 | |
// "あbc"
|
1796 | |
segment->set_key("\xE3\x81\x82\xEF\xBD\x82\xEF\xBD\x83");
|
1797 | |
// "あべし"
|
1798 | |
segment->add_candidate()->value = "\xE3\x81\x82\xE3\x81\xB9\xE3\x81\x97";
|
|
1695 |
segment->set_key("あbc");
|
|
1696 |
segment->add_candidate()->value = "あべし";
|
1799 | 1697 |
}
|
1800 | 1698 |
ConversionRequest request;
|
1801 | 1699 |
SetComposer(session.get(), &request);
|
|
1804 | 1702 |
|
1805 | 1703 |
command.Clear();
|
1806 | 1704 |
session->ConvertToHalfWidth(&command);
|
1807 | |
// "アbc"
|
1808 | |
EXPECT_SINGLE_SEGMENT("\xEF\xBD\xB1\x62\x63", command);
|
|
1705 |
EXPECT_SINGLE_SEGMENT("アbc", command);
|
1809 | 1706 |
|
1810 | 1707 |
command.Clear();
|
1811 | 1708 |
session->ConvertToFullASCII(&command);
|
|
1827 | 1724 |
InsertCharacterChars("dvd", session.get(), &command);
|
1828 | 1725 |
|
1829 | 1726 |
segment = segments.add_segment();
|
1830 | |
// "dvd"
|
1831 | |
segment->set_key("\xEF\xBD\x84\xEF\xBD\x96\xEF\xBD\x84");
|
|
1727 |
segment->set_key("dvd");
|
1832 | 1728 |
candidate = segment->add_candidate();
|
1833 | 1729 |
candidate->value = "DVD";
|
1834 | 1730 |
candidate = segment->add_candidate();
|
|
1841 | 1737 |
|
1842 | 1738 |
command.Clear();
|
1843 | 1739 |
session->ConvertToFullASCII(&command);
|
1844 | |
// "dvd"
|
1845 | |
EXPECT_SINGLE_SEGMENT("\xEF\xBD\x84\xEF\xBD\x96\xEF\xBD\x84", command);
|
|
1740 |
EXPECT_SINGLE_SEGMENT("dvd", command);
|
1846 | 1741 |
|
1847 | 1742 |
command.Clear();
|
1848 | 1743 |
session->ConvertToFullASCII(&command);
|
1849 | |
// "DVD"
|
1850 | |
EXPECT_SINGLE_SEGMENT("\xEF\xBC\xA4\xEF\xBC\xB6\xEF\xBC\xA4", command);
|
|
1744 |
EXPECT_SINGLE_SEGMENT("DVD", command);
|
1851 | 1745 |
|
1852 | 1746 |
command.Clear();
|
1853 | 1747 |
session->ConvertToFullASCII(&command);
|
1854 | |
// "Dvd"
|
1855 | |
EXPECT_SINGLE_SEGMENT("\xEF\xBC\xA4\xEF\xBD\x96\xEF\xBD\x84", command);
|
|
1748 |
EXPECT_SINGLE_SEGMENT("Dvd", command);
|
1856 | 1749 |
|
1857 | 1750 |
command.Clear();
|
1858 | 1751 |
session->ConvertToFullASCII(&command);
|
1859 | |
// "dvd"
|
1860 | |
EXPECT_SINGLE_SEGMENT("\xEF\xBD\x84\xEF\xBD\x96\xEF\xBD\x84", command);
|
|
1752 |
EXPECT_SINGLE_SEGMENT("dvd", command);
|
1861 | 1753 |
}
|
1862 | 1754 |
|
1863 | 1755 |
TEST_F(SessionTest, ConvertConsonantsToFullAlphanumericWithoutCascadingWindow) {
|
|
1876 | 1768 |
InsertCharacterChars("dvd", session.get(), &command);
|
1877 | 1769 |
|
1878 | 1770 |
segment = segments.add_segment();
|
1879 | |
// "dvd"
|
1880 | |
segment->set_key("\xEF\xBD\x84\xEF\xBD\x96\xEF\xBD\x84");
|
|
1771 |
segment->set_key("dvd");
|
1881 | 1772 |
candidate = segment->add_candidate();
|
1882 | 1773 |
candidate->value = "DVD";
|
1883 | 1774 |
candidate = segment->add_candidate();
|
|
1890 | 1781 |
|
1891 | 1782 |
command.Clear();
|
1892 | 1783 |
session->ConvertToFullASCII(&command);
|
1893 | |
// "dvd"
|
1894 | |
EXPECT_SINGLE_SEGMENT("\xEF\xBD\x84\xEF\xBD\x96\xEF\xBD\x84", command);
|
|
1784 |
EXPECT_SINGLE_SEGMENT("dvd", command);
|
1895 | 1785 |
|
1896 | 1786 |
command.Clear();
|
1897 | 1787 |
session->ConvertToFullASCII(&command);
|
1898 | |
// "DVD"
|
1899 | |
EXPECT_SINGLE_SEGMENT("\xEF\xBC\xA4\xEF\xBC\xB6\xEF\xBC\xA4", command);
|
|
1788 |
EXPECT_SINGLE_SEGMENT("DVD", command);
|
1900 | 1789 |
|
1901 | 1790 |
command.Clear();
|
1902 | 1791 |
session->ConvertToFullASCII(&command);
|
1903 | |
// "Dvd"
|
1904 | |
EXPECT_SINGLE_SEGMENT("\xEF\xBC\xA4\xEF\xBD\x96\xEF\xBD\x84", command);
|
|
1792 |
EXPECT_SINGLE_SEGMENT("Dvd", command);
|
1905 | 1793 |
|
1906 | 1794 |
command.Clear();
|
1907 | 1795 |
session->ConvertToFullASCII(&command);
|
1908 | |
// "dvd"
|
1909 | |
EXPECT_SINGLE_SEGMENT("\xEF\xBD\x84\xEF\xBD\x96\xEF\xBD\x84", command);
|
|
1796 |
EXPECT_SINGLE_SEGMENT("dvd", command);
|
1910 | 1797 |
}
|
1911 | 1798 |
|
1912 | 1799 |
// Convert input string to Hiragana, Katakana, and Half Katakana
|
|
1920 | 1807 |
Segments segments;
|
1921 | 1808 |
{ // Initialize segments.
|
1922 | 1809 |
Segment *segment = segments.add_segment();
|
1923 | |
// "あbc"
|
1924 | |
segment->set_key("\xE3\x81\x82\xEF\xBD\x82\xEF\xBD\x83");
|
1925 | |
// "あべし"
|
1926 | |
segment->add_candidate()->value = "\xE3\x81\x82\xE3\x81\xB9\xE3\x81\x97";
|
|
1810 |
segment->set_key("あbc");
|
|
1811 |
segment->add_candidate()->value = "あべし";
|
1927 | 1812 |
}
|
1928 | 1813 |
|
1929 | 1814 |
ConversionRequest request;
|
|
1933 | 1818 |
|
1934 | 1819 |
command.Clear();
|
1935 | 1820 |
session->SwitchKanaType(&command);
|
1936 | |
// "アbc"
|
1937 | |
EXPECT_SINGLE_SEGMENT("\xE3\x82\xA2\xEF\xBD\x82\xEF\xBD\x83", command);
|
|
1821 |
EXPECT_SINGLE_SEGMENT("アbc", command);
|
1938 | 1822 |
|
1939 | 1823 |
command.Clear();
|
1940 | 1824 |
session->SwitchKanaType(&command);
|
1941 | |
// "アbc"
|
1942 | |
EXPECT_SINGLE_SEGMENT("\xEF\xBD\xB1\x62\x63", command);
|
|
1825 |
EXPECT_SINGLE_SEGMENT("アbc", command);
|
1943 | 1826 |
|
1944 | 1827 |
command.Clear();
|
1945 | 1828 |
session->SwitchKanaType(&command);
|
1946 | |
// "あbc"
|
1947 | |
EXPECT_SINGLE_SEGMENT("\xE3\x81\x82\xEF\xBD\x82\xEF\xBD\x83", command);
|
|
1829 |
EXPECT_SINGLE_SEGMENT("あbc", command);
|
1948 | 1830 |
|
1949 | 1831 |
command.Clear();
|
1950 | 1832 |
session->SwitchKanaType(&command);
|
1951 | |
// "アbc"
|
1952 | |
EXPECT_SINGLE_SEGMENT("\xE3\x82\xA2\xEF\xBD\x82\xEF\xBD\x83", command);
|
|
1833 |
EXPECT_SINGLE_SEGMENT("アbc", command);
|
1953 | 1834 |
}
|
1954 | 1835 |
|
1955 | 1836 |
{ // From conversion mode.
|
|
1961 | 1842 |
Segments segments;
|
1962 | 1843 |
{ // Initialize segments.
|
1963 | 1844 |
Segment *segment = segments.add_segment();
|
1964 | |
// "かんじ"
|
1965 | |
segment->set_key("\xE3\x81\x8B\xE3\x82\x93\xE3\x81\x98");
|
1966 | |
// "漢字"
|
1967 | |
segment->add_candidate()->value = "\xE6\xBC\xA2\xE5\xAD\x97";
|
|
1845 |
segment->set_key("かんじ");
|
|
1846 |
segment->add_candidate()->value = "漢字";
|
1968 | 1847 |
}
|
1969 | 1848 |
|
1970 | 1849 |
ConversionRequest request;
|
|
1974 | 1853 |
|
1975 | 1854 |
command.Clear();
|
1976 | 1855 |
session->Convert(&command);
|
1977 | |
// "漢字"
|
1978 | |
EXPECT_SINGLE_SEGMENT("\xE6\xBC\xA2\xE5\xAD\x97", command);
|
|
1856 |
EXPECT_SINGLE_SEGMENT("漢字", command);
|
1979 | 1857 |
|
1980 | 1858 |
command.Clear();
|
1981 | 1859 |
session->SwitchKanaType(&command);
|
1982 | |
// "かんじ"
|
1983 | |
EXPECT_SINGLE_SEGMENT("\xE3\x81\x8B\xE3\x82\x93\xE3\x81\x98", command);
|
|
1860 |
EXPECT_SINGLE_SEGMENT("かんじ", command);
|
1984 | 1861 |
|
1985 | 1862 |
command.Clear();
|
1986 | 1863 |
session->SwitchKanaType(&command);
|
1987 | |
// "カンジ"
|
1988 | |
EXPECT_SINGLE_SEGMENT("\xE3\x82\xAB\xE3\x83\xB3\xE3\x82\xB8", command);
|
|
1864 |
EXPECT_SINGLE_SEGMENT("カンジ", command);
|
1989 | 1865 |
|
1990 | 1866 |
command.Clear();
|
1991 | 1867 |
session->SwitchKanaType(&command);
|
1992 | |
// "カンジ"
|
1993 | 1868 |
EXPECT_SINGLE_SEGMENT(
|
1994 | |
"\xEF\xBD\xB6\xEF\xBE\x9D\xEF\xBD\xBC\xEF\xBE\x9E", command);
|
|
1869 |
"カンジ", command);
|
1995 | 1870 |
|
1996 | 1871 |
command.Clear();
|
1997 | 1872 |
session->SwitchKanaType(&command);
|
1998 | |
// "かんじ"
|
1999 | |
EXPECT_SINGLE_SEGMENT("\xE3\x81\x8B\xE3\x82\x93\xE3\x81\x98", command);
|
|
1873 |
EXPECT_SINGLE_SEGMENT("かんじ", command);
|
2000 | 1874 |
}
|
2001 | 1875 |
}
|
2002 | 1876 |
|
|
2008 | 1882 |
|
2009 | 1883 |
// HIRAGANA
|
2010 | 1884 |
InsertCharacterChars("a", session.get(), &command);
|
2011 | |
// "あ"
|
2012 | |
EXPECT_EQ(kHiraganaA, GetComposition(command));
|
|
1885 |
EXPECT_EQ("あ", GetComposition(command));
|
2013 | 1886 |
EXPECT_TRUE(command.output().has_mode());
|
2014 | 1887 |
EXPECT_EQ(commands::HIRAGANA, command.output().mode());
|
2015 | 1888 |
|
|
2019 | 1892 |
command.Clear();
|
2020 | 1893 |
session->InputModeSwitchKanaType(&command);
|
2021 | 1894 |
InsertCharacterChars("a", session.get(), &command);
|
2022 | |
// "ア"
|
2023 | |
EXPECT_EQ("\xE3\x82\xA2", GetComposition(command));
|
|
1895 |
EXPECT_EQ("ア", GetComposition(command));
|
2024 | 1896 |
EXPECT_TRUE(command.output().has_mode());
|
2025 | 1897 |
EXPECT_EQ(commands::FULL_KATAKANA, command.output().mode());
|
2026 | 1898 |
|
|
2030 | 1902 |
command.Clear();
|
2031 | 1903 |
session->InputModeSwitchKanaType(&command);
|
2032 | 1904 |
InsertCharacterChars("a", session.get(), &command);
|
2033 | |
// "ア"
|
2034 | |
EXPECT_EQ("\xEF\xBD\xB1",
|
2035 | |
GetComposition(command));
|
|
1905 |
EXPECT_EQ("ア", GetComposition(command));
|
2036 | 1906 |
EXPECT_TRUE(command.output().has_mode());
|
2037 | 1907 |
EXPECT_EQ(commands::HALF_KATAKANA, command.output().mode());
|
2038 | 1908 |
|
|
2042 | 1912 |
command.Clear();
|
2043 | 1913 |
session->InputModeSwitchKanaType(&command);
|
2044 | 1914 |
InsertCharacterChars("a", session.get(), &command);
|
2045 | |
// "あ"
|
2046 | |
EXPECT_EQ(kHiraganaA, GetComposition(command));
|
|
1915 |
EXPECT_EQ("あ", GetComposition(command));
|
2047 | 1916 |
EXPECT_TRUE(command.output().has_mode());
|
2048 | 1917 |
EXPECT_EQ(commands::HIRAGANA, command.output().mode());
|
2049 | 1918 |
|
|
2053 | 1922 |
command.Clear();
|
2054 | 1923 |
session->InputModeHalfASCII(&command);
|
2055 | 1924 |
InsertCharacterChars("a", session.get(), &command);
|
2056 | |
// "a"
|
2057 | 1925 |
EXPECT_EQ("a", GetComposition(command));
|
2058 | 1926 |
EXPECT_TRUE(command.output().has_mode());
|
2059 | 1927 |
EXPECT_EQ(commands::HALF_ASCII, command.output().mode());
|
|
2064 | 1932 |
command.Clear();
|
2065 | 1933 |
session->InputModeSwitchKanaType(&command);
|
2066 | 1934 |
InsertCharacterChars("a", session.get(), &command);
|
2067 | |
// "a"
|
2068 | 1935 |
EXPECT_EQ("a", GetComposition(command));
|
2069 | 1936 |
EXPECT_TRUE(command.output().has_mode());
|
2070 | 1937 |
EXPECT_EQ(commands::HALF_ASCII, command.output().mode());
|
|
2075 | 1942 |
command.Clear();
|
2076 | 1943 |
session->InputModeFullASCII(&command);
|
2077 | 1944 |
InsertCharacterChars("a", session.get(), &command);
|
2078 | |
// "a"
|
2079 | |
EXPECT_EQ(kFullWidthSmallA, GetComposition(command));
|
|
1945 |
EXPECT_EQ("a", GetComposition(command));
|
2080 | 1946 |
EXPECT_TRUE(command.output().has_mode());
|
2081 | 1947 |
EXPECT_EQ(commands::FULL_ASCII, command.output().mode());
|
2082 | 1948 |
|
|
2086 | 1952 |
command.Clear();
|
2087 | 1953 |
session->InputModeSwitchKanaType(&command);
|
2088 | 1954 |
InsertCharacterChars("a", session.get(), &command);
|
2089 | |
// "a"
|
2090 | |
EXPECT_EQ(kFullWidthSmallA, GetComposition(command));
|
|
1955 |
EXPECT_EQ("a", GetComposition(command));
|
2091 | 1956 |
EXPECT_TRUE(command.output().has_mode());
|
2092 | 1957 |
EXPECT_EQ(commands::FULL_ASCII, command.output().mode());
|
2093 | 1958 |
}
|
|
2100 | 1965 |
|
2101 | 1966 |
command.Clear();
|
2102 | 1967 |
session->TranslateHalfWidth(&command);
|
2103 | |
// "アbc"
|
2104 | |
EXPECT_SINGLE_SEGMENT("\xEF\xBD\xB1\x62\x63", command);
|
|
1968 |
EXPECT_SINGLE_SEGMENT("アbc", command);
|
2105 | 1969 |
|
2106 | 1970 |
command.Clear();
|
2107 | 1971 |
session->TranslateFullASCII(&command);
|
2108 | |
// "abc".
|
2109 | |
EXPECT_SINGLE_SEGMENT("\xEF\xBD\x81\xEF\xBD\x82\xEF\xBD\x83", command);
|
|
1972 |
EXPECT_SINGLE_SEGMENT("abc", command);
|
2110 | 1973 |
|
2111 | 1974 |
command.Clear();
|
2112 | 1975 |
session->TranslateHalfWidth(&command);
|
|
2178 | 2041 |
Segment *segment;
|
2179 | 2042 |
Segment::Candidate *candidate;
|
2180 | 2043 |
composer::Table table;
|
2181 | |
// "ぱ"
|
2182 | |
table.AddRule("pa", "\xe3\x81\xb1", "");
|
2183 | |
// "ん"
|
2184 | |
table.AddRule("n", "\xe3\x82\x93", "");
|
2185 | |
// "な"
|
2186 | |
table.AddRule("na", "\xe3\x81\xaa", "");
|
|
2044 |
table.AddRule("pa", "ぱ", "");
|
|
2045 |
table.AddRule("n", "ん", "");
|
|
2046 |
table.AddRule("na", "な", "");
|
2187 | 2047 |
// This rule makes the "n" rule ambiguous.
|
2188 | 2048 |
|
2189 | 2049 |
std::unique_ptr<Session> session(new Session(engine_.get()));
|
|
2193 | 2053 |
commands::Command command;
|
2194 | 2054 |
InsertCharacterChars("pan", session.get(), &command);
|
2195 | 2055 |
|
2196 | |
// "ぱn"
|
2197 | |
EXPECT_EQ("\xe3\x81\xb1\xef\xbd\x8e",
|
|
2056 |
EXPECT_EQ("ぱn",
|
2198 | 2057 |
command.output().preedit().segment(0).value());
|
2199 | 2058 |
|
2200 | 2059 |
command.Clear();
|
2201 | 2060 |
|
2202 | 2061 |
segment = segments.add_segment();
|
2203 | |
// "ぱん"
|
2204 | |
segment->set_key("\xe3\x81\xb1\xe3\x82\x93");
|
|
2062 |
segment->set_key("ぱん");
|
2205 | 2063 |
candidate = segment->add_candidate();
|
2206 | |
// "パン"
|
2207 | |
candidate->value = "\xe3\x83\x91\xe3\x83\xb3";
|
|
2064 |
candidate->value = "パン";
|
2208 | 2065 |
|
2209 | 2066 |
ConversionRequest request;
|
2210 | 2067 |
SetComposer(session.get(), &request);
|
|
2212 | 2069 |
GetConverterMock()->SetStartConversionForRequest(&segments, true);
|
2213 | 2070 |
|
2214 | 2071 |
session->ConvertToHiragana(&command);
|
2215 | |
// "ぱん"
|
2216 | |
EXPECT_SINGLE_SEGMENT("\xe3\x81\xb1\xe3\x82\x93", command);
|
|
2072 |
EXPECT_SINGLE_SEGMENT("ぱん", command);
|
2217 | 2073 |
|
2218 | 2074 |
command.Clear();
|
2219 | 2075 |
session->ConvertToHalfASCII(&command);
|
|
2226 | 2082 |
Segment *segment;
|
2227 | 2083 |
Segment::Candidate *candidate;
|
2228 | 2084 |
composer::Table table;
|
2229 | |
// "す゛", "ず"
|
2230 | |
table.AddRule("\xe3\x81\x99\xe3\x82\x9b", "\xe3\x81\x9a", "");
|
|
2085 |
table.AddRule("す゛", "ず", "");
|
2231 | 2086 |
|
2232 | 2087 |
std::unique_ptr<Session> session(new Session(engine_.get()));
|
2233 | 2088 |
session->get_internal_composer_only_for_unittest()->SetTable(&table);
|
|
2235 | 2090 |
|
2236 | 2091 |
commands::Command command;
|
2237 | 2092 |
SetSendKeyCommand("m", &command);
|
2238 | |
// "も"
|
2239 | |
command.mutable_input()->mutable_key()->set_key_string("\xe3\x82\x82");
|
|
2093 |
command.mutable_input()->mutable_key()->set_key_string("も");
|
2240 | 2094 |
session->SendKey(&command);
|
2241 | 2095 |
|
2242 | 2096 |
SetSendKeyCommand("r", &command);
|
2243 | |
// "す"
|
2244 | |
command.mutable_input()->mutable_key()->set_key_string("\xe3\x81\x99");
|
|
2097 |
command.mutable_input()->mutable_key()->set_key_string("す");
|
2245 | 2098 |
session->SendKey(&command);
|
2246 | 2099 |
|
2247 | 2100 |
SetSendKeyCommand("@", &command);
|
2248 | |
// "゛"
|
2249 | |
command.mutable_input()->mutable_key()->set_key_string("\xe3\x82\x9b");
|
|
2101 |
command.mutable_input()->mutable_key()->set_key_string("゛");
|
2250 | 2102 |
session->SendKey(&command);
|
2251 | 2103 |
|
2252 | 2104 |
SetSendKeyCommand("h", &command);
|
2253 | |
// "く"
|
2254 | |
command.mutable_input()->mutable_key()->set_key_string("\xe3\x81\x8f");
|
|
2105 |
command.mutable_input()->mutable_key()->set_key_string("く");
|
2255 | 2106 |
session->SendKey(&command);
|
2256 | 2107 |
|
2257 | 2108 |
SetSendKeyCommand("!", &command);
|
2258 | 2109 |
command.mutable_input()->mutable_key()->set_key_string("!");
|
2259 | 2110 |
session->SendKey(&command);
|
2260 | 2111 |
|
2261 | |
// "もずく!"
|
2262 | |
EXPECT_EQ("\xe3\x82\x82\xe3\x81\x9a\xe3\x81\x8f\xef\xbc\x81",
|
2263 | |
command.output().preedit().segment(0).value());
|
|
2112 |
EXPECT_EQ("もずく!", command.output().preedit().segment(0).value());
|
2264 | 2113 |
|
2265 | 2114 |
segment = segments.add_segment();
|
2266 | |
// "もずく!"
|
2267 | |
segment->set_key("\xe3\x82\x82\xe3\x81\x9a\xe3\x81\x8f!");
|
|
2115 |
segment->set_key("もずく!");
|
2268 | 2116 |
candidate = segment->add_candidate();
|
2269 | |
// "もずく!"
|
2270 | |
candidate->value = "\xe3\x82\x82\xe3\x81\x9a\xe3\x81\x8f\xef\xbc\x81";
|
|
2117 |
candidate->value = "もずく!";
|
2271 | 2118 |
|
2272 | 2119 |
ConversionRequest request;
|
2273 | 2120 |
SetComposer(session.get(), &request);
|
|
2293 | 2140 |
|
2294 | 2141 |
string long_a;
|
2295 | 2142 |
for (int i = 0; i < 500; ++i) {
|
2296 | |
// "あ"
|
2297 | |
long_a += kHiraganaA;
|
|
2143 |
long_a += "あ";
|
2298 | 2144 |
}
|
2299 | 2145 |
segment = segments.add_segment();
|
2300 | 2146 |
segment->set_key(long_a);
|
|
2412 | 2258 |
InsertCharacterChars("ai", &session, &command);
|
2413 | 2259 |
ConversionRequest request;
|
2414 | 2260 |
SetComposer(&session, &request);
|
2415 | |
// "あい"
|
2416 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x81\x84", GetComposition(command));
|
|
2261 |
EXPECT_EQ("あい", GetComposition(command));
|
2417 | 2262 |
|
2418 | 2263 |
command.Clear();
|
2419 | 2264 |
GetConverterMock()->SetFinishConversion(&empty_segments, true);
|
2420 | 2265 |
session.CommitFirstSuggestion(&command);
|
2421 | 2266 |
EXPECT_FALSE(command.output().has_preedit());
|
2422 | |
// "あいうえお"
|
2423 | |
EXPECT_RESULT(kAiueo, command);
|
|
2267 |
EXPECT_RESULT("あいうえお", command);
|
2424 | 2268 |
EXPECT_EQ(ImeContext::PRECOMPOSITION, session.context().state());
|
2425 | 2269 |
|
2426 | 2270 |
command.Clear();
|
|
2429 | 2273 |
EXPECT_TRUE(command.output().has_deletion_range());
|
2430 | 2274 |
EXPECT_EQ(-5, command.output().deletion_range().offset());
|
2431 | 2275 |
EXPECT_EQ(5, command.output().deletion_range().length());
|
2432 | |
// "あい"
|
2433 | |
EXPECT_SINGLE_SEGMENT("\xE3\x81\x82\xE3\x81\x84", command);
|
|
2276 |
EXPECT_SINGLE_SEGMENT("あい", command);
|
2434 | 2277 |
EXPECT_EQ(2, command.output().candidates().size());
|
2435 | 2278 |
EXPECT_EQ(ImeContext::COMPOSITION, session.context().state());
|
2436 | 2279 |
}
|
|
2495 | 2338 |
command.Clear();
|
2496 | 2339 |
session->Convert(&command);
|
2497 | 2340 |
EXPECT_FALSE(command.output().has_result());
|
2498 | |
// "あいうえお"
|
2499 | |
EXPECT_PREEDIT(kAiueo, command);
|
|
2341 |
EXPECT_PREEDIT("あいうえお", command);
|
2500 | 2342 |
|
2501 | 2343 |
GetConverterMock()->SetCommitSegmentValue(&segments, true);
|
2502 | 2344 |
command.Clear();
|
2503 | 2345 |
session->Commit(&command);
|
2504 | 2346 |
EXPECT_FALSE(command.output().has_preedit());
|
2505 | |
// "あいうえお"
|
2506 | |
EXPECT_RESULT(kAiueo, command);
|
|
2347 |
EXPECT_RESULT("あいうえお", command);
|
2507 | 2348 |
|
2508 | 2349 |
command.Clear();
|
2509 | 2350 |
session->Undo(&command);
|
|
2511 | 2352 |
EXPECT_TRUE(command.output().has_deletion_range());
|
2512 | 2353 |
EXPECT_EQ(-5, command.output().deletion_range().offset());
|
2513 | 2354 |
EXPECT_EQ(5, command.output().deletion_range().length());
|
2514 | |
// "あいうえお"
|
2515 | |
EXPECT_PREEDIT(kAiueo, command);
|
|
2355 |
EXPECT_PREEDIT("あいうえお", command);
|
2516 | 2356 |
|
2517 | 2357 |
// Undo twice - do nothing and keep the previous status.
|
2518 | 2358 |
command.Clear();
|
2519 | 2359 |
session->Undo(&command);
|
2520 | 2360 |
EXPECT_FALSE(command.output().has_result());
|
2521 | 2361 |
EXPECT_FALSE(command.output().has_deletion_range());
|
2522 | |
// "あいうえお"
|
2523 | |
EXPECT_PREEDIT(kAiueo, command);
|
|
2362 |
EXPECT_PREEDIT("あいうえお", command);
|
2524 | 2363 |
}
|
2525 | 2364 |
|
2526 | 2365 |
{ // Undo after commitment of conversion
|
2527 | 2366 |
command.Clear();
|
2528 | 2367 |
session->ConvertNext(&command);
|
2529 | 2368 |
EXPECT_FALSE(command.output().has_result());
|
2530 | |
// "アイウエオ"
|
2531 | |
EXPECT_PREEDIT(kKatakanaAiueo, command);
|
|
2369 |
EXPECT_PREEDIT("アイウエオ", command);
|
2532 | 2370 |
|
2533 | 2371 |
GetConverterMock()->SetCommitSegmentValue(&segments, true);
|
2534 | 2372 |
command.Clear();
|
2535 | 2373 |
session->Commit(&command);
|
2536 | 2374 |
EXPECT_FALSE(command.output().has_preedit());
|
2537 | |
// "アイウエオ"
|
2538 | |
EXPECT_RESULT(kKatakanaAiueo, command);
|
|
2375 |
EXPECT_RESULT("アイウエオ", command);
|
2539 | 2376 |
|
2540 | 2377 |
command.Clear();
|
2541 | 2378 |
session->Undo(&command);
|
|
2543 | 2380 |
EXPECT_TRUE(command.output().has_deletion_range());
|
2544 | 2381 |
EXPECT_EQ(-5, command.output().deletion_range().offset());
|
2545 | 2382 |
EXPECT_EQ(5, command.output().deletion_range().length());
|
2546 | |
// "アイウエオ"
|
2547 | |
EXPECT_PREEDIT(kKatakanaAiueo, command);
|
|
2383 |
EXPECT_PREEDIT("アイウエオ", command);
|
2548 | 2384 |
|
2549 | 2385 |
// Undo twice - do nothing and keep the previous status.
|
2550 | 2386 |
command.Clear();
|
2551 | 2387 |
session->Undo(&command);
|
2552 | 2388 |
EXPECT_FALSE(command.output().has_result());
|
2553 | 2389 |
EXPECT_FALSE(command.output().has_deletion_range());
|
2554 | |
// "アイウエオ"
|
2555 | |
EXPECT_PREEDIT(kKatakanaAiueo, command);
|
|
2390 |
EXPECT_PREEDIT("アイウエオ", command);
|
2556 | 2391 |
}
|
2557 | 2392 |
|
2558 | 2393 |
{ // Undo after commitment of conversion with Ctrl-Backspace.
|
|
2808 | 2643 |
command.Clear();
|
2809 | 2644 |
session->Convert(&command);
|
2810 | 2645 |
EXPECT_FALSE(command.output().has_result());
|
2811 | |
// "あいうえお"
|
2812 | |
EXPECT_PREEDIT(kAiueo, command);
|
|
2646 |
EXPECT_PREEDIT("あいうえお", command);
|
2813 | 2647 |
|
2814 | 2648 |
GetConverterMock()->SetCommitSegmentValue(&segments, true);
|
2815 | 2649 |
command.Clear();
|
2816 | 2650 |
session->Commit(&command);
|
2817 | 2651 |
EXPECT_FALSE(command.output().has_preedit());
|
2818 | |
// "あいうえお"
|
2819 | |
EXPECT_RESULT(kAiueo, command);
|
|
2652 |
EXPECT_RESULT("あいうえお", command);
|
2820 | 2653 |
}
|
2821 | 2654 |
}
|
2822 | 2655 |
// Try UndoOrRewind twice.
|
|
2825 | 2658 |
command.Clear();
|
2826 | 2659 |
session->UndoOrRewind(&command);
|
2827 | 2660 |
EXPECT_FALSE(command.output().has_result());
|
2828 | |
// "あいうえお"
|
2829 | |
EXPECT_PREEDIT(kAiueo, command);
|
|
2661 |
EXPECT_PREEDIT("あいうえお", command);
|
2830 | 2662 |
EXPECT_TRUE(command.output().has_deletion_range());
|
2831 | 2663 |
command.Clear();
|
2832 | 2664 |
session->UndoOrRewind(&command);
|
2833 | 2665 |
EXPECT_FALSE(command.output().has_result());
|
2834 | |
// "あいうえお"
|
2835 | |
EXPECT_PREEDIT(kAiueo, command);
|
|
2666 |
EXPECT_PREEDIT("あいうえお", command);
|
2836 | 2667 |
EXPECT_FALSE(command.output().has_deletion_range());
|
2837 | 2668 |
}
|
2838 | 2669 |
|
|
2853 | 2684 |
commands::Command command;
|
2854 | 2685 |
InsertCharacterChars("11111", session.get(), &command);
|
2855 | 2686 |
EXPECT_FALSE(command.output().has_result());
|
2856 | |
// "お"
|
2857 | |
EXPECT_PREEDIT("\xE3\x81\x8A", command);
|
|
2687 |
EXPECT_PREEDIT("お", command);
|
2858 | 2688 |
EXPECT_FALSE(command.output().has_deletion_range());
|
2859 | 2689 |
EXPECT_TRUE(command.output().has_all_candidate_words());
|
2860 | 2690 |
|
2861 | 2691 |
command.Clear();
|
2862 | 2692 |
session->UndoOrRewind(&command);
|
2863 | 2693 |
EXPECT_FALSE(command.output().has_result());
|
2864 | |
// "え"
|
2865 | |
EXPECT_PREEDIT("\xE3\x81\x88", command);
|
|
2694 |
EXPECT_PREEDIT("え", command);
|
2866 | 2695 |
EXPECT_FALSE(command.output().has_deletion_range());
|
2867 | 2696 |
EXPECT_TRUE(command.output().has_all_candidate_words());
|
2868 | 2697 |
}
|
|
2878 | 2707 |
Segments segments;
|
2879 | 2708 |
{ // Initialize segments.
|
2880 | 2709 |
Segment *segment = segments.add_segment();
|
2881 | |
// "あbc"
|
2882 | |
segment->set_key("\xE3\x81\x82\xEF\xBD\x82\xEF\xBD\x83");
|
2883 | |
// "あべし"
|
2884 | |
segment->add_candidate()->value = "\xE3\x81\x82\xE3\x81\xB9\xE3\x81\x97";
|
|
2710 |
segment->set_key("あbc");
|
|
2711 |
segment->add_candidate()->value = "あべし";
|
2885 | 2712 |
}
|
2886 | 2713 |
|
2887 | 2714 |
command.Clear();
|
2888 | 2715 |
SetSendCommandCommand(commands::SessionCommand::COMMIT_RAW_TEXT, &command);
|
2889 | 2716 |
session->SendCommand(&command);
|
2890 | |
// "abc"
|
2891 | 2717 |
EXPECT_RESULT_AND_KEY("abc", "abc", command);
|
2892 | 2718 |
EXPECT_EQ(ImeContext::PRECOMPOSITION, session->context().state());
|
2893 | 2719 |
}
|
|
2901 | 2727 |
Segments segments;
|
2902 | 2728 |
{ // Initialize segments.
|
2903 | 2729 |
Segment *segment = segments.add_segment();
|
2904 | |
// "あbc"
|
2905 | |
segment->set_key("\xE3\x81\x82\xEF\xBD\x82\xEF\xBD\x83");
|
2906 | |
// "あべし"
|
2907 | |
segment->add_candidate()->value = "\xE3\x81\x82\xE3\x81\xB9\xE3\x81\x97";
|
|
2730 |
segment->set_key("あbc");
|
|
2731 |
segment->add_candidate()->value = "あべし";
|
2908 | 2732 |
}
|
2909 | 2733 |
|
2910 | 2734 |
ConversionRequest request;
|
|
2913 | 2737 |
GetConverterMock()->SetStartConversionForRequest(&segments, true);
|
2914 | 2738 |
command.Clear();
|
2915 | 2739 |
session->Convert(&command);
|
2916 | |
// "あべし"
|
2917 | |
EXPECT_PREEDIT("\xE3\x81\x82\xE3\x81\xB9\xE3\x81\x97", command);
|
|
2740 |
EXPECT_PREEDIT("あべし", command);
|
2918 | 2741 |
EXPECT_EQ(ImeContext::CONVERSION, session->context().state());
|
2919 | 2742 |
|
2920 | 2743 |
command.Clear();
|
2921 | 2744 |
SetSendCommandCommand(commands::SessionCommand::COMMIT_RAW_TEXT, &command);
|
2922 | 2745 |
session->SendCommand(&command);
|
2923 | |
// "abc"
|
2924 | 2746 |
EXPECT_RESULT_AND_KEY("abc", "abc", command);
|
2925 | 2747 |
EXPECT_EQ(ImeContext::PRECOMPOSITION, session->context().state());
|
2926 | 2748 |
}
|
|
2931 | 2753 |
Segment *segment;
|
2932 | 2754 |
Segment::Candidate *candidate;
|
2933 | 2755 |
composer::Table table;
|
2934 | |
// "す゛", "ず"
|
2935 | |
table.AddRule("\xe3\x81\x99\xe3\x82\x9b", "\xe3\x81\x9a", "");
|
|
2756 |
table.AddRule("す゛", "ず", "");
|
2936 | 2757 |
|
2937 | 2758 |
std::unique_ptr<Session> session(new Session(engine_.get()));
|
2938 | 2759 |
session->get_internal_composer_only_for_unittest()->SetTable(&table);
|
|
2940 | 2761 |
|
2941 | 2762 |
commands::Command command;
|
2942 | 2763 |
SetSendKeyCommand("m", &command);
|
2943 | |
// "も"
|
2944 | |
command.mutable_input()->mutable_key()->set_key_string("\xe3\x82\x82");
|
|
2764 |
command.mutable_input()->mutable_key()->set_key_string("も");
|
2945 | 2765 |
session->SendKey(&command);
|
2946 | 2766 |
|
2947 | 2767 |
SetSendKeyCommand("r", &command);
|
2948 | |
// "す"
|
2949 | |
command.mutable_input()->mutable_key()->set_key_string("\xe3\x81\x99");
|
|
2768 |
command.mutable_input()->mutable_key()->set_key_string("す");
|
2950 | 2769 |
session->SendKey(&command);
|
2951 | 2770 |
|
2952 | 2771 |
SetSendKeyCommand("@", &command);
|
2953 | |
// "゛"
|
2954 | |
command.mutable_input()->mutable_key()->set_key_string("\xe3\x82\x9b");
|
|
2772 |
command.mutable_input()->mutable_key()->set_key_string("゛");
|
2955 | 2773 |
session->SendKey(&command);
|
2956 | 2774 |
|
2957 | 2775 |
SetSendKeyCommand("h", &command);
|
2958 | |
// "く"
|
2959 | |
command.mutable_input()->mutable_key()->set_key_string("\xe3\x81\x8f");
|
|
2776 |
command.mutable_input()->mutable_key()->set_key_string("く");
|
2960 | 2777 |
session->SendKey(&command);
|
2961 | 2778 |
|
2962 | 2779 |
SetSendKeyCommand("!", &command);
|
2963 | 2780 |
command.mutable_input()->mutable_key()->set_key_string("!");
|
2964 | 2781 |
session->SendKey(&command);
|
2965 | 2782 |
|
2966 | |
// "もずく!"
|
2967 | |
EXPECT_EQ("\xe3\x82\x82\xe3\x81\x9a\xe3\x81\x8f\xef\xbc\x81",
|
2968 | |
command.output().preedit().segment(0).value());
|
|
2783 |
EXPECT_EQ("もずく!", command.output().preedit().segment(0).value());
|
2969 | 2784 |
|
2970 | 2785 |
segment = segments.add_segment();
|
2971 | |
// "もずく!"
|
2972 | |
segment->set_key("\xe3\x82\x82\xe3\x81\x9a\xe3\x81\x8f!");
|
|
2786 |
segment->set_key("もずく!");
|
2973 | 2787 |
candidate = segment->add_candidate();
|
2974 | |
// "もずく!"
|
2975 | |
candidate->value = "\xe3\x82\x82\xe3\x81\x9a\xe3\x81\x8f\xef\xbc\x81";
|
|
2788 |
candidate->value = "もずく!";
|
2976 | 2789 |
|
2977 | 2790 |
ConversionRequest request;
|
2978 | 2791 |
SetComposer(session.get(), &request);
|
|
2982 | 2795 |
command.Clear();
|
2983 | 2796 |
SetSendCommandCommand(commands::SessionCommand::COMMIT_RAW_TEXT, &command);
|
2984 | 2797 |
session->SendCommand(&command);
|
2985 | |
// "abc"
|
2986 | 2798 |
EXPECT_RESULT_AND_KEY("mr@h!", "mr@h!", command);
|
2987 | 2799 |
EXPECT_EQ(ImeContext::PRECOMPOSITION, session->context().state());
|
2988 | 2800 |
}
|
|
3011 | 2823 |
}
|
3012 | 2824 |
|
3013 | 2825 |
InsertCharacterChars("aiueo", session.get(), &command);
|
3014 | |
EXPECT_PREEDIT(kAiueo, command);
|
|
2826 |
EXPECT_PREEDIT("あいうえお", command);
|
3015 | 2827 |
|
3016 | 2828 |
// Should be ignored in composition state.
|
3017 | 2829 |
{
|
|
3021 | 2833 |
commands::SessionCommand::CONVERT_NEXT_PAGE);
|
3022 | 2834 |
ASSERT_TRUE(session->SendCommand(&command));
|
3023 | 2835 |
EXPECT_TRUE(command.output().consumed());
|
3024 | |
EXPECT_PREEDIT(kAiueo, command) << "should do nothing";
|
|
2836 |
EXPECT_PREEDIT("あいうえお", command) << "should do nothing";
|
3025 | 2837 |
|
3026 | 2838 |
command.Clear();
|
3027 | 2839 |
command.mutable_input()->set_type(commands::Input::SEND_COMMAND);
|
|
3029 | 2841 |
commands::SessionCommand::CONVERT_PREV_PAGE);
|
3030 | 2842 |
ASSERT_TRUE(session->SendCommand(&command));
|
3031 | 2843 |
EXPECT_TRUE(command.output().consumed());
|
3032 | |
EXPECT_PREEDIT(kAiueo, command) << "should do nothing";
|
|
2844 |
EXPECT_PREEDIT("あいうえお", command) << "should do nothing";
|
3033 | 2845 |
}
|
3034 | 2846 |
|
3035 | 2847 |
// Generate sequential candidates as follows.
|
|
3047 | 2859 |
Segments segments;
|
3048 | 2860 |
Segment *segment = NULL;
|
3049 | 2861 |
segment = segments.add_segment();
|
3050 | |
segment->set_key(kAiueo);
|
|
2862 |
segment->set_key("あいうえお");
|
3051 | 2863 |
for (int page_index = 0; page_index < 3; ++page_index) {
|
3052 | 2864 |
for (int cand_index = 0; cand_index < 9; ++cand_index) {
|
3053 | 2865 |
segment->add_candidate()->value = Util::StringPrintf(
|
|
3114 | 2926 |
command.Clear();
|
3115 | 2927 |
session->Convert(&command);
|
3116 | 2928 |
EXPECT_FALSE(command.output().has_result());
|
3117 | |
// "あいうえお"
|
3118 | |
EXPECT_PREEDIT(kAiueo, command);
|
|
2929 |
EXPECT_PREEDIT("あいうえお", command);
|
3119 | 2930 |
|
3120 | 2931 |
GetConverterMock()->SetCommitSegmentValue(&segments, true);
|
3121 | 2932 |
command.Clear();
|
3122 | 2933 |
session->Commit(&command);
|
3123 | 2934 |
EXPECT_FALSE(command.output().has_preedit());
|
3124 | |
// "あいうえお"
|
3125 | |
EXPECT_RESULT(kAiueo, command);
|
|
2935 |
EXPECT_RESULT("あいうえお", command);
|
3126 | 2936 |
|
3127 | 2937 |
SendKey("Shift", session.get(), &command);
|
3128 | 2938 |
EXPECT_FALSE(command.output().has_result());
|
|
3134 | 2944 |
EXPECT_TRUE(command.output().has_deletion_range());
|
3135 | 2945 |
EXPECT_EQ(-5, command.output().deletion_range().offset());
|
3136 | 2946 |
EXPECT_EQ(5, command.output().deletion_range().length());
|
3137 | |
// "あいうえお"
|
3138 | |
EXPECT_PREEDIT(kAiueo, command);
|
|
2947 |
EXPECT_PREEDIT("あいうえお", command);
|
3139 | 2948 |
}
|
3140 | 2949 |
|
3141 | 2950 |
{ // Type "aiueo" -> Convert -> Type "a" -> Escape -> Undo
|
|
3149 | 2958 |
command.Clear();
|
3150 | 2959 |
session->Convert(&command);
|
3151 | 2960 |
EXPECT_FALSE(command.output().has_result());
|
3152 | |
// "あいうえお"
|
3153 | |
EXPECT_PREEDIT(kAiueo, command);
|
|
2961 |
EXPECT_PREEDIT("あいうえお", command);
|
3154 | 2962 |
|
3155 | 2963 |
SendKey("a", session.get(), &command);
|
3156 | |
// "あいうえお"
|
3157 | |
EXPECT_RESULT(kAiueo, command);
|
3158 | |
// "あ"
|
3159 | |
EXPECT_SINGLE_SEGMENT(kHiraganaA, command);
|
|
2964 |
EXPECT_RESULT("あいうえお", command);
|
|
2965 |
EXPECT_SINGLE_SEGMENT("あ", command);
|
3160 | 2966 |
|
3161 | 2967 |
SendKey("Escape", session.get(), &command);
|
3162 | 2968 |
EXPECT_FALSE(command.output().has_result());
|
|
3168 | 2974 |
EXPECT_TRUE(command.output().has_deletion_range());
|
3169 | 2975 |
EXPECT_EQ(-5, command.output().deletion_range().offset());
|
3170 | 2976 |
EXPECT_EQ(5, command.output().deletion_range().length());
|
3171 | |
// "あいうえお"
|
3172 | |
EXPECT_PREEDIT(kAiueo, command);
|
|
2977 |
EXPECT_PREEDIT("あいうえお", command);
|
3173 | 2978 |
}
|
3174 | 2979 |
}
|
3175 | 2980 |
|
|
3202 | 3007 |
command.Clear();
|
3203 | 3008 |
session->Convert(&command);
|
3204 | 3009 |
EXPECT_FALSE(command.output().has_result());
|
3205 | |
// "あいうえお"
|
3206 | |
EXPECT_PREEDIT(kAiueo, command);
|
|
3010 |
EXPECT_PREEDIT("あいうえお", command);
|
3207 | 3011 |
// Direct input
|
3208 | 3012 |
SendKey("Numpad0", session.get(), &command);
|
3209 | 3013 |
EXPECT_TRUE(GetComposition(command).empty());
|
3210 | |
// "あいうえお0"
|
3211 | |
EXPECT_RESULT(string(kAiueo) + "0", command);
|
|
3014 |
EXPECT_RESULT("あいうえお0", command);
|
3212 | 3015 |
|
3213 | 3016 |
// Undo - Do NOT nothing
|
3214 | 3017 |
command.Clear();
|
|
3257 | 3060 |
SendKey("a", session.get(), &command);
|
3258 | 3061 |
EXPECT_EQ(commands::HIRAGANA, command.output().mode());
|
3259 | 3062 |
EXPECT_FALSE(command.output().has_result());
|
3260 | |
// "AAあ"
|
3261 | |
EXPECT_PREEDIT("AA\xE3\x81\x82", command);
|
|
3063 |
EXPECT_PREEDIT("AAあ", command);
|
3262 | 3064 |
|
3263 | 3065 |
// Submit and Undo
|
3264 | 3066 |
SendKey("Enter", session.get(), &command);
|
|
3267 | 3069 |
session->Undo(&command);
|
3268 | 3070 |
EXPECT_EQ(commands::HIRAGANA, command.output().mode());
|
3269 | 3071 |
EXPECT_FALSE(command.output().has_result());
|
3270 | |
// "AAあ"
|
3271 | |
EXPECT_PREEDIT("AA\xE3\x81\x82", command);
|
|
3072 |
EXPECT_PREEDIT("AAあ", command);
|
3272 | 3073 |
|
3273 | 3074 |
// Input additional "Aa"
|
3274 | 3075 |
SendKey("A", session.get(), &command);
|
3275 | 3076 |
SendKey("a", session.get(), &command);
|
3276 | 3077 |
EXPECT_FALSE(command.output().has_result());
|
3277 | |
// "AAあAa"
|
3278 | |
EXPECT_PREEDIT("AA" + string(kHiraganaA) + "Aa", command);
|
|
3078 |
EXPECT_PREEDIT("AAあAa", command);
|
3279 | 3079 |
EXPECT_EQ(commands::HALF_ASCII, command.output().mode());
|
3280 | 3080 |
|
3281 | 3081 |
// Submit and Undo
|
|
3285 | 3085 |
session->Undo(&command);
|
3286 | 3086 |
EXPECT_EQ(commands::HALF_ASCII, command.output().mode());
|
3287 | 3087 |
EXPECT_FALSE(command.output().has_result());
|
3288 | |
// "AAあAa"
|
3289 | |
EXPECT_PREEDIT("AA" + string(kHiraganaA) + "Aa", command);
|
|
3088 |
EXPECT_PREEDIT("AAあAa", command);
|
3290 | 3089 |
}
|
3291 | 3090 |
|
3292 | 3091 |
TEST_F(SessionTest, DCHECKFailureAfterUndo) {
|
|
3305 | 3104 |
command.Clear();
|
3306 | 3105 |
session->Undo(&command);
|
3307 | 3106 |
EXPECT_FALSE(command.output().has_result());
|
3308 | |
// "あべ"
|
3309 | |
EXPECT_PREEDIT("\xE3\x81\x82\xE3\x81\xB9", command);
|
|
3107 |
EXPECT_PREEDIT("あべ", command);
|
3310 | 3108 |
|
3311 | 3109 |
InsertCharacterChars("s", session.get(), &command);
|
3312 | 3110 |
EXPECT_FALSE(command.output().has_result());
|
3313 | |
// "あべs"
|
3314 | |
EXPECT_PREEDIT("\xE3\x81\x82\xE3\x81\xB9\xEF\xBD\x93", command);
|
|
3111 |
EXPECT_PREEDIT("あべs", command);
|
3315 | 3112 |
|
3316 | 3113 |
InsertCharacterChars("h", session.get(), &command);
|
3317 | 3114 |
EXPECT_FALSE(command.output().has_result());
|
3318 | |
// "あべsh"
|
3319 | |
EXPECT_PREEDIT("\xE3\x81\x82\xE3\x81\xB9\xEF\xBD\x93\xEF\xBD\x88", command);
|
|
3115 |
EXPECT_PREEDIT("あべsh", command);
|
3320 | 3116 |
|
3321 | 3117 |
InsertCharacterChars("i", session.get(), &command);
|
3322 | 3118 |
EXPECT_FALSE(command.output().has_result());
|
3323 | |
// "あべし"
|
3324 | |
EXPECT_PREEDIT("\xE3\x81\x82\xE3\x81\xB9\xE3\x81\x97", command);
|
|
3119 |
EXPECT_PREEDIT("あべし", command);
|
3325 | 3120 |
}
|
3326 | 3121 |
|
3327 | 3122 |
TEST_F(SessionTest, ConvertToFullOrHalfAlphanumericAfterUndo) {
|
|
3349 | 3144 |
session->Undo(&command);
|
3350 | 3145 |
EXPECT_FALSE(command.output().has_result());
|
3351 | 3146 |
ASSERT_TRUE(command.output().has_preedit());
|
3352 | |
// "あいうえお"
|
3353 | |
EXPECT_EQ(kAiueo, GetComposition(command));
|
|
3147 |
EXPECT_EQ("あいうえお", GetComposition(command));
|
3354 | 3148 |
|
3355 | 3149 |
GetConverterMock()->SetStartConversionForRequest(&segments, true);
|
3356 | 3150 |
command.Clear();
|
|
3369 | 3163 |
session->Undo(&command);
|
3370 | 3164 |
EXPECT_FALSE(command.output().has_result());
|
3371 | 3165 |
ASSERT_TRUE(command.output().has_preedit());
|
3372 | |
// "あいうえお"
|
3373 | |
EXPECT_EQ(kAiueo, GetComposition(command));
|
|
3166 |
EXPECT_EQ("あいうえお", GetComposition(command));
|
3374 | 3167 |
|
3375 | 3168 |
GetConverterMock()->SetStartConversionForRequest(&segments, true);
|
3376 | 3169 |
command.Clear();
|
3377 | 3170 |
session->ConvertToFullASCII(&command);
|
3378 | 3171 |
EXPECT_FALSE(command.output().has_result());
|
3379 | 3172 |
ASSERT_TRUE(command.output().has_preedit());
|
3380 | |
// "aiueo"
|
3381 | |
EXPECT_EQ("\xEF\xBD\x81\xEF\xBD\x89\xEF\xBD\x95\xEF\xBD\x85\xEF\xBD\x8F",
|
3382 | |
GetComposition(command));
|
|
3173 |
EXPECT_EQ("aiueo", GetComposition(command));
|
3383 | 3174 |
}
|
3384 | 3175 |
}
|
3385 | 3176 |
|
|
3399 | 3190 |
|
3400 | 3191 |
commands::Command command;
|
3401 | 3192 |
|
3402 | |
// "ち"
|
3403 | |
InsertCharacterCodeAndString('a', "\xE3\x81\xA1", session.get(), &command);
|
3404 | |
// "ち"
|
3405 | |
EXPECT_EQ("\xE3\x81\xA1", GetComposition(command));
|
|
3193 |
InsertCharacterCodeAndString('a', "ち", session.get(), &command);
|
|
3194 |
EXPECT_EQ("ち", GetComposition(command));
|
3406 | 3195 |
|
3407 | 3196 |
SendKey("Enter", session.get(), &command);
|
3408 | 3197 |
command.Clear();
|
|
3410 | 3199 |
|
3411 | 3200 |
EXPECT_FALSE(command.output().has_result());
|
3412 | 3201 |
ASSERT_TRUE(command.output().has_preedit());
|
3413 | |
// "ち"
|
3414 | |
EXPECT_EQ("\xE3\x81\xA1", GetComposition(command));
|
3415 | |
|
3416 | |
// "゛"
|
3417 | |
InsertCharacterCodeAndString('@', "\xE3\x82\x9B", session.get(), &command);
|
|
3202 |
EXPECT_EQ("ち", GetComposition(command));
|
|
3203 |
|
|
3204 |
InsertCharacterCodeAndString('@', "゛", session.get(), &command);
|
3418 | 3205 |
EXPECT_FALSE(command.output().has_result());
|
3419 | 3206 |
ASSERT_TRUE(command.output().has_preedit());
|
3420 | |
// "ぢ"
|
3421 | |
EXPECT_EQ("\xE3\x81\xA2", GetComposition(command));
|
|
3207 |
EXPECT_EQ("ぢ", GetComposition(command));
|
3422 | 3208 |
}
|
3423 | 3209 |
|
3424 | 3210 |
TEST_F(SessionTest, SpaceOnAlphanumeric) {
|
|
3454 | 3240 |
|
3455 | 3241 |
SendKey("a", &session, &command);
|
3456 | 3242 |
EXPECT_RESULT("A ", command);
|
3457 | |
// "あ"
|
3458 | |
EXPECT_EQ(kHiraganaA, GetComposition(command));
|
|
3243 |
EXPECT_EQ("あ", GetComposition(command));
|
3459 | 3244 |
}
|
3460 | 3245 |
|
3461 | 3246 |
{
|
|
3490 | 3275 |
InsertCharacterChars("watasinonamae", session.get(), &command);
|
3491 | 3276 |
|
3492 | 3277 |
segment = segments.add_segment();
|
3493 | |
// "わたしの"
|
3494 | |
segment->set_key("\xe3\x82\x8f\xe3\x81\x9f\xe3\x81\x97\xe3\x81\xae");
|
|
3278 |
segment->set_key("わたしの");
|
3495 | 3279 |
candidate = segment->add_candidate();
|
3496 | |
// "私の"
|
3497 | |
candidate->value = "\xe7\xa7\x81\xe3\x81\xae";
|
|
3280 |
candidate->value = "私の";
|
3498 | 3281 |
candidate = segment->add_candidate();
|
3499 | |
// "渡しの"
|
3500 | |
candidate->value = "\xe6\xb8\xa1\xe3\x81\x97\xe3\x81\xae";
|
|
3282 |
candidate->value = "渡しの";
|
3501 | 3283 |
segment = segments.add_segment();
|
3502 | |
// "名前"
|
3503 | |
segment->set_key("\xe5\x90\x8d\xe5\x89\x8d");
|
|
3284 |
segment->set_key("名前");
|
3504 | 3285 |
candidate = segment->add_candidate();
|
3505 | |
// "なまえ"
|
3506 | |
candidate->value = "\xe3\x81\xaa\xe3\x81\xbe\xe3\x81\x88";
|
|
3286 |
candidate->value = "なまえ";
|
3507 | 3287 |
candidate = segment->add_candidate();
|
3508 | |
// "ナマエ"
|
3509 | |
candidate->value = "\xe3\x83\x8a\xe3\x83\x9e\xe3\x82\xa8";
|
|
3288 |
candidate->value = "ナマエ";
|
3510 | 3289 |
|
3511 | 3290 |
ConversionRequest request;
|
3512 | 3291 |
SetComposer(session.get(), &request);
|
|
3548 | 3327 |
commands::Command command;
|
3549 | 3328 |
InsertCharacterChars("kamabokonoinbou", session.get(), &command);
|
3550 | 3329 |
segment = segments.add_segment();
|
3551 | |
// "かまぼこの"
|
3552 | |
segment->set_key(
|
3553 | |
"\xe3\x81\x8b\xe3\x81\xbe\xe3\x81\xbc\xe3\x81\x93\xe3\x81\xae");
|
|
3330 |
segment->set_key("かまぼこの");
|
3554 | 3331 |
candidate = segment->add_candidate();
|
3555 | |
// "かまぼこの"
|
3556 | |
candidate->value
|
3557 | |
= "\xe3\x81\x8b\xe3\x81\xbe\xe3\x81\xbc\xe3\x81\x93\xe3\x81\xae";
|
|
3332 |
candidate->value = "かまぼこの";
|
3558 | 3333 |
candidate = segment->add_candidate();
|
3559 | |
// "カマボコの"
|
3560 | |
candidate->value
|
3561 | |
= "\xe3\x82\xab\xe3\x83\x9e\xe3\x83\x9c\xe3\x82\xb3\xe3\x81\xae";
|
|
3334 |
candidate->value = "カマボコの";
|
3562 | 3335 |
segment = segments.add_segment();
|
3563 | |
// "いんぼう"
|
3564 | |
segment->set_key("\xe3\x81\x84\xe3\x82\x93\xe3\x81\xbc\xe3\x81\x86");
|
|
3336 |
segment->set_key("いんぼう");
|
3565 | 3337 |
candidate = segment->add_candidate();
|
3566 | |
// "陰謀"
|
3567 | |
candidate->value = "\xe9\x99\xb0\xe8\xac\x80";
|
|
3338 |
candidate->value = "陰謀";
|
3568 | 3339 |
candidate = segment->add_candidate();
|
3569 | |
// "印房"
|
3570 | |
candidate->value = "\xe5\x8d\xb0\xe6\x88\xbf";
|
|
3340 |
candidate->value = "印房";
|
3571 | 3341 |
|
3572 | 3342 |
ConversionRequest request;
|
3573 | 3343 |
SetComposer(session.get(), &request);
|
|
3590 | 3360 |
|
3591 | 3361 |
segments.Clear();
|
3592 | 3362 |
segment = segments.add_segment();
|
3593 | |
// "いんぼう"
|
3594 | |
segment->set_key("\xe3\x81\x84\xe3\x82\x93\xe3\x81\xbc\xe3\x81\x86");
|
|
3363 |
segment->set_key("いんぼう");
|
3595 | 3364 |
candidate = segment->add_candidate();
|
3596 | |
// "陰謀"
|
3597 | |
candidate->value = "\xe9\x99\xb0\xe8\xac\x80";
|
|
3365 |
candidate->value = "陰謀";
|
3598 | 3366 |
candidate = segment->add_candidate();
|
3599 | |
// "陰謀論"
|
3600 | |
candidate->value = "\xe9\x99\xb0\xe8\xac\x80\xe8\xab\x96";
|
|
3367 |
candidate->value = "陰謀論";
|
3601 | 3368 |
candidate = segment->add_candidate();
|
3602 | |
// "陰謀説"
|
3603 | |
candidate->value = "\xe9\x99\xb0\xe8\xac\x80\xe8\xaa\xac";
|
|
3369 |
candidate->value = "陰謀説";
|
3604 | 3370 |
|
3605 | 3371 |
GetConverterMock()->SetStartPredictionForRequest(&segments, true);
|
3606 | 3372 |
|
|
3620 | 3386 |
Segments segments;
|
3621 | 3387 |
Segment *segment;
|
3622 | 3388 |
segment = segments.add_segment();
|
3623 | |
// "かまぼこの"
|
3624 | |
segment->set_key(
|
3625 | |
"\xe3\x81\x8b\xe3\x81\xbe\xe3\x81\xbc\xe3\x81\x93\xe3\x81\xae");
|
|
3389 |
segment->set_key("かまぼこの");
|
3626 | 3390 |
candidate = segment->add_candidate();
|
3627 | |
// "かまぼこの"
|
3628 | |
candidate->value
|
3629 | |
= "\xe3\x81\x8b\xe3\x81\xbe\xe3\x81\xbc\xe3\x81\x93\xe3\x81\xae";
|
|
3391 |
candidate->value = "かまぼこの";
|
3630 | 3392 |
candidate = segment->add_candidate();
|
3631 | |
// "カマボコの"
|
3632 | |
candidate->value
|
3633 | |
= "\xe3\x82\xab\xe3\x83\x9e\xe3\x83\x9c\xe3\x82\xb3\xe3\x81\xae";
|
|
3393 |
candidate->value = "カマボコの";
|
3634 | 3394 |
|
3635 | 3395 |
segment = segments.add_segment();
|
3636 | |
// "いんぼう"
|
3637 | |
segment->set_key("\xe3\x81\x84\xe3\x82\x93\xe3\x81\xbc\xe3\x81\x86");
|
|
3396 |
segment->set_key("いんぼう");
|
3638 | 3397 |
candidate = segment->add_candidate();
|
3639 | |
// "陰謀"
|
3640 | |
candidate->value = "\xe9\x99\xb0\xe8\xac\x80";
|
|
3398 |
candidate->value = "陰謀";
|
3641 | 3399 |
candidate = segment->add_candidate();
|
3642 | |
// "印房"
|
3643 | |
candidate->value = "\xe5\x8d\xb0\xe6\x88\xbf";
|
|
3400 |
candidate->value = "印房";
|
3644 | 3401 |
ConversionRequest request;
|
3645 | 3402 |
SetComposer(session.get(), &request);
|
3646 | 3403 |
FillT13Ns(request, &segments);
|
|
3650 | 3407 |
Segments segments;
|
3651 | 3408 |
Segment *segment;
|
3652 | 3409 |
segment = segments.add_segment();
|
3653 | |
// "かまぼこの"
|
3654 | |
segment->set_key(
|
3655 | |
"\xe3\x81\x8b\xe3\x81\xbe\xe3\x81\xbc\xe3\x81\x93\xe3\x81\xae");
|
|
3410 |
segment->set_key("かまぼこの");
|
3656 | 3411 |
candidate = segment->add_candidate();
|
3657 | |
// "かまぼこの"
|
3658 | |
candidate->value
|
3659 | |
= "\xe3\x81\x8b\xe3\x81\xbe\xe3\x81\xbc\xe3\x81\x93\xe3\x81\xae";
|
|
3412 |
candidate->value = "かまぼこの";
|
3660 | 3413 |
candidate = segment->add_candidate();
|
3661 | |
// "カマボコの"
|
3662 | |
candidate->value
|
3663 | |
= "\xe3\x82\xab\xe3\x83\x9e\xe3\x83\x9c\xe3\x82\xb3\xe3\x81\xae";
|
|
3414 |
candidate->value = "カマボコの";
|
3664 | 3415 |
|
3665 | 3416 |
segment = segments.add_segment();
|
3666 | |
// "いんぼ"
|
3667 | |
segment->set_key("\xe3\x81\x84\xe3\x82\x93\xe3\x81\xbc");
|
|
3417 |
segment->set_key("いんぼ");
|
3668 | 3418 |
candidate = segment->add_candidate();
|
3669 | |
// "いんぼ"
|
3670 | |
candidate->value = "\xe3\x81\x84\xe3\x82\x93\xe3\x81\xbc";
|
|
3419 |
candidate->value = "いんぼ";
|
3671 | 3420 |
candidate = segment->add_candidate();
|
3672 | |
// "インボ"
|
3673 | |
candidate->value = "\xe3\x82\xa4\xe3\x83\xb3\xe3\x83\x9c";
|
|
3421 |
candidate->value = "インボ";
|
3674 | 3422 |
|
3675 | 3423 |
segment = segments.add_segment();
|
3676 | |
// "う"
|
3677 | |
segment->set_key("\xe3\x81\x86");
|
|
3424 |
segment->set_key("う");
|
3678 | 3425 |
candidate = segment->add_candidate();
|
3679 | |
// "ウ"
|
3680 | |
candidate->value = "\xe3\x82\xa6";
|
|
3426 |
candidate->value = "ウ";
|
3681 | 3427 |
candidate = segment->add_candidate();
|
3682 | |
// "卯"
|
3683 | |
candidate->value = "\xe5\x8d\xaf";
|
|
3428 |
candidate->value = "卯";
|
3684 | 3429 |
|
3685 | 3430 |
ConversionRequest request;
|
3686 | 3431 |
SetComposer(session.get(), &request);
|
|
3697 | 3442 |
// Convert to T13N (Half katakana)
|
3698 | 3443 |
SendKey("F8", session.get(), &command);
|
3699 | 3444 |
|
3700 | |
// "インボ"
|
3701 | |
EXPECT_EQ("\xef\xbd\xb2\xef\xbe\x9d\xef\xbe\x8e\xef\xbe\x9e",
|
3702 | |
command.output().preedit().segment(1).value());
|
|
3445 |
EXPECT_EQ("インボ", command.output().preedit().segment(1).value());
|
3703 | 3446 |
}
|
3704 | 3447 |
|
3705 | 3448 |
TEST_F(SessionTest, Shortcut) {
|
|
3784 | 3527 |
// See the description in command.proto.
|
3785 | 3528 |
EXPECT_TRUE(SendKey("CAPS S", session.get(), &command));
|
3786 | 3529 |
EXPECT_TRUE(command.output().consumed());
|
3787 | |
// "アイウエオ"
|
3788 | |
EXPECT_EQ("\xE3\x82\xA2\xE3\x82\xA4\xE3\x82\xA6\xE3\x82\xA8\xE3\x82\xAA",
|
3789 | |
GetComposition(command));
|
|
3530 |
EXPECT_EQ("アイウエオ", GetComposition(command));
|
3790 | 3531 |
}
|
3791 | 3532 |
|
3792 | 3533 |
TEST_F(SessionTest, NumpadKey) {
|
|
3854 | 3595 |
EXPECT_TRUE(TestSendKey("0", session.get(), &command));
|
3855 | 3596 |
EXPECT_TRUE(SendKey("0", session.get(), &command));
|
3856 | 3597 |
|
3857 | |
// "0"
|
3858 | |
EXPECT_SINGLE_SEGMENT_AND_KEY("\xEF\xBC\x90", "\xEF\xBC\x90", command);
|
|
3598 |
EXPECT_SINGLE_SEGMENT_AND_KEY("0", "0", command);
|
3859 | 3599 |
|
3860 | 3600 |
// In the Composition state, DIVIDE on the pre-edit should be treated as "/".
|
3861 | 3601 |
EXPECT_TRUE(TestSendKey("Divide", session.get(), &command));
|
3862 | 3602 |
EXPECT_TRUE(SendKey("Divide", session.get(), &command));
|
3863 | 3603 |
|
3864 | |
// "0/"
|
3865 | |
EXPECT_SINGLE_SEGMENT_AND_KEY(
|
3866 | |
"\xEF\xBC\x90\x2F", "\xEF\xBC\x90\x2F", command);
|
|
3604 |
EXPECT_SINGLE_SEGMENT_AND_KEY("0/", "0/", command);
|
3867 | 3605 |
|
3868 | 3606 |
// In the Composition state, "Numpad0" should be treated as half-width "0".
|
3869 | 3607 |
EXPECT_TRUE(SendKey("Numpad0", session.get(), &command));
|
3870 | 3608 |
|
3871 | |
// "0/0"
|
3872 | |
EXPECT_SINGLE_SEGMENT_AND_KEY(
|
3873 | |
"\xEF\xBC\x90\x2F\x30", "\xEF\xBC\x90\x2F\x30", command);
|
|
3609 |
EXPECT_SINGLE_SEGMENT_AND_KEY("0/0", "0/0", command);
|
3874 | 3610 |
|
3875 | 3611 |
// Separator should be treated as Enter.
|
3876 | 3612 |
EXPECT_TRUE(TestSendKey("Separator", session.get(), &command));
|
3877 | 3613 |
EXPECT_TRUE(SendKey("Separator", session.get(), &command));
|
3878 | 3614 |
|
3879 | 3615 |
EXPECT_FALSE(command.output().has_preedit());
|
3880 | |
// "0/0"
|
3881 | |
EXPECT_RESULT("\xEF\xBC\x90\x2F\x30", command);
|
|
3616 |
EXPECT_RESULT("0/0", command);
|
3882 | 3617 |
|
3883 | 3618 |
// http://b/2097087
|
3884 | 3619 |
EXPECT_TRUE(SendKey("0", session.get(), &command));
|
3885 | 3620 |
|
3886 | |
// "0"
|
3887 | |
EXPECT_SINGLE_SEGMENT_AND_KEY("\xEF\xBC\x90", "\xEF\xBC\x90", command);
|
|
3621 |
EXPECT_SINGLE_SEGMENT_AND_KEY("0", "0", command);
|
3888 | 3622 |
|
3889 | 3623 |
EXPECT_TRUE(SendKey("Divide", session.get(), &command));
|
3890 | |
// "0/"
|
3891 | |
EXPECT_SINGLE_SEGMENT_AND_KEY(
|
3892 | |
"\xEF\xBC\x90\x2F", "\xEF\xBC\x90\x2F", command);
|
|
3624 |
EXPECT_SINGLE_SEGMENT_AND_KEY("0/", "0/", command);
|
3893 | 3625 |
|
3894 | 3626 |
EXPECT_TRUE(SendKey("Divide", session.get(), &command));
|
3895 | |
// "0//"
|
3896 | |
EXPECT_SINGLE_SEGMENT_AND_KEY(
|
3897 | |
"\xEF\xBC\x90\x2F\x2F", "\xEF\xBC\x90\x2F\x2F", command);
|
|
3627 |
EXPECT_SINGLE_SEGMENT_AND_KEY("0//", "0//", command);
|
3898 | 3628 |
|
3899 | 3629 |
EXPECT_TRUE(SendKey("Subtract", session.get(), &command));
|
3900 | 3630 |
EXPECT_TRUE(SendKey("Subtract", session.get(), &command));
|
3901 | 3631 |
EXPECT_TRUE(SendKey("Decimal", session.get(), &command));
|
3902 | 3632 |
EXPECT_TRUE(SendKey("Decimal", session.get(), &command));
|
3903 | |
// "0//--.."
|
3904 | |
EXPECT_SINGLE_SEGMENT_AND_KEY(
|
3905 | |
"\xEF\xBC\x90\x2F\x2F\x2D\x2D\x2E\x2E",
|
3906 | |
"\xEF\xBC\x90\x2F\x2F\x2D\x2D\x2E\x2E", command);
|
|
3633 |
EXPECT_SINGLE_SEGMENT_AND_KEY("0//--..", "0//--..", command);
|
3907 | 3634 |
}
|
3908 | 3635 |
|
3909 | 3636 |
TEST_F(SessionTest, KanaSymbols) {
|
|
3918 | 3645 |
{
|
3919 | 3646 |
commands::Command command;
|
3920 | 3647 |
SetSendKeyCommand("<", &command);
|
3921 | |
// "、"
|
3922 | |
command.mutable_input()->mutable_key()->set_key_string("\xe3\x80\x81");
|
|
3648 |
command.mutable_input()->mutable_key()->set_key_string("、");
|
3923 | 3649 |
EXPECT_TRUE(session->SendKey(&command));
|
3924 | |
// ","
|
3925 | 3650 |
EXPECT_EQ(static_cast<uint32>(','), command.input().key().key_code());
|
3926 | |
EXPECT_EQ("\xef\xbc\x8c", command.input().key().key_string());
|
3927 | |
EXPECT_EQ("\xef\xbc\x8c", command.output().preedit().segment(0).value());
|
|
3651 |
EXPECT_EQ(",", command.input().key().key_string());
|
|
3652 |
EXPECT_EQ(",", command.output().preedit().segment(0).value());
|
3928 | 3653 |
}
|
3929 | 3654 |
{
|
3930 | 3655 |
commands::Command command;
|
|
3933 | 3658 |
{
|
3934 | 3659 |
commands::Command command;
|
3935 | 3660 |
SetSendKeyCommand("?", &command);
|
3936 | |
// "・"
|
3937 | |
command.mutable_input()->mutable_key()->set_key_string("\xe3\x83\xbb");
|
|
3661 |
command.mutable_input()->mutable_key()->set_key_string("・");
|
3938 | 3662 |
EXPECT_TRUE(session->SendKey(&command));
|
3939 | |
// "/"
|
3940 | 3663 |
EXPECT_EQ(static_cast<uint32>('/'), command.input().key().key_code());
|
3941 | |
EXPECT_EQ("\xef\xbc\x8f", command.input().key().key_string());
|
3942 | |
EXPECT_EQ("\xef\xbc\x8f", command.output().preedit().segment(0).value());
|
|
3664 |
EXPECT_EQ("/", command.input().key().key_string());
|
|
3665 |
EXPECT_EQ("/", command.output().preedit().segment(0).value());
|
3943 | 3666 |
}
|
3944 | 3667 |
}
|
3945 | 3668 |
|
|
3957 | 3680 |
// Shift does nothing because the input mode has already been reverted.
|
3958 | 3681 |
EXPECT_TRUE(SendKey("Shift", session.get(), &command));
|
3959 | 3682 |
EXPECT_TRUE(SendKey("a", session.get(), &command)); // "あAaああ"
|
3960 | |
// "あAaああ"
|
3961 | |
EXPECT_EQ("\xE3\x81\x82\x41\x61\xE3\x81\x82\xE3\x81\x82",
|
3962 | |
GetComposition(command));
|
|
3683 |
EXPECT_EQ("あAaああ", GetComposition(command));
|
3963 | 3684 |
}
|
3964 | 3685 |
|
3965 | 3686 |
{ // Revert back to the previous input mode.
|
|
3977 | 3698 |
// Shift does nothing because the input mode has already been reverted.
|
3978 | 3699 |
EXPECT_TRUE(SendKey("Shift", session.get(), &command));
|
3979 | 3700 |
EXPECT_TRUE(SendKey("a", session.get(), &command)); // "アAaアア"
|
3980 | |
// "アAaアア"
|
3981 | |
EXPECT_EQ("\xE3\x82\xA2\x41\x61\xE3\x82\xA2\xE3\x82\xA2",
|
3982 | |
GetComposition(command));
|
|
3701 |
EXPECT_EQ("アAaアア", GetComposition(command));
|
3983 | 3702 |
}
|
3984 | 3703 |
}
|
3985 | 3704 |
|
|
4406 | 4125 |
segments_jueri.set_request_type(Segments::PARTIAL_SUGGESTION);
|
4407 | 4126 |
Segment *segment;
|
4408 | 4127 |
segment = segments_jueri.add_segment();
|
4409 | |
// "じゅえり"
|
4410 | |
const char kJueri[] = "\xE3\x81\x98\xE3\x82\x85\xE3\x81\x88\xE3\x82\x8A";
|
|
4128 |
const char kJueri[] = "じゅえり";
|
4411 | 4129 |
segment->set_key(kJueri);
|
4412 | 4130 |
Segment::Candidate *candidate = segment->add_candidate();
|
4413 | |
candidate->key = "\xE3\x81\x8F\xE3\x81\x88\xE3\x82\x8A"; // "くえり"
|
|
4131 |
candidate->key = "くえり";
|
4414 | 4132 |
candidate->content_key = candidate->key;
|
4415 | |
candidate->value = "\xE3\x82\xAF\xE3\x82\xA8\xE3\x83\xAA"; // "クエリ"
|
|
4133 |
candidate->value = "クエリ";
|
4416 | 4134 |
candidate->attributes = Segment::Candidate::PARTIALLY_KEY_CONSUMED;
|
4417 | 4135 |
candidate->consumed_key_size = Util::CharsLen(kJueri);
|
4418 | 4136 |
|
|
4425 | 4143 |
|
4426 | 4144 |
ASSERT_TRUE(command.output().has_candidates());
|
4427 | 4145 |
EXPECT_EQ(1, command.output().preedit().segment_size());
|
4428 | |
EXPECT_EQ(kJueri,
|
4429 | |
command.output().preedit().segment(0).key());
|
|
4146 |
EXPECT_EQ(kJueri, command.output().preedit().segment(0).key());
|
4430 | 4147 |
EXPECT_EQ(1, command.output().candidates().candidate_size());
|
4431 | |
EXPECT_EQ("\xE3\x82\xAF\xE3\x82\xA8\xE3\x83\xAA", // "クエリ"
|
4432 | |
command.output().candidates().candidate(0).value());
|
|
4148 |
EXPECT_EQ("クエリ", command.output().candidates().candidate(0).value());
|
4433 | 4149 |
|
4434 | 4150 |
// commit partial suggestion
|
4435 | 4151 |
Segments empty_segments;
|
|
4439 | 4155 |
GetConverterMock()->SetStartSuggestionForRequest(&segments_jueri, true);
|
4440 | 4156 |
session->SendCommand(&command);
|
4441 | 4157 |
EXPECT_TRUE(command.output().consumed());
|
4442 | |
// "クエリ", "くえり"
|
4443 | |
EXPECT_RESULT_AND_KEY(
|
4444 | |
"\xE3\x82\xAF\xE3\x82\xA8\xE3\x83\xAA",
|
4445 | |
"\xE3\x81\x8F\xE3\x81\x88\xE3\x82\x8A", command);
|
|
4158 |
EXPECT_RESULT_AND_KEY("クエリ", "くえり", command);
|
4446 | 4159 |
EXPECT_FALSE(command.output().has_preedit());
|
4447 | 4160 |
}
|
4448 | 4161 |
|
|
4457 | 4170 |
segments_wata.set_request_type(Segments::PARTIAL_SUGGESTION);
|
4458 | 4171 |
Segment *segment;
|
4459 | 4172 |
segment = segments_wata.add_segment();
|
4460 | |
// "わた"
|
4461 | |
const char kWata[] = "\xe3\x82\x8f\xe3\x81\x9f";
|
|
4173 |
const char kWata[] = "わた";
|
4462 | 4174 |
segment->set_key(kWata);
|
4463 | |
Segment::Candidate *cand1 = AddCandidate(kWata,
|
4464 | |
"\xe7\xb6\xbf", segment); // "綿"
|
|
4175 |
Segment::Candidate *cand1 = AddCandidate(kWata, "綿", segment);
|
4465 | 4176 |
cand1->attributes = Segment::Candidate::PARTIALLY_KEY_CONSUMED;
|
4466 | 4177 |
cand1->consumed_key_size = Util::CharsLen(kWata);
|
4467 | 4178 |
Segment::Candidate *cand2 = AddCandidate(kWata, kWata, segment);
|
|
4474 | 4185 |
segments_watashino.set_request_type(Segments::SUGGESTION);
|
4475 | 4186 |
Segment *segment;
|
4476 | 4187 |
segment = segments_watashino.add_segment();
|
4477 | |
// "わたしの"
|
4478 | |
const char kWatashino[] =
|
4479 | |
"\xe3\x82\x8f\xe3\x81\x9f\xe3\x81\x97\xe3\x81\xae";
|
|
4188 |
const char kWatashino[] = "わたしの";
|
4480 | 4189 |
segment->set_key(kWatashino);
|
4481 | 4190 |
Segment::Candidate *cand1 = segment->add_candidate();
|
4482 | |
cand1->value = "\xe7\xa7\x81\xe3\x81\xae"; // "私の";
|
|
4191 |
cand1->value = "私の";
|
4483 | 4192 |
cand1->attributes = Segment::Candidate::PARTIALLY_KEY_CONSUMED;
|
4484 | 4193 |
cand1->consumed_key_size = Util::CharsLen(kWatashino);
|
4485 | 4194 |
Segment::Candidate *cand2 = segment->add_candidate();
|
|
4493 | 4202 |
segments_shino.set_request_type(Segments::SUGGESTION);
|
4494 | 4203 |
Segment *segment;
|
4495 | 4204 |
segment = segments_shino.add_segment();
|
4496 | |
// "しの"
|
4497 | |
const char kShino[] = "\xe3\x81\x97\xe3\x81\xae";
|
|
4205 |
const char kShino[] = "しの";
|
4498 | 4206 |
segment->set_key(kShino);
|
4499 | 4207 |
Segment::Candidate *candidate;
|
4500 | |
candidate = AddCandidate(
|
4501 | |
"\xe3\x81\x97\xe3\x81\xae\xe3\x81\xbf\xe3\x82\x84", // "しのみや"
|
4502 | |
"\xe5\x9b\x9b\xe3\x83\x8e\xe5\xae\xae", segment); // "四ノ宮"
|
|
4208 |
candidate = AddCandidate("しのみや", "四ノ宮", segment);
|
4503 | 4209 |
candidate->content_key = segment->key();
|
4504 | 4210 |
candidate->attributes = Segment::Candidate::PARTIALLY_KEY_CONSUMED;
|
4505 | 4211 |
candidate->consumed_key_size = Util::CharsLen(kShino);
|
|
4514 | 4220 |
InsertCharacterChars("watashino", session.get(), &command);
|
4515 | 4221 |
ASSERT_TRUE(command.output().has_candidates());
|
4516 | 4222 |
EXPECT_EQ(2, command.output().candidates().candidate_size());
|
4517 | |
// "私の"
|
4518 | |
EXPECT_EQ("\xe7\xa7\x81\xe3\x81\xae",
|
4519 | |
command.output().candidates().candidate(0).value());
|
|
4223 |
EXPECT_EQ("私の", command.output().candidates().candidate(0).value());
|
4520 | 4224 |
|
4521 | 4225 |
// partial suggestion for "わた|しの"
|
4522 | 4226 |
GetConverterMock()->SetStartPartialSuggestion(&segments_wata, false);
|
|
4528 | 4232 |
// partial suggestion candidates
|
4529 | 4233 |
ASSERT_TRUE(command.output().has_candidates());
|
4530 | 4234 |
EXPECT_EQ(2, command.output().candidates().candidate_size());
|
4531 | |
// "綿"
|
4532 | |
EXPECT_EQ("\xe7\xb6\xbf", command.output().candidates().candidate(0).value());
|
|
4235 |
EXPECT_EQ("綿", command.output().candidates().candidate(0).value());
|
4533 | 4236 |
|
4534 | 4237 |
// commit partial suggestion
|
4535 | 4238 |
SetSendCommandCommand(commands::SessionCommand::SUBMIT_CANDIDATE, &command);
|
|
4537 | 4240 |
GetConverterMock()->SetStartSuggestionForRequest(&segments_shino, true);
|
4538 | 4241 |
session->SendCommand(&command);
|
4539 | 4242 |
EXPECT_TRUE(command.output().consumed());
|
4540 | |
// "綿", "わた"
|
4541 | |
EXPECT_RESULT_AND_KEY("\xe7\xb6\xbf", "\xe3\x82\x8f\xe3\x81\x9f", command);
|
|
4243 |
EXPECT_RESULT_AND_KEY("綿", "わた", command);
|
4542 | 4244 |
|
4543 | 4245 |
// remaining text in preedit
|
4544 | 4246 |
EXPECT_EQ(2, command.output().preedit().cursor());
|
4545 | |
// "しの"
|
4546 | |
EXPECT_SINGLE_SEGMENT("\xe3\x81\x97\xe3\x81\xae", command);
|
|
4247 |
EXPECT_SINGLE_SEGMENT("しの", command);
|
4547 | 4248 |
|
4548 | 4249 |
// Suggestion for new text fills the candidates.
|
4549 | 4250 |
EXPECT_TRUE(command.output().has_candidates());
|
4550 | |
// "四ノ宮"
|
4551 | |
EXPECT_EQ("\xe5\x9b\x9b\xe3\x83\x8e\xe5\xae\xae",
|
4552 | |
command.output().candidates().candidate(0).value());
|
|
4251 |
EXPECT_EQ("四ノ宮", command.output().candidates().candidate(0).value());
|
4553 | 4252 |
}
|
4554 | 4253 |
|
4555 | 4254 |
TEST_F(SessionTest, ToggleAlphanumericMode) {
|
|
4559 | 4258 |
|
4560 | 4259 |
{
|
4561 | 4260 |
InsertCharacterChars("a", session.get(), &command);
|
4562 | |
// "あ"
|
4563 | |
EXPECT_EQ(kHiraganaA, GetComposition(command));
|
|
4261 |
EXPECT_EQ("あ", GetComposition(command));
|
4564 | 4262 |
EXPECT_TRUE(command.output().has_mode());
|
4565 | 4263 |
EXPECT_EQ(commands::HIRAGANA, command.output().mode());
|
4566 | 4264 |
|
|
4568 | 4266 |
session->ToggleAlphanumericMode(&command);
|
4569 | 4267 |
EXPECT_EQ(commands::HALF_ASCII, command.output().mode());
|
4570 | 4268 |
InsertCharacterChars("a", session.get(), &command);
|
4571 | |
// "あa"
|
4572 | |
EXPECT_EQ("\xE3\x81\x82\x61", GetComposition(command));
|
|
4269 |
EXPECT_EQ("あa", GetComposition(command));
|
4573 | 4270 |
EXPECT_TRUE(command.output().has_mode());
|
4574 | 4271 |
EXPECT_EQ(commands::HALF_ASCII, command.output().mode());
|
4575 | 4272 |
|
4576 | 4273 |
command.Clear();
|
4577 | 4274 |
session->ToggleAlphanumericMode(&command);
|
4578 | 4275 |
InsertCharacterChars("a", session.get(), &command);
|
4579 | |
// "あaあ"
|
4580 | |
EXPECT_EQ("\xE3\x81\x82\x61\xE3\x81\x82", GetComposition(command));
|
|
4276 |
EXPECT_EQ("あaあ", GetComposition(command));
|
4581 | 4277 |
EXPECT_TRUE(command.output().has_mode());
|
4582 | 4278 |
EXPECT_EQ(commands::HIRAGANA, command.output().mode());
|
4583 | 4279 |
}
|
|
4610 | 4306 |
session->ToggleAlphanumericMode(&command);
|
4611 | 4307 |
EXPECT_EQ(commands::HIRAGANA, command.output().mode());
|
4612 | 4308 |
InsertCharacterChars("n", session.get(), &command); // on Hiragana mode
|
4613 | |
// "n"
|
4614 | |
EXPECT_EQ("\xEF\xBD\x8E", GetComposition(command));
|
|
4309 |
EXPECT_EQ("n", GetComposition(command));
|
4615 | 4310 |
|
4616 | 4311 |
command.Clear();
|
4617 | 4312 |
session->ToggleAlphanumericMode(&command);
|
4618 | 4313 |
EXPECT_EQ(commands::HALF_ASCII, command.output().mode());
|
4619 | 4314 |
InsertCharacterChars("a", session.get(), &command); // on Half ascii mode.
|
4620 | |
// "na"
|
4621 | |
EXPECT_EQ("\xEF\xBD\x8E\x61", GetComposition(command));
|
|
4315 |
EXPECT_EQ("na", GetComposition(command));
|
4622 | 4316 |
}
|
4623 | 4317 |
|
4624 | 4318 |
{
|
|
4632 | 4326 |
|
4633 | 4327 |
session->InputModeHiragana(&command);
|
4634 | 4328 |
InsertCharacterChars("a", session.get(), &command); // on Hiragana mode
|
4635 | |
// "あ"
|
4636 | |
EXPECT_EQ(kHiraganaA, GetComposition(command));
|
|
4329 |
EXPECT_EQ("あ", GetComposition(command));
|
4637 | 4330 |
|
4638 | 4331 |
Segments segments;
|
4639 | 4332 |
SetAiueo(&segments);
|
|
4645 | 4338 |
command.Clear();
|
4646 | 4339 |
session->Convert(&command);
|
4647 | 4340 |
|
4648 | |
// "あいうえお"
|
4649 | |
EXPECT_EQ(kAiueo, GetComposition(command));
|
|
4341 |
EXPECT_EQ("あいうえお", GetComposition(command));
|
4650 | 4342 |
|
4651 | 4343 |
command.Clear();
|
4652 | 4344 |
session->ToggleAlphanumericMode(&command);
|
|
4673 | 4365 |
EXPECT_TRUE(session->InsertSpace(&command));
|
4674 | 4366 |
EXPECT_TRUE(command.output().consumed());
|
4675 | 4367 |
EXPECT_FALSE(command.output().has_preedit());
|
4676 | |
// " " (full-width space)
|
4677 | |
EXPECT_RESULT(kFullWidthSpace, command);
|
|
4368 |
EXPECT_RESULT(" ", command); // Full-width space
|
4678 | 4369 |
|
4679 | 4370 |
// Change the setting to HALF_WIDTH.
|
4680 | 4371 |
config::Config config;
|
|
4694 | 4385 |
EXPECT_TRUE(session->InsertSpace(&command));
|
4695 | 4386 |
EXPECT_TRUE(command.output().consumed());
|
4696 | 4387 |
EXPECT_FALSE(command.output().has_preedit());
|
4697 | |
// " " (full-width space)
|
4698 | |
EXPECT_RESULT(kFullWidthSpace, command);
|
|
4388 |
EXPECT_RESULT(" ", command); // Full-width space
|
4699 | 4389 |
}
|
4700 | 4390 |
|
4701 | 4391 |
TEST_F(SessionTest, InsertSpaceToggled) {
|
|
4723 | 4413 |
EXPECT_TRUE(session->InsertSpaceToggled(&command));
|
4724 | 4414 |
EXPECT_TRUE(command.output().consumed());
|
4725 | 4415 |
EXPECT_FALSE(command.output().has_preedit());
|
4726 | |
// " " (full-width space)
|
4727 | |
EXPECT_RESULT(kFullWidthSpace, command);
|
|
4416 |
EXPECT_RESULT(" ", command); // Full-width space
|
4728 | 4417 |
|
4729 | 4418 |
// Change the setting to FULL_WIDTH.
|
4730 | 4419 |
config.set_space_character_form(config::Config::FUNDAMENTAL_FULL_WIDTH);
|
|
4751 | 4440 |
EXPECT_FALSE(command.output().has_result());
|
4752 | 4441 |
|
4753 | 4442 |
EXPECT_TRUE(SendKey("a", session.get(), &command));
|
4754 | |
// "あ"
|
4755 | |
EXPECT_EQ(kHiraganaA, GetComposition(command));
|
|
4443 |
EXPECT_EQ("あ", GetComposition(command));
|
4756 | 4444 |
|
4757 | 4445 |
command.Clear();
|
4758 | 4446 |
EXPECT_TRUE(session->InsertSpaceHalfWidth(&command));
|
4759 | |
// "あ "
|
4760 | |
EXPECT_EQ("\xE3\x81\x82\x20", GetComposition(command));
|
|
4447 |
EXPECT_EQ("あ ", GetComposition(command));
|
4761 | 4448 |
|
4762 | 4449 |
{ // Convert "あ " with dummy conversions.
|
4763 | 4450 |
Segments segments;
|
4764 | |
// "亜 "
|
4765 | |
segments.add_segment()->add_candidate()->value = "\xE4\xBA\x9C\x20";
|
|
4451 |
segments.add_segment()->add_candidate()->value = "亜 ";
|
4766 | 4452 |
ConversionRequest request;
|
4767 | 4453 |
SetComposer(session.get(), &request);
|
4768 | 4454 |
FillT13Ns(request, &segments);
|
|
4774 | 4460 |
|
4775 | 4461 |
command.Clear();
|
4776 | 4462 |
EXPECT_TRUE(session->InsertSpaceHalfWidth(&command));
|
4777 | |
// "亜 "
|
4778 | |
EXPECT_EQ("\xE4\xBA\x9C ", command.output().result().value());
|
|
4463 |
EXPECT_EQ("亜 ", command.output().result().value());
|
4779 | 4464 |
EXPECT_EQ("", GetComposition(command));
|
4780 | 4465 |
}
|
4781 | 4466 |
|
|
4791 | 4476 |
EXPECT_TRUE(session->InsertSpaceFullWidth(&command));
|
4792 | 4477 |
EXPECT_TRUE(command.output().consumed());
|
4793 | 4478 |
EXPECT_FALSE(command.output().has_preedit());
|
4794 | |
EXPECT_RESULT(kFullWidthSpace, command);
|
|
4479 |
EXPECT_RESULT(" ", command); // Full-width space
|
4795 | 4480 |
|
4796 | 4481 |
EXPECT_TRUE(SendKey("a", session.get(), &command));
|
4797 | |
// "あ"
|
4798 | |
EXPECT_EQ(kHiraganaA, GetComposition(command));
|
|
4482 |
EXPECT_EQ("あ", GetComposition(command));
|
4799 | 4483 |
|
4800 | 4484 |
command.Clear();
|
4801 | 4485 |
command.mutable_input()->mutable_key()->CopyFrom(space_key);
|
4802 | 4486 |
EXPECT_TRUE(session->InsertSpaceFullWidth(&command));
|
4803 | |
// "あ " (full-width space)
|
4804 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x80\x80", GetComposition(command));
|
4805 | |
|
4806 | |
{ // Convert "あ " with dummy conversions.
|
|
4487 |
EXPECT_EQ("あ ", // full-width space
|
|
4488 |
GetComposition(command));
|
|
4489 |
|
|
4490 |
{ // Convert "あ " (full-width space) with dummy conversions.
|
4807 | 4491 |
Segments segments;
|
4808 | |
// "亜 "
|
4809 | |
segments.add_segment()->add_candidate()->value = "\xE4\xBA\x9C\xE3\x80\x80";
|
|
4492 |
segments.add_segment()->add_candidate()->value = "亜 ";
|
4810 | 4493 |
ConversionRequest request;
|
4811 | 4494 |
SetComposer(session.get(), &request);
|
4812 | 4495 |
FillT13Ns(request, &segments);
|
|
4819 | 4502 |
command.Clear();
|
4820 | 4503 |
command.mutable_input()->mutable_key()->CopyFrom(space_key);
|
4821 | 4504 |
EXPECT_TRUE(session->InsertSpaceFullWidth(&command));
|
4822 | |
// "亜 "
|
4823 | |
EXPECT_EQ("\xE4\xBA\x9C\xE3\x80\x80\xE3\x80\x80",
|
4824 | |
command.output().result().value());
|
|
4505 |
EXPECT_EQ("亜 ", command.output().result().value());
|
4825 | 4506 |
EXPECT_EQ("", GetComposition(command));
|
4826 | 4507 |
}
|
4827 | 4508 |
|
|
4861 | 4542 |
EXPECT_TRUE(command.output().consumed());
|
4862 | 4543 |
EXPECT_TRUE(SendKey("a", session.get(), &command));
|
4863 | 4544 |
EXPECT_TRUE(command.output().consumed());
|
4864 | |
// "あ"
|
4865 | |
EXPECT_PREEDIT(kHiraganaA, command);
|
|
4545 |
EXPECT_PREEDIT("あ", command);
|
4866 | 4546 |
EXPECT_EQ(ImeContext::COMPOSITION, session->context().state());
|
4867 | 4547 |
|
4868 | 4548 |
EXPECT_TRUE(TestSendKeyWithMode(
|
|
4871 | 4551 |
EXPECT_TRUE(SendKeyWithMode(
|
4872 | 4552 |
"Space", commands::HALF_KATAKANA, session.get(), &command));
|
4873 | 4553 |
EXPECT_TRUE(command.output().consumed());
|
4874 | |
// "あ "
|
4875 | |
EXPECT_PREEDIT(string(kHiraganaA) + " ", command);
|
|
4554 |
EXPECT_PREEDIT("あ ", command);
|
4876 | 4555 |
EXPECT_EQ(ImeContext::COMPOSITION, session->context().state());
|
4877 | 4556 |
}
|
4878 | 4557 |
|
|
4896 | 4575 |
EXPECT_TRUE(SendKeyWithMode(
|
4897 | 4576 |
"Space", commands::HALF_KATAKANA, session.get(), &command));
|
4898 | 4577 |
EXPECT_TRUE(command.output().consumed());
|
4899 | |
// " "
|
4900 | |
EXPECT_RESULT(kFullWidthSpace, command);
|
|
4578 |
EXPECT_RESULT(" ", command);
|
4901 | 4579 |
EXPECT_EQ(ImeContext::PRECOMPOSITION, session->context().state());
|
4902 | 4580 |
EXPECT_EQ(commands::HALF_KATAKANA, command.output().mode());
|
4903 | 4581 |
}
|
|
4911 | 4589 |
EXPECT_TRUE(command.output().consumed());
|
4912 | 4590 |
EXPECT_TRUE(SendKey("a", session.get(), &command));
|
4913 | 4591 |
EXPECT_TRUE(command.output().consumed());
|
4914 | |
// "あ"
|
4915 | |
EXPECT_PREEDIT(kHiraganaA, command);
|
|
4592 |
EXPECT_PREEDIT("あ", command);
|
4916 | 4593 |
EXPECT_EQ(ImeContext::COMPOSITION, session->context().state());
|
4917 | 4594 |
|
4918 | 4595 |
EXPECT_TRUE(TestSendKeyWithMode(
|
|
4921 | 4598 |
EXPECT_TRUE(SendKeyWithMode(
|
4922 | 4599 |
"Space", commands::HALF_KATAKANA, session.get(), &command));
|
4923 | 4600 |
EXPECT_TRUE(command.output().consumed());
|
4924 | |
// "あ "
|
4925 | |
EXPECT_PREEDIT(string(kHiraganaA) + kFullWidthSpace, command);
|
|
4601 |
EXPECT_PREEDIT("あ ", command); // Full-width space
|
4926 | 4602 |
EXPECT_EQ(ImeContext::COMPOSITION, session->context().state());
|
4927 | 4603 |
}
|
4928 | 4604 |
|
|
4950 | 4626 |
EXPECT_TRUE(SendKeyWithMode(
|
4951 | 4627 |
"Space", commands::HALF_ASCII, session.get(), &command));
|
4952 | 4628 |
EXPECT_TRUE(command.output().consumed());
|
4953 | |
// " "
|
4954 | |
EXPECT_RESULT(kFullWidthSpace, command);
|
|
4629 |
EXPECT_RESULT(" ", command);
|
4955 | 4630 |
EXPECT_EQ(ImeContext::PRECOMPOSITION, session->context().state());
|
4956 | 4631 |
EXPECT_EQ(commands::HALF_ASCII, command.output().mode());
|
4957 | 4632 |
}
|
|
4976 | 4651 |
EXPECT_TRUE(SendKeyWithMode(
|
4977 | 4652 |
"Space", commands::HALF_ASCII, session.get(), &command));
|
4978 | 4653 |
EXPECT_TRUE(command.output().consumed());
|
4979 | |
// "a "
|
4980 | |
EXPECT_PREEDIT(string("a") + kFullWidthSpace, command);
|
|
4654 |
EXPECT_PREEDIT("a ", command); // Full-width space
|
4981 | 4655 |
EXPECT_EQ(commands::HALF_ASCII, command.output().mode());
|
4982 | 4656 |
}
|
4983 | 4657 |
|
|
5017 | 4691 |
EXPECT_TRUE(SendKeyWithMode(
|
5018 | 4692 |
"a", commands::FULL_ASCII, session.get(), &command));
|
5019 | 4693 |
EXPECT_TRUE(command.output().consumed());
|
5020 | |
// "a"
|
5021 | |
EXPECT_PREEDIT(kFullWidthSmallA, command);
|
|
4694 |
EXPECT_PREEDIT("a", command);
|
5022 | 4695 |
EXPECT_EQ(commands::FULL_ASCII, command.output().mode());
|
5023 | 4696 |
|
5024 | 4697 |
EXPECT_TRUE(TestSendKeyWithMode(
|
|
5027 | 4700 |
EXPECT_TRUE(SendKeyWithMode(
|
5028 | 4701 |
"Space", commands::FULL_ASCII, session.get(), &command));
|
5029 | 4702 |
EXPECT_TRUE(command.output().consumed());
|
5030 | |
// "a "
|
5031 | |
EXPECT_PREEDIT(kFullWidthSmallA + string(" "), command);
|
|
4703 |
EXPECT_PREEDIT("a ", command);
|
5032 | 4704 |
EXPECT_EQ(commands::FULL_ASCII, command.output().mode());
|
5033 | 4705 |
}
|
5034 | 4706 |
}
|
|
5184 | 4856 |
EXPECT_TRUE(SendKey("Space", session.get(), &command));
|
5185 | 4857 |
EXPECT_TRUE(command.output().consumed());
|
5186 | 4858 |
EXPECT_FALSE(command.output().has_preedit());
|
5187 | |
// " " (full-width space)
|
5188 | |
EXPECT_RESULT(kFullWidthSpace, command);
|
|
4859 |
EXPECT_RESULT(" ", command); // Full-width space
|
5189 | 4860 |
EXPECT_TRUE(TryUndoAndAssertDoNothing(session.get()));
|
5190 | 4861 |
|
5191 | 4862 |
// A space key event with any modifier key assigned to InsertFullSpace should
|
|
5199 | 4870 |
EXPECT_TRUE(SendKey("Shift Space", session.get(), &command));
|
5200 | 4871 |
EXPECT_TRUE(command.output().consumed());
|
5201 | 4872 |
EXPECT_FALSE(command.output().has_preedit());
|
5202 | |
// " " (full-width space)
|
5203 | |
EXPECT_RESULT(kFullWidthSpace, command);
|
|
4873 |
EXPECT_RESULT(" ", command); // Full-width space
|
5204 | 4874 |
EXPECT_TRUE(TryUndoAndAssertDoNothing(session.get()));
|
5205 | 4875 |
}
|
5206 | 4876 |
|
|
5281 | 4951 |
commands::Command command;
|
5282 | 4952 |
|
5283 | 4953 |
SendKey("a", session.get(), &command);
|
5284 | |
// "あ"
|
5285 | |
EXPECT_EQ(kHiraganaA, GetComposition(command));
|
|
4954 |
EXPECT_EQ("あ", GetComposition(command));
|
5286 | 4955 |
EXPECT_EQ(ImeContext::COMPOSITION, session->context().state());
|
5287 | 4956 |
|
5288 | 4957 |
EXPECT_TRUE(TestSendKey("Ctrl a", session.get(), &command));
|
5289 | 4958 |
EXPECT_TRUE(command.output().consumed());
|
5290 | 4959 |
|
5291 | 4960 |
SendKey("Ctrl a", session.get(), &command);
|
5292 | |
// "あ "
|
5293 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x80\x80", GetComposition(command));
|
|
4961 |
EXPECT_EQ("あ ", GetComposition(command));
|
5294 | 4962 |
|
5295 | 4963 |
EXPECT_TRUE(TestSendKey("Ctrl b", session.get(), &command));
|
5296 | 4964 |
EXPECT_TRUE(command.output().consumed());
|
5297 | 4965 |
|
5298 | 4966 |
SendKey("Ctrl b", session.get(), &command);
|
5299 | |
// "あ "
|
5300 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x80\x80 ", GetComposition(command));
|
|
4967 |
EXPECT_EQ("あ ", GetComposition(command));
|
5301 | 4968 |
|
5302 | 4969 |
EXPECT_TRUE(TestSendKey("Ctrl c", session.get(), &command));
|
5303 | 4970 |
EXPECT_TRUE(command.output().consumed());
|
5304 | 4971 |
|
5305 | 4972 |
SendKey("Ctrl c", session.get(), &command);
|
5306 | |
// "あ "
|
5307 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x80\x80 ", GetComposition(command));
|
|
4973 |
EXPECT_EQ("あ ", GetComposition(command));
|
5308 | 4974 |
|
5309 | 4975 |
EXPECT_TRUE(TestSendKey("Ctrl d", session.get(), &command));
|
5310 | 4976 |
EXPECT_TRUE(command.output().consumed());
|
5311 | 4977 |
|
5312 | 4978 |
SendKey("Ctrl d", session.get(), &command);
|
5313 | |
// "あ "
|
5314 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x80\x80 \xE3\x80\x80", GetComposition(command));
|
|
4979 |
EXPECT_EQ("あ ", GetComposition(command));
|
5315 | 4980 |
}
|
5316 | 4981 |
|
5317 | 4982 |
TEST_F(SessionTest, InsertSpaceInConversionMode) {
|
|
5340 | 5005 |
EXPECT_TRUE(SendKey("Ctrl a", session.get(), &command));
|
5341 | 5006 |
EXPECT_TRUE(GetComposition(command).empty());
|
5342 | 5007 |
ASSERT_TRUE(command.output().has_result());
|
5343 | |
// "あいうえお "
|
5344 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86\xE3\x81\x88"
|
5345 | |
"\xE3\x81\x8A\xE3\x80\x80",
|
5346 | |
command.output().result().value());
|
|
5008 |
EXPECT_EQ("あいうえお ", command.output().result().value());
|
5347 | 5009 |
EXPECT_TRUE(TryUndoAndAssertDoNothing(session.get()));
|
5348 | 5010 |
}
|
5349 | 5011 |
|
|
5357 | 5019 |
EXPECT_TRUE(SendKey("Ctrl b", session.get(), &command));
|
5358 | 5020 |
EXPECT_TRUE(GetComposition(command).empty());
|
5359 | 5021 |
ASSERT_TRUE(command.output().has_result());
|
5360 | |
// "あいうえお "
|
5361 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86\xE3\x81\x88\xE3\x81\x8A ",
|
5362 | |
command.output().result().value());
|
|
5022 |
EXPECT_EQ("あいうえお ", command.output().result().value());
|
5363 | 5023 |
EXPECT_TRUE(TryUndoAndAssertDoNothing(session.get()));
|
5364 | 5024 |
}
|
5365 | 5025 |
|
|
5373 | 5033 |
EXPECT_TRUE(SendKey("Ctrl c", session.get(), &command));
|
5374 | 5034 |
EXPECT_TRUE(GetComposition(command).empty());
|
5375 | 5035 |
ASSERT_TRUE(command.output().has_result());
|
5376 | |
// "あいうえお "
|
5377 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86\xE3\x81\x88\xE3\x81\x8A ",
|
5378 | |
command.output().result().value());
|
|
5036 |
EXPECT_EQ("あいうえお ", command.output().result().value());
|
5379 | 5037 |
EXPECT_TRUE(TryUndoAndAssertDoNothing(session.get()));
|
5380 | 5038 |
}
|
5381 | 5039 |
|
|
5389 | 5047 |
EXPECT_TRUE(SendKey("Ctrl d", session.get(), &command));
|
5390 | 5048 |
EXPECT_TRUE(GetComposition(command).empty());
|
5391 | 5049 |
ASSERT_TRUE(command.output().has_result());
|
5392 | |
// "あいうえお "
|
5393 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86\xE3\x81\x88"
|
5394 | |
"\xE3\x81\x8A\xE3\x80\x80",
|
5395 | |
command.output().result().value());
|
|
5050 |
EXPECT_EQ("あいうえお ", command.output().result().value());
|
5396 | 5051 |
EXPECT_TRUE(TryUndoAndAssertDoNothing(session.get()));
|
5397 | 5052 |
}
|
5398 | 5053 |
}
|
|
5405 | 5060 |
EXPECT_TRUE(session->InputModeHalfKatakana(&command));
|
5406 | 5061 |
EXPECT_EQ(commands::HALF_KATAKANA, command.output().mode());
|
5407 | 5062 |
InsertCharacterChars("a", session.get(), &command);
|
5408 | |
// "ア"
|
5409 | |
EXPECT_EQ("\xEF\xBD\xB1", GetComposition(command));
|
|
5063 |
EXPECT_EQ("ア", GetComposition(command));
|
5410 | 5064 |
|
5411 | 5065 |
command.Clear();
|
5412 | 5066 |
commands::KeyEvent space_key;
|
5413 | 5067 |
space_key.set_special_key(commands::KeyEvent::SPACE);
|
5414 | 5068 |
command.mutable_input()->mutable_key()->CopyFrom(space_key);
|
5415 | 5069 |
EXPECT_TRUE(session->InsertSpaceFullWidth(&command));
|
5416 | |
// "ア " (full-width space)
|
5417 | |
EXPECT_EQ("\xEF\xBD\xB1\xE3\x80\x80", GetComposition(command));
|
|
5070 |
EXPECT_EQ("ア ", GetComposition(command)); // "ア " (full-width space)
|
5418 | 5071 |
}
|
5419 | 5072 |
|
5420 | 5073 |
TEST_F(SessionTest, IsFullWidthInsertSpace) {
|
|
5623 | 5276 |
Segments segments;
|
5624 | 5277 |
Segment *segment;
|
5625 | 5278 |
segment = segments.add_segment();
|
5626 | |
// "いんぼう"
|
5627 | |
segment->set_key("\xe3\x81\x84\xe3\x82\x93\xe3\x81\xbc\xe3\x81\x86");
|
5628 | |
// "陰謀"
|
5629 | |
segment->add_candidate()->value = "\xe9\x99\xb0\xe8\xac\x80";
|
5630 | |
// "陰謀論"
|
5631 | |
segment->add_candidate()->value = "\xe9\x99\xb0\xe8\xac\x80\xe8\xab\x96";
|
5632 | |
// "陰謀説"
|
5633 | |
segment->add_candidate()->value = "\xe9\x99\xb0\xe8\xac\x80\xe8\xaa\xac";
|
|
5279 |
segment->set_key("いんぼう");
|
|
5280 |
segment->add_candidate()->value = "陰謀";
|
|
5281 |
segment->add_candidate()->value = "陰謀論";
|
|
5282 |
segment->add_candidate()->value = "陰謀説";
|
5634 | 5283 |
GetConverterMock()->SetStartPredictionForRequest(&segments, true);
|
5635 | 5284 |
|
5636 | 5285 |
std::unique_ptr<Session> session(new Session(engine_.get()));
|
|
5647 | 5296 |
|
5648 | 5297 |
command.Clear();
|
5649 | 5298 |
EXPECT_TRUE(session->CommitSegment(&command));
|
5650 | |
// "陰謀"
|
5651 | |
EXPECT_RESULT("\xE9\x99\xB0\xE8\xAC\x80", command);
|
|
5299 |
EXPECT_RESULT("陰謀", command);
|
5652 | 5300 |
EXPECT_FALSE(command.output().has_preedit());
|
5653 | 5301 |
}
|
5654 | 5302 |
|
|
5691 | 5339 |
std::unique_ptr<Session> session(new Session(engine_.get()));
|
5692 | 5340 |
InitSessionToPrecomposition(session.get());
|
5693 | 5341 |
|
5694 | |
// "a"
|
5695 | 5342 |
commands::Command command;
|
5696 | 5343 |
InsertCharacterChars("a", session.get(), &command);
|
5697 | 5344 |
|
|
5709 | 5356 |
command.Clear();
|
5710 | 5357 |
EXPECT_TRUE(session->CommitSegment(&command));
|
5711 | 5358 |
|
5712 | |
// "a"
|
5713 | 5359 |
InsertCharacterChars("a", session.get(), &command);
|
5714 | |
EXPECT_SINGLE_SEGMENT(kHiraganaA, command);
|
|
5360 |
EXPECT_SINGLE_SEGMENT("あ", command);
|
5715 | 5361 |
EXPECT_FALSE(command.output().has_candidates());
|
5716 | 5362 |
}
|
5717 | 5363 |
|
|
5747 | 5393 |
|
5748 | 5394 |
// The composition should have been reset.
|
5749 | 5395 |
InsertCharacterChars("ku", session.get(), &command);
|
5750 | |
// "く"
|
5751 | |
EXPECT_EQ("\343\201\217", command.output().preedit().segment(0).value());
|
|
5396 |
EXPECT_EQ("く", command.output().preedit().segment(0).value());
|
5752 | 5397 |
}
|
5753 | 5398 |
|
5754 | 5399 |
TEST_F(SessionTest, Issue2026354) {
|
|
5772 | 5417 |
|
5773 | 5418 |
// EXPECT_TRUE(session->ConvertNext(&command));
|
5774 | 5419 |
TestSendKey("Space", session.get(), &command);
|
5775 | |
EXPECT_PREEDIT(kAiueo, command);
|
|
5420 |
EXPECT_PREEDIT("あいうえお", command);
|
5776 | 5421 |
command.mutable_output()->clear_candidates();
|
5777 | 5422 |
EXPECT_FALSE(command.output().has_candidates());
|
5778 | 5423 |
}
|
|
5820 | 5465 |
|
5821 | 5466 |
// After submission, input mode should be reverted.
|
5822 | 5467 |
SendKey("a", session.get(), &command);
|
5823 | |
// "あ"
|
5824 | |
EXPECT_EQ(kHiraganaA, GetComposition(command));
|
|
5468 |
EXPECT_EQ("あ", GetComposition(command));
|
5825 | 5469 |
|
5826 | 5470 |
command.Clear();
|
5827 | 5471 |
session->EditCancel(&command);
|
|
5847 | 5491 |
commands::Command command;
|
5848 | 5492 |
session->ToggleAlphanumericMode(&command);
|
5849 | 5493 |
|
5850 | |
// "ち"
|
5851 | |
InsertCharacterCodeAndString('a', "\xE3\x81\xA1", session.get(), &command);
|
|
5494 |
InsertCharacterCodeAndString('a', "ち", session.get(), &command);
|
5852 | 5495 |
EXPECT_EQ("a", GetComposition(command));
|
5853 | 5496 |
|
5854 | 5497 |
command.Clear();
|
5855 | 5498 |
session->ToggleAlphanumericMode(&command);
|
5856 | 5499 |
EXPECT_EQ("a", GetComposition(command));
|
5857 | 5500 |
|
5858 | |
// "に"
|
5859 | |
InsertCharacterCodeAndString('i', "\xE3\x81\xAB", session.get(), &command);
|
5860 | |
// "aに"
|
5861 | |
EXPECT_EQ("a\xE3\x81\xAB", GetComposition(command));
|
|
5501 |
InsertCharacterCodeAndString('i', "に", session.get(), &command);
|
|
5502 |
EXPECT_EQ("aに", GetComposition(command));
|
5862 | 5503 |
}
|
5863 | 5504 |
|
5864 | 5505 |
TEST_F(SessionTest, Issue1556649) {
|
|
5867 | 5508 |
InitSessionToPrecomposition(session.get());
|
5868 | 5509 |
commands::Command command;
|
5869 | 5510 |
InsertCharacterChars("kudoudesu", session.get(), &command);
|
5870 | |
// "くどうです"
|
5871 | |
EXPECT_EQ("\xE3\x81\x8F\xE3\x81\xA9\xE3\x81\x86\xE3\x81\xA7\xE3\x81\x99",
|
|
5511 |
EXPECT_EQ("くどうです",
|
5872 | 5512 |
GetComposition(command));
|
5873 | 5513 |
EXPECT_EQ(5, command.output().preedit().cursor());
|
5874 | 5514 |
|
5875 | 5515 |
command.Clear();
|
5876 | 5516 |
EXPECT_TRUE(session->DisplayAsHalfKatakana(&command));
|
5877 | |
// "クドウデス"
|
5878 | |
EXPECT_EQ("\xEF\xBD\xB8\xEF\xBE\x84\xEF\xBE\x9E\xEF\xBD\xB3\xEF\xBE\x83"
|
5879 | |
"\xEF\xBE\x9E\xEF\xBD\xBD",
|
5880 | |
GetComposition(command));
|
|
5517 |
EXPECT_EQ("クドウデス", GetComposition(command));
|
5881 | 5518 |
EXPECT_EQ(7, command.output().preedit().cursor());
|
5882 | 5519 |
|
5883 | 5520 |
for (size_t i = 0; i < 7; ++i) {
|
|
5898 | 5535 |
command.Clear();
|
5899 | 5536 |
EXPECT_TRUE(session->ToggleAlphanumericMode(&command));
|
5900 | 5537 |
EXPECT_TRUE(SendKey("i", session.get(), &command));
|
5901 | |
// "あi"
|
5902 | |
EXPECT_EQ("\xE3\x81\x82\x69", GetComposition(command));
|
|
5538 |
EXPECT_EQ("あi", GetComposition(command));
|
5903 | 5539 |
|
5904 | 5540 |
EXPECT_TRUE(SendKey("Space", session.get(), &command));
|
5905 | |
// "あi "
|
5906 | |
EXPECT_EQ("\xE3\x81\x82\x69\x20", GetComposition(command));
|
|
5541 |
EXPECT_EQ("あi ", GetComposition(command));
|
5907 | 5542 |
}
|
5908 | 5543 |
|
5909 | 5544 |
{
|
|
5912 | 5547 |
commands::Command command;
|
5913 | 5548 |
EXPECT_TRUE(SendKey("a", session.get(), &command));
|
5914 | 5549 |
EXPECT_TRUE(SendKey("I", session.get(), &command));
|
5915 | |
// "あI"
|
5916 | |
EXPECT_EQ("\xE3\x81\x82\x49", GetComposition(command));
|
|
5550 |
EXPECT_EQ("あI", GetComposition(command));
|
5917 | 5551 |
|
5918 | 5552 |
EXPECT_TRUE(SendKey("Space", session.get(), &command));
|
5919 | |
// "あI "
|
5920 | |
EXPECT_EQ("\xE3\x81\x82\x49\x20", GetComposition(command));
|
|
5553 |
EXPECT_EQ("あI ", GetComposition(command));
|
5921 | 5554 |
}
|
5922 | 5555 |
}
|
5923 | 5556 |
|
|
5928 | 5561 |
InitSessionToPrecomposition(session.get());
|
5929 | 5562 |
commands::Command command;
|
5930 | 5563 |
InsertCharacterChars("aiu", session.get(), &command);
|
5931 | |
// "あいう"
|
5932 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86", GetComposition(command));
|
|
5564 |
EXPECT_EQ("あいう", GetComposition(command));
|
5933 | 5565 |
|
5934 | 5566 |
for (size_t i = 0; i < 3; ++i) {
|
5935 | 5567 |
const size_t expected_pos = 2 - i;
|
|
6005 | 5637 |
EXPECT_TRUE(SendKey("Eisu", session.get(), &command));
|
6006 | 5638 |
EXPECT_TRUE(SendKey("i", session.get(), &command));
|
6007 | 5639 |
|
6008 | |
// "あ い"
|
6009 | |
EXPECT_EQ("\xE3\x81\x82\x20\xE3\x81\x84", GetComposition(command));
|
|
5640 |
EXPECT_EQ("あ い", GetComposition(command));
|
6010 | 5641 |
|
6011 | 5642 |
command.Clear();
|
6012 | 5643 |
EXPECT_TRUE(session->DisplayAsFullKatakana(&command));
|
6013 | 5644 |
|
6014 | |
// "ア イ"(fullwidth space)
|
6015 | |
EXPECT_EQ("\xE3\x82\xA2\xE3\x80\x80\xE3\x82\xA4", GetComposition(command));
|
|
5645 |
EXPECT_EQ("ア イ", GetComposition(command)); // fullwidth space
|
6016 | 5646 |
}
|
6017 | 5647 |
|
6018 | 5648 |
{ // ConvertToFullKatakana
|
|
6026 | 5656 |
EXPECT_TRUE(SendKey("Eisu", session.get(), &command));
|
6027 | 5657 |
EXPECT_TRUE(SendKey("i", session.get(), &command));
|
6028 | 5658 |
|
6029 | |
// "あ い"
|
6030 | |
EXPECT_EQ("\xE3\x81\x82\x20\xE3\x81\x84", GetComposition(command));
|
|
5659 |
EXPECT_EQ("あ い", GetComposition(command));
|
6031 | 5660 |
|
6032 | 5661 |
{ // Initialize GetConverterMock() to generate t13n candidates.
|
6033 | 5662 |
Segments segments;
|
6034 | 5663 |
Segment *segment;
|
6035 | 5664 |
segments.set_request_type(Segments::CONVERSION);
|
6036 | 5665 |
segment = segments.add_segment();
|
6037 | |
// "あ い"
|
6038 | |
segment->set_key("\xE3\x81\x82\x20\xE3\x81\x84");
|
|
5666 |
segment->set_key("あ い");
|
6039 | 5667 |
Segment::Candidate *candidate;
|
6040 | 5668 |
candidate = segment->add_candidate();
|
6041 | |
// "あ い"
|
6042 | |
candidate->value = "\xE3\x81\x82\x20\xE3\x81\x84";
|
|
5669 |
candidate->value = "あ い";
|
6043 | 5670 |
ConversionRequest request;
|
6044 | 5671 |
SetComposer(session.get(), &request);
|
6045 | 5672 |
FillT13Ns(request, &segments);
|
|
6049 | 5676 |
command.Clear();
|
6050 | 5677 |
EXPECT_TRUE(session->ConvertToFullKatakana(&command));
|
6051 | 5678 |
|
6052 | |
// "ア イ"(fullwidth space)
|
6053 | |
EXPECT_EQ("\xE3\x82\xA2\xE3\x80\x80\xE3\x82\xA4", GetComposition(command));
|
|
5679 |
EXPECT_EQ("ア イ", GetComposition(command)); // fullwidth space
|
6054 | 5680 |
}
|
6055 | 5681 |
}
|
6056 | 5682 |
#endif // !OS_NACL
|
|
6129 | 5755 |
|
6130 | 5756 |
EXPECT_TRUE(SendKey("Ctrl Shift Space", session.get(), &command));
|
6131 | 5757 |
EXPECT_TRUE(command.output().consumed());
|
6132 | |
EXPECT_PREEDIT(string("a") + kFullWidthSpace, command);
|
|
5758 |
EXPECT_PREEDIT("a ", command); // Full-width space
|
6133 | 5759 |
}
|
6134 | 5760 |
|
6135 | 5761 |
TEST_F(SessionTest, Issue2297060) {
|
|
6165 | 5791 |
Segment::Candidate *candidate;
|
6166 | 5792 |
|
6167 | 5793 |
segment = segments.add_segment();
|
6168 | |
// "あ"
|
6169 | |
segment->set_key(kHiraganaA);
|
|
5794 |
segment->set_key("あ");
|
6170 | 5795 |
candidate = segment->add_candidate();
|
6171 | |
// "亜"
|
6172 | |
candidate->value = "\xE4\xBA\x9C";
|
|
5796 |
candidate->value = "亜";
|
6173 | 5797 |
ConversionRequest request;
|
6174 | 5798 |
request.set_config(&config);
|
6175 | 5799 |
SetComposer(session.get(), &request);
|
|
6178 | 5802 |
}
|
6179 | 5803 |
|
6180 | 5804 |
EXPECT_TRUE(SendKey("a", session.get(), &command));
|
6181 | |
// "あ"
|
6182 | |
EXPECT_EQ(kHiraganaA, GetComposition(command));
|
|
5805 |
EXPECT_EQ("あ", GetComposition(command));
|
6183 | 5806 |
|
6184 | 5807 |
EXPECT_TRUE(SendKey("Space", session.get(), &command));
|
6185 | |
// "亜"
|
6186 | |
EXPECT_EQ("\xE4\xBA\x9C", GetComposition(command));
|
|
5808 |
EXPECT_EQ("亜", GetComposition(command));
|
6187 | 5809 |
|
6188 | 5810 |
EXPECT_TRUE(SendKey("Numpad0", session.get(), &command));
|
6189 | 5811 |
EXPECT_TRUE(GetComposition(command).empty());
|
6190 | |
// "亜0", "あ0"
|
6191 | |
EXPECT_RESULT_AND_KEY("\xE4\xBA\x9C\x30", "\xE3\x81\x82\x30", command);
|
|
5812 |
EXPECT_RESULT_AND_KEY("亜0", "あ0", command);
|
6192 | 5813 |
|
6193 | 5814 |
// The previous Numpad0 must not affect the current composition.
|
6194 | 5815 |
EXPECT_TRUE(SendKey("a", session.get(), &command));
|
6195 | |
// "あ"
|
6196 | |
EXPECT_EQ(kHiraganaA, GetComposition(command));
|
|
5816 |
EXPECT_EQ("あ", GetComposition(command));
|
6197 | 5817 |
}
|
6198 | 5818 |
|
6199 | 5819 |
TEST_F(SessionTest, Issue2569789) {
|
|
6242 | 5862 |
EXPECT_EQ(commands::HIRAGANA, command.output().mode());
|
6243 | 5863 |
|
6244 | 5864 |
InsertCharacterChars("aaa", session.get(), &command);
|
6245 | |
// "Googleあああ"
|
6246 | |
EXPECT_EQ("Google\xE3\x81\x82\xE3\x81\x82\xE3\x81\x82",
|
6247 | |
GetComposition(command));
|
|
5865 |
EXPECT_EQ("Googleあああ", GetComposition(command));
|
6248 | 5866 |
}
|
6249 | 5867 |
|
6250 | 5868 |
{
|
|
6275 | 5893 |
session->InputModeFullKatakana(&command);
|
6276 | 5894 |
|
6277 | 5895 |
SendKey("i", session.get(), &command);
|
6278 | |
// "あイ"
|
6279 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x82\xA4", GetComposition(command));
|
|
5896 |
EXPECT_EQ("あイ", GetComposition(command));
|
6280 | 5897 |
|
6281 | 5898 |
SendKey("backspace", session.get(), &command);
|
6282 | |
// "あ"
|
6283 | |
EXPECT_EQ(kHiraganaA, GetComposition(command));
|
|
5899 |
EXPECT_EQ("あ", GetComposition(command));
|
6284 | 5900 |
EXPECT_EQ(commands::FULL_KATAKANA, command.output().mode());
|
6285 | 5901 |
}
|
6286 | 5902 |
|
|
6300 | 5916 |
ASSERT_TRUE(command.output().consumed());
|
6301 | 5917 |
|
6302 | 5918 |
ASSERT_TRUE(command.output().has_result());
|
6303 | |
// "あ"
|
6304 | |
EXPECT_EQ(kHiraganaA, command.output().result().value());
|
|
5919 |
EXPECT_EQ("あ", command.output().result().value());
|
6305 | 5920 |
EXPECT_EQ(commands::DIRECT, command.output().mode());
|
6306 | 5921 |
|
6307 | 5922 |
ASSERT_FALSE(command.output().has_preedit());
|
|
6325 | 5940 |
ASSERT_TRUE(command.output().consumed());
|
6326 | 5941 |
|
6327 | 5942 |
ASSERT_TRUE(command.output().has_result());
|
6328 | |
// "あ"
|
6329 | |
EXPECT_EQ(kHiraganaA, command.output().result().value());
|
|
5943 |
EXPECT_EQ("あ", command.output().result().value());
|
6330 | 5944 |
EXPECT_EQ(commands::DIRECT, command.output().mode());
|
6331 | 5945 |
|
6332 | 5946 |
ASSERT_FALSE(command.output().has_preedit());
|
|
6344 | 5958 |
ASSERT_TRUE(command.output().consumed());
|
6345 | 5959 |
|
6346 | 5960 |
ASSERT_TRUE(command.output().has_result());
|
6347 | |
// "あ"
|
6348 | |
EXPECT_EQ(kHiraganaA, command.output().result().value());
|
|
5961 |
EXPECT_EQ("あ", command.output().result().value());
|
6349 | 5962 |
EXPECT_EQ(commands::DIRECT, command.output().mode());
|
6350 | 5963 |
|
6351 | 5964 |
ASSERT_FALSE(command.output().has_preedit());
|
|
6371 | 5984 |
|
6372 | 5985 |
EXPECT_TRUE(SendKey("Hiragana", session.get(), &command));
|
6373 | 5986 |
EXPECT_TRUE(SendKey("a", session.get(), &command));
|
6374 | |
// "あ"
|
6375 | |
EXPECT_SINGLE_SEGMENT(kHiraganaA, command);
|
|
5987 |
EXPECT_SINGLE_SEGMENT("あ", command);
|
6376 | 5988 |
#endif // OS_WIN
|
6377 | 5989 |
}
|
6378 | 5990 |
|
6379 | 5991 |
TEST_F(SessionTest, HandlingDirectInputTableAttribute) {
|
6380 | 5992 |
composer::Table table;
|
6381 | |
// "か"
|
6382 | |
table.AddRuleWithAttributes("ka", "\xE3\x81\x8B", "",
|
|
5993 |
table.AddRuleWithAttributes("ka", "か", "",
|
6383 | 5994 |
composer::DIRECT_INPUT);
|
6384 | |
// "っ"
|
6385 | |
table.AddRuleWithAttributes("tt", "\xE3\x81\xA3", "t",
|
|
5995 |
table.AddRuleWithAttributes("tt", "っ", "t",
|
6386 | 5996 |
composer::DIRECT_INPUT);
|
6387 | |
// "た"
|
6388 | |
table.AddRuleWithAttributes("ta", "\xE3\x81\x9F", "",
|
|
5997 |
table.AddRuleWithAttributes("ta", "た", "",
|
6389 | 5998 |
composer::NO_TABLE_ATTRIBUTE);
|
6390 | 5999 |
|
6391 | 6000 |
Session session(engine_.get());
|
|
6397 | 6006 |
EXPECT_FALSE(command.output().has_result());
|
6398 | 6007 |
|
6399 | 6008 |
SendKey("a", &session, &command);
|
6400 | |
// "か"
|
6401 | |
EXPECT_RESULT("\xE3\x81\x8B", command);
|
|
6009 |
EXPECT_RESULT("か", command);
|
6402 | 6010 |
|
6403 | 6011 |
SendKey("t", &session, &command);
|
6404 | 6012 |
EXPECT_FALSE(command.output().has_result());
|
|
6407 | 6015 |
EXPECT_FALSE(command.output().has_result());
|
6408 | 6016 |
|
6409 | 6017 |
SendKey("a", &session, &command);
|
6410 | |
// "った"
|
6411 | |
EXPECT_RESULT("\xE3\x81\xA3\xE3\x81\x9F", command);
|
|
6018 |
EXPECT_RESULT("った", command);
|
6412 | 6019 |
}
|
6413 | 6020 |
|
6414 | 6021 |
TEST_F(SessionTest, IMEOnWithModeTest) {
|
|
6426 | 6033 |
EXPECT_EQ(commands::HIRAGANA,
|
6427 | 6034 |
command.output().mode());
|
6428 | 6035 |
SendKey("a", session.get(), &command);
|
6429 | |
// "あ"
|
6430 | |
EXPECT_SINGLE_SEGMENT(kHiraganaA, command);
|
|
6036 |
EXPECT_SINGLE_SEGMENT("あ", command);
|
6431 | 6037 |
}
|
6432 | 6038 |
{
|
6433 | 6039 |
std::unique_ptr<Session> session(new Session(engine_.get()));
|
|
6441 | 6047 |
EXPECT_EQ(commands::FULL_KATAKANA,
|
6442 | 6048 |
command.output().mode());
|
6443 | 6049 |
SendKey("a", session.get(), &command);
|
6444 | |
// "ア"
|
6445 | |
EXPECT_SINGLE_SEGMENT("\xE3\x82\xA2", command);
|
|
6050 |
EXPECT_SINGLE_SEGMENT("ア", command);
|
6446 | 6051 |
}
|
6447 | 6052 |
{
|
6448 | 6053 |
std::unique_ptr<Session> session(new Session(engine_.get()));
|
|
6457 | 6062 |
command.output().mode());
|
6458 | 6063 |
SendKey("a", session.get(), &command);
|
6459 | 6064 |
// "ア" (half-width Katakana)
|
6460 | |
EXPECT_SINGLE_SEGMENT("\xEF\xBD\xB1", command);
|
|
6065 |
EXPECT_SINGLE_SEGMENT("ア", command);
|
6461 | 6066 |
}
|
6462 | 6067 |
{
|
6463 | 6068 |
std::unique_ptr<Session> session(new Session(engine_.get()));
|
|
6471 | 6076 |
EXPECT_EQ(commands::FULL_ASCII,
|
6472 | 6077 |
command.output().mode());
|
6473 | 6078 |
SendKey("a", session.get(), &command);
|
6474 | |
// "a"
|
6475 | |
EXPECT_SINGLE_SEGMENT("\xEF\xBD\x81", command);
|
|
6079 |
EXPECT_SINGLE_SEGMENT("a", command);
|
6476 | 6080 |
}
|
6477 | 6081 |
{
|
6478 | 6082 |
std::unique_ptr<Session> session(new Session(engine_.get()));
|
|
6486 | 6090 |
EXPECT_EQ(commands::HALF_ASCII,
|
6487 | 6091 |
command.output().mode());
|
6488 | 6092 |
SendKey("a", session.get(), &command);
|
6489 | |
// "a"
|
6490 | 6093 |
EXPECT_SINGLE_SEGMENT("a", command);
|
6491 | 6094 |
}
|
6492 | 6095 |
}
|
|
6540 | 6143 |
InitSessionToPrecomposition(session.get());
|
6541 | 6144 |
commands::Command command;
|
6542 | 6145 |
SendKey("a", session.get(), &command);
|
6543 | |
// "あ"
|
6544 | |
EXPECT_SINGLE_SEGMENT(kHiraganaA, command);
|
|
6146 |
EXPECT_SINGLE_SEGMENT("あ", command);
|
6545 | 6147 |
|
6546 | 6148 |
command.Clear();
|
6547 | 6149 |
EXPECT_TRUE(session->InputModeHiragana(&command));
|
6548 | 6150 |
EXPECT_TRUE(command.output().consumed());
|
6549 | 6151 |
EXPECT_EQ(mozc::commands::HIRAGANA, command.output().mode());
|
6550 | |
// "あ"
|
6551 | |
EXPECT_SINGLE_SEGMENT(kHiraganaA, command);
|
|
6152 |
EXPECT_SINGLE_SEGMENT("あ", command);
|
6552 | 6153 |
|
6553 | 6154 |
command.Clear();
|
6554 | 6155 |
EXPECT_TRUE(session->InputModeFullKatakana(&command));
|
6555 | 6156 |
EXPECT_TRUE(command.output().consumed());
|
6556 | 6157 |
EXPECT_EQ(mozc::commands::FULL_KATAKANA, command.output().mode());
|
6557 | |
// "あ"
|
6558 | |
EXPECT_SINGLE_SEGMENT(kHiraganaA, command);
|
|
6158 |
EXPECT_SINGLE_SEGMENT("あ", command);
|
6559 | 6159 |
|
6560 | 6160 |
command.Clear();
|
6561 | 6161 |
EXPECT_TRUE(session->InputModeHalfKatakana(&command));
|
6562 | 6162 |
EXPECT_TRUE(command.output().consumed());
|
6563 | 6163 |
EXPECT_EQ(mozc::commands::HALF_KATAKANA, command.output().mode());
|
6564 | |
// "あ"
|
6565 | |
EXPECT_SINGLE_SEGMENT(kHiraganaA, command);
|
|
6164 |
EXPECT_SINGLE_SEGMENT("あ", command);
|
6566 | 6165 |
|
6567 | 6166 |
command.Clear();
|
6568 | 6167 |
EXPECT_TRUE(session->InputModeFullASCII(&command));
|
6569 | 6168 |
EXPECT_TRUE(command.output().consumed());
|
6570 | 6169 |
EXPECT_EQ(mozc::commands::FULL_ASCII, command.output().mode());
|
6571 | |
// "あ"
|
6572 | |
EXPECT_SINGLE_SEGMENT(kHiraganaA, command);
|
|
6170 |
EXPECT_SINGLE_SEGMENT("あ", command);
|
6573 | 6171 |
|
6574 | 6172 |
command.Clear();
|
6575 | 6173 |
EXPECT_TRUE(session->InputModeHalfASCII(&command));
|
6576 | 6174 |
EXPECT_TRUE(command.output().consumed());
|
6577 | 6175 |
EXPECT_EQ(mozc::commands::HALF_ASCII, command.output().mode());
|
6578 | |
// "あ"
|
6579 | |
EXPECT_SINGLE_SEGMENT(kHiraganaA, command);
|
|
6176 |
EXPECT_SINGLE_SEGMENT("あ", command);
|
6580 | 6177 |
}
|
6581 | 6178 |
|
6582 | 6179 |
TEST_F(SessionTest, InputModeOutputHasCandidates) {
|
|
6738 | 6335 |
command.Clear();
|
6739 | 6336 |
session->Convert(&command);
|
6740 | 6337 |
EXPECT_FALSE(command.output().has_result());
|
6741 | |
// "あいうえお"
|
6742 | |
EXPECT_SINGLE_SEGMENT(kAiueo, command);
|
|
6338 |
EXPECT_SINGLE_SEGMENT("あいうえお", command);
|
6743 | 6339 |
|
6744 | 6340 |
GetConverterMock()->SetCommitSegmentValue(&segments, true);
|
6745 | 6341 |
command.Clear();
|
6746 | 6342 |
session->Commit(&command);
|
6747 | 6343 |
EXPECT_FALSE(command.output().has_preedit());
|
6748 | |
// "あいうえお"
|
6749 | |
EXPECT_RESULT(kAiueo, command);
|
|
6344 |
EXPECT_RESULT("あいうえお", command);
|
6750 | 6345 |
|
6751 | 6346 |
command.Clear();
|
6752 | 6347 |
session->ResetContext(&command);
|
|
6823 | 6418 |
command.Clear();
|
6824 | 6419 |
session->Convert(&command);
|
6825 | 6420 |
EXPECT_FALSE(command.output().has_result());
|
6826 | |
// "あいうえお"
|
6827 | |
EXPECT_SINGLE_SEGMENT(kAiueo, command);
|
|
6421 |
EXPECT_SINGLE_SEGMENT("あいうえお", command);
|
6828 | 6422 |
|
6829 | 6423 |
convertermock->SetCommitSegmentValue(&segments, true);
|
6830 | 6424 |
command.Clear();
|
6831 | 6425 |
session->Commit(&command);
|
6832 | 6426 |
EXPECT_FALSE(command.output().has_preedit());
|
6833 | |
// "あいうえお"
|
6834 | |
EXPECT_RESULT(kAiueo, command);
|
|
6427 |
EXPECT_RESULT("あいうえお", command);
|
6835 | 6428 |
|
6836 | 6429 |
command.Clear();
|
6837 | 6430 |
session->Undo(&command);
|
|
6888 | 6481 |
// The last "." is a triggering key for auto conversion
|
6889 | 6482 |
InsertCharacterChars("tesuto.", session.get(), &command);
|
6890 | 6483 |
|
6891 | |
// "てすと。",
|
6892 | |
EXPECT_SINGLE_SEGMENT_AND_KEY(
|
6893 | |
"\xE3\x81\xA6\xE3\x81\x99\xE3\x81\xA8\xE3\x80\x82",
|
6894 | |
"\xE3\x81\xA6\xE3\x81\x99\xE3\x81\xA8\xE3\x80\x82", command);
|
|
6484 |
EXPECT_SINGLE_SEGMENT_AND_KEY("てすと。", "てすと。", command);
|
6895 | 6485 |
}
|
6896 | 6486 |
{
|
6897 | 6487 |
std::unique_ptr<Session> session(new Session(engine_.get()));
|
|
6900 | 6490 |
commands::Command command;
|
6901 | 6491 |
|
6902 | 6492 |
// The last "." is a triggering key for auto conversion
|
6903 | |
// "てすと。"
|
6904 | |
InsertCharacterString("\xE3\x81\xA6\xE3\x81\x99\xE3\x81\xA8\xE3\x80\x82",
|
6905 | |
"wrs/", session.get(), &command);
|
6906 | |
|
6907 | |
// "てすと。",
|
6908 | |
EXPECT_SINGLE_SEGMENT_AND_KEY(
|
6909 | |
"\xE3\x81\xA6\xE3\x81\x99\xE3\x81\xA8\xE3\x80\x82",
|
6910 | |
"\xE3\x81\xA6\xE3\x81\x99\xE3\x81\xA8\xE3\x80\x82", command);
|
|
6493 |
InsertCharacterString("てすと。", "wrs/", session.get(), &command);
|
|
6494 |
|
|
6495 |
EXPECT_SINGLE_SEGMENT_AND_KEY("てすと。", "てすと。", command);
|
6911 | 6496 |
}
|
6912 | 6497 |
|
6913 | 6498 |
// Auto On
|
|
6922 | 6507 |
// The last "." is a triggering key for auto conversion
|
6923 | 6508 |
InsertCharacterChars("tesuto.", session.get(), &command);
|
6924 | 6509 |
|
6925 | |
EXPECT_SINGLE_SEGMENT_AND_KEY(kAiueo, kAiueo, command);
|
|
6510 |
EXPECT_SINGLE_SEGMENT_AND_KEY("あいうえお", "あいうえお", command);
|
6926 | 6511 |
}
|
6927 | 6512 |
{
|
6928 | 6513 |
std::unique_ptr<Session> session(new Session(engine_.get()));
|
|
6932 | 6517 |
commands::Command command;
|
6933 | 6518 |
|
6934 | 6519 |
// The last "." is a triggering key for auto conversion
|
6935 | |
// "てすと。",
|
6936 | |
InsertCharacterString("\xE3\x81\xA6\xE3\x81\x99\xE3\x81\xA8\xE3\x80\x82",
|
6937 | |
"wrs/", session.get(), &command);
|
6938 | |
|
6939 | |
EXPECT_SINGLE_SEGMENT_AND_KEY(kAiueo, kAiueo, command);
|
|
6520 |
InsertCharacterString("てすと。", "wrs/", session.get(), &command);
|
|
6521 |
|
|
6522 |
EXPECT_SINGLE_SEGMENT_AND_KEY("あいうえお", "あいうえお", command);
|
6940 | 6523 |
}
|
6941 | 6524 |
|
6942 | 6525 |
// Don't trigger auto conversion for the pattern number + "."
|
|
6949 | 6532 |
// The last "." is a triggering key for auto conversion
|
6950 | 6533 |
InsertCharacterChars("123.", session.get(), &command);
|
6951 | 6534 |
|
6952 | |
// "123."
|
6953 | |
EXPECT_SINGLE_SEGMENT_AND_KEY(
|
6954 | |
"\xEF\xBC\x91\xEF\xBC\x92\xEF\xBC\x93\xEF\xBC\x8E",
|
6955 | |
"\xEF\xBC\x91\xEF\xBC\x92\xEF\xBC\x93\xEF\xBC\x8E", command);
|
|
6535 |
EXPECT_SINGLE_SEGMENT_AND_KEY("123.", "123.", command);
|
6956 | 6536 |
}
|
6957 | 6537 |
|
6958 | 6538 |
// Don't trigger auto conversion for the ".."
|
|
6965 | 6545 |
// The last "." is a triggering key for auto conversion
|
6966 | 6546 |
InsertCharacterChars("..", session.get(), &command);
|
6967 | 6547 |
|
6968 | |
// "。。"
|
6969 | |
EXPECT_SINGLE_SEGMENT_AND_KEY(
|
6970 | |
"\xE3\x80\x82\xE3\x80\x82", "\xE3\x80\x82\xE3\x80\x82", command);
|
|
6548 |
EXPECT_SINGLE_SEGMENT_AND_KEY("。。", "。。", command);
|
6971 | 6549 |
}
|
6972 | 6550 |
|
6973 | 6551 |
{
|
|
6977 | 6555 |
commands::Command command;
|
6978 | 6556 |
|
6979 | 6557 |
// The last "." is a triggering key for auto conversion
|
6980 | |
// "123。"
|
6981 | |
InsertCharacterString("\xEF\xBC\x91\xEF\xBC\x92\xEF\xBC\x93\xE3\x80\x82",
|
6982 | |
"123.", session.get(), &command);
|
6983 | |
|
6984 | |
// "123."
|
6985 | |
EXPECT_SINGLE_SEGMENT_AND_KEY(
|
6986 | |
"\xEF\xBC\x91\xEF\xBC\x92\xEF\xBC\x93\xEF\xBC\x8E",
|
6987 | |
"\xEF\xBC\x91\xEF\xBC\x92\xEF\xBC\x93\xEF\xBC\x8E", command);
|
|
6558 |
InsertCharacterString("123。", "123.", session.get(), &command);
|
|
6559 |
|
|
6560 |
EXPECT_SINGLE_SEGMENT_AND_KEY("123.", "123.", command);
|
6988 | 6561 |
}
|
6989 | 6562 |
|
6990 | 6563 |
// Don't trigger auto conversion for "." only.
|
|
6997 | 6570 |
// The last "." is a triggering key for auto conversion
|
6998 | 6571 |
InsertCharacterChars(".", session.get(), &command);
|
6999 | 6572 |
|
7000 | |
// "。"
|
7001 | |
EXPECT_SINGLE_SEGMENT_AND_KEY("\xE3\x80\x82", "\xE3\x80\x82", command);
|
|
6573 |
EXPECT_SINGLE_SEGMENT_AND_KEY("。", "。", command);
|
7002 | 6574 |
}
|
7003 | 6575 |
|
7004 | 6576 |
{
|
|
7008 | 6580 |
commands::Command command;
|
7009 | 6581 |
|
7010 | 6582 |
// The last "." is a triggering key for auto conversion
|
7011 | |
// "。",
|
7012 | |
InsertCharacterString("\xE3\x80\x82", "/", session.get(), &command);
|
7013 | |
|
7014 | |
// "。"
|
7015 | |
EXPECT_SINGLE_SEGMENT_AND_KEY("\xE3\x80\x82", "\xE3\x80\x82", command);
|
|
6583 |
InsertCharacterString("。", "/", session.get(), &command);
|
|
6584 |
|
|
6585 |
EXPECT_SINGLE_SEGMENT_AND_KEY("。", "。", command);
|
7016 | 6586 |
}
|
7017 | 6587 |
|
7018 | 6588 |
// Do auto conversion even if romanji-table is modified.
|
|
7023 | 6593 |
|
7024 | 6594 |
// Modify romanji-table to convert "zz" -> "。"
|
7025 | 6595 |
composer::Table zz_table;
|
7026 | |
// "てすと。"
|
7027 | |
zz_table.AddRule("te", "\xE3\x81\xA6", "");
|
7028 | |
zz_table.AddRule("su", "\xE3\x81\x99", "");
|
7029 | |
zz_table.AddRule("to", "\xE3\x81\xA8", "");
|
7030 | |
zz_table.AddRule("zz", "\xE3\x80\x82", "");
|
|
6596 |
zz_table.AddRule("te", "て", "");
|
|
6597 |
zz_table.AddRule("su", "す", "");
|
|
6598 |
zz_table.AddRule("to", "と", "");
|
|
6599 |
zz_table.AddRule("zz", "。", "");
|
7031 | 6600 |
session->get_internal_composer_only_for_unittest()->SetTable(&zz_table);
|
7032 | 6601 |
|
7033 | 6602 |
// The last "zz" is converted to "." and triggering key for auto conversion
|
7034 | 6603 |
commands::Command command;
|
7035 | 6604 |
InsertCharacterChars("tesutozz", session.get(), &command);
|
7036 | 6605 |
|
7037 | |
EXPECT_SINGLE_SEGMENT_AND_KEY(kAiueo, kAiueo, command);
|
|
6606 |
EXPECT_SINGLE_SEGMENT_AND_KEY("あいうえお", "あいうえお", command);
|
7038 | 6607 |
}
|
7039 | 6608 |
|
7040 | 6609 |
{
|
|
7068 | 6637 |
commands::Command command;
|
7069 | 6638 |
|
7070 | 6639 |
if (kana_mode) {
|
7071 | |
// "てすと"
|
7072 | |
string key = "\xE3\x81\xA6\xE3\x81\x99\xE3\x81\xA8";
|
|
6640 |
string key = "てすと";
|
7073 | 6641 |
key += trigger_key[i];
|
7074 | 6642 |
InsertCharacterString(key, "wst/", session.get(), &command);
|
7075 | 6643 |
} else {
|
|
7083 | 6651 |
EXPECT_TRUE(command.output().preedit().segment(0).has_key());
|
7084 | 6652 |
|
7085 | 6653 |
if (onoff > 0 && flag[i] > 0) {
|
7086 | |
// "あいうえお"
|
7087 | |
EXPECT_EQ("\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86"
|
7088 | |
"\xe3\x81\x88\xe3\x81\x8a",
|
|
6654 |
EXPECT_EQ("あいうえお",
|
7089 | 6655 |
command.output().preedit().segment(0).key());
|
7090 | 6656 |
} else {
|
7091 | 6657 |
// Not "あいうえお"
|
7092 | |
EXPECT_NE("\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86"
|
7093 | |
"\xe3\x81\x88\xe3\x81\x8a",
|
|
6658 |
EXPECT_NE("あいうえお",
|
7094 | 6659 |
command.output().preedit().segment(0).key());
|
7095 | 6660 |
}
|
7096 | 6661 |
}
|
|
7115 | 6680 |
command.mutable_input()->mutable_key()->set_mode(commands::FULL_KATAKANA);
|
7116 | 6681 |
EXPECT_TRUE(session->SendKey(&command));
|
7117 | 6682 |
EXPECT_TRUE(command.output().consumed());
|
7118 | |
EXPECT_RESULT(kFullWidthSpace, command);
|
|
6683 |
EXPECT_RESULT(" ", command);
|
7119 | 6684 |
EXPECT_EQ(mozc::commands::FULL_KATAKANA, command.output().mode());
|
7120 | 6685 |
}
|
7121 | 6686 |
|
|
7127 | 6692 |
|
7128 | 6693 |
commands::Command command;
|
7129 | 6694 |
InsertCharacterChars("ssh", session.get(), &command);
|
7130 | |
// "っsh"
|
7131 | |
EXPECT_EQ("\xE3\x81\xA3\xEF\xBD\x93\xEF\xBD\x88", GetComposition(command));
|
|
6695 |
EXPECT_EQ("っsh", GetComposition(command));
|
7132 | 6696 |
|
7133 | 6697 |
Segments segments;
|
7134 | 6698 |
// Set a dummy segments for ConvertToHalfASCII.
|
7135 | 6699 |
{
|
7136 | 6700 |
Segment *segment;
|
7137 | 6701 |
segment = segments.add_segment();
|
7138 | |
// // "っsh"
|
7139 | |
// segment->set_key("\xE3\x81\xA3\xEF\xBD\x93\xEF\xBD\x88");
|
7140 | |
// "っsh"
|
7141 | |
segment->set_key("\xE3\x81\xA3sh");
|
|
6702 |
segment->set_key("っsh");
|
7142 | 6703 |
|
7143 | 6704 |
segment->add_candidate()->value = "[SSH]";
|
7144 | 6705 |
}
|
|
7163 | 6724 |
|
7164 | 6725 |
SendKey("1", session.get(), &command);
|
7165 | 6726 |
// "あ|"
|
7166 | |
EXPECT_EQ(kHiraganaA, command.output().preedit().segment(0).value());
|
|
6727 |
EXPECT_EQ("あ", command.output().preedit().segment(0).value());
|
7167 | 6728 |
EXPECT_EQ(1, command.output().preedit().cursor());
|
7168 | 6729 |
|
7169 | 6730 |
SendKey("1", session.get(), &command);
|
7170 | 6731 |
// "い|"
|
7171 | |
EXPECT_EQ("\xE3\x81\x84", command.output().preedit().segment(0).value());
|
|
6732 |
EXPECT_EQ("い", command.output().preedit().segment(0).value());
|
7172 | 6733 |
EXPECT_EQ(1, command.output().preedit().cursor());
|
7173 | 6734 |
|
7174 | 6735 |
SendKey("1", session.get(), &command);
|
|
7180 | 6741 |
SendKey("1", session.get(), &command);
|
7181 | 6742 |
SendKey("1", session.get(), &command);
|
7182 | 6743 |
SendKey("1", session.get(), &command);
|
7183 | |
// "あ|"
|
7184 | |
EXPECT_EQ(kHiraganaA, command.output().preedit().segment(0).value());
|
|
6744 |
EXPECT_EQ("あ", command.output().preedit().segment(0).value());
|
7185 | 6745 |
EXPECT_EQ(1, command.output().preedit().cursor());
|
7186 | 6746 |
|
7187 | 6747 |
SendKey("2", session.get(), &command);
|
7188 | |
// "あか|"
|
7189 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x81\x8B",
|
|
6748 |
EXPECT_EQ("あか",
|
7190 | 6749 |
command.output().preedit().segment(0).value());
|
7191 | 6750 |
EXPECT_EQ(2, command.output().preedit().cursor());
|
7192 | 6751 |
|
7193 | 6752 |
SendKey("2", session.get(), &command);
|
7194 | |
// "あき|"
|
7195 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x81\x8D",
|
|
6753 |
EXPECT_EQ("あき",
|
7196 | 6754 |
command.output().preedit().segment(0).value());
|
7197 | 6755 |
EXPECT_EQ(2, command.output().preedit().cursor());
|
7198 | 6756 |
|
7199 | 6757 |
SendKey("*", session.get(), &command);
|
7200 | |
// "あぎ|"
|
7201 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x81\x8E",
|
|
6758 |
EXPECT_EQ("あぎ",
|
7202 | 6759 |
command.output().preedit().segment(0).value());
|
7203 | 6760 |
EXPECT_EQ(2, command.output().preedit().cursor());
|
7204 | 6761 |
|
7205 | 6762 |
SendKey("*", session.get(), &command);
|
7206 | |
// "あき|"
|
7207 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x81\x8D",
|
|
6763 |
EXPECT_EQ("あき",
|
7208 | 6764 |
command.output().preedit().segment(0).value());
|
7209 | 6765 |
EXPECT_EQ(2, command.output().preedit().cursor());
|
7210 | 6766 |
|
7211 | 6767 |
SendKey("3", session.get(), &command);
|
7212 | |
// "あきさ|"
|
7213 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x81\x8D\xE3\x81\x95",
|
|
6768 |
EXPECT_EQ("あきさ",
|
7214 | 6769 |
command.output().preedit().segment(0).value());
|
7215 | 6770 |
EXPECT_EQ(3, command.output().preedit().cursor());
|
7216 | 6771 |
|
7217 | 6772 |
SendSpecialKey(commands::KeyEvent::RIGHT, session.get(), &command);
|
7218 | |
// "あきさ|"
|
7219 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x81\x8D\xE3\x81\x95",
|
|
6773 |
EXPECT_EQ("あきさ",
|
7220 | 6774 |
command.output().preedit().segment(0).value());
|
7221 | 6775 |
EXPECT_EQ(3, command.output().preedit().cursor());
|
7222 | 6776 |
|
7223 | 6777 |
SendKey("3", session.get(), &command);
|
7224 | |
// "あきささ|"
|
7225 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x81\x8D\xE3\x81\x95\xE3\x81\x95",
|
|
6778 |
EXPECT_EQ("あきささ",
|
7226 | 6779 |
command.output().preedit().segment(0).value());
|
7227 | 6780 |
EXPECT_EQ(4, command.output().preedit().cursor());
|
7228 | 6781 |
|
7229 | 6782 |
SendSpecialKey(commands::KeyEvent::LEFT, session.get(), &command);
|
7230 | |
// "あきさ|さ"
|
7231 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x81\x8D\xE3\x81\x95\xE3\x81\x95",
|
|
6783 |
EXPECT_EQ("あきささ",
|
7232 | 6784 |
command.output().preedit().segment(0).value());
|
7233 | 6785 |
EXPECT_EQ(3, command.output().preedit().cursor());
|
7234 | 6786 |
|
7235 | 6787 |
SendKey("4", session.get(), &command);
|
7236 | |
// "あきさた|さ"
|
7237 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x81\x8D\xE3\x81\x95\xE3\x81\x9F\xE3\x81\x95",
|
|
6788 |
EXPECT_EQ("あきさたさ",
|
7238 | 6789 |
command.output().preedit().segment(0).value());
|
7239 | 6790 |
EXPECT_EQ(4, command.output().preedit().cursor());
|
7240 | 6791 |
|
7241 | 6792 |
SendSpecialKey(commands::KeyEvent::LEFT, session.get(), &command);
|
7242 | |
// "あきさ|たさ"
|
7243 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x81\x8D\xE3\x81\x95\xE3\x81\x9F\xE3\x81\x95",
|
|
6793 |
EXPECT_EQ("あきさたさ",
|
7244 | 6794 |
command.output().preedit().segment(0).value());
|
7245 | 6795 |
EXPECT_EQ(3, command.output().preedit().cursor());
|
7246 | 6796 |
|
7247 | 6797 |
SendKey("*", session.get(), &command);
|
7248 | |
// "あきざ|たさ"
|
7249 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x81\x8D\xE3\x81\x96\xE3\x81\x9F\xE3\x81\x95",
|
|
6798 |
EXPECT_EQ("あきざたさ",
|
7250 | 6799 |
command.output().preedit().segment(0).value());
|
7251 | 6800 |
EXPECT_EQ(3, command.output().preedit().cursor());
|
7252 | 6801 |
|
|
7257 | 6806 |
SendSpecialKey(commands::KeyEvent::END, session.get(), &command);
|
7258 | 6807 |
SendKey("6", session.get(), &command);
|
7259 | 6808 |
SendKey("*", session.get(), &command);
|
7260 | |
// "あきざたさひば|"
|
7261 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x81\x8D\xE3\x81\x96\xE3\x81\x9F\xE3\x81\x95"
|
7262 | |
"\xE3\x81\xB2\xE3\x81\xB0",
|
|
6809 |
EXPECT_EQ("あきざたさひば",
|
7263 | 6810 |
command.output().preedit().segment(0).value());
|
7264 | 6811 |
EXPECT_EQ(7, command.output().preedit().cursor());
|
7265 | 6812 |
|
|
7270 | 6817 |
SendSpecialKey(commands::KeyEvent::RIGHT, session.get(), &command);
|
7271 | 6818 |
SendKey("6", session.get(), &command);
|
7272 | 6819 |
SendKey("*", session.get(), &command);
|
7273 | |
// "あきざたさひばひば|"
|
7274 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x81\x8D\xE3\x81\x96\xE3\x81\x9F\xE3\x81\x95"
|
7275 | |
"\xE3\x81\xB2\xE3\x81\xB0\xE3\x81\xB2\xE3\x81\xB0",
|
|
6820 |
EXPECT_EQ("あきざたさひばひば",
|
7276 | 6821 |
command.output().preedit().segment(0).value());
|
7277 | 6822 |
EXPECT_EQ(9, command.output().preedit().cursor());
|
7278 | 6823 |
|
|
7280 | 6825 |
SendSpecialKey(commands::KeyEvent::END, session.get(), &command);
|
7281 | 6826 |
SendKey("6", session.get(), &command);
|
7282 | 6827 |
SendKey("6", session.get(), &command);
|
7283 | |
// "あきざたさひばひばひ|"
|
7284 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x81\x8D\xE3\x81\x96\xE3\x81\x9F\xE3\x81\x95"
|
7285 | |
"\xE3\x81\xB2\xE3\x81\xB0\xE3\x81\xB2\xE3\x81\xB0\xE3\x81\xB2",
|
|
6828 |
EXPECT_EQ("あきざたさひばひばひ",
|
7286 | 6829 |
command.output().preedit().segment(0).value());
|
7287 | 6830 |
SendSpecialKey(commands::KeyEvent::LEFT, session.get(), &command);
|
7288 | 6831 |
SendKey("6", session.get(), &command);
|
7289 | |
// "あきざたさひばひばは|ひ"
|
7290 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x81\x8D\xE3\x81\x96\xE3\x81\x9F\xE3\x81\x95"
|
7291 | |
"\xE3\x81\xB2\xE3\x81\xB0\xE3\x81\xB2\xE3\x81\xB0\xE3\x81\xAF"
|
7292 | |
"\xE3\x81\xB2",
|
|
6832 |
EXPECT_EQ("あきざたさひばひばはひ",
|
7293 | 6833 |
command.output().preedit().segment(0).value());
|
7294 | 6834 |
SendKey("*", session.get(), &command);
|
7295 | |
// "あきざたさひばひばば|ひ"
|
7296 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x81\x8D\xE3\x81\x96\xE3\x81\x9F\xE3\x81\x95"
|
7297 | |
"\xE3\x81\xB2\xE3\x81\xB0\xE3\x81\xB2\xE3\x81\xB0\xE3\x81\xB0"
|
7298 | |
"\xE3\x81\xB2",
|
|
6835 |
EXPECT_EQ("あきざたさひばひばばひ",
|
7299 | 6836 |
command.output().preedit().segment(0).value());
|
7300 | 6837 |
EXPECT_EQ(10, command.output().preedit().cursor());
|
7301 | 6838 |
|
7302 | 6839 |
// Test for Home key
|
7303 | 6840 |
SendSpecialKey(commands::KeyEvent::HOME, session.get(), &command);
|
7304 | |
// "|あきざたさひばひばばひ"
|
7305 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x81\x8D\xE3\x81\x96\xE3\x81\x9F\xE3\x81\x95"
|
7306 | |
"\xE3\x81\xB2\xE3\x81\xB0\xE3\x81\xB2\xE3\x81\xB0\xE3\x81\xB0"
|
7307 | |
"\xE3\x81\xB2",
|
|
6841 |
EXPECT_EQ("あきざたさひばひばばひ",
|
7308 | 6842 |
command.output().preedit().segment(0).value());
|
7309 | 6843 |
SendKey("6", session.get(), &command);
|
7310 | 6844 |
SendKey("*", session.get(), &command);
|
7311 | |
// "ば|あきざたさひばひばばひ"
|
7312 | |
EXPECT_EQ("\xE3\x81\xB0\xE3\x81\x82\xE3\x81\x8D\xE3\x81\x96\xE3\x81\x9F"
|
7313 | |
"\xE3\x81\x95\xE3\x81\xB2\xE3\x81\xB0\xE3\x81\xB2\xE3\x81\xB0"
|
7314 | |
"\xE3\x81\xB0\xE3\x81\xB2",
|
|
6845 |
EXPECT_EQ("ばあきざたさひばひばばひ",
|
7315 | 6846 |
command.output().preedit().segment(0).value());
|
7316 | 6847 |
EXPECT_EQ(1, command.output().preedit().cursor());
|
7317 | 6848 |
|
7318 | 6849 |
SendSpecialKey(commands::KeyEvent::END, session.get(), &command);
|
7319 | 6850 |
SendKey("5", session.get(), &command);
|
7320 | |
// "ばあきざたさひばひばばひな|"
|
7321 | |
EXPECT_EQ("\xE3\x81\xB0\xE3\x81\x82\xE3\x81\x8D\xE3\x81\x96\xE3\x81\x9F"
|
7322 | |
"\xE3\x81\x95\xE3\x81\xB2\xE3\x81\xB0\xE3\x81\xB2\xE3\x81\xB0"
|
7323 | |
"\xE3\x81\xB0\xE3\x81\xB2\xE3\x81\xAA",
|
|
6851 |
EXPECT_EQ("ばあきざたさひばひばばひな",
|
7324 | 6852 |
command.output().preedit().segment(0).value());
|
7325 | 6853 |
SendKey("*", session.get(), &command); // no effect
|
7326 | |
// "ばあきざたさひばひばばひな|"
|
7327 | |
EXPECT_EQ("\xE3\x81\xB0\xE3\x81\x82\xE3\x81\x8D\xE3\x81\x96\xE3\x81\x9F"
|
7328 | |
"\xE3\x81\x95\xE3\x81\xB2\xE3\x81\xB0\xE3\x81\xB2\xE3\x81\xB0"
|
7329 | |
"\xE3\x81\xB0\xE3\x81\xB2\xE3\x81\xAA",
|
|
6854 |
EXPECT_EQ("ばあきざたさひばひばばひな",
|
7330 | 6855 |
command.output().preedit().segment(0).value());
|
7331 | 6856 |
EXPECT_EQ(13, command.output().preedit().cursor());
|
7332 | 6857 |
}
|
|
7340 | 6865 |
std::unique_ptr<Session> session(new Session(engine_.get()));
|
7341 | 6866 |
session->SetConfig(&config);
|
7342 | 6867 |
InitSessionToPrecomposition(session.get(), *mobile_request_);
|
7343 | |
// "は"
|
7344 | |
InsertCharacterCodeAndString('6', "\xE3\x81\xAF", session.get(), &command);
|
7345 | |
// "し"
|
7346 | |
InsertCharacterCodeAndString('3', "\xE3\x81\x97", session.get(), &command);
|
|
6868 |
InsertCharacterCodeAndString('6', "は", session.get(), &command);
|
|
6869 |
InsertCharacterCodeAndString('3', "し", session.get(), &command);
|
7347 | 6870 |
SendKey("*", session.get(), &command);
|
7348 | |
// "ょ"
|
7349 | |
InsertCharacterCodeAndString('3', "\xE3\x82\x87", session.get(), &command);
|
7350 | |
// "う"
|
7351 | |
InsertCharacterCodeAndString('1', "\xE3\x81\x86", session.get(), &command);
|
7352 | |
// "はじょう"
|
7353 | |
EXPECT_EQ("\xE3\x81\xAF\xE3\x81\x98\xE3\x82\x87\xE3\x81\x86",
|
|
6871 |
InsertCharacterCodeAndString('3', "ょ", session.get(), &command);
|
|
6872 |
InsertCharacterCodeAndString('1', "う", session.get(), &command);
|
|
6873 |
EXPECT_EQ("はじょう",
|
7354 | 6874 |
command.output().preedit().segment(0).value());
|
7355 | 6875 |
}
|
7356 | 6876 |
|
|
7363 | 6883 |
SendKey("3", session.get(), &command);
|
7364 | 6884 |
SendKey("3", session.get(), &command);
|
7365 | 6885 |
SendKey("*", session.get(), &command);
|
7366 | |
// "ょ"
|
7367 | |
InsertCharacterCodeAndString('3', "\xE3\x82\x87", session.get(), &command);
|
7368 | |
// "う"
|
7369 | |
InsertCharacterCodeAndString('1', "\xE3\x81\x86", session.get(), &command);
|
7370 | |
// "はじょう"
|
7371 | |
EXPECT_EQ("\xE3\x81\xAF\xE3\x81\x98\xE3\x82\x87\xE3\x81\x86",
|
7372 | |
command.output().preedit().segment(0).value());
|
|
6886 |
InsertCharacterCodeAndString('3', "ょ", session.get(), &command);
|
|
6887 |
InsertCharacterCodeAndString('1', "う", session.get(), &command);
|
|
6888 |
EXPECT_EQ("はじょう", command.output().preedit().segment(0).value());
|
7373 | 6889 |
}
|
7374 | 6890 |
|
7375 | 6891 |
{
|
|
7381 | 6897 |
SendKey("2", session.get(), &command);
|
7382 | 6898 |
SendKey("3", session.get(), &command);
|
7383 | 6899 |
SendKey("3", session.get(), &command);
|
7384 | |
// "あかし"
|
7385 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x81\x8B\xE3\x81\x97",
|
7386 | |
command.output().preedit().segment(0).value());
|
7387 | |
// "の"
|
7388 | |
InsertCharacterCodeAndString('5', "\xE3\x81\xAE", session.get(), &command);
|
7389 | |
// "く"
|
7390 | |
InsertCharacterCodeAndString('2', "\xE3\x81\x8F", session.get(), &command);
|
7391 | |
// "し"
|
7392 | |
InsertCharacterCodeAndString('3', "\xE3\x81\x97", session.get(), &command);
|
7393 | |
// "あかしのくし"
|
7394 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x81\x8B\xE3\x81\x97\xE3\x81\xAE\xE3\x81\x8F\xE3"
|
7395 | |
"\x81\x97",
|
7396 | |
command.output().preedit().segment(0).value());
|
|
6900 |
EXPECT_EQ("あかし", command.output().preedit().segment(0).value());
|
|
6901 |
InsertCharacterCodeAndString('5', "の", session.get(), &command);
|
|
6902 |
InsertCharacterCodeAndString('2', "く", session.get(), &command);
|
|
6903 |
InsertCharacterCodeAndString('3', "し", session.get(), &command);
|
|
6904 |
EXPECT_EQ("あかしのくし", command.output().preedit().segment(0).value());
|
7397 | 6905 |
SendSpecialKey(commands::KeyEvent::LEFT, session.get(), &command);
|
7398 | 6906 |
SendSpecialKey(commands::KeyEvent::LEFT, session.get(), &command);
|
7399 | 6907 |
SendSpecialKey(commands::KeyEvent::LEFT, session.get(), &command);
|
|
7409 | 6917 |
SendKey("9", session.get(), &command);
|
7410 | 6918 |
SendSpecialKey(commands::KeyEvent::RIGHT, session.get(), &command);
|
7411 | 6919 |
SendSpecialKey(commands::KeyEvent::RIGHT, session.get(), &command);
|
7412 | |
// "ん"
|
7413 | |
InsertCharacterCodeAndString('0', "\xE3\x82\x93", session.get(), &command);
|
|
6920 |
InsertCharacterCodeAndString('0', "ん", session.get(), &command);
|
7414 | 6921 |
SendSpecialKey(commands::KeyEvent::END, session.get(), &command);
|
7415 | 6922 |
SendKey("1", session.get(), &command);
|
7416 | 6923 |
SendKey("1", session.get(), &command);
|
7417 | 6924 |
SendKey("1", session.get(), &command);
|
7418 | 6925 |
SendKey("*", session.get(), &command);
|
7419 | 6926 |
SendSpecialKey(commands::KeyEvent::LEFT, session.get(), &command);
|
7420 | |
// "ゆ"
|
7421 | |
InsertCharacterCodeAndString('8', "\xE3\x82\x86", session.get(), &command);
|
|
6927 |
InsertCharacterCodeAndString('8', "ゆ", session.get(), &command);
|
7422 | 6928 |
SendKey("*", session.get(), &command);
|
7423 | 6929 |
SendSpecialKey(commands::KeyEvent::RIGHT, session.get(), &command);
|
7424 | 6930 |
SendKey("*", session.get(), &command);
|
7425 | 6931 |
SendKey("*", session.get(), &command);
|
7426 | |
// "あるかしんのくしゅう"
|
7427 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x82\x8B\xE3\x81\x8B\xE3\x81\x97\xE3\x82\x93\xE3"
|
7428 | |
"\x81\xAE\xE3\x81\x8F\xE3\x81\x97\xE3\x82\x85\xE3\x81\x86",
|
7429 | |
command.output().preedit().segment(0).value());
|
|
6932 |
EXPECT_EQ("あるかしんのくしゅう",
|
|
6933 |
command.output().preedit().segment(0).value());
|
7430 | 6934 |
SendSpecialKey(commands::KeyEvent::HOME, session.get(), &command);
|
7431 | 6935 |
SendSpecialKey(commands::KeyEvent::RIGHT, session.get(), &command);
|
7432 | 6936 |
SendSpecialKey(commands::KeyEvent::RIGHT, session.get(), &command);
|
7433 | |
// "は"
|
7434 | |
InsertCharacterCodeAndString('6', "\xE3\x81\xAF", session.get(), &command);
|
|
6937 |
InsertCharacterCodeAndString('6', "は", session.get(), &command);
|
7435 | 6938 |
SendKey("*", session.get(), &command);
|
7436 | 6939 |
SendKey("*", session.get(), &command);
|
7437 | 6940 |
SendKey("*", session.get(), &command);
|
|
7444 | 6947 |
SendKey("6", session.get(), &command);
|
7445 | 6948 |
SendKey("6", session.get(), &command);
|
7446 | 6949 |
SendKey("6", session.get(), &command);
|
7447 | |
// "あるぱかしんのふくしゅう"
|
7448 | |
EXPECT_EQ("\xE3\x81\x82\xE3\x82\x8B\xE3\x81\xB1\xE3\x81\x8B\xE3\x81\x97\xE3"
|
7449 | |
"\x82\x93\xE3\x81\xAE\xE3\x81\xB5\xE3\x81\x8F\xE3\x81\x97\xE3\x82\x85"
|
7450 | |
"\xE3\x81\x86",
|
7451 | |
command.output().preedit().segment(0).value());
|
|
6950 |
EXPECT_EQ("あるぱかしんのふくしゅう",
|
|
6951 |
command.output().preedit().segment(0).value());
|
7452 | 6952 |
}
|
7453 | 6953 |
}
|
7454 | 6954 |
|
|
7468 | 6968 |
Segment::Candidate *candidate;
|
7469 | 6969 |
|
7470 | 6970 |
segment = segments.add_segment();
|
7471 | |
// "ねこの"
|
7472 | |
segment->set_key("\xE3\x81\xAD\xE3\x81\x93\xE3\x81\xAE");
|
|
6971 |
segment->set_key("ねこの");
|
7473 | 6972 |
candidate = segment->add_candidate();
|
7474 | |
// "猫の"
|
7475 | |
candidate->value = "\xE7\x8C\xAB\xE3\x81\xAE";
|
|
6973 |
candidate->value = "猫の";
|
7476 | 6974 |
|
7477 | 6975 |
segment = segments.add_segment();
|
7478 | |
// "しっぽを"
|
7479 | |
segment->set_key("\xE3\x81\x97\xE3\x81\xA3\xE3\x81\xBD\xE3\x82\x92");
|
|
6976 |
segment->set_key("しっぽを");
|
7480 | 6977 |
candidate = segment->add_candidate();
|
7481 | |
// "しっぽを"
|
7482 | |
candidate->value = "\xE3\x81\x97\xE3\x81\xA3\xE3\x81\xBD\xE3\x82\x92";
|
|
6978 |
candidate->value = "しっぽを";
|
7483 | 6979 |
|
7484 | 6980 |
segment = segments.add_segment();
|
7485 | |
// "ぬいた"
|
7486 | |
segment->set_key("\xE3\x81\xAC\xE3\x81\x84\xE3\x81\x9F");
|
|
6981 |
segment->set_key("ぬいた");
|
7487 | 6982 |
candidate = segment->add_candidate();
|
7488 | |
// "抜いた"
|
7489 | |
candidate->value = "\xE6\x8A\x9C\xE3\x81\x84\xE3\x81\x9F";
|
|
6983 |
candidate->value = "抜いた";
|
7490 | 6984 |
|
7491 | 6985 |
GetConverterMock()->SetStartConversionForRequest(&segments, true);
|
7492 | 6986 |
}
|
|
7505 | 6999 |
Segment::Candidate *candidate;
|
7506 | 7000 |
|
7507 | 7001 |
segment = segments.add_segment();
|
7508 | |
// "ぬいた"
|
7509 | |
segment->set_key("\xE3\x81\xAC\xE3\x81\x84\xE3\x81\x9F");
|
|
7002 |
segment->set_key("ぬいた");
|
7510 | 7003 |
candidate = segment->add_candidate();
|
7511 | |
// "抜いた"
|
7512 | |
candidate->value = "\xE6\x8A\x9C\xE3\x81\x84\xE3\x81\x9F";
|
|
7004 |
candidate->value = "抜いた";
|
7513 | 7005 |
|
7514 | 7006 |
GetConverterMock()->SetCommitSegments(&segments, true);
|
7515 | 7007 |
}
|
|
7517 | 7009 |
command.Clear();
|
7518 | 7010 |
command.mutable_input()->mutable_command()->set_id(0);
|
7519 | 7011 |
ASSERT_TRUE(session->CommitCandidate(&command));
|
7520 | |
// "抜いた"
|
7521 | |
EXPECT_PREEDIT("\xE6\x8A\x9C\xE3\x81\x84\xE3\x81\x9F", command);
|
7522 | |
// "抜いた" "ぬいた"
|
7523 | |
EXPECT_SINGLE_SEGMENT_AND_KEY("\xE6\x8A\x9C\xE3\x81\x84\xE3\x81\x9F",
|
7524 | |
"\xE3\x81\xAC\xE3\x81\x84\xE3\x81\x9F",
|
7525 | |
command);
|
7526 | |
// "猫のしっぽを"
|
7527 | |
EXPECT_RESULT("\xE7\x8C\xAB\xE3\x81\xAE"
|
7528 | |
"\xE3\x81\x97\xE3\x81\xA3\xE3\x81\xBD\xE3\x82\x92", command);
|
|
7012 |
EXPECT_PREEDIT("抜いた", command);
|
|
7013 |
EXPECT_SINGLE_SEGMENT_AND_KEY("抜いた", "ぬいた", command);
|
|
7014 |
EXPECT_RESULT("猫のしっぽを", command);
|
7529 | 7015 |
}
|
7530 | 7016 |
|
7531 | 7017 |
TEST_F(SessionTest, CommitCandidateAt3rdOf3Segments) {
|
|
7544 | 7030 |
Segment::Candidate *candidate;
|
7545 | 7031 |
|
7546 | 7032 |
segment = segments.add_segment();
|
7547 | |
// "ねこの"
|
7548 | |
segment->set_key("\xE3\x81\xAD\xE3\x81\x93\xE3\x81\xAE");
|
|
7033 |
segment->set_key("ねこの");
|
7549 | 7034 |
candidate = segment->add_candidate();
|
7550 | |
// "猫の"
|
7551 | |
candidate->value = "\xE7\x8C\xAB\xE3\x81\xAE";
|
|
7035 |
candidate->value = "猫の";
|
7552 | 7036 |
|
7553 | 7037 |
segment = segments.add_segment();
|
7554 | |
// "しっぽを"
|
7555 | |
segment->set_key("\xE3\x81\x97\xE3\x81\xA3\xE3\x81\xBD\xE3\x82\x92");
|
|
7038 |
segment->set_key("しっぽを");
|
7556 | 7039 |
candidate = segment->add_candidate();
|
7557 | |
// "しっぽを"
|
7558 | |
candidate->value = "\xE3\x81\x97\xE3\x81\xA3\xE3\x81\xBD\xE3\x82\x92";
|
|
7040 |
candidate->value = "しっぽを";
|
7559 | 7041 |
|
7560 | 7042 |
segment = segments.add_segment();
|
7561 | |
// "ぬいた"
|
7562 | |
segment->set_key("\xE3\x81\xAC\xE3\x81\x84\xE3\x81\x9F");
|
|
7043 |
segment->set_key("ぬいた");
|
7563 | 7044 |
candidate = segment->add_candidate();
|
7564 | |
// "抜いた"
|
7565 | |
candidate->value = "\xE6\x8A\x9C\xE3\x81\x84\xE3\x81\x9F";
|
|
7045 |
candidate->value = "抜いた";
|
7566 | 7046 |
|
7567 | 7047 |
GetConverterMock()->SetStartConversionForRequest(&segments, true);
|
7568 | 7048 |
}
|
|
7585 | 7065 |
command.mutable_input()->mutable_command()->set_id(0);
|
7586 | 7066 |
ASSERT_TRUE(session->CommitCandidate(&command));
|
7587 | 7067 |
EXPECT_FALSE(command.output().has_preedit());
|
7588 | |
// "猫のしっぽを抜いた"
|
7589 | |
EXPECT_RESULT("\xE7\x8C\xAB\xE3\x81\xAE"
|
7590 | |
"\xE3\x81\x97\xE3\x81\xA3\xE3\x81\xBD\xE3\x82\x92"
|
7591 | |
"\xE6\x8A\x9C\xE3\x81\x84\xE3\x81\x9F" , command);
|
|
7068 |
EXPECT_RESULT("猫のしっぽを抜いた" , command);
|
7592 | 7069 |
}
|
7593 | 7070 |
|
7594 | 7071 |
TEST_F(SessionTest, CommitCandidate_suggestion) {
|
|
7732 | 7209 |
TEST_F(SessionTest, ConvertReverse) {
|
7733 | 7210 |
std::unique_ptr<Session> session(new Session(engine_.get()));
|
7734 | 7211 |
InitSessionToPrecomposition(session.get());
|
7735 | |
// "阿伊宇江於"
|
7736 | |
const char kKanjiAiueo[] =
|
7737 | |
"\xe9\x98\xbf\xe4\xbc\x8a\xe5\xae\x87\xe6\xb1\x9f\xe6\x96\xbc";
|
|
7212 |
const char kKanjiAiueo[] = "阿伊宇江於";
|
7738 | 7213 |
commands::Command command;
|
7739 | 7214 |
SetupCommandForReverseConversion(kKanjiAiueo, command.mutable_input());
|
7740 | |
SetupMockForReverseConversion(kKanjiAiueo, kAiueo);
|
|
7215 |
SetupMockForReverseConversion(kKanjiAiueo, "あいうえお");
|
7741 | 7216 |
|
7742 | 7217 |
EXPECT_TRUE(session->SendCommand(&command));
|
7743 | 7218 |
EXPECT_TRUE(command.output().consumed());
|
|
7752 | 7227 |
TEST_F(SessionTest, EscapeFromConvertReverse) {
|
7753 | 7228 |
std::unique_ptr<Session> session(new Session(engine_.get()));
|
7754 | 7229 |
InitSessionToPrecomposition(session.get());
|
7755 | |
// "阿伊宇江於"
|
7756 | |
const char kKanjiAiueo[] =
|
7757 | |
"\xe9\x98\xbf\xe4\xbc\x8a\xe5\xae\x87\xe6\xb1\x9f\xe6\x96\xbc";
|
|
7230 |
const char kKanjiAiueo[] = "阿伊宇江於";
|
7758 | 7231 |
|
7759 | 7232 |
commands::Command command;
|
7760 | 7233 |
SetupCommandForReverseConversion(kKanjiAiueo, command.mutable_input());
|
7761 | |
SetupMockForReverseConversion(kKanjiAiueo, kAiueo);
|
|
7234 |
SetupMockForReverseConversion(kKanjiAiueo, "あいうえお");
|
7762 | 7235 |
|
7763 | 7236 |
EXPECT_TRUE(session->SendCommand(&command));
|
7764 | 7237 |
EXPECT_TRUE(command.output().consumed());
|
|
7767 | 7240 |
SendKey("ESC", session.get(), &command);
|
7768 | 7241 |
|
7769 | 7242 |
// KANJI should be converted into HIRAGANA in pre-edit state.
|
7770 | |
EXPECT_SINGLE_SEGMENT(kAiueo, command);
|
|
7243 |
EXPECT_SINGLE_SEGMENT("あいうえお", command);
|
7771 | 7244 |
|
7772 | 7245 |
SendKey("ESC", session.get(), &command);
|
7773 | 7246 |
|
|
7779 | 7252 |
TEST_F(SessionTest, SecondEscapeFromConvertReverse) {
|
7780 | 7253 |
std::unique_ptr<Session> session(new Session(engine_.get()));
|
7781 | 7254 |
InitSessionToPrecomposition(session.get());
|
7782 | |
// "阿伊宇江於"
|
7783 | |
const char kKanjiAiueo[] =
|
7784 | |
"\xe9\x98\xbf\xe4\xbc\x8a\xe5\xae\x87\xe6\xb1\x9f\xe6\x96\xbc";
|
|
7255 |
const char kKanjiAiueo[] = "阿伊宇江於";
|
7785 | 7256 |
commands::Command command;
|
7786 | 7257 |
SetupCommandForReverseConversion(kKanjiAiueo, command.mutable_input());
|
7787 | |
SetupMockForReverseConversion(kKanjiAiueo, kAiueo);
|
|
7258 |
SetupMockForReverseConversion(kKanjiAiueo, "あいうえお");
|
7788 | 7259 |
|
7789 | 7260 |
EXPECT_TRUE(session->SendCommand(&command));
|
7790 | 7261 |
EXPECT_TRUE(command.output().consumed());
|
|
7799 | 7270 |
EXPECT_RESULT_AND_KEY(kKanjiAiueo, kKanjiAiueo, command);
|
7800 | 7271 |
|
7801 | 7272 |
SendKey("a", session.get(), &command);
|
7802 | |
// "あ"
|
7803 | |
EXPECT_EQ(kHiraganaA, GetComposition(command));
|
|
7273 |
EXPECT_EQ("あ", GetComposition(command));
|
7804 | 7274 |
|
7805 | 7275 |
SendKey("ESC", session.get(), &command);
|
7806 | 7276 |
EXPECT_FALSE(command.output().has_preedit());
|
|
7838 | 7308 |
|
7839 | 7309 |
std::unique_ptr<Session> session(new Session(engine_.get()));
|
7840 | 7310 |
InitSessionToPrecomposition(session.get());
|
7841 | |
// "ゔ"
|
7842 | |
const char kInput[] = "\xE3\x82\x94";
|
|
7311 |
const char kInput[] = "ゔ";
|
7843 | 7312 |
|
7844 | 7313 |
commands::Command command;
|
7845 | 7314 |
SetupCommandForReverseConversion(kInput, command.mutable_input());
|
|
7862 | 7331 |
TEST_F(SessionTest, EscapeFromCompositionAfterConvertReverse) {
|
7863 | 7332 |
std::unique_ptr<Session> session(new Session(engine_.get()));
|
7864 | 7333 |
InitSessionToPrecomposition(session.get());
|
7865 | |
// "阿伊宇江於"
|
7866 | |
const char kKanjiAiueo[] =
|
7867 | |
"\xe9\x98\xbf\xe4\xbc\x8a\xe5\xae\x87\xe6\xb1\x9f\xe6\x96\xbc";
|
|
7334 |
const char kKanjiAiueo[] = "阿伊宇江於";
|
7868 | 7335 |
|
7869 | 7336 |
commands::Command command;
|
7870 | 7337 |
SetupCommandForReverseConversion(kKanjiAiueo, command.mutable_input());
|
7871 | |
SetupMockForReverseConversion(kKanjiAiueo, kAiueo);
|
|
7338 |
SetupMockForReverseConversion(kKanjiAiueo, "あいうえお");
|
7872 | 7339 |
|
7873 | 7340 |
// Conversion Reverse
|
7874 | 7341 |
EXPECT_TRUE(session->SendCommand(&command));
|
|
7881 | 7348 |
|
7882 | 7349 |
// Escape in composition state
|
7883 | 7350 |
SendKey("a", session.get(), &command);
|
7884 | |
// "あ"
|
7885 | |
EXPECT_EQ(kHiraganaA, GetComposition(command));
|
|
7351 |
EXPECT_EQ("あ", GetComposition(command));
|
7886 | 7352 |
|
7887 | 7353 |
SendKey("ESC", session.get(), &command);
|
7888 | 7354 |
EXPECT_FALSE(command.output().has_preedit());
|
|
7892 | 7358 |
TEST_F(SessionTest, ConvertReverseFromOffState) {
|
7893 | 7359 |
std::unique_ptr<Session> session(new Session(engine_.get()));
|
7894 | 7360 |
InitSessionToPrecomposition(session.get());
|
7895 | |
// "阿伊宇江於"
|
7896 | |
const string kanji_aiueo =
|
7897 | |
"\xe9\x98\xbf\xe4\xbc\x8a\xe5\xae\x87\xe6\xb1\x9f\xe6\x96\xbc";
|
|
7361 |
const string kanji_aiueo = "阿伊宇江於";
|
7898 | 7362 |
|
7899 | 7363 |
// IMEOff
|
7900 | 7364 |
commands::Command command;
|
7901 | 7365 |
SendSpecialKey(commands::KeyEvent::OFF, session.get(), &command);
|
7902 | 7366 |
|
7903 | 7367 |
SetupCommandForReverseConversion(kanji_aiueo, command.mutable_input());
|
7904 | |
SetupMockForReverseConversion(kanji_aiueo, kAiueo);
|
|
7368 |
SetupMockForReverseConversion(kanji_aiueo, "あいうえお");
|
7905 | 7369 |
EXPECT_TRUE(session->SendCommand(&command));
|
7906 | 7370 |
EXPECT_TRUE(command.output().consumed());
|
7907 | 7371 |
}
|
|
7912 | 7376 |
InitSessionToPrecomposition(session.get());
|
7913 | 7377 |
|
7914 | 7378 |
commands::Command command;
|
7915 | |
SetupCommandForReverseConversion(kAiueo, command.mutable_input());
|
7916 | |
SetupMockForReverseConversion(kAiueo, kAiueo);
|
|
7379 |
SetupCommandForReverseConversion("あいうえお", command.mutable_input());
|
|
7380 |
SetupMockForReverseConversion("あいうえお", "あいうえお");
|
7917 | 7381 |
EXPECT_TRUE(session->SendCommand(&command));
|
7918 | 7382 |
EXPECT_TRUE(command.output().consumed());
|
7919 | |
EXPECT_EQ(kAiueo, command.output().preedit().segment(0).value());
|
7920 | |
EXPECT_EQ(kAiueo,
|
|
7383 |
EXPECT_EQ("あいうえお", command.output().preedit().segment(0).value());
|
|
7384 |
EXPECT_EQ("あいうえお",
|
7921 | 7385 |
command.output().all_candidate_words().candidates(0).value());
|
7922 | 7386 |
EXPECT_TRUE(command.output().has_candidates());
|
7923 | 7387 |
EXPECT_GT(command.output().candidates().candidate_size(), 0);
|
7924 | 7388 |
|
7925 | 7389 |
SendKey("ESC", session.get(), &command);
|
7926 | 7390 |
SendKey("a", session.get(), &command);
|
7927 | |
// "あいうえおあ"
|
7928 | |
EXPECT_EQ(string(kAiueo) + kHiraganaA,
|
7929 | |
command.output().preedit().segment(0).value());
|
|
7391 |
EXPECT_EQ("あいうえおあ", command.output().preedit().segment(0).value());
|
7930 | 7392 |
EXPECT_FALSE(command.output().has_result());
|
7931 | 7393 |
}
|
7932 | 7394 |
|
|
8158 | 7620 |
EXPECT_TRUE(command.output().consumed());
|
8159 | 7621 |
EXPECT_FALSE(command.output().has_preedit());
|
8160 | 7622 |
EXPECT_EQ("", GetComposition(command));
|
8161 | |
// " " (full-width space)
|
8162 | |
EXPECT_RESULT(kFullWidthSpace, command);
|
|
7623 |
EXPECT_RESULT(" ", command); // Full-width space
|
8163 | 7624 |
EXPECT_EQ(ImeContext::PRECOMPOSITION, session.context().state());
|
8164 | 7625 |
}
|
8165 | 7626 |
|
|
8174 | 7635 |
EXPECT_TRUE(command.output().consumed());
|
8175 | 7636 |
EXPECT_FALSE(command.output().has_result());
|
8176 | 7637 |
EXPECT_EQ(commands::HIRAGANA, command.output().mode());
|
8177 | |
// "あ"
|
8178 | |
EXPECT_PREEDIT(kHiraganaA, command);
|
|
7638 |
EXPECT_PREEDIT("あ", command);
|
8179 | 7639 |
EXPECT_EQ(ImeContext::COMPOSITION, session.context().state());
|
8180 | 7640 |
}
|
8181 | 7641 |
|
|
8371 | 7831 |
SetSendKeyCommand("3", &command);
|
8372 | 7832 |
command.mutable_input()->mutable_config()->CopyFrom(overriding_config);
|
8373 | 7833 |
session.SendKey(&command);
|
8374 | |
// "さ"
|
8375 | |
EXPECT_EQ("\xE3\x81\x95", GetComposition(command));
|
|
7834 |
EXPECT_EQ("さ", GetComposition(command));
|
8376 | 7835 |
|
8377 | 7836 |
SetSendKeyCommand("3", &command);
|
8378 | 7837 |
command.mutable_input()->mutable_config()->CopyFrom(overriding_config);
|
8379 | 7838 |
session.SendKey(&command);
|
8380 | |
// "し"
|
8381 | |
EXPECT_EQ("\xE3\x81\x97", GetComposition(command));
|
|
7839 |
EXPECT_EQ("し", GetComposition(command));
|
8382 | 7840 |
|
8383 | 7841 |
SetSendCommandCommand(commands::SessionCommand::UNDO_OR_REWIND, &command);
|
8384 | 7842 |
command.mutable_input()->mutable_config()->CopyFrom(overriding_config);
|
8385 | 7843 |
session.SendCommand(&command);
|
8386 | |
// "さ"
|
8387 | |
EXPECT_EQ("\xE3\x81\x95", GetComposition(command));
|
|
7844 |
EXPECT_EQ("さ", GetComposition(command));
|
8388 | 7845 |
EXPECT_TRUE(command.output().consumed());
|
8389 | 7846 |
command.Clear();
|
8390 | 7847 |
|
8391 | 7848 |
SetSendCommandCommand(commands::SessionCommand::UNDO_OR_REWIND, &command);
|
8392 | 7849 |
command.mutable_input()->mutable_config()->CopyFrom(overriding_config);
|
8393 | 7850 |
session.SendCommand(&command);
|
8394 | |
// "そ"
|
8395 | |
EXPECT_EQ("\xE3\x81\x9D", GetComposition(command));
|
|
7851 |
EXPECT_EQ("そ", GetComposition(command));
|
8396 | 7852 |
EXPECT_TRUE(command.output().consumed());
|
8397 | 7853 |
command.Clear();
|
8398 | 7854 |
}
|
|
8418 | 7874 |
SetSendKeyCommand("3", &command);
|
8419 | 7875 |
command.mutable_input()->mutable_config()->CopyFrom(overriding_config);
|
8420 | 7876 |
session.SendKey(&command);
|
8421 | |
// "さ"
|
8422 | |
EXPECT_EQ("\xE3\x81\x95", GetComposition(command));
|
|
7877 |
EXPECT_EQ("さ", GetComposition(command));
|
8423 | 7878 |
|
8424 | 7879 |
SetSendKeyCommand("*", &command);
|
8425 | 7880 |
command.mutable_input()->mutable_config()->CopyFrom(overriding_config);
|
8426 | 7881 |
session.SendKey(&command);
|
8427 | |
// "ざ"
|
8428 | |
EXPECT_EQ("\xE3\x81\x96", GetComposition(command));
|
|
7882 |
EXPECT_EQ("ざ", GetComposition(command));
|
8429 | 7883 |
|
8430 | 7884 |
SetSendCommandCommand(commands::SessionCommand::UNDO_OR_REWIND, &command);
|
8431 | 7885 |
command.mutable_input()->mutable_config()->CopyFrom(overriding_config);
|
8432 | 7886 |
session.SendCommand(&command);
|
8433 | |
// "ざ"
|
8434 | |
EXPECT_EQ("\xE3\x81\x96", GetComposition(command));
|
|
7887 |
EXPECT_EQ("ざ", GetComposition(command));
|
8435 | 7888 |
EXPECT_TRUE(command.output().consumed());
|
8436 | 7889 |
|
8437 | 7890 |
|
8438 | 7891 |
SetSendKeyCommand("*", &command);
|
8439 | 7892 |
command.mutable_input()->mutable_config()->CopyFrom(overriding_config);
|
8440 | 7893 |
session.SendKey(&command);
|
8441 | |
// "さ"
|
8442 | |
EXPECT_EQ("\xE3\x81\x95", GetComposition(command));
|
|
7894 |
EXPECT_EQ("さ", GetComposition(command));
|
8443 | 7895 |
command.Clear();
|
8444 | 7896 |
|
8445 | 7897 |
SetSendCommandCommand(commands::SessionCommand::UNDO_OR_REWIND, &command);
|
8446 | 7898 |
command.mutable_input()->mutable_config()->CopyFrom(overriding_config);
|
8447 | 7899 |
session.SendCommand(&command);
|
8448 | |
// "さ"
|
8449 | |
EXPECT_EQ("\xE3\x81\x95", GetComposition(command));
|
|
7900 |
EXPECT_EQ("さ", GetComposition(command));
|
8450 | 7901 |
EXPECT_TRUE(command.output().consumed());
|
8451 | 7902 |
command.Clear();
|
8452 | 7903 |
}
|
|
8501 | 7952 |
command.Clear();
|
8502 | 7953 |
session.Convert(&command);
|
8503 | 7954 |
EXPECT_FALSE(command.output().has_result());
|
8504 | |
// "あいうえお"
|
8505 | |
EXPECT_PREEDIT(kAiueo, command);
|
|
7955 |
EXPECT_PREEDIT("あいうえお", command);
|
8506 | 7956 |
|
8507 | 7957 |
GetConverterMock()->SetCommitSegmentValue(&segments, true);
|
8508 | 7958 |
command.Clear();
|
8509 | 7959 |
session.Commit(&command);
|
8510 | 7960 |
EXPECT_FALSE(command.output().has_preedit());
|
8511 | |
// "あいうえお"
|
8512 | |
EXPECT_RESULT(kAiueo, command);
|
|
7961 |
EXPECT_RESULT("あいうえお", command);
|
8513 | 7962 |
|
8514 | 7963 |
command.Clear();
|
8515 | 7964 |
SetSendCommandCommand(commands::SessionCommand::UNDO_OR_REWIND, &command);
|
|
8519 | 7968 |
EXPECT_TRUE(command.output().has_deletion_range());
|
8520 | 7969 |
EXPECT_EQ(-5, command.output().deletion_range().offset());
|
8521 | 7970 |
EXPECT_EQ(5, command.output().deletion_range().length());
|
8522 | |
// "あいうえお"
|
8523 | |
EXPECT_PREEDIT(kAiueo, command);
|
|
7971 |
EXPECT_PREEDIT("あいうえお", command);
|
8524 | 7972 |
EXPECT_TRUE(command.output().consumed());
|
8525 | 7973 |
|
8526 | 7974 |
// Undo twice - do nothing and keep the previous status.
|
|
8529 | 7977 |
session.SendCommand(&command);
|
8530 | 7978 |
EXPECT_FALSE(command.output().has_result());
|
8531 | 7979 |
EXPECT_FALSE(command.output().has_deletion_range());
|
8532 | |
// "あいうえお"
|
8533 | |
EXPECT_PREEDIT(kAiueo, command);
|
|
7980 |
EXPECT_PREEDIT("あいうえお", command);
|
8534 | 7981 |
EXPECT_TRUE(command.output().consumed());
|
8535 | 7982 |
}
|
8536 | 7983 |
|
|
8555 | 8002 |
SetSendKeyCommand("1", &command);
|
8556 | 8003 |
command.mutable_input()->mutable_config()->CopyFrom(overriding_config);
|
8557 | 8004 |
session.SendKey(&command);
|
8558 | |
// "あ"
|
8559 | |
EXPECT_EQ(kHiraganaA, GetComposition(command));
|
|
8005 |
EXPECT_EQ("あ", GetComposition(command));
|
8560 | 8006 |
command.Clear();
|
8561 | 8007 |
|
8562 | 8008 |
session.Commit(&command);
|
8563 | 8009 |
EXPECT_FALSE(command.output().has_preedit());
|
8564 | |
// "あ"
|
8565 | |
EXPECT_RESULT(kHiraganaA, command);
|
|
8010 |
EXPECT_RESULT("あ", command);
|
8566 | 8011 |
|
8567 | 8012 |
// Produce "か" in composition.
|
8568 | 8013 |
SetSendKeyCommand("2", &command);
|
8569 | 8014 |
command.mutable_input()->mutable_config()->CopyFrom(overriding_config);
|
8570 | 8015 |
session.SendKey(&command);
|
8571 | |
// "か"
|
8572 | |
EXPECT_EQ("\xE3\x81\x8B", GetComposition(command));
|
|
8016 |
EXPECT_EQ("か", GetComposition(command));
|
8573 | 8017 |
EXPECT_TRUE(command.output().consumed());
|
8574 | 8018 |
command.Clear();
|
8575 | 8019 |
|
|
8577 | 8021 |
SetSendCommandCommand(commands::SessionCommand::UNDO_OR_REWIND, &command);
|
8578 | 8022 |
command.mutable_input()->mutable_config()->CopyFrom(overriding_config);
|
8579 | 8023 |
session.SendCommand(&command);
|
8580 | |
// "こ"
|
8581 | |
EXPECT_PREEDIT("\xE3\x81\x93", command);
|
|
8024 |
EXPECT_PREEDIT("こ", command);
|
8582 | 8025 |
EXPECT_TRUE(command.output().consumed());
|
8583 | 8026 |
command.Clear();
|
8584 | 8027 |
}
|
|
8611 | 8054 |
SetSendKeyCommand("!", &command);
|
8612 | 8055 |
session.SendKey(&command);
|
8613 | 8056 |
EXPECT_EQ(ImeContext::COMPOSITION, session.context().state());
|
8614 | |
// "!"
|
8615 | |
EXPECT_EQ("\xef\xbc\x81", GetComposition(command));
|
|
8057 |
EXPECT_EQ("!", GetComposition(command));
|
8616 | 8058 |
|
8617 | 8059 |
ASSERT_TRUE(command.output().has_candidates());
|
8618 | 8060 |
|
8619 | 8061 |
std::vector<int> ids;
|
8620 | |
// "!"
|
8621 | |
FindCandidateIDs(
|
8622 | |
command.output().candidates(), "\xef\xbc\x81", &ids);
|
|
8062 |
FindCandidateIDs(command.output().candidates(), "!", &ids);
|
8623 | 8063 |
EXPECT_GE(1, ids.size());
|
8624 | 8064 |
|
8625 | 8065 |
FindCandidateIDs(command.output().candidates(), "!", &ids);
|
|
8639 | 8079 |
EXPECT_TRUE(command.output().has_deletion_range());
|
8640 | 8080 |
ASSERT_TRUE(command.output().has_candidates());
|
8641 | 8081 |
|
8642 | |
// "!"
|
8643 | |
FindCandidateIDs(
|
8644 | |
command.output().candidates(), "\xef\xbc\x81", &ids);
|
|
8082 |
FindCandidateIDs(command.output().candidates(), "!", &ids);
|
8645 | 8083 |
EXPECT_GE(1, ids.size());
|
8646 | 8084 |
|
8647 | 8085 |
FindCandidateIDs(command.output().candidates(), "!", &ids);
|
|
8815 | 8253 |
TEST_F(SessionTest, CommitHead) {
|
8816 | 8254 |
std::unique_ptr<Session> session(new Session(engine_.get()));
|
8817 | 8255 |
composer::Table table;
|
8818 | |
// "も"
|
8819 | |
table.AddRule("mo", "\xe3\x82\x82", "");
|
8820 | |
// "ず"
|
8821 | |
table.AddRule("zu", "\xe3\x81\x9a", "");
|
|
8256 |
table.AddRule("mo", "も", "");
|
|
8257 |
table.AddRule("zu", "ず", "");
|
8822 | 8258 |
|
8823 | 8259 |
session->get_internal_composer_only_for_unittest()->SetTable(&table);
|
8824 | 8260 |
|
|
8826 | 8262 |
commands::Command command;
|
8827 | 8263 |
|
8828 | 8264 |
InsertCharacterChars("moz", session.get(), &command);
|
8829 | |
// 'もz'
|
8830 | |
EXPECT_EQ("\xe3\x82\x82\xef\xbd\x9a", GetComposition(command));
|
|
8265 |
EXPECT_EQ("もz", GetComposition(command));
|
8831 | 8266 |
command.Clear();
|
8832 | 8267 |
session->CommitHead(1, &command);
|
8833 | 8268 |
EXPECT_EQ(commands::Result_ResultType_STRING,
|
8834 | 8269 |
command.output().result().type());
|
8835 | |
EXPECT_EQ("\xe3\x82\x82", command.output().result().value()); // 'も'
|
8836 | |
EXPECT_EQ("\xef\xbd\x9a", GetComposition(command)); // 'z'
|
|
8270 |
EXPECT_EQ("も", command.output().result().value());
|
|
8271 |
EXPECT_EQ("z", GetComposition(command));
|
8837 | 8272 |
InsertCharacterChars("u", session.get(), &command);
|
8838 | |
// 'ず'
|
8839 | |
EXPECT_EQ("\xe3\x81\x9a", GetComposition(command));
|
|
8273 |
EXPECT_EQ("ず", GetComposition(command));
|
8840 | 8274 |
}
|
8841 | 8275 |
|
8842 | 8276 |
TEST_F(SessionTest, PasswordWithToggleAlpabetInput) {
|
|
9493 | 8927 |
segments_a_conv.set_request_type(Segments::CONVERSION);
|
9494 | 8928 |
Segment *segment;
|
9495 | 8929 |
segment = segments_a_conv.add_segment();
|
9496 | |
segment->set_key(kHiraganaA);
|
9497 | |
segment->add_candidate()->value = kHiraganaA;
|
|
8930 |
segment->set_key("あ");
|
|
8931 |
segment->add_candidate()->value = "あ";
|
9498 | 8932 |
}
|
9499 | 8933 |
GetConverterMock()->SetStartConversionForRequest(&segments_a_conv, true);
|
9500 | 8934 |
|
|
9558 | 8992 |
EXPECT_TRUE(SendKey("d", session.get(), &command));
|
9559 | 8993 |
EXPECT_TRUE(SendKey("e", session.get(), &command));
|
9560 | 8994 |
EXPECT_TRUE(SendKey("l", session.get(), &command));
|
9561 | |
EXPECT_PREEDIT("\xE3\x81\xA7\xEF\xBD\x8C", command); // "でl"
|
|
8995 |
EXPECT_PREEDIT("でl", command);
|
9562 | 8996 |
|
9563 | 8997 |
// Start prediction. Preedit = "DeleteHistory".
|
9564 | 8998 |
command.Clear();
|
|
9571 | 9005 |
// composition state and preedit gets back to "でl" again.
|
9572 | 9006 |
EXPECT_TRUE(SendKey("Ctrl Delete", session.get(), &command));
|
9573 | 9007 |
EXPECT_EQ(ImeContext::COMPOSITION, session->context().state());
|
9574 | |
EXPECT_PREEDIT("\xE3\x81\xA7\xEF\xBD\x8C", command); // "でl"
|
|
9008 |
EXPECT_PREEDIT("でl", command);
|
9575 | 9009 |
}
|
9576 | 9010 |
|
9577 | 9011 |
TEST_F(SessionTest, SendKeyWithKeyString_Direct) {
|
|
9579 | 9013 |
InitSessionToDirect(&session);
|
9580 | 9014 |
|
9581 | 9015 |
commands::Command command;
|
9582 | |
const char kZa[] = "\xE3\x81\x96"; // "ざ"
|
|
9016 |
const char kZa[] = "ざ";
|
9583 | 9017 |
SetSendKeyCommandWithKeyString(kZa, &command);
|
9584 | 9018 |
EXPECT_TRUE(session.TestSendKey(&command));
|
9585 | 9019 |
EXPECT_FALSE(command.output().consumed());
|
|
9596 | 9030 |
|
9597 | 9031 |
// Test for precomposition state.
|
9598 | 9032 |
EXPECT_EQ(ImeContext::PRECOMPOSITION, session.context().state());
|
9599 | |
const char kZa[] = "\xE3\x81\x96"; // "ざ"
|
|
9033 |
const char kZa[] = "ざ";
|
9600 | 9034 |
SetSendKeyCommandWithKeyString(kZa, &command);
|
9601 | 9035 |
EXPECT_TRUE(session.TestSendKey(&command));
|
9602 | 9036 |
EXPECT_TRUE(command.output().consumed());
|
|
9609 | 9043 |
|
9610 | 9044 |
// Test for composition state.
|
9611 | 9045 |
EXPECT_EQ(ImeContext::COMPOSITION, session.context().state());
|
9612 | |
const char kOnsenManju[] = "\xE2\x99\xA8\xE9\xA5\x85\xE9\xA0\xAD"; // "♨饅頭"
|
|
9046 |
const char kOnsenManju[] = "♨饅頭";
|
9613 | 9047 |
SetSendKeyCommandWithKeyString(kOnsenManju, &command);
|
9614 | 9048 |
EXPECT_TRUE(session.TestSendKey(&command));
|
9615 | 9049 |
EXPECT_TRUE(command.output().consumed());
|
|
9795 | 9229 |
command.mutable_input()->mutable_command()->set_composition_mode(
|
9796 | 9230 |
commands::FULL_KATAKANA);
|
9797 | 9231 |
ASSERT_TRUE(session->SendCommand(&command));
|
9798 | |
EXPECT_RESULT(kAiueo, command);
|
|
9232 |
EXPECT_RESULT("あいうえお", command);
|
9799 | 9233 |
EXPECT_TRUE(command.output().consumed());
|
9800 | 9234 |
ASSERT_TRUE(command.output().has_status());
|
9801 | 9235 |
EXPECT_FALSE(command.output().status().activated());
|