summaryrefslogtreecommitdiff
path: root/tests/scene/test_code_edit.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/scene/test_code_edit.h')
-rw-r--r--tests/scene/test_code_edit.h566
1 files changed, 285 insertions, 281 deletions
diff --git a/tests/scene/test_code_edit.h b/tests/scene/test_code_edit.h
index 8bd35df107..0e0d2a218c 100644
--- a/tests/scene/test_code_edit.h
+++ b/tests/scene/test_code_edit.h
@@ -2901,291 +2901,293 @@ TEST_CASE("[SceneTree][CodeEdit] completion") {
}
SUBCASE("[CodeEdit] autocomplete completion") {
- CHECK(code_edit->get_code_completion_selected_index() == -1);
- code_edit->set_code_completion_enabled(true);
- CHECK(code_edit->get_code_completion_selected_index() == -1);
-
- code_edit->update_code_completion_options();
- code_edit->set_code_completion_selected_index(1);
- CHECK(code_edit->get_code_completion_selected_index() == -1);
- CHECK(code_edit->get_code_completion_option(0).size() == 0);
- CHECK(code_edit->get_code_completion_options().size() == 0);
-
- /* Adding does not update the list. */
- code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "item_0.", "item_0");
-
- code_edit->set_code_completion_selected_index(1);
- CHECK(code_edit->get_code_completion_selected_index() == -1);
- CHECK(code_edit->get_code_completion_option(0).size() == 0);
- CHECK(code_edit->get_code_completion_options().size() == 0);
-
- /* After update, pending add should not be counted, */
- /* also does not work on col 0 */
- code_edit->insert_text_at_caret("i");
- code_edit->update_code_completion_options();
- code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0", Color(1, 0, 0), RES(), Color(1, 0, 0));
- code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "item_1.", "item_1");
- code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "item_2.", "item_2");
-
- ERR_PRINT_OFF;
- code_edit->set_code_completion_selected_index(1);
- ERR_PRINT_ON;
- CHECK(code_edit->get_code_completion_selected_index() == 0);
- CHECK(code_edit->get_code_completion_option(0).size() == 6);
- CHECK(code_edit->get_code_completion_options().size() == 1);
-
- /* Check cancel closes completion. */
- SEND_GUI_ACTION(code_edit, "ui_cancel");
- CHECK(code_edit->get_code_completion_selected_index() == -1);
-
- code_edit->update_code_completion_options();
- CHECK(code_edit->get_code_completion_selected_index() == 0);
- code_edit->set_code_completion_selected_index(1);
- CHECK(code_edit->get_code_completion_selected_index() == 1);
- CHECK(code_edit->get_code_completion_option(0).size() == 6);
- CHECK(code_edit->get_code_completion_options().size() == 3);
-
- /* Check data. */
- Dictionary option = code_edit->get_code_completion_option(0);
- CHECK((int)option["kind"] == (int)CodeEdit::CodeCompletionKind::KIND_CLASS);
- CHECK(option["display_text"] == "item_0.");
- CHECK(option["insert_text"] == "item_0");
- CHECK(option["font_color"] == Color(1, 0, 0));
- CHECK(option["icon"] == RES());
- CHECK(option["default_value"] == Color(1, 0, 0));
-
- /* Set size for mouse input. */
- code_edit->set_size(Size2(100, 100));
-
- /* Check input. */
- SEND_GUI_ACTION(code_edit, "ui_end");
- CHECK(code_edit->get_code_completion_selected_index() == 2);
-
- SEND_GUI_ACTION(code_edit, "ui_home");
- CHECK(code_edit->get_code_completion_selected_index() == 0);
-
- SEND_GUI_ACTION(code_edit, "ui_page_down");
- CHECK(code_edit->get_code_completion_selected_index() == 2);
-
- SEND_GUI_ACTION(code_edit, "ui_page_up");
- CHECK(code_edit->get_code_completion_selected_index() == 0);
-
- SEND_GUI_ACTION(code_edit, "ui_up");
- CHECK(code_edit->get_code_completion_selected_index() == 2);
-
- SEND_GUI_ACTION(code_edit, "ui_down");
- CHECK(code_edit->get_code_completion_selected_index() == 0);
-
- SEND_GUI_KEY_EVENT(code_edit, Key::T);
- CHECK(code_edit->get_code_completion_selected_index() == 0);
-
- SEND_GUI_ACTION(code_edit, "ui_left");
- CHECK(code_edit->get_code_completion_selected_index() == 0);
-
- SEND_GUI_ACTION(code_edit, "ui_right");
- CHECK(code_edit->get_code_completion_selected_index() == 0);
-
- SEND_GUI_ACTION(code_edit, "ui_text_backspace");
- CHECK(code_edit->get_code_completion_selected_index() == 0);
+ if (TS->has_feature(TextServer::FEATURE_FONT_DYNAMIC) && TS->has_feature(TextServer::FEATURE_SIMPLE_LAYOUT)) {
+ CHECK(code_edit->get_code_completion_selected_index() == -1);
+ code_edit->set_code_completion_enabled(true);
+ CHECK(code_edit->get_code_completion_selected_index() == -1);
+
+ code_edit->update_code_completion_options();
+ code_edit->set_code_completion_selected_index(1);
+ CHECK(code_edit->get_code_completion_selected_index() == -1);
+ CHECK(code_edit->get_code_completion_option(0).size() == 0);
+ CHECK(code_edit->get_code_completion_options().size() == 0);
+
+ /* Adding does not update the list. */
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "item_0.", "item_0");
+
+ code_edit->set_code_completion_selected_index(1);
+ CHECK(code_edit->get_code_completion_selected_index() == -1);
+ CHECK(code_edit->get_code_completion_option(0).size() == 0);
+ CHECK(code_edit->get_code_completion_options().size() == 0);
+
+ /* After update, pending add should not be counted, */
+ /* also does not work on col 0 */
+ code_edit->insert_text_at_caret("i");
+ code_edit->update_code_completion_options();
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0", Color(1, 0, 0), RES(), Color(1, 0, 0));
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "item_1.", "item_1");
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "item_2.", "item_2");
- Point2 caret_pos = code_edit->get_caret_draw_pos();
- caret_pos.y -= code_edit->get_line_height();
- SEND_GUI_MOUSE_EVENT(code_edit, caret_pos, MouseButton::WHEEL_DOWN, MouseButton::NONE);
- CHECK(code_edit->get_code_completion_selected_index() == 1);
-
- SEND_GUI_MOUSE_EVENT(code_edit, caret_pos, MouseButton::WHEEL_UP, MouseButton::NONE);
- CHECK(code_edit->get_code_completion_selected_index() == 0);
-
- /* Single click selects. */
- SEND_GUI_MOUSE_EVENT(code_edit, caret_pos, MouseButton::LEFT, MouseButton::MASK_LEFT);
- CHECK(code_edit->get_code_completion_selected_index() == 2);
-
- /* Double click inserts. */
- SEND_GUI_DOUBLE_CLICK(code_edit, caret_pos);
- CHECK(code_edit->get_code_completion_selected_index() == -1);
- CHECK(code_edit->get_line(0) == "item_2");
+ ERR_PRINT_OFF;
+ code_edit->set_code_completion_selected_index(1);
+ ERR_PRINT_ON;
+ CHECK(code_edit->get_code_completion_selected_index() == 0);
+ CHECK(code_edit->get_code_completion_option(0).size() == 6);
+ CHECK(code_edit->get_code_completion_options().size() == 1);
- code_edit->set_auto_brace_completion_enabled(false);
+ /* Check cancel closes completion. */
+ SEND_GUI_ACTION(code_edit, "ui_cancel");
+ CHECK(code_edit->get_code_completion_selected_index() == -1);
- /* Does nothing in readonly. */
- code_edit->undo();
- code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0");
- code_edit->update_code_completion_options();
- code_edit->set_editable(false);
- code_edit->confirm_code_completion();
- code_edit->set_editable(true);
- CHECK(code_edit->get_line(0) == "i");
+ code_edit->update_code_completion_options();
+ CHECK(code_edit->get_code_completion_selected_index() == 0);
+ code_edit->set_code_completion_selected_index(1);
+ CHECK(code_edit->get_code_completion_selected_index() == 1);
+ CHECK(code_edit->get_code_completion_option(0).size() == 6);
+ CHECK(code_edit->get_code_completion_options().size() == 3);
- /* Replace */
- code_edit->clear();
- code_edit->insert_text_at_caret("item_1 test");
- code_edit->set_caret_column(2);
- code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0");
- code_edit->update_code_completion_options();
- SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
- CHECK(code_edit->get_line(0) == "item_0 test");
+ /* Check data. */
+ Dictionary option = code_edit->get_code_completion_option(0);
+ CHECK((int)option["kind"] == (int)CodeEdit::CodeCompletionKind::KIND_CLASS);
+ CHECK(option["display_text"] == "item_0.");
+ CHECK(option["insert_text"] == "item_0");
+ CHECK(option["font_color"] == Color(1, 0, 0));
+ CHECK(option["icon"] == RES());
+ CHECK(option["default_value"] == Color(1, 0, 0));
- /* Replace string. */
- code_edit->clear();
- code_edit->insert_text_at_caret("\"item_1 test\"");
- code_edit->set_caret_column(2);
- code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0");
- code_edit->update_code_completion_options();
- SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
- CHECK(code_edit->get_line(0) == "\"item_0\"");
+ /* Set size for mouse input. */
+ code_edit->set_size(Size2(100, 100));
- /* Normal replace if no end is given. */
- code_edit->clear();
- code_edit->insert_text_at_caret("\"item_1 test");
- code_edit->set_caret_column(2);
- code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0");
- code_edit->update_code_completion_options();
- SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
- CHECK(code_edit->get_line(0) == "\"item_0\" test");
+ /* Check input. */
+ SEND_GUI_ACTION(code_edit, "ui_end");
+ CHECK(code_edit->get_code_completion_selected_index() == 2);
- /* Insert at completion. */
- code_edit->clear();
- code_edit->insert_text_at_caret("item_1 test");
- code_edit->set_caret_column(2);
- code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0");
- code_edit->update_code_completion_options();
- SEND_GUI_ACTION(code_edit, "ui_text_completion_accept");
- CHECK(code_edit->get_line(0) == "item_01 test");
+ SEND_GUI_ACTION(code_edit, "ui_home");
+ CHECK(code_edit->get_code_completion_selected_index() == 0);
- /* Insert at completion with string should have same output. */
- code_edit->clear();
- code_edit->insert_text_at_caret("\"item_1 test\"");
- code_edit->set_caret_column(2);
- code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0");
- code_edit->update_code_completion_options();
- SEND_GUI_ACTION(code_edit, "ui_text_completion_accept");
- CHECK(code_edit->get_line(0) == "\"item_0\"1 test\"");
+ SEND_GUI_ACTION(code_edit, "ui_page_down");
+ CHECK(code_edit->get_code_completion_selected_index() == 2);
- /* Merge symbol at end on insert text. */
- /* End on completion entry. */
- code_edit->clear();
- code_edit->insert_text_at_caret("item_1 test");
- code_edit->set_caret_column(2);
- code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0(", "item_0(");
- code_edit->update_code_completion_options();
- SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
- CHECK(code_edit->get_line(0) == "item_0( test");
- CHECK(code_edit->get_caret_column() == 7);
+ SEND_GUI_ACTION(code_edit, "ui_page_up");
+ CHECK(code_edit->get_code_completion_selected_index() == 0);
- /* End of text*/
- code_edit->clear();
- code_edit->insert_text_at_caret("item_1( test");
- code_edit->set_caret_column(2);
- code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0", "item_0");
- code_edit->update_code_completion_options();
- SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
- CHECK(code_edit->get_line(0) == "item_0( test");
- CHECK(code_edit->get_caret_column() == 6);
+ SEND_GUI_ACTION(code_edit, "ui_up");
+ CHECK(code_edit->get_code_completion_selected_index() == 2);
- /* End of both. */
- code_edit->clear();
- code_edit->insert_text_at_caret("item_1( test");
- code_edit->set_caret_column(2);
- code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0(", "item_0(");
- code_edit->update_code_completion_options();
- SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
- CHECK(code_edit->get_line(0) == "item_0( test");
- CHECK(code_edit->get_caret_column() == 7);
+ SEND_GUI_ACTION(code_edit, "ui_down");
+ CHECK(code_edit->get_code_completion_selected_index() == 0);
- /* Full set. */
- /* End on completion entry. */
- code_edit->clear();
- code_edit->insert_text_at_caret("item_1 test");
- code_edit->set_caret_column(2);
- code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0()", "item_0()");
- code_edit->update_code_completion_options();
- SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
- CHECK(code_edit->get_line(0) == "item_0() test");
- CHECK(code_edit->get_caret_column() == 8);
+ SEND_GUI_KEY_EVENT(code_edit, Key::T);
+ CHECK(code_edit->get_code_completion_selected_index() == 0);
- /* End of text*/
- code_edit->clear();
- code_edit->insert_text_at_caret("item_1() test");
- code_edit->set_caret_column(2);
- code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0", "item_0");
- code_edit->update_code_completion_options();
- SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
- CHECK(code_edit->get_line(0) == "item_0() test");
- CHECK(code_edit->get_caret_column() == 6);
+ SEND_GUI_ACTION(code_edit, "ui_left");
+ CHECK(code_edit->get_code_completion_selected_index() == 0);
- /* End of both. */
- code_edit->clear();
- code_edit->insert_text_at_caret("item_1() test");
- code_edit->set_caret_column(2);
- code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0()", "item_0()");
- code_edit->update_code_completion_options();
- SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
- CHECK(code_edit->get_line(0) == "item_0() test");
- CHECK(code_edit->get_caret_column() == 8);
+ SEND_GUI_ACTION(code_edit, "ui_right");
+ CHECK(code_edit->get_code_completion_selected_index() == 0);
- /* Autobrace completion. */
- code_edit->set_auto_brace_completion_enabled(true);
+ SEND_GUI_ACTION(code_edit, "ui_text_backspace");
+ CHECK(code_edit->get_code_completion_selected_index() == 0);
- /* End on completion entry. */
- code_edit->clear();
- code_edit->insert_text_at_caret("item_1 test");
- code_edit->set_caret_column(2);
- code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0(", "item_0(");
- code_edit->update_code_completion_options();
- SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
- CHECK(code_edit->get_line(0) == "item_0() test");
- CHECK(code_edit->get_caret_column() == 7);
+ Point2 caret_pos = code_edit->get_caret_draw_pos();
+ caret_pos.y -= code_edit->get_line_height();
+ SEND_GUI_MOUSE_EVENT(code_edit, caret_pos, MouseButton::WHEEL_DOWN, MouseButton::NONE);
+ CHECK(code_edit->get_code_completion_selected_index() == 1);
- /* End of text*/
- code_edit->clear();
- code_edit->insert_text_at_caret("item_1( test");
- code_edit->set_caret_column(2);
- code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0", "item_0");
- code_edit->update_code_completion_options();
- SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
- CHECK(code_edit->get_line(0) == "item_0( test");
- CHECK(code_edit->get_caret_column() == 6);
+ SEND_GUI_MOUSE_EVENT(code_edit, caret_pos, MouseButton::WHEEL_UP, MouseButton::NONE);
+ CHECK(code_edit->get_code_completion_selected_index() == 0);
- /* End of both. */
- code_edit->clear();
- code_edit->insert_text_at_caret("item_1( test");
- code_edit->set_caret_column(2);
- code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0(", "item_0(");
- code_edit->update_code_completion_options();
- SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
- CHECK(code_edit->get_line(0) == "item_0( test");
- CHECK(code_edit->get_caret_column() == 7);
+ /* Single click selects. */
+ SEND_GUI_MOUSE_EVENT(code_edit, caret_pos, MouseButton::LEFT, MouseButton::MASK_LEFT);
+ CHECK(code_edit->get_code_completion_selected_index() == 2);
- /* Full set. */
- /* End on completion entry. */
- code_edit->clear();
- code_edit->insert_text_at_caret("item_1 test");
- code_edit->set_caret_column(2);
- code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0()", "item_0()");
- code_edit->update_code_completion_options();
- SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
- CHECK(code_edit->get_line(0) == "item_0() test");
- CHECK(code_edit->get_caret_column() == 8);
+ /* Double click inserts. */
+ SEND_GUI_DOUBLE_CLICK(code_edit, caret_pos);
+ CHECK(code_edit->get_code_completion_selected_index() == -1);
+ CHECK(code_edit->get_line(0) == "item_2");
- /* End of text*/
- code_edit->clear();
- code_edit->insert_text_at_caret("item_1() test");
- code_edit->set_caret_column(2);
- code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0", "item_0");
- code_edit->update_code_completion_options();
- SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
- CHECK(code_edit->get_line(0) == "item_0() test");
- CHECK(code_edit->get_caret_column() == 6);
+ code_edit->set_auto_brace_completion_enabled(false);
- /* End of both. */
- code_edit->clear();
- code_edit->insert_text_at_caret("item_1() test");
- code_edit->set_caret_column(2);
- code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0()", "item_0()");
- code_edit->update_code_completion_options();
- SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
- CHECK(code_edit->get_line(0) == "item_0() test");
- CHECK(code_edit->get_caret_column() == 8);
+ /* Does nothing in readonly. */
+ code_edit->undo();
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0");
+ code_edit->update_code_completion_options();
+ code_edit->set_editable(false);
+ code_edit->confirm_code_completion();
+ code_edit->set_editable(true);
+ CHECK(code_edit->get_line(0) == "i");
+
+ /* Replace */
+ code_edit->clear();
+ code_edit->insert_text_at_caret("item_1 test");
+ code_edit->set_caret_column(2);
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0");
+ code_edit->update_code_completion_options();
+ SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
+ CHECK(code_edit->get_line(0) == "item_0 test");
+
+ /* Replace string. */
+ code_edit->clear();
+ code_edit->insert_text_at_caret("\"item_1 test\"");
+ code_edit->set_caret_column(2);
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0");
+ code_edit->update_code_completion_options();
+ SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
+ CHECK(code_edit->get_line(0) == "\"item_0\"");
+
+ /* Normal replace if no end is given. */
+ code_edit->clear();
+ code_edit->insert_text_at_caret("\"item_1 test");
+ code_edit->set_caret_column(2);
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0");
+ code_edit->update_code_completion_options();
+ SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
+ CHECK(code_edit->get_line(0) == "\"item_0\" test");
+
+ /* Insert at completion. */
+ code_edit->clear();
+ code_edit->insert_text_at_caret("item_1 test");
+ code_edit->set_caret_column(2);
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0");
+ code_edit->update_code_completion_options();
+ SEND_GUI_ACTION(code_edit, "ui_text_completion_accept");
+ CHECK(code_edit->get_line(0) == "item_01 test");
+
+ /* Insert at completion with string should have same output. */
+ code_edit->clear();
+ code_edit->insert_text_at_caret("\"item_1 test\"");
+ code_edit->set_caret_column(2);
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0.", "item_0");
+ code_edit->update_code_completion_options();
+ SEND_GUI_ACTION(code_edit, "ui_text_completion_accept");
+ CHECK(code_edit->get_line(0) == "\"item_0\"1 test\"");
+
+ /* Merge symbol at end on insert text. */
+ /* End on completion entry. */
+ code_edit->clear();
+ code_edit->insert_text_at_caret("item_1 test");
+ code_edit->set_caret_column(2);
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0(", "item_0(");
+ code_edit->update_code_completion_options();
+ SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
+ CHECK(code_edit->get_line(0) == "item_0( test");
+ CHECK(code_edit->get_caret_column() == 7);
+
+ /* End of text*/
+ code_edit->clear();
+ code_edit->insert_text_at_caret("item_1( test");
+ code_edit->set_caret_column(2);
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0", "item_0");
+ code_edit->update_code_completion_options();
+ SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
+ CHECK(code_edit->get_line(0) == "item_0( test");
+ CHECK(code_edit->get_caret_column() == 6);
+
+ /* End of both. */
+ code_edit->clear();
+ code_edit->insert_text_at_caret("item_1( test");
+ code_edit->set_caret_column(2);
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0(", "item_0(");
+ code_edit->update_code_completion_options();
+ SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
+ CHECK(code_edit->get_line(0) == "item_0( test");
+ CHECK(code_edit->get_caret_column() == 7);
+
+ /* Full set. */
+ /* End on completion entry. */
+ code_edit->clear();
+ code_edit->insert_text_at_caret("item_1 test");
+ code_edit->set_caret_column(2);
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0()", "item_0()");
+ code_edit->update_code_completion_options();
+ SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
+ CHECK(code_edit->get_line(0) == "item_0() test");
+ CHECK(code_edit->get_caret_column() == 8);
+
+ /* End of text*/
+ code_edit->clear();
+ code_edit->insert_text_at_caret("item_1() test");
+ code_edit->set_caret_column(2);
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0", "item_0");
+ code_edit->update_code_completion_options();
+ SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
+ CHECK(code_edit->get_line(0) == "item_0() test");
+ CHECK(code_edit->get_caret_column() == 6);
+
+ /* End of both. */
+ code_edit->clear();
+ code_edit->insert_text_at_caret("item_1() test");
+ code_edit->set_caret_column(2);
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0()", "item_0()");
+ code_edit->update_code_completion_options();
+ SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
+ CHECK(code_edit->get_line(0) == "item_0() test");
+ CHECK(code_edit->get_caret_column() == 8);
+
+ /* Autobrace completion. */
+ code_edit->set_auto_brace_completion_enabled(true);
+
+ /* End on completion entry. */
+ code_edit->clear();
+ code_edit->insert_text_at_caret("item_1 test");
+ code_edit->set_caret_column(2);
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0(", "item_0(");
+ code_edit->update_code_completion_options();
+ SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
+ CHECK(code_edit->get_line(0) == "item_0() test");
+ CHECK(code_edit->get_caret_column() == 7);
+
+ /* End of text*/
+ code_edit->clear();
+ code_edit->insert_text_at_caret("item_1( test");
+ code_edit->set_caret_column(2);
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0", "item_0");
+ code_edit->update_code_completion_options();
+ SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
+ CHECK(code_edit->get_line(0) == "item_0( test");
+ CHECK(code_edit->get_caret_column() == 6);
+
+ /* End of both. */
+ code_edit->clear();
+ code_edit->insert_text_at_caret("item_1( test");
+ code_edit->set_caret_column(2);
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0(", "item_0(");
+ code_edit->update_code_completion_options();
+ SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
+ CHECK(code_edit->get_line(0) == "item_0( test");
+ CHECK(code_edit->get_caret_column() == 7);
+
+ /* Full set. */
+ /* End on completion entry. */
+ code_edit->clear();
+ code_edit->insert_text_at_caret("item_1 test");
+ code_edit->set_caret_column(2);
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0()", "item_0()");
+ code_edit->update_code_completion_options();
+ SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
+ CHECK(code_edit->get_line(0) == "item_0() test");
+ CHECK(code_edit->get_caret_column() == 8);
+
+ /* End of text*/
+ code_edit->clear();
+ code_edit->insert_text_at_caret("item_1() test");
+ code_edit->set_caret_column(2);
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0", "item_0");
+ code_edit->update_code_completion_options();
+ SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
+ CHECK(code_edit->get_line(0) == "item_0() test");
+ CHECK(code_edit->get_caret_column() == 6);
+
+ /* End of both. */
+ code_edit->clear();
+ code_edit->insert_text_at_caret("item_1() test");
+ code_edit->set_caret_column(2);
+ code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_CLASS, "item_0()", "item_0()");
+ code_edit->update_code_completion_options();
+ SEND_GUI_ACTION(code_edit, "ui_text_completion_replace");
+ CHECK(code_edit->get_line(0) == "item_0() test");
+ CHECK(code_edit->get_caret_column() == 8);
+ }
}
memdelete(code_edit);
@@ -3198,33 +3200,35 @@ TEST_CASE("[SceneTree][CodeEdit] symbol lookup") {
code_edit->set_symbol_lookup_on_click_enabled(true);
CHECK(code_edit->is_symbol_lookup_on_click_enabled());
- /* Set size for mouse input. */
- code_edit->set_size(Size2(100, 100));
+ if (TS->has_feature(TextServer::FEATURE_FONT_DYNAMIC) && TS->has_feature(TextServer::FEATURE_SIMPLE_LAYOUT)) {
+ /* Set size for mouse input. */
+ code_edit->set_size(Size2(100, 100));
- code_edit->set_text("this is some text");
+ code_edit->set_text("this is some text");
- Point2 caret_pos = code_edit->get_caret_draw_pos();
- caret_pos.x += 58;
- SEND_GUI_MOUSE_EVENT(code_edit, caret_pos, MouseButton::NONE, MouseButton::NONE);
- CHECK(code_edit->get_text_for_symbol_lookup() == "this is s" + String::chr(0xFFFF) + "ome text");
+ Point2 caret_pos = code_edit->get_caret_draw_pos();
+ caret_pos.x += 58;
+ SEND_GUI_MOUSE_EVENT(code_edit, caret_pos, MouseButton::NONE, MouseButton::NONE);
+ CHECK(code_edit->get_text_for_symbol_lookup() == "this is s" + String::chr(0xFFFF) + "ome text");
- SIGNAL_WATCH(code_edit, "symbol_validate");
+ SIGNAL_WATCH(code_edit, "symbol_validate");
#ifdef OSX_ENABLED
- SEND_GUI_KEY_EVENT(code_edit, Key::META);
+ SEND_GUI_KEY_EVENT(code_edit, Key::META);
#else
- SEND_GUI_KEY_EVENT(code_edit, Key::CTRL);
+ SEND_GUI_KEY_EVENT(code_edit, Key::CTRL);
#endif
- Array signal_args;
- Array arg;
- arg.push_back("some");
- signal_args.push_back(arg);
- SIGNAL_CHECK("symbol_validate", signal_args);
+ Array signal_args;
+ Array arg;
+ arg.push_back("some");
+ signal_args.push_back(arg);
+ SIGNAL_CHECK("symbol_validate", signal_args);
- SIGNAL_UNWATCH(code_edit, "symbol_validate");
+ SIGNAL_UNWATCH(code_edit, "symbol_validate");
- memdelete(code_edit);
+ memdelete(code_edit);
+ }
}
TEST_CASE("[SceneTree][CodeEdit] line length guidelines") {