summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/scene/test_code_edit.h86
-rw-r--r--tests/servers/test_text_server.h48
2 files changed, 117 insertions, 17 deletions
diff --git a/tests/scene/test_code_edit.h b/tests/scene/test_code_edit.h
index 3940bdb37a..fa31a3a461 100644
--- a/tests/scene/test_code_edit.h
+++ b/tests/scene/test_code_edit.h
@@ -2871,6 +2871,89 @@ TEST_CASE("[SceneTree][CodeEdit] completion") {
CHECK(code_edit->get_text() == "\'\'\'");
}
+ SUBCASE("[CodeEdit] autocomplete with brace completion") {
+ code_edit->set_auto_brace_completion_enabled(true);
+ CHECK(code_edit->is_auto_brace_completion_enabled());
+
+ code_edit->insert_text_at_caret("(te)");
+ code_edit->set_caret_column(3);
+
+ // Full completion.
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_FUNCTION, "test()", "test()");
+ code_edit->update_code_completion_options();
+ code_edit->confirm_code_completion();
+ CHECK(code_edit->get_line(0) == "(test())");
+ CHECK(code_edit->get_caret_column() == 7);
+ code_edit->undo();
+
+ // With "arg".
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_FUNCTION, "test(", "test(");
+ code_edit->update_code_completion_options();
+ code_edit->confirm_code_completion();
+ CHECK(code_edit->get_line(0) == "(test())");
+ CHECK(code_edit->get_caret_column() == 6);
+ code_edit->undo();
+
+ // brace completion disbaled
+ code_edit->set_auto_brace_completion_enabled(false);
+
+ // Full completion.
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_FUNCTION, "test()", "test()");
+ code_edit->update_code_completion_options();
+ code_edit->confirm_code_completion();
+ CHECK(code_edit->get_line(0) == "(test())");
+ CHECK(code_edit->get_caret_column() == 7);
+ code_edit->undo();
+
+ // With "arg".
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_FUNCTION, "test(", "test(");
+ code_edit->update_code_completion_options();
+ code_edit->confirm_code_completion();
+ CHECK(code_edit->get_line(0) == "(test()");
+ CHECK(code_edit->get_caret_column() == 6);
+
+ // String
+ code_edit->set_auto_brace_completion_enabled(true);
+ code_edit->clear();
+ code_edit->insert_text_at_caret("\"\"");
+ code_edit->set_caret_column(1);
+
+ // Full completion.
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_NODE_PATH, "\"test\"", "\"test\"");
+ code_edit->update_code_completion_options();
+ code_edit->confirm_code_completion();
+ CHECK(code_edit->get_line(0) == "\"test\"");
+ CHECK(code_edit->get_caret_column() == 6);
+ code_edit->undo();
+
+ // With "arg".
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_NODE_PATH, "\"test", "\"test");
+ code_edit->update_code_completion_options();
+ code_edit->confirm_code_completion();
+ CHECK(code_edit->get_line(0) == "\"\"test\"\"");
+ CHECK(code_edit->get_caret_column() == 7);
+ code_edit->undo();
+
+ // brace completion disbaled
+ code_edit->set_auto_brace_completion_enabled(false);
+
+ // Full completion.
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_NODE_PATH, "\"test\"", "\"test\"");
+ code_edit->update_code_completion_options();
+ code_edit->confirm_code_completion();
+ CHECK(code_edit->get_line(0) == "\"test\"");
+ CHECK(code_edit->get_caret_column() == 6);
+ code_edit->undo();
+
+ // With "arg".
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_NODE_PATH, "\"test", "\"test");
+ code_edit->update_code_completion_options();
+ code_edit->confirm_code_completion();
+ CHECK(code_edit->get_line(0) == "\"\"test\"");
+ CHECK(code_edit->get_caret_column() == 7);
+ code_edit->undo();
+ }
+
SUBCASE("[CodeEdit] autocomplete") {
code_edit->set_code_completion_enabled(true);
CHECK(code_edit->is_code_completion_enabled());
@@ -3027,7 +3110,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") {
CHECK(code_edit->get_code_completion_selected_index() == 0);
Point2 caret_pos = code_edit->get_caret_draw_pos();
- caret_pos.y -= code_edit->get_line_height();
+ caret_pos.y += code_edit->get_line_height();
SEND_GUI_MOUSE_BUTTON_EVENT(code_edit, caret_pos, MouseButton::WHEEL_DOWN, MouseButton::NONE, Key::NONE);
CHECK(code_edit->get_code_completion_selected_index() == 1);
@@ -3035,6 +3118,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") {
CHECK(code_edit->get_code_completion_selected_index() == 0);
/* Single click selects. */
+ caret_pos.y += code_edit->get_line_height() * 2;
SEND_GUI_MOUSE_BUTTON_EVENT(code_edit, caret_pos, MouseButton::LEFT, MouseButton::MASK_LEFT, Key::NONE);
CHECK(code_edit->get_code_completion_selected_index() == 2);
diff --git a/tests/servers/test_text_server.h b/tests/servers/test_text_server.h
index 297f7d2068..b3c120e0ba 100644
--- a/tests/servers/test_text_server.h
+++ b/tests/servers/test_text_server.h
@@ -593,12 +593,18 @@ TEST_SUITE("[TextServer]") {
String text1 = U"linguistically similar and effectively form";
// 14^ 22^ 26^ 38^
PackedInt32Array breaks = ts->string_get_word_breaks(text1, "en");
- CHECK(breaks.size() == 4);
- if (breaks.size() == 4) {
- CHECK(breaks[0] == 14);
- CHECK(breaks[1] == 22);
- CHECK(breaks[2] == 26);
- CHECK(breaks[3] == 38);
+ CHECK(breaks.size() == 10);
+ if (breaks.size() == 10) {
+ CHECK(breaks[0] == 0);
+ CHECK(breaks[1] == 14);
+ CHECK(breaks[2] == 15);
+ CHECK(breaks[3] == 22);
+ CHECK(breaks[4] == 23);
+ CHECK(breaks[5] == 26);
+ CHECK(breaks[6] == 27);
+ CHECK(breaks[7] == 38);
+ CHECK(breaks[8] == 39);
+ CHECK(breaks[9] == 43);
}
}
@@ -608,16 +614,26 @@ TEST_SUITE("[TextServer]") {
// 3^ 7^ 13^ 16^ 20^ 25^ 29^ 32^
PackedInt32Array breaks = ts->string_get_word_breaks(text2, "th");
- CHECK(breaks.size() == 8);
- if (breaks.size() == 8) {
- CHECK(breaks[0] == 3);
- CHECK(breaks[1] == 7);
- CHECK(breaks[2] == 13);
- CHECK(breaks[3] == 16);
- CHECK(breaks[4] == 20);
- CHECK(breaks[5] == 25);
- CHECK(breaks[6] == 29);
- CHECK(breaks[7] == 32);
+ CHECK(breaks.size() == 18);
+ if (breaks.size() == 18) {
+ CHECK(breaks[0] == 0);
+ CHECK(breaks[1] == 4);
+ CHECK(breaks[2] == 4);
+ CHECK(breaks[3] == 8);
+ CHECK(breaks[4] == 8);
+ CHECK(breaks[5] == 14);
+ CHECK(breaks[6] == 14);
+ CHECK(breaks[7] == 17);
+ CHECK(breaks[8] == 17);
+ CHECK(breaks[9] == 21);
+ CHECK(breaks[10] == 21);
+ CHECK(breaks[11] == 26);
+ CHECK(breaks[12] == 26);
+ CHECK(breaks[13] == 30);
+ CHECK(breaks[14] == 30);
+ CHECK(breaks[15] == 33);
+ CHECK(breaks[16] == 33);
+ CHECK(breaks[17] == 42);
}
}
}