diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-03-18 14:29:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-18 14:29:58 +0100 |
commit | 5c8bd6fd71ac289415f0ff670442cd52bdc0d52b (patch) | |
tree | f2b2b3c3e1f1d67b1df414d08f054c2f1f8c8331 /tests | |
parent | da26fcc91a5643d592067d44d6cace34295fadda (diff) | |
parent | f19cd44346a68a649cabfe85cc3ba7a44ceb0ca4 (diff) |
Merge pull request #58233 from bruvzg/gde_ts
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/object/test_class_db.h | 4 | ||||
-rw-r--r-- | tests/scene/test_code_edit.h | 566 | ||||
-rw-r--r-- | tests/servers/test_text_server.h | 66 |
3 files changed, 328 insertions, 308 deletions
diff --git a/tests/core/object/test_class_db.h b/tests/core/object/test_class_db.h index e4145c8408..5cf5403a50 100644 --- a/tests/core/object/test_class_db.h +++ b/tests/core/object/test_class_db.h @@ -671,10 +671,6 @@ void add_exposed_classes(Context &r_context) { } else { exposed_class.methods.push_back(method); } - - if (method.is_virtual) { - TEST_COND(String(method.name)[0] != '_', "Virtual method ", String(method.name), " does not start with underscore."); - } } // Add signals 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") { diff --git a/tests/servers/test_text_server.h b/tests/servers/test_text_server.h index 0a64237285..d7de94516f 100644 --- a/tests/servers/test_text_server.h +++ b/tests/servers/test_text_server.h @@ -46,10 +46,14 @@ TEST_SUITE("[[TextServer]") { Ref<TextServer> ts = TextServerManager::get_singleton()->get_interface(i); TEST_FAIL_COND(ts.is_null(), "Invalid TS interface."); + if (!ts->has_feature(TextServer::FEATURE_FONT_DYNAMIC)) { + continue; + } + RID font = ts->create_font(); ts->font_set_data_ptr(font, _font_NotoSans_Regular, _font_NotoSans_Regular_size); TEST_FAIL_COND(font == RID(), "Loading font failed."); - ts->free(font); + ts->free_rid(font); } } @@ -58,12 +62,16 @@ TEST_SUITE("[[TextServer]") { Ref<TextServer> ts = TextServerManager::get_singleton()->get_interface(i); TEST_FAIL_COND(ts.is_null(), "Invalid TS interface."); + if (!ts->has_feature(TextServer::FEATURE_FONT_DYNAMIC) || !ts->has_feature(TextServer::FEATURE_SIMPLE_LAYOUT)) { + continue; + } + RID font1 = ts->create_font(); ts->font_set_data_ptr(font1, _font_NotoSans_Regular, _font_NotoSans_Regular_size); RID font2 = ts->create_font(); ts->font_set_data_ptr(font2, _font_NotoSansThaiUI_Regular, _font_NotoSansThaiUI_Regular_size); - Vector<RID> font; + Array font; font.push_back(font1); font.push_back(font2); @@ -93,10 +101,10 @@ TEST_SUITE("[[TextServer]") { TEST_FAIL_COND(glyphs[j].font_size != 16, "Incorrect glyph font size."); } - ts->free(ctx); + ts->free_rid(ctx); for (int j = 0; j < font.size(); j++) { - ts->free(font[j]); + ts->free_rid(font[j]); } font.clear(); } @@ -107,7 +115,7 @@ TEST_SUITE("[[TextServer]") { Ref<TextServer> ts = TextServerManager::get_singleton()->get_interface(i); TEST_FAIL_COND(ts.is_null(), "Invalid TS interface."); - if (!ts->has_feature(TextServer::FEATURE_BIDI_LAYOUT)) { + if (!ts->has_feature(TextServer::FEATURE_FONT_DYNAMIC) || !ts->has_feature(TextServer::FEATURE_BIDI_LAYOUT)) { continue; } @@ -116,7 +124,7 @@ TEST_SUITE("[[TextServer]") { RID font2 = ts->create_font(); ts->font_set_data_ptr(font2, _font_NotoNaskhArabicUI_Regular, _font_NotoNaskhArabicUI_Regular_size); - Vector<RID> font; + Array font; font.push_back(font1); font.push_back(font2); @@ -145,10 +153,10 @@ TEST_SUITE("[[TextServer]") { } } - ts->free(ctx); + ts->free_rid(ctx); for (int j = 0; j < font.size(); j++) { - ts->free(font[j]); + ts->free_rid(font[j]); } font.clear(); } @@ -159,6 +167,10 @@ TEST_SUITE("[[TextServer]") { Ref<TextServer> ts = TextServerManager::get_singleton()->get_interface(i); TEST_FAIL_COND(ts.is_null(), "Invalid TS interface."); + if (!ts->has_feature(TextServer::FEATURE_FONT_DYNAMIC) || !ts->has_feature(TextServer::FEATURE_SIMPLE_LAYOUT)) { + continue; + } + RID font1 = ts->create_font(); ts->font_set_data_ptr(font1, _font_NotoSans_Regular, _font_NotoSans_Regular_size); RID font2 = ts->create_font(); @@ -166,7 +178,7 @@ TEST_SUITE("[[TextServer]") { RID font3 = ts->create_font(); ts->font_set_data_ptr(font3, _font_NotoNaskhArabicUI_Regular, _font_NotoNaskhArabicUI_Regular_size); - Vector<RID> font; + Array font; font.push_back(font1); font.push_back(font2); font.push_back(font3); @@ -198,7 +210,7 @@ TEST_SUITE("[[TextServer]") { TEST_FAIL_COND((soft || space || hard || virt || elo), "Invalid glyph flags."); } } - ts->free(ctx); + ts->free_rid(ctx); } { @@ -241,7 +253,7 @@ TEST_SUITE("[[TextServer]") { } } } - ts->free(ctx); + ts->free_rid(ctx); } { @@ -294,7 +306,7 @@ TEST_SUITE("[[TextServer]") { } } - ts->free(ctx); + ts->free_rid(ctx); } { @@ -322,7 +334,7 @@ TEST_SUITE("[[TextServer]") { TEST_FAIL_COND((soft || space || hard || virt || elo), "Invalid glyph flags."); } } - ts->free(ctx); + ts->free_rid(ctx); } if (ts->has_feature(TextServer::FEATURE_BREAK_ITERATORS)) { @@ -350,11 +362,11 @@ TEST_SUITE("[[TextServer]") { TEST_FAIL_COND((soft || space || hard || virt || elo), "Invalid glyph flags."); } } - ts->free(ctx); + ts->free_rid(ctx); } for (int j = 0; j < font.size(); j++) { - ts->free(font[j]); + ts->free_rid(font[j]); } font.clear(); } @@ -365,6 +377,10 @@ TEST_SUITE("[[TextServer]") { Ref<TextServer> ts = TextServerManager::get_singleton()->get_interface(i); TEST_FAIL_COND(ts.is_null(), "Invalid TS interface."); + if (!ts->has_feature(TextServer::FEATURE_FONT_DYNAMIC) || !ts->has_feature(TextServer::FEATURE_SIMPLE_LAYOUT)) { + continue; + } + String test_1 = U"test test test"; // 5^ 10^ @@ -373,7 +389,7 @@ TEST_SUITE("[[TextServer]") { RID font2 = ts->create_font(); ts->font_set_data_ptr(font2, _font_NotoSansThaiUI_Regular, _font_NotoSansThaiUI_Regular_size); - Vector<RID> font; + Array font; font.push_back(font1); font.push_back(font2); @@ -395,10 +411,10 @@ TEST_SUITE("[[TextServer]") { TEST_FAIL_COND(brks[5] != 14, "Invalid line break position."); } - ts->free(ctx); + ts->free_rid(ctx); for (int j = 0; j < font.size(); j++) { - ts->free(font[j]); + ts->free_rid(font[j]); } font.clear(); } @@ -409,12 +425,16 @@ TEST_SUITE("[[TextServer]") { Ref<TextServer> ts = TextServerManager::get_singleton()->get_interface(i); TEST_FAIL_COND(ts.is_null(), "Invalid TS interface."); + if (!ts->has_feature(TextServer::FEATURE_FONT_DYNAMIC) || !ts->has_feature(TextServer::FEATURE_SIMPLE_LAYOUT)) { + continue; + } + RID font1 = ts->create_font(); ts->font_set_data_ptr(font1, _font_NotoSans_Regular, _font_NotoSans_Regular_size); RID font2 = ts->create_font(); ts->font_set_data_ptr(font2, _font_NotoNaskhArabicUI_Regular, _font_NotoNaskhArabicUI_Regular_size); - Vector<RID> font; + Array font; font.push_back(font1); font.push_back(font2); @@ -438,7 +458,7 @@ TEST_SUITE("[[TextServer]") { width = ts->shaped_text_fit_to_width(ctx, 100, TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA); TEST_FAIL_COND((width <= width_old || width > 100), "Invalid fill width."); - ts->free(ctx); + ts->free_rid(ctx); ctx = ts->create_shaped_text(); TEST_FAIL_COND(ctx == RID(), "Creating text buffer failed."); @@ -451,7 +471,7 @@ TEST_SUITE("[[TextServer]") { width = ts->shaped_text_fit_to_width(ctx, 100, TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA); TEST_FAIL_COND((width <= width_old || width > 100), "Invalid fill width."); - ts->free(ctx); + ts->free_rid(ctx); } ctx = ts->create_shaped_text(); @@ -463,10 +483,10 @@ TEST_SUITE("[[TextServer]") { width = ts->shaped_text_fit_to_width(ctx, 100, TextServer::JUSTIFICATION_WORD_BOUND); TEST_FAIL_COND((width <= width_old || width > 100), "Invalid fill width."); - ts->free(ctx); + ts->free_rid(ctx); for (int j = 0; j < font.size(); j++) { - ts->free(font[j]); + ts->free_rid(font[j]); } font.clear(); } |