@@ -487,6 +487,7 @@ void RegisterTests_WidgetsInputText(ImGuiTestEngine* e)
487
487
#endif
488
488
489
489
// ## Test input text multiline cursor movement: left, up, right, down, origin, end, ctrl+origin, ctrl+end, page up, page down
490
+ // ## Test on multi-byte characters (see Set 2)
490
491
// TODO ## Test input text multiline cursor with selection: left, up, right, down, origin, end, ctrl+origin, ctrl+end, page up, page down
491
492
// TODO ## Test input text multiline scroll movement only: ctrl + (left, up, right, down)
492
493
// TODO ## Test input text multiline page up/page down history ?
@@ -809,6 +810,46 @@ void RegisterTests_WidgetsInputText(ImGuiTestEngine* e)
809
810
// FIXME-TODO: More tests needed.
810
811
}
811
812
813
+ // [SET 2: multibytes codepoints]
814
+ ctx->KeyCharsReplace (" \xE3\x83\x8F\xE3\x83\xAD\xE3\x83\xBC " " \xE3\x80\x80 " " \xE4\xB8\x96\xE7\x95\x8C " " \xE3\x80\x82 " ); // "HARO- SEKAI. " (with double-width space)
815
+ KeyPressAndDebugPrint (ImGuiKey_Home);
816
+ IM_CHECK_EQ (state->GetCursorPos (), 0 ); // "|HARO- "
817
+ if (!is_osx)
818
+ {
819
+ // Windows
820
+ KeyPressAndDebugPrint (chord_word_next);
821
+ IM_CHECK_EQ (state->GetCursorPos (), 4 ); // "HARO- |"
822
+ KeyPressAndDebugPrint (chord_word_prev);
823
+ IM_CHECK_EQ (state->GetCursorPos (), 0 ); // "|HARO- "
824
+ for (int n = 0 ; n < 3 ; n++)
825
+ KeyPressAndDebugPrint (ImGuiKey_RightArrow);
826
+ IM_CHECK_EQ (state->GetCursorPos (), 3 ); // "HARO-| "
827
+ KeyPressAndDebugPrint (chord_word_next);
828
+ IM_CHECK_EQ (state->GetCursorPos (), 3 +1 ); // "HARO- |"
829
+
830
+ KeyPressAndDebugPrint (chord_word_next);
831
+ IM_CHECK_EQ (state->GetCursorPos (), 3 +1 + 2 ); // "HARO- SEKAI|." // VS(Win) does this, GitHub-Web(Win) doesn't.
832
+ KeyPressAndDebugPrint (chord_word_next);
833
+ IM_CHECK_EQ (state->GetCursorPos (), 3 +1 + 2 +1 ); // "HARO- SEKAI.|"
834
+
835
+ // ... not duplicating all tests, we just want basic coverage that multi-byte UTF-8 codepoints are correctly taken into account.
836
+
837
+ ctx->KeyPress (ImGuiKey_End);
838
+ IM_CHECK_EQ (state->GetCursorPos (), 3 +1 + 2 +1 ); // "HARO- SEKAI.|"
839
+
840
+ KeyPressAndDebugPrint (chord_word_prev);
841
+ IM_CHECK_EQ (state->GetCursorPos (), 3 +1 + 2 ); // "HARO- SEKAI|." // VS-Win: STOP, GitHubWeb-Win: SKIP
842
+ KeyPressAndDebugPrint (chord_word_prev);
843
+ IM_CHECK_EQ (state->GetCursorPos (), 3 +1 ); // "HARO- |"
844
+
845
+ KeyPressAndDebugPrint (chord_word_prev);
846
+ IM_CHECK_EQ (state->GetCursorPos (), 0 ); // "|HARO- SEKAI."
847
+
848
+ KeyPressAndDebugPrint (chord_word_prev);
849
+ IM_CHECK_EQ (state->GetCursorPos (), 0 ); // (no-op)
850
+ }
851
+
852
+ // [SET 3]
812
853
// [SET 2]
813
854
// Delete all, Extra Test with Multiple Spaces
814
855
ctx->KeyCharsReplace (" Hello world.....HELLO" );
0 commit comments