822 | 822 |
use_proportional_font, is_vertical, cursor_offset, hwnd, command);
|
823 | 823 |
}
|
824 | 824 |
|
825 | |
// Verification of changes for b/3200425.
|
826 | |
static void VerifyCompositionStyleBitsCompatibilityForIssue3200425(
|
827 | |
bool use_deprecated_style, CompositionForm::Style style,
|
828 | |
bool use_new_style, uint32 style_bits) {
|
829 | |
const int kCursorOffsetX = 0;
|
830 | |
|
831 | |
RendererCommand command;
|
832 | |
|
833 | |
HWND hwnd = nullptr;
|
834 | |
LayoutManager layout_mgr(CreateDefaultGUIFontEmulator(),
|
835 | |
CreateWindowEmulatorWithDPIScaling(1.0, &hwnd));
|
836 | |
vector<CompositionWindowLayout> layouts;
|
837 | |
CandidateWindowLayout candidate_layout;
|
838 | |
|
839 | |
CLogFont logfont;
|
840 | |
|
841 | |
bool result = false;
|
842 | |
|
843 | |
// w/ candidates, monospaced, horizontal
|
844 | |
SetRenderereCommandForTest(
|
845 | |
false, true, false, kCursorOffsetX, hwnd, &command);
|
846 | |
|
847 | |
if (use_deprecated_style) {
|
848 | |
command.mutable_application_info()->mutable_composition_form()
|
849 | |
->set_deprecated_style(style);
|
850 | |
} else {
|
851 | |
command.mutable_application_info()->mutable_composition_form()
|
852 | |
->clear_deprecated_style();
|
853 | |
}
|
854 | |
if (use_new_style) {
|
855 | |
command.mutable_application_info()->mutable_composition_form()
|
856 | |
->set_style_bits(style_bits);
|
857 | |
} else {
|
858 | |
command.mutable_application_info()->mutable_composition_form()
|
859 | |
->clear_style_bits();
|
860 | |
}
|
861 | |
|
862 | |
EXPECT_TRUE(mozc::win32::FontUtil::ToLOGFONT(
|
863 | |
command.application_info().composition_font(), &logfont));
|
864 | |
layouts.clear();
|
865 | |
candidate_layout.Clear();
|
866 | |
result = layout_mgr.LayoutCompositionWindow(
|
867 | |
command, &layouts, &candidate_layout);
|
868 | |
EXPECT_TRUE(result);
|
869 | |
|
870 | |
ASSERT_EQ(2, layouts.size());
|
871 | |
|
872 | |
// The first line
|
873 | |
{
|
874 | |
const CompositionWindowLayout &layout = layouts.at(0);
|
875 | |
EXPECT_COMPOSITION_WINDOW_LAYOUT(1868, 599, 2003, 648, 0, 0, 135, 49,
|
876 | |
0, 0, 0, 0, 0, 0, logfont, layout);
|
877 | |
{
|
878 | |
// "これは"
|
879 | |
const char kMsg[] = "\343\201\223\343\202\214\343\201\257";
|
880 | |
wstring msg;
|
881 | |
mozc::Util::UTF8ToWide(kMsg, &msg);
|
882 | |
EXPECT_EQ(msg, layout.text);
|
883 | |
}
|
884 | |
ASSERT_EQ(1, layout.marker_layouts.size());
|
885 | |
|
886 | |
EXPECT_EQ(CPoint(0, 48), layout.marker_layouts[0].from);
|
887 | |
EXPECT_EQ(CPoint(126, 48), layout.marker_layouts[0].to);
|
888 | |
EXPECT_FALSE(layout.marker_layouts[0].highlighted);
|
889 | |
}
|
890 | |
|
891 | |
// The second line
|
892 | |
{
|
893 | |
const CompositionWindowLayout &layout = layouts.at(1);
|
894 | |
EXPECT_COMPOSITION_WINDOW_LAYOUT(1193, 648, 1840, 697, 0, 0, 646, 49,
|
895 | |
0, 0, 646, 0, 647, 49, logfont, layout);
|
896 | |
{
|
897 | |
// "、Google日本語入力のTestです"
|
898 | |
const char kMsg[] =
|
899 | |
"\343\200\201Google\346\227\245\346\234\254\350\252\236\345\205\245"
|
900 | |
"\345\212\233\343\201\256Test\343\201\247\343\201\231";
|
901 | |
wstring msg;
|
902 | |
mozc::Util::UTF8ToWide(kMsg, &msg);
|
903 | |
EXPECT_EQ(msg, layout.text);
|
904 | |
}
|
905 | |
ASSERT_EQ(4, layout.marker_layouts.size());
|
906 | |
|
907 | |
EXPECT_EQ(CPoint(0, 48), layout.marker_layouts[0].from);
|
908 | |
EXPECT_EQ(CPoint(36, 48), layout.marker_layouts[0].to);
|
909 | |
EXPECT_FALSE(layout.marker_layouts[0].highlighted);
|
910 | |
EXPECT_EQ(CPoint(45, 48), layout.marker_layouts[1].from);
|
911 | |
EXPECT_EQ(CPoint(190, 48), layout.marker_layouts[1].to);
|
912 | |
EXPECT_TRUE(layout.marker_layouts[1].highlighted);
|
913 | |
EXPECT_EQ(CPoint(196, 48), layout.marker_layouts[2].from);
|
914 | |
EXPECT_EQ(CPoint(457, 48), layout.marker_layouts[2].to);
|
915 | |
EXPECT_FALSE(layout.marker_layouts[2].highlighted);
|
916 | |
EXPECT_EQ(CPoint(466, 48), layout.marker_layouts[3].from);
|
917 | |
EXPECT_EQ(CPoint(646, 48), layout.marker_layouts[3].to);
|
918 | |
EXPECT_FALSE(layout.marker_layouts[3].highlighted);
|
919 | |
}
|
920 | |
EXPECT_EXCLUDE_CANDIDATE_WINDOW_LAYOUT(
|
921 | |
1238, 697, 1238, 648, 1839, 697, candidate_layout);
|
922 | |
|
923 | |
// Check other candidate positions.
|
924 | |
command.mutable_output()->mutable_candidates()->set_position(0);
|
925 | |
layouts.clear();
|
926 | |
candidate_layout.Clear();
|
927 | |
result = layout_mgr.LayoutCompositionWindow(
|
928 | |
command, &layouts, &candidate_layout);
|
929 | |
EXPECT_EXCLUDE_CANDIDATE_WINDOW_LAYOUT(
|
930 | |
1868, 648, 1868, 599, 2003, 648, candidate_layout);
|
931 | |
|
932 | |
command.mutable_output()->mutable_candidates()->set_position(3);
|
933 | |
layouts.clear();
|
934 | |
candidate_layout.Clear();
|
935 | |
result = layout_mgr.LayoutCompositionWindow(
|
936 | |
command, &layouts, &candidate_layout);
|
937 | |
EXPECT_EXCLUDE_CANDIDATE_WINDOW_LAYOUT(
|
938 | |
1193, 697, 1193, 648, 1839, 697, candidate_layout);
|
939 | |
|
940 | |
command.mutable_output()->mutable_candidates()->set_position(10);
|
941 | |
layouts.clear();
|
942 | |
candidate_layout.Clear();
|
943 | |
result = layout_mgr.LayoutCompositionWindow(
|
944 | |
command, &layouts, &candidate_layout);
|
945 | |
EXPECT_EXCLUDE_CANDIDATE_WINDOW_LAYOUT(
|
946 | |
1389, 697, 1389, 648, 1839, 697, candidate_layout);
|
947 | |
|
948 | |
command.mutable_output()->mutable_candidates()->set_position(16);
|
949 | |
layouts.clear();
|
950 | |
candidate_layout.Clear();
|
951 | |
result = layout_mgr.LayoutCompositionWindow(
|
952 | |
command, &layouts, &candidate_layout);
|
953 | |
EXPECT_EXCLUDE_CANDIDATE_WINDOW_LAYOUT(
|
954 | |
1659, 697, 1659, 648, 1839, 697, candidate_layout);
|
955 | |
|
956 | |
// w/o candidates, monospaced, horizontal
|
957 | |
SetRenderereCommandForTest(false, false, false, 0, hwnd, &command);
|
958 | |
EXPECT_TRUE(mozc::win32::FontUtil::ToLOGFONT(
|
959 | |
command.application_info().composition_font(), &logfont));
|
960 | |
layouts.clear();
|
961 | |
candidate_layout.Clear();
|
962 | |
result = layout_mgr.LayoutCompositionWindow(
|
963 | |
command, &layouts, &candidate_layout);
|
964 | |
EXPECT_TRUE(result);
|
965 | |
EXPECT_FALSE(candidate_layout.initialized());
|
966 | |
}
|
967 | |
|
968 | 825 |
protected:
|
969 | 826 |
static void SetUpTestCase() {
|
970 | 827 |
// On Windows XP, the availability of typical Japanese fonts such are as
|
|
3486 | 3343 |
// We should consider the case where two or more style bits are specified
|
3487 | 3344 |
// at the same time.
|
3488 | 3345 |
TEST_F(Win32RendererUtilTest, CompositionFormRECTAsBitFlag_Issue3200425) {
|
3489 | |
// Check the backward compatibility.
|
3490 | |
VerifyCompositionStyleBitsCompatibilityForIssue3200425(
|
3491 | |
true, CompositionForm::RECT,
|
3492 | |
false, CompositionForm::DEFAULT);
|
3493 | |
|
3494 | |
// Set CompositionForm::RECT and CompositionForm::POINT at the same time.
|
3495 | |
VerifyCompositionStyleBitsCompatibilityForIssue3200425(
|
3496 | |
false, CompositionForm::DEFAULT,
|
3497 | |
true, CompositionForm::RECT | CompositionForm::POINT);
|
3498 | |
|
3499 | |
// If both of them are specified, the legacy one is used.
|
3500 | |
VerifyCompositionStyleBitsCompatibilityForIssue3200425(
|
3501 | |
true, CompositionForm::RECT,
|
3502 | |
true, CompositionForm::POINT);
|
|
3346 |
const uint32 kStyleBit = CompositionForm::RECT | CompositionForm::POINT;
|
|
3347 |
|
|
3348 |
const int kCursorOffsetX = 0;
|
|
3349 |
|
|
3350 |
RendererCommand command;
|
|
3351 |
|
|
3352 |
HWND hwnd = nullptr;
|
|
3353 |
LayoutManager layout_mgr(CreateDefaultGUIFontEmulator(),
|
|
3354 |
CreateWindowEmulatorWithDPIScaling(1.0, &hwnd));
|
|
3355 |
vector<CompositionWindowLayout> layouts;
|
|
3356 |
CandidateWindowLayout candidate_layout;
|
|
3357 |
|
|
3358 |
CLogFont logfont;
|
|
3359 |
|
|
3360 |
bool result = false;
|
|
3361 |
|
|
3362 |
// w/ candidates, monospaced, horizontal
|
|
3363 |
SetRenderereCommandForTest(
|
|
3364 |
false, true, false, kCursorOffsetX, hwnd, &command);
|
|
3365 |
command.mutable_application_info()->mutable_composition_form()
|
|
3366 |
->set_style_bits(kStyleBit);
|
|
3367 |
|
|
3368 |
EXPECT_TRUE(mozc::win32::FontUtil::ToLOGFONT(
|
|
3369 |
command.application_info().composition_font(), &logfont));
|
|
3370 |
layouts.clear();
|
|
3371 |
candidate_layout.Clear();
|
|
3372 |
result = layout_mgr.LayoutCompositionWindow(
|
|
3373 |
command, &layouts, &candidate_layout);
|
|
3374 |
EXPECT_TRUE(result);
|
|
3375 |
|
|
3376 |
ASSERT_EQ(2, layouts.size());
|
|
3377 |
|
|
3378 |
// The first line
|
|
3379 |
{
|
|
3380 |
const CompositionWindowLayout &layout = layouts.at(0);
|
|
3381 |
EXPECT_COMPOSITION_WINDOW_LAYOUT(1868, 599, 2003, 648, 0, 0, 135, 49,
|
|
3382 |
0, 0, 0, 0, 0, 0, logfont, layout);
|
|
3383 |
{
|
|
3384 |
// "これは"
|
|
3385 |
const char kMsg[] = "\343\201\223\343\202\214\343\201\257";
|
|
3386 |
wstring msg;
|
|
3387 |
mozc::Util::UTF8ToWide(kMsg, &msg);
|
|
3388 |
EXPECT_EQ(msg, layout.text);
|
|
3389 |
}
|
|
3390 |
ASSERT_EQ(1, layout.marker_layouts.size());
|
|
3391 |
|
|
3392 |
EXPECT_EQ(CPoint(0, 48), layout.marker_layouts[0].from);
|
|
3393 |
EXPECT_EQ(CPoint(126, 48), layout.marker_layouts[0].to);
|
|
3394 |
EXPECT_FALSE(layout.marker_layouts[0].highlighted);
|
|
3395 |
}
|
|
3396 |
|
|
3397 |
// The second line
|
|
3398 |
{
|
|
3399 |
const CompositionWindowLayout &layout = layouts.at(1);
|
|
3400 |
EXPECT_COMPOSITION_WINDOW_LAYOUT(1193, 648, 1840, 697, 0, 0, 646, 49,
|
|
3401 |
0, 0, 646, 0, 647, 49, logfont, layout);
|
|
3402 |
{
|
|
3403 |
// "、Google日本語入力のTestです"
|
|
3404 |
const char kMsg[] =
|
|
3405 |
"\343\200\201Google\346\227\245\346\234\254\350\252\236\345\205\245"
|
|
3406 |
"\345\212\233\343\201\256Test\343\201\247\343\201\231";
|
|
3407 |
wstring msg;
|
|
3408 |
mozc::Util::UTF8ToWide(kMsg, &msg);
|
|
3409 |
EXPECT_EQ(msg, layout.text);
|
|
3410 |
}
|
|
3411 |
ASSERT_EQ(4, layout.marker_layouts.size());
|
|
3412 |
|
|
3413 |
EXPECT_EQ(CPoint(0, 48), layout.marker_layouts[0].from);
|
|
3414 |
EXPECT_EQ(CPoint(36, 48), layout.marker_layouts[0].to);
|
|
3415 |
EXPECT_FALSE(layout.marker_layouts[0].highlighted);
|
|
3416 |
EXPECT_EQ(CPoint(45, 48), layout.marker_layouts[1].from);
|
|
3417 |
EXPECT_EQ(CPoint(190, 48), layout.marker_layouts[1].to);
|
|
3418 |
EXPECT_TRUE(layout.marker_layouts[1].highlighted);
|
|
3419 |
EXPECT_EQ(CPoint(196, 48), layout.marker_layouts[2].from);
|
|
3420 |
EXPECT_EQ(CPoint(457, 48), layout.marker_layouts[2].to);
|
|
3421 |
EXPECT_FALSE(layout.marker_layouts[2].highlighted);
|
|
3422 |
EXPECT_EQ(CPoint(466, 48), layout.marker_layouts[3].from);
|
|
3423 |
EXPECT_EQ(CPoint(646, 48), layout.marker_layouts[3].to);
|
|
3424 |
EXPECT_FALSE(layout.marker_layouts[3].highlighted);
|
|
3425 |
}
|
|
3426 |
EXPECT_EXCLUDE_CANDIDATE_WINDOW_LAYOUT(
|
|
3427 |
1238, 697, 1238, 648, 1839, 697, candidate_layout);
|
|
3428 |
|
|
3429 |
// Check other candidate positions.
|
|
3430 |
command.mutable_output()->mutable_candidates()->set_position(0);
|
|
3431 |
layouts.clear();
|
|
3432 |
candidate_layout.Clear();
|
|
3433 |
result = layout_mgr.LayoutCompositionWindow(
|
|
3434 |
command, &layouts, &candidate_layout);
|
|
3435 |
EXPECT_EXCLUDE_CANDIDATE_WINDOW_LAYOUT(
|
|
3436 |
1868, 648, 1868, 599, 2003, 648, candidate_layout);
|
|
3437 |
|
|
3438 |
command.mutable_output()->mutable_candidates()->set_position(3);
|
|
3439 |
layouts.clear();
|
|
3440 |
candidate_layout.Clear();
|
|
3441 |
result = layout_mgr.LayoutCompositionWindow(
|
|
3442 |
command, &layouts, &candidate_layout);
|
|
3443 |
EXPECT_EXCLUDE_CANDIDATE_WINDOW_LAYOUT(
|
|
3444 |
1193, 697, 1193, 648, 1839, 697, candidate_layout);
|
|
3445 |
|
|
3446 |
command.mutable_output()->mutable_candidates()->set_position(10);
|
|
3447 |
layouts.clear();
|
|
3448 |
candidate_layout.Clear();
|
|
3449 |
result = layout_mgr.LayoutCompositionWindow(
|
|
3450 |
command, &layouts, &candidate_layout);
|
|
3451 |
EXPECT_EXCLUDE_CANDIDATE_WINDOW_LAYOUT(
|
|
3452 |
1389, 697, 1389, 648, 1839, 697, candidate_layout);
|
|
3453 |
|
|
3454 |
command.mutable_output()->mutable_candidates()->set_position(16);
|
|
3455 |
layouts.clear();
|
|
3456 |
candidate_layout.Clear();
|
|
3457 |
result = layout_mgr.LayoutCompositionWindow(
|
|
3458 |
command, &layouts, &candidate_layout);
|
|
3459 |
EXPECT_EXCLUDE_CANDIDATE_WINDOW_LAYOUT(
|
|
3460 |
1659, 697, 1659, 648, 1839, 697, candidate_layout);
|
|
3461 |
|
|
3462 |
// w/o candidates, monospaced, horizontal
|
|
3463 |
SetRenderereCommandForTest(false, false, false, 0, hwnd, &command);
|
|
3464 |
EXPECT_TRUE(mozc::win32::FontUtil::ToLOGFONT(
|
|
3465 |
command.application_info().composition_font(), &logfont));
|
|
3466 |
layouts.clear();
|
|
3467 |
candidate_layout.Clear();
|
|
3468 |
result = layout_mgr.LayoutCompositionWindow(
|
|
3469 |
command, &layouts, &candidate_layout);
|
|
3470 |
EXPECT_TRUE(result);
|
|
3471 |
EXPECT_FALSE(candidate_layout.initialized());
|
3503 | 3472 |
}
|
3504 | 3473 |
|
3505 | 3474 |
// Evernote Windows Client 4.0.0.2880 (107102) / Editor component
|