diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/math/test_vector3.h | 8 | ||||
-rw-r--r-- | tests/core/math/test_vector3i.h | 7 | ||||
-rw-r--r-- | tests/core/math/test_vector4.h | 8 | ||||
-rw-r--r-- | tests/core/math/test_vector4i.h | 8 | ||||
-rw-r--r-- | tests/core/string/test_string.h | 8 | ||||
-rw-r--r-- | tests/display_server_mock.h | 20 | ||||
-rw-r--r-- | tests/scene/test_code_edit.h | 236 | ||||
-rw-r--r-- | tests/scene/test_text_edit.h | 303 | ||||
-rw-r--r-- | tests/scene/test_viewport.h | 718 | ||||
-rw-r--r-- | tests/test_macros.h | 89 | ||||
-rw-r--r-- | tests/test_main.cpp | 4 |
11 files changed, 1092 insertions, 317 deletions
diff --git a/tests/core/math/test_vector3.h b/tests/core/math/test_vector3.h index c3488954ce..ca0aa02882 100644 --- a/tests/core/math/test_vector3.h +++ b/tests/core/math/test_vector3.h @@ -354,6 +354,14 @@ TEST_CASE("[Vector3] Other methods") { CHECK_MESSAGE( vector.snapped(Vector3(0.25, 0.25, 0.25)) == Vector3(1.25, 3.5, 5.5), "Vector3 snapped to 0.25 should give exact results."); + + CHECK_MESSAGE( + Vector3(1.2, 2.5, 2.0).is_equal_approx(vector.min(Vector3(3.0, 2.5, 2.0))), + "Vector3 min should return expected value."); + + CHECK_MESSAGE( + Vector3(5.3, 3.4, 5.6).is_equal_approx(vector.max(Vector3(5.3, 2.0, 3.0))), + "Vector3 max should return expected value."); } TEST_CASE("[Vector3] Plane methods") { diff --git a/tests/core/math/test_vector3i.h b/tests/core/math/test_vector3i.h index 6eef129a36..485a500715 100644 --- a/tests/core/math/test_vector3i.h +++ b/tests/core/math/test_vector3i.h @@ -131,6 +131,13 @@ TEST_CASE("[Vector3i] Other methods") { const Vector3i vector = Vector3i(1, 3, -7); CHECK_MESSAGE( + vector.min(Vector3i(3, 2, 5)) == Vector3i(1, 2, -7), + "Vector3i min should return expected value."); + CHECK_MESSAGE( + vector.max(Vector3i(5, 2, 4)) == Vector3i(5, 3, 4), + "Vector3i max should return expected value."); + + CHECK_MESSAGE( vector.snapped(Vector3i(4, 2, 5)) == Vector3i(0, 4, -5), "Vector3i snapped should work as expected."); } diff --git a/tests/core/math/test_vector4.h b/tests/core/math/test_vector4.h index b85cc710e0..331e0fcfd5 100644 --- a/tests/core/math/test_vector4.h +++ b/tests/core/math/test_vector4.h @@ -255,6 +255,14 @@ TEST_CASE("[Vector4] Other methods") { CHECK_MESSAGE( vector.snapped(Vector4(0.25, 0.25, 0.25, 0.25)) == Vector4(1.25, 3.5, 5.5, 1.5), "Vector4 snapped to 0.25 should give exact results."); + + CHECK_MESSAGE( + Vector4(1.2, 2.5, 2.0, 1.6).is_equal_approx(vector.min(Vector4(3.0, 2.5, 2.0, 3.4))), + "Vector4 min should return expected value."); + + CHECK_MESSAGE( + Vector4(5.3, 3.4, 5.6, 4.2).is_equal_approx(vector.max(Vector4(5.3, 2.0, 3.0, 4.2))), + "Vector4 max should return expected value."); } TEST_CASE("[Vector4] Rounding methods") { diff --git a/tests/core/math/test_vector4i.h b/tests/core/math/test_vector4i.h index e5b47af7c4..5fda6f1778 100644 --- a/tests/core/math/test_vector4i.h +++ b/tests/core/math/test_vector4i.h @@ -134,6 +134,14 @@ TEST_CASE("[Vector3i] Other methods") { const Vector4i vector = Vector4i(1, 3, -7, 13); CHECK_MESSAGE( + vector.min(Vector4i(3, 2, 5, 8)) == Vector4i(1, 2, -7, 8), + "Vector4i min should return expected value."); + + CHECK_MESSAGE( + vector.max(Vector4i(5, 2, 4, 8)) == Vector4i(5, 3, 4, 13), + "Vector4i max should return expected value."); + + CHECK_MESSAGE( vector.snapped(Vector4i(4, 2, 5, 8)) == Vector4i(0, 4, -5, 16), "Vector4i snapped should work as expected."); } diff --git a/tests/core/string/test_string.h b/tests/core/string/test_string.h index 0cf3448a48..5d19b5a164 100644 --- a/tests/core/string/test_string.h +++ b/tests/core/string/test_string.h @@ -512,6 +512,14 @@ TEST_CASE("[String] Splitting") { CHECK(l[i] == slices_3[i]); } + s = ""; + l = s.split(); + CHECK(l.size() == 1); + CHECK(l[0] == ""); + + l = s.split("", false); + CHECK(l.size() == 0); + s = "Mars Jupiter Saturn Uranus"; const char *slices_s[4] = { "Mars", "Jupiter", "Saturn", "Uranus" }; l = s.split_spaces(); diff --git a/tests/display_server_mock.h b/tests/display_server_mock.h index 1736f2c452..fe36fa0b69 100644 --- a/tests/display_server_mock.h +++ b/tests/display_server_mock.h @@ -42,6 +42,7 @@ private: friend class DisplayServer; Point2i mouse_position = Point2i(-1, -1); // Outside of Window. + CursorShape cursor_shape = CursorShape::CURSOR_ARROW; bool window_over = false; Callable event_callback; Callable input_event_callback; @@ -103,6 +104,7 @@ public: bool has_feature(Feature p_feature) const override { switch (p_feature) { case FEATURE_MOUSE: + case FEATURE_CURSOR_SHAPE: return true; default: { } @@ -115,12 +117,24 @@ public: // You can simulate DisplayServer-events by calling this function. // The events will be deliverd to Godot's Input-system. // Mouse-events (Button & Motion) will additionally update the DisplayServer's mouse position. + // For Mouse motion events, the `relative`-property is set based on the distance to the previous mouse position. void simulate_event(Ref<InputEvent> p_event) { + Ref<InputEvent> event = p_event; Ref<InputEventMouse> me = p_event; if (me.is_valid()) { + Ref<InputEventMouseMotion> mm = p_event; + if (mm.is_valid()) { + mm->set_relative(mm->get_position() - mouse_position); + event = mm; + } _set_mouse_position(me->get_position()); } - Input::get_singleton()->parse_input_event(p_event); + Input::get_singleton()->parse_input_event(event); + } + + // Returns the current cursor shape. + CursorShape get_cursor_shape() { + return cursor_shape; } virtual Point2i mouse_get_position() const override { return mouse_position; } @@ -129,6 +143,10 @@ public: return Size2i(1920, 1080); } + virtual void cursor_set_shape(CursorShape p_shape) override { + cursor_shape = p_shape; + } + virtual void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID) override { event_callback = p_callable; } diff --git a/tests/scene/test_code_edit.h b/tests/scene/test_code_edit.h index 828029dabe..c681c76846 100644 --- a/tests/scene/test_code_edit.h +++ b/tests/scene/test_code_edit.h @@ -189,7 +189,7 @@ TEST_CASE("[SceneTree][CodeEdit] line gutters") { arg2.push_back(1); args.push_back(arg2); - SEND_GUI_ACTION(code_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); CHECK(code_edit->get_line_count() == 2); CHECK_FALSE(code_edit->is_line_breakpointed(0)); CHECK(code_edit->is_line_breakpointed(1)); @@ -198,7 +198,7 @@ TEST_CASE("[SceneTree][CodeEdit] line gutters") { /* Non-Breaking. */ ((Array)args[0])[0] = 1; ((Array)args[1])[0] = 2; - SEND_GUI_ACTION(code_edit, "ui_text_newline_blank"); + SEND_GUI_ACTION("ui_text_newline_blank"); CHECK(code_edit->get_line_count() == 3); CHECK_FALSE(code_edit->is_line_breakpointed(1)); CHECK(code_edit->is_line_breakpointed(2)); @@ -207,7 +207,7 @@ TEST_CASE("[SceneTree][CodeEdit] line gutters") { /* Above. */ ((Array)args[0])[0] = 2; ((Array)args[1])[0] = 3; - SEND_GUI_ACTION(code_edit, "ui_text_newline_above"); + SEND_GUI_ACTION("ui_text_newline_above"); CHECK(code_edit->get_line_count() == 4); CHECK_FALSE(code_edit->is_line_breakpointed(2)); CHECK(code_edit->is_line_breakpointed(3)); @@ -227,7 +227,7 @@ TEST_CASE("[SceneTree][CodeEdit] line gutters") { SIGNAL_CHECK("breakpoint_toggled", args); /* Normal. */ - SEND_GUI_ACTION(code_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); CHECK(code_edit->get_line_count() == 2); CHECK(code_edit->is_line_breakpointed(0)); CHECK_FALSE(code_edit->is_line_breakpointed(1)); @@ -235,7 +235,7 @@ TEST_CASE("[SceneTree][CodeEdit] line gutters") { /* Non-Breaking. */ code_edit->set_caret_line(0); - SEND_GUI_ACTION(code_edit, "ui_text_newline_blank"); + SEND_GUI_ACTION("ui_text_newline_blank"); CHECK(code_edit->get_line_count() == 3); CHECK(code_edit->is_line_breakpointed(0)); CHECK_FALSE(code_edit->is_line_breakpointed(1)); @@ -248,7 +248,7 @@ TEST_CASE("[SceneTree][CodeEdit] line gutters") { args.push_back(arg2); code_edit->set_caret_line(0); - SEND_GUI_ACTION(code_edit, "ui_text_newline_above"); + SEND_GUI_ACTION("ui_text_newline_above"); CHECK(code_edit->get_line_count() == 4); CHECK_FALSE(code_edit->is_line_breakpointed(0)); CHECK(code_edit->is_line_breakpointed(1)); @@ -269,12 +269,12 @@ TEST_CASE("[SceneTree][CodeEdit] line gutters") { code_edit->set_caret_line(2); /* backspace onto line does not remove breakpoint */ - SEND_GUI_ACTION(code_edit, "ui_text_backspace"); + SEND_GUI_ACTION("ui_text_backspace"); CHECK(code_edit->is_line_breakpointed(1)); SIGNAL_CHECK_FALSE("breakpoint_toggled"); /* backspace on breakpointed line removes it */ - SEND_GUI_ACTION(code_edit, "ui_text_backspace"); + SEND_GUI_ACTION("ui_text_backspace"); CHECK_FALSE(code_edit->is_line_breakpointed(0)); ERR_PRINT_OFF; CHECK_FALSE(code_edit->is_line_breakpointed(1)); @@ -294,7 +294,7 @@ TEST_CASE("[SceneTree][CodeEdit] line gutters") { Array arg2; arg2.push_back(1); args.push_back(arg2); - SEND_GUI_ACTION(code_edit, "ui_text_backspace"); + SEND_GUI_ACTION("ui_text_backspace"); ERR_PRINT_OFF; CHECK_FALSE(code_edit->is_line_breakpointed(2)); ERR_PRINT_ON; @@ -315,14 +315,14 @@ TEST_CASE("[SceneTree][CodeEdit] line gutters") { code_edit->set_caret_line(1); /* Delete onto breakpointed lines does not remove it. */ - SEND_GUI_ACTION(code_edit, "ui_text_delete"); + SEND_GUI_ACTION("ui_text_delete"); CHECK(code_edit->get_line_count() == 2); CHECK(code_edit->is_line_breakpointed(1)); SIGNAL_CHECK_FALSE("breakpoint_toggled"); /* Delete moving breakpointed line up removes it. */ code_edit->set_caret_line(0); - SEND_GUI_ACTION(code_edit, "ui_text_delete"); + SEND_GUI_ACTION("ui_text_delete"); CHECK(code_edit->get_line_count() == 1); ERR_PRINT_OFF; CHECK_FALSE(code_edit->is_line_breakpointed(1)); @@ -342,7 +342,7 @@ TEST_CASE("[SceneTree][CodeEdit] line gutters") { Array arg2; arg2.push_back(1); args.push_back(arg2); - SEND_GUI_ACTION(code_edit, "ui_text_delete"); + SEND_GUI_ACTION("ui_text_delete"); ERR_PRINT_OFF; CHECK_FALSE(code_edit->is_line_breakpointed(2)); ERR_PRINT_ON; @@ -380,7 +380,7 @@ TEST_CASE("[SceneTree][CodeEdit] line gutters") { Array arg2; arg2.push_back(4); args.push_back(arg2); - SEND_GUI_ACTION(code_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); ERR_PRINT_OFF; CHECK_FALSE(code_edit->is_line_breakpointed(9)); ERR_PRINT_ON; @@ -524,19 +524,19 @@ TEST_CASE("[SceneTree][CodeEdit] line gutters") { CHECK(code_edit->is_line_bookmarked(0)); /* Normal. */ - SEND_GUI_ACTION(code_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); CHECK(code_edit->get_line_count() == 2); CHECK_FALSE(code_edit->is_line_bookmarked(0)); CHECK(code_edit->is_line_bookmarked(1)); /* Non-Breaking. */ - SEND_GUI_ACTION(code_edit, "ui_text_newline_blank"); + SEND_GUI_ACTION("ui_text_newline_blank"); CHECK(code_edit->get_line_count() == 3); CHECK_FALSE(code_edit->is_line_bookmarked(1)); CHECK(code_edit->is_line_bookmarked(2)); /* Above. */ - SEND_GUI_ACTION(code_edit, "ui_text_newline_above"); + SEND_GUI_ACTION("ui_text_newline_above"); CHECK(code_edit->get_line_count() == 4); CHECK_FALSE(code_edit->is_line_bookmarked(2)); CHECK(code_edit->is_line_bookmarked(3)); @@ -549,21 +549,21 @@ TEST_CASE("[SceneTree][CodeEdit] line gutters") { CHECK(code_edit->is_line_bookmarked(0)); /* Normal. */ - SEND_GUI_ACTION(code_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); CHECK(code_edit->get_line_count() == 2); CHECK(code_edit->is_line_bookmarked(0)); CHECK_FALSE(code_edit->is_line_bookmarked(1)); /* Non-Breaking. */ code_edit->set_caret_line(0); - SEND_GUI_ACTION(code_edit, "ui_text_newline_blank"); + SEND_GUI_ACTION("ui_text_newline_blank"); CHECK(code_edit->get_line_count() == 3); CHECK(code_edit->is_line_bookmarked(0)); CHECK_FALSE(code_edit->is_line_bookmarked(1)); /* Above does move. */ code_edit->set_caret_line(0); - SEND_GUI_ACTION(code_edit, "ui_text_newline_above"); + SEND_GUI_ACTION("ui_text_newline_above"); CHECK(code_edit->get_line_count() == 4); CHECK_FALSE(code_edit->is_line_bookmarked(0)); CHECK(code_edit->is_line_bookmarked(1)); @@ -577,11 +577,11 @@ TEST_CASE("[SceneTree][CodeEdit] line gutters") { code_edit->set_caret_line(2); /* backspace onto line does not remove bookmark */ - SEND_GUI_ACTION(code_edit, "ui_text_backspace"); + SEND_GUI_ACTION("ui_text_backspace"); CHECK(code_edit->is_line_bookmarked(1)); /* backspace on bookmarked line removes it */ - SEND_GUI_ACTION(code_edit, "ui_text_backspace"); + SEND_GUI_ACTION("ui_text_backspace"); CHECK_FALSE(code_edit->is_line_bookmarked(0)); ERR_PRINT_OFF; CHECK_FALSE(code_edit->is_line_bookmarked(1)); @@ -595,13 +595,13 @@ TEST_CASE("[SceneTree][CodeEdit] line gutters") { code_edit->set_caret_line(1); /* Delete onto bookmarked lines does not remove it. */ - SEND_GUI_ACTION(code_edit, "ui_text_delete"); + SEND_GUI_ACTION("ui_text_delete"); CHECK(code_edit->get_line_count() == 2); CHECK(code_edit->is_line_bookmarked(1)); /* Delete moving bookmarked line up removes it. */ code_edit->set_caret_line(0); - SEND_GUI_ACTION(code_edit, "ui_text_delete"); + SEND_GUI_ACTION("ui_text_delete"); CHECK(code_edit->get_line_count() == 1); ERR_PRINT_OFF; CHECK_FALSE(code_edit->is_line_bookmarked(1)); @@ -730,19 +730,19 @@ TEST_CASE("[SceneTree][CodeEdit] line gutters") { CHECK(code_edit->is_line_executing(0)); /* Normal. */ - SEND_GUI_ACTION(code_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); CHECK(code_edit->get_line_count() == 2); CHECK_FALSE(code_edit->is_line_executing(0)); CHECK(code_edit->is_line_executing(1)); /* Non-Breaking. */ - SEND_GUI_ACTION(code_edit, "ui_text_newline_blank"); + SEND_GUI_ACTION("ui_text_newline_blank"); CHECK(code_edit->get_line_count() == 3); CHECK_FALSE(code_edit->is_line_executing(1)); CHECK(code_edit->is_line_executing(2)); /* Above. */ - SEND_GUI_ACTION(code_edit, "ui_text_newline_above"); + SEND_GUI_ACTION("ui_text_newline_above"); CHECK(code_edit->get_line_count() == 4); CHECK_FALSE(code_edit->is_line_executing(2)); CHECK(code_edit->is_line_executing(3)); @@ -755,21 +755,21 @@ TEST_CASE("[SceneTree][CodeEdit] line gutters") { CHECK(code_edit->is_line_executing(0)); /* Normal. */ - SEND_GUI_ACTION(code_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); CHECK(code_edit->get_line_count() == 2); CHECK(code_edit->is_line_executing(0)); CHECK_FALSE(code_edit->is_line_executing(1)); /* Non-Breaking. */ code_edit->set_caret_line(0); - SEND_GUI_ACTION(code_edit, "ui_text_newline_blank"); + SEND_GUI_ACTION("ui_text_newline_blank"); CHECK(code_edit->get_line_count() == 3); CHECK(code_edit->is_line_executing(0)); CHECK_FALSE(code_edit->is_line_executing(1)); /* Above does move. */ code_edit->set_caret_line(0); - SEND_GUI_ACTION(code_edit, "ui_text_newline_above"); + SEND_GUI_ACTION("ui_text_newline_above"); CHECK(code_edit->get_line_count() == 4); CHECK_FALSE(code_edit->is_line_executing(0)); CHECK(code_edit->is_line_executing(1)); @@ -783,11 +783,11 @@ TEST_CASE("[SceneTree][CodeEdit] line gutters") { code_edit->set_caret_line(2); /* backspace onto line does not remove executing lines. */ - SEND_GUI_ACTION(code_edit, "ui_text_backspace"); + SEND_GUI_ACTION("ui_text_backspace"); CHECK(code_edit->is_line_executing(1)); /* backspace on executing line removes it */ - SEND_GUI_ACTION(code_edit, "ui_text_backspace"); + SEND_GUI_ACTION("ui_text_backspace"); CHECK_FALSE(code_edit->is_line_executing(0)); ERR_PRINT_OFF; CHECK_FALSE(code_edit->is_line_executing(1)); @@ -801,13 +801,13 @@ TEST_CASE("[SceneTree][CodeEdit] line gutters") { code_edit->set_caret_line(1); /* Delete onto executing lines does not remove it. */ - SEND_GUI_ACTION(code_edit, "ui_text_delete"); + SEND_GUI_ACTION("ui_text_delete"); CHECK(code_edit->get_line_count() == 2); CHECK(code_edit->is_line_executing(1)); /* Delete moving executing line up removes it. */ code_edit->set_caret_line(0); - SEND_GUI_ACTION(code_edit, "ui_text_delete"); + SEND_GUI_ACTION("ui_text_delete"); CHECK(code_edit->get_line_count() == 1); ERR_PRINT_OFF; CHECK_FALSE(code_edit->is_line_executing(1)); @@ -1814,7 +1814,7 @@ TEST_CASE("[SceneTree][CodeEdit] indent") { CHECK(code_edit->get_line(0) == "\t"); /* Check input action. */ - SEND_GUI_ACTION(code_edit, "ui_text_indent"); + SEND_GUI_ACTION("ui_text_indent"); CHECK(code_edit->get_line(0) == "\t\t"); /* Insert in place. */ @@ -1887,7 +1887,7 @@ TEST_CASE("[SceneTree][CodeEdit] indent") { CHECK(code_edit->get_line(0) == " "); /* Check input action. */ - SEND_GUI_ACTION(code_edit, "ui_text_indent"); + SEND_GUI_ACTION("ui_text_indent"); CHECK(code_edit->get_line(0) == " "); /* Insert in place. */ @@ -1985,7 +1985,7 @@ TEST_CASE("[SceneTree][CodeEdit] indent") { /* Check input action. */ code_edit->set_text("\t\ttest"); - SEND_GUI_ACTION(code_edit, "ui_text_dedent"); + SEND_GUI_ACTION("ui_text_dedent"); CHECK(code_edit->get_line(0) == "\ttest"); /* Selection does entire line. */ @@ -2076,7 +2076,7 @@ TEST_CASE("[SceneTree][CodeEdit] indent") { /* Check input action. */ code_edit->set_text(" test"); - SEND_GUI_ACTION(code_edit, "ui_text_dedent"); + SEND_GUI_ACTION("ui_text_dedent"); CHECK(code_edit->get_line(0) == " test"); /* Selection does entire line. */ @@ -2124,28 +2124,28 @@ TEST_CASE("[SceneTree][CodeEdit] indent") { /* Simple indent on new line. */ code_edit->set_text(""); code_edit->insert_text_at_caret("test:"); - SEND_GUI_ACTION(code_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); CHECK(code_edit->get_line(0) == "test:"); CHECK(code_edit->get_line(1) == "\t"); /* new blank line should still indent. */ code_edit->set_text(""); code_edit->insert_text_at_caret("test:"); - SEND_GUI_ACTION(code_edit, "ui_text_newline_blank"); + SEND_GUI_ACTION("ui_text_newline_blank"); CHECK(code_edit->get_line(0) == "test:"); CHECK(code_edit->get_line(1) == "\t"); /* new line above should not indent. */ code_edit->set_text(""); code_edit->insert_text_at_caret("test:"); - SEND_GUI_ACTION(code_edit, "ui_text_newline_above"); + SEND_GUI_ACTION("ui_text_newline_above"); CHECK(code_edit->get_line(0) == ""); CHECK(code_edit->get_line(1) == "test:"); /* Whitespace between symbol and caret is okay. */ code_edit->set_text(""); code_edit->insert_text_at_caret("test: "); - SEND_GUI_ACTION(code_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); CHECK(code_edit->get_line(0) == "test: "); CHECK(code_edit->get_line(1) == "\t"); @@ -2153,7 +2153,7 @@ TEST_CASE("[SceneTree][CodeEdit] indent") { code_edit->add_comment_delimiter("#", ""); code_edit->set_text(""); code_edit->insert_text_at_caret("test: # comment"); - SEND_GUI_ACTION(code_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); CHECK(code_edit->get_line(0) == "test: # comment"); CHECK(code_edit->get_line(1) == "\t"); code_edit->remove_comment_delimiter("#"); @@ -2162,7 +2162,7 @@ TEST_CASE("[SceneTree][CodeEdit] indent") { code_edit->add_string_delimiter("#", ""); code_edit->set_text(""); code_edit->insert_text_at_caret("test: # string"); - SEND_GUI_ACTION(code_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); CHECK(code_edit->get_line(0) == "test: # string"); CHECK(code_edit->get_line(1) == ""); code_edit->remove_string_delimiter("#"); @@ -2171,7 +2171,7 @@ TEST_CASE("[SceneTree][CodeEdit] indent") { code_edit->add_comment_delimiter("#", ""); code_edit->set_text(""); code_edit->insert_text_at_caret("test := 0 # comment"); - SEND_GUI_ACTION(code_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); CHECK(code_edit->get_line(0) == "test := 0 # comment"); CHECK(code_edit->get_line(1) == ""); code_edit->remove_comment_delimiter("#"); @@ -2179,7 +2179,7 @@ TEST_CASE("[SceneTree][CodeEdit] indent") { /* Even when there's no comments. */ code_edit->set_text(""); code_edit->insert_text_at_caret("test := 0"); - SEND_GUI_ACTION(code_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); CHECK(code_edit->get_line(0) == "test := 0"); CHECK(code_edit->get_line(1) == ""); @@ -2187,7 +2187,7 @@ TEST_CASE("[SceneTree][CodeEdit] indent") { code_edit->set_text(""); code_edit->insert_text_at_caret("test{}"); code_edit->set_caret_column(5); - SEND_GUI_ACTION(code_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); CHECK(code_edit->get_line(0) == "test{"); CHECK(code_edit->get_line(1) == "\t"); CHECK(code_edit->get_line(2) == "}"); @@ -2196,7 +2196,7 @@ TEST_CASE("[SceneTree][CodeEdit] indent") { code_edit->set_text(""); code_edit->insert_text_at_caret("test{}"); code_edit->set_caret_column(5); - SEND_GUI_ACTION(code_edit, "ui_text_newline_above"); + SEND_GUI_ACTION("ui_text_newline_above"); CHECK(code_edit->get_line(0) == ""); CHECK(code_edit->get_line(1) == "test{}"); @@ -2204,7 +2204,7 @@ TEST_CASE("[SceneTree][CodeEdit] indent") { code_edit->set_text(""); code_edit->insert_text_at_caret("test{}"); code_edit->set_caret_column(5); - SEND_GUI_ACTION(code_edit, "ui_text_newline_blank"); + SEND_GUI_ACTION("ui_text_newline_blank"); CHECK(code_edit->get_line(0) == "test{}"); CHECK(code_edit->get_line(1) == ""); } @@ -2217,28 +2217,28 @@ TEST_CASE("[SceneTree][CodeEdit] indent") { /* Simple indent on new line. */ code_edit->set_text(""); code_edit->insert_text_at_caret("test:"); - SEND_GUI_ACTION(code_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); CHECK(code_edit->get_line(0) == "test:"); CHECK(code_edit->get_line(1) == " "); /* new blank line should still indent. */ code_edit->set_text(""); code_edit->insert_text_at_caret("test:"); - SEND_GUI_ACTION(code_edit, "ui_text_newline_blank"); + SEND_GUI_ACTION("ui_text_newline_blank"); CHECK(code_edit->get_line(0) == "test:"); CHECK(code_edit->get_line(1) == " "); /* new line above should not indent. */ code_edit->set_text(""); code_edit->insert_text_at_caret("test:"); - SEND_GUI_ACTION(code_edit, "ui_text_newline_above"); + SEND_GUI_ACTION("ui_text_newline_above"); CHECK(code_edit->get_line(0) == ""); CHECK(code_edit->get_line(1) == "test:"); /* Whitespace between symbol and caret is okay. */ code_edit->set_text(""); code_edit->insert_text_at_caret("test: "); - SEND_GUI_ACTION(code_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); CHECK(code_edit->get_line(0) == "test: "); CHECK(code_edit->get_line(1) == " "); @@ -2246,7 +2246,7 @@ TEST_CASE("[SceneTree][CodeEdit] indent") { code_edit->add_comment_delimiter("#", ""); code_edit->set_text(""); code_edit->insert_text_at_caret("test: # comment"); - SEND_GUI_ACTION(code_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); CHECK(code_edit->get_line(0) == "test: # comment"); CHECK(code_edit->get_line(1) == " "); code_edit->remove_comment_delimiter("#"); @@ -2255,7 +2255,7 @@ TEST_CASE("[SceneTree][CodeEdit] indent") { code_edit->add_string_delimiter("#", ""); code_edit->set_text(""); code_edit->insert_text_at_caret("test: # string"); - SEND_GUI_ACTION(code_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); CHECK(code_edit->get_line(0) == "test: # string"); CHECK(code_edit->get_line(1) == ""); code_edit->remove_string_delimiter("#"); @@ -2264,7 +2264,7 @@ TEST_CASE("[SceneTree][CodeEdit] indent") { code_edit->add_comment_delimiter("#", ""); code_edit->set_text(""); code_edit->insert_text_at_caret("test := 0 # comment"); - SEND_GUI_ACTION(code_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); CHECK(code_edit->get_line(0) == "test := 0 # comment"); CHECK(code_edit->get_line(1) == ""); code_edit->remove_comment_delimiter("#"); @@ -2272,7 +2272,7 @@ TEST_CASE("[SceneTree][CodeEdit] indent") { /* Even when there's no comments. */ code_edit->set_text(""); code_edit->insert_text_at_caret("test := 0"); - SEND_GUI_ACTION(code_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); CHECK(code_edit->get_line(0) == "test := 0"); CHECK(code_edit->get_line(1) == ""); @@ -2280,7 +2280,7 @@ TEST_CASE("[SceneTree][CodeEdit] indent") { code_edit->set_text(""); code_edit->insert_text_at_caret("test{}"); code_edit->set_caret_column(5); - SEND_GUI_ACTION(code_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); CHECK(code_edit->get_line(0) == "test{"); CHECK(code_edit->get_line(1) == " "); CHECK(code_edit->get_line(2) == "}"); @@ -2289,7 +2289,7 @@ TEST_CASE("[SceneTree][CodeEdit] indent") { code_edit->set_text(""); code_edit->insert_text_at_caret("test{}"); code_edit->set_caret_column(5); - SEND_GUI_ACTION(code_edit, "ui_text_newline_above"); + SEND_GUI_ACTION("ui_text_newline_above"); CHECK(code_edit->get_line(0) == ""); CHECK(code_edit->get_line(1) == "test{}"); @@ -2297,7 +2297,7 @@ TEST_CASE("[SceneTree][CodeEdit] indent") { code_edit->set_text(""); code_edit->insert_text_at_caret("test{}"); code_edit->set_caret_column(5); - SEND_GUI_ACTION(code_edit, "ui_text_newline_blank"); + SEND_GUI_ACTION("ui_text_newline_blank"); CHECK(code_edit->get_line(0) == "test{}"); CHECK(code_edit->get_line(1) == ""); } @@ -2764,57 +2764,57 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { /* Check typing inserts closing pair. */ code_edit->clear(); - SEND_GUI_KEY_EVENT(code_edit, Key::BRACKETLEFT); + SEND_GUI_KEY_EVENT(Key::BRACKETLEFT); CHECK(code_edit->get_line(0) == "[]"); /* Should first match and insert smaller key. */ code_edit->clear(); - SEND_GUI_KEY_EVENT(code_edit, Key::APOSTROPHE); + SEND_GUI_KEY_EVENT(Key::APOSTROPHE); CHECK(code_edit->get_line(0) == "''"); CHECK(code_edit->get_caret_column() == 1); /* Move out from center, Should match and insert larger key. */ - SEND_GUI_ACTION(code_edit, "ui_text_caret_right"); - SEND_GUI_KEY_EVENT(code_edit, Key::APOSTROPHE); + SEND_GUI_ACTION("ui_text_caret_right"); + SEND_GUI_KEY_EVENT(Key::APOSTROPHE); CHECK(code_edit->get_line(0) == "''''''"); CHECK(code_edit->get_caret_column() == 3); /* Backspace should remove all. */ - SEND_GUI_ACTION(code_edit, "ui_text_backspace"); + SEND_GUI_ACTION("ui_text_backspace"); CHECK(code_edit->get_line(0).is_empty()); /* If in between and typing close key should "skip". */ - SEND_GUI_KEY_EVENT(code_edit, Key::BRACKETLEFT); + SEND_GUI_KEY_EVENT(Key::BRACKETLEFT); CHECK(code_edit->get_line(0) == "[]"); CHECK(code_edit->get_caret_column() == 1); - SEND_GUI_KEY_EVENT(code_edit, Key::BRACKETRIGHT); + SEND_GUI_KEY_EVENT(Key::BRACKETRIGHT); CHECK(code_edit->get_line(0) == "[]"); CHECK(code_edit->get_caret_column() == 2); /* If current is char and inserting a string, do not autocomplete. */ code_edit->clear(); - SEND_GUI_KEY_EVENT(code_edit, Key::A); - SEND_GUI_KEY_EVENT(code_edit, Key::APOSTROPHE); + SEND_GUI_KEY_EVENT(Key::A); + SEND_GUI_KEY_EVENT(Key::APOSTROPHE); CHECK(code_edit->get_line(0) == "A'"); /* If in comment, do not complete. */ code_edit->add_comment_delimiter("#", ""); code_edit->clear(); - SEND_GUI_KEY_EVENT(code_edit, Key::NUMBERSIGN); - SEND_GUI_KEY_EVENT(code_edit, Key::APOSTROPHE); + SEND_GUI_KEY_EVENT(Key::NUMBERSIGN); + SEND_GUI_KEY_EVENT(Key::APOSTROPHE); CHECK(code_edit->get_line(0) == "#'"); /* If in string, and inserting string do not complete. */ code_edit->clear(); - SEND_GUI_KEY_EVENT(code_edit, Key::APOSTROPHE); - SEND_GUI_KEY_EVENT(code_edit, Key::QUOTEDBL); + SEND_GUI_KEY_EVENT(Key::APOSTROPHE); + SEND_GUI_KEY_EVENT(Key::QUOTEDBL); CHECK(code_edit->get_line(0) == "'\"'"); /* Wrap single line selection with brackets */ code_edit->clear(); code_edit->insert_text_at_caret("abc"); code_edit->select_all(); - SEND_GUI_KEY_EVENT(code_edit, Key::BRACKETLEFT); + SEND_GUI_KEY_EVENT(Key::BRACKETLEFT); CHECK(code_edit->get_line(0) == "[abc]"); /* Caret should be after the last character of the single line selection */ @@ -2824,7 +2824,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { code_edit->clear(); code_edit->insert_text_at_caret("abc\nabc"); code_edit->select_all(); - SEND_GUI_KEY_EVENT(code_edit, Key::BRACKETLEFT); + SEND_GUI_KEY_EVENT(Key::BRACKETLEFT); CHECK(code_edit->get_text() == "[abc\nabc]"); /* Caret should be after the last character of the multi line selection */ @@ -2835,14 +2835,14 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { code_edit->clear(); code_edit->insert_text_at_caret("abc"); code_edit->select_all(); - SEND_GUI_KEY_EVENT(code_edit, Key::KEY_1); + SEND_GUI_KEY_EVENT(Key::KEY_1); CHECK(code_edit->get_text() == "1"); /* If potential multichar and single brace completion is matched, it should wrap the single. */ code_edit->clear(); code_edit->insert_text_at_caret("\'\'abc"); code_edit->select(0, 2, 0, 5); - SEND_GUI_KEY_EVENT(code_edit, Key::APOSTROPHE); + SEND_GUI_KEY_EVENT(Key::APOSTROPHE); CHECK(code_edit->get_text() == "\'\'\'abc\'"); /* If only the potential multichar brace completion is matched, it does not wrap or complete. */ @@ -2853,7 +2853,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { code_edit->clear(); code_edit->insert_text_at_caret("\'\'abc"); code_edit->select(0, 2, 0, 5); - SEND_GUI_KEY_EVENT(code_edit, Key::APOSTROPHE); + SEND_GUI_KEY_EVENT(Key::APOSTROPHE); CHECK(code_edit->get_text() == "\'\'\'"); } @@ -2977,7 +2977,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { SIGNAL_CHECK("code_completion_requested", signal_args); /* Manual request should force. */ - SEND_GUI_ACTION(code_edit, "ui_text_completion_query"); + SEND_GUI_ACTION("ui_text_completion_query"); SIGNAL_CHECK("code_completion_requested", signal_args); /* Insert prefix. */ @@ -3042,7 +3042,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { CHECK(code_edit->get_code_completion_options().size() == 1); /* Check cancel closes completion. */ - SEND_GUI_ACTION(code_edit, "ui_cancel"); + SEND_GUI_ACTION("ui_cancel"); CHECK(code_edit->get_code_completion_selected_index() == -1); code_edit->update_code_completion_options(); @@ -3065,51 +3065,51 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { code_edit->set_size(Size2(100, 100)); /* Check input. */ - SEND_GUI_ACTION(code_edit, "ui_end"); + SEND_GUI_ACTION("ui_end"); CHECK(code_edit->get_code_completion_selected_index() == 2); - SEND_GUI_ACTION(code_edit, "ui_home"); + SEND_GUI_ACTION("ui_home"); CHECK(code_edit->get_code_completion_selected_index() == 0); - SEND_GUI_ACTION(code_edit, "ui_page_down"); + SEND_GUI_ACTION("ui_page_down"); CHECK(code_edit->get_code_completion_selected_index() == 2); - SEND_GUI_ACTION(code_edit, "ui_page_up"); + SEND_GUI_ACTION("ui_page_up"); CHECK(code_edit->get_code_completion_selected_index() == 0); - SEND_GUI_ACTION(code_edit, "ui_up"); + SEND_GUI_ACTION("ui_up"); CHECK(code_edit->get_code_completion_selected_index() == 2); - SEND_GUI_ACTION(code_edit, "ui_down"); + SEND_GUI_ACTION("ui_down"); CHECK(code_edit->get_code_completion_selected_index() == 0); - SEND_GUI_KEY_EVENT(code_edit, Key::T); + SEND_GUI_KEY_EVENT(Key::T); CHECK(code_edit->get_code_completion_selected_index() == 0); - SEND_GUI_ACTION(code_edit, "ui_left"); + SEND_GUI_ACTION("ui_left"); CHECK(code_edit->get_code_completion_selected_index() == 0); - SEND_GUI_ACTION(code_edit, "ui_right"); + SEND_GUI_ACTION("ui_right"); CHECK(code_edit->get_code_completion_selected_index() == 0); - SEND_GUI_ACTION(code_edit, "ui_text_backspace"); + SEND_GUI_ACTION("ui_text_backspace"); 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(); - SEND_GUI_MOUSE_BUTTON_EVENT(code_edit, caret_pos, MouseButton::WHEEL_DOWN, 0, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(caret_pos, MouseButton::WHEEL_DOWN, 0, Key::NONE); CHECK(code_edit->get_code_completion_selected_index() == 1); - SEND_GUI_MOUSE_BUTTON_EVENT(code_edit, caret_pos, MouseButton::WHEEL_UP, 0, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(caret_pos, MouseButton::WHEEL_UP, 0, Key::NONE); 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, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(caret_pos, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); CHECK(code_edit->get_code_completion_selected_index() == 2); /* Double click inserts. */ - SEND_GUI_DOUBLE_CLICK(code_edit, caret_pos, Key::NONE); + SEND_GUI_DOUBLE_CLICK(caret_pos, Key::NONE); CHECK(code_edit->get_code_completion_selected_index() == -1); CHECK(code_edit->get_line(0) == "item_2"); @@ -3130,7 +3130,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { 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"); + SEND_GUI_ACTION("ui_text_completion_replace"); CHECK(code_edit->get_line(0) == "item_0 test"); /* Replace string. */ @@ -3139,7 +3139,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { 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"); + SEND_GUI_ACTION("ui_text_completion_replace"); CHECK(code_edit->get_line(0) == "\"item_0\""); /* Normal replace if no end is given. */ @@ -3148,7 +3148,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { 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"); + SEND_GUI_ACTION("ui_text_completion_replace"); CHECK(code_edit->get_line(0) == "\"item_0\" test"); /* Insert at completion. */ @@ -3157,7 +3157,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { 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"); + SEND_GUI_ACTION("ui_text_completion_accept"); CHECK(code_edit->get_line(0) == "item_01 test"); /* Insert at completion with string should have same output. */ @@ -3166,7 +3166,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { 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"); + SEND_GUI_ACTION("ui_text_completion_accept"); CHECK(code_edit->get_line(0) == "\"item_0\"1 test\""); /* Merge symbol at end on insert text. */ @@ -3176,7 +3176,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { 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"); + SEND_GUI_ACTION("ui_text_completion_replace"); CHECK(code_edit->get_line(0) == "item_0( test"); CHECK(code_edit->get_caret_column() == 7); @@ -3186,7 +3186,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { 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"); + SEND_GUI_ACTION("ui_text_completion_replace"); CHECK(code_edit->get_line(0) == "item_0( test"); CHECK(code_edit->get_caret_column() == 6); @@ -3196,7 +3196,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { 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"); + SEND_GUI_ACTION("ui_text_completion_replace"); CHECK(code_edit->get_line(0) == "item_0( test"); CHECK(code_edit->get_caret_column() == 7); @@ -3207,7 +3207,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { 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"); + SEND_GUI_ACTION("ui_text_completion_replace"); CHECK(code_edit->get_line(0) == "item_0() test"); CHECK(code_edit->get_caret_column() == 8); @@ -3217,7 +3217,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { 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"); + SEND_GUI_ACTION("ui_text_completion_replace"); CHECK(code_edit->get_line(0) == "item_0() test"); CHECK(code_edit->get_caret_column() == 6); @@ -3227,7 +3227,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { 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"); + SEND_GUI_ACTION("ui_text_completion_replace"); CHECK(code_edit->get_line(0) == "item_0() test"); CHECK(code_edit->get_caret_column() == 8); @@ -3240,7 +3240,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { 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"); + SEND_GUI_ACTION("ui_text_completion_replace"); CHECK(code_edit->get_line(0) == "item_0() test"); CHECK(code_edit->get_caret_column() == 7); @@ -3250,7 +3250,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { 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"); + SEND_GUI_ACTION("ui_text_completion_replace"); CHECK(code_edit->get_line(0) == "item_0( test"); CHECK(code_edit->get_caret_column() == 6); @@ -3260,7 +3260,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { 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"); + SEND_GUI_ACTION("ui_text_completion_replace"); CHECK(code_edit->get_line(0) == "item_0( test"); CHECK(code_edit->get_caret_column() == 7); @@ -3271,7 +3271,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { 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"); + SEND_GUI_ACTION("ui_text_completion_replace"); CHECK(code_edit->get_line(0) == "item_0() test"); CHECK(code_edit->get_caret_column() == 8); @@ -3281,7 +3281,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { 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"); + SEND_GUI_ACTION("ui_text_completion_replace"); CHECK(code_edit->get_line(0) == "item_0() test"); CHECK(code_edit->get_caret_column() == 6); @@ -3291,7 +3291,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { 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"); + SEND_GUI_ACTION("ui_text_completion_replace"); CHECK(code_edit->get_line(0) == "item_0() test"); CHECK(code_edit->get_caret_column() == 8); } @@ -3316,15 +3316,15 @@ TEST_CASE("[SceneTree][CodeEdit] symbol lookup") { Point2 caret_pos = code_edit->get_caret_draw_pos(); caret_pos.x += 60; - SEND_GUI_MOUSE_BUTTON_EVENT(code_edit, caret_pos, MouseButton::NONE, 0, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(caret_pos, MouseButton::NONE, 0, Key::NONE); CHECK(code_edit->get_text_for_symbol_lookup() == "this is s" + String::chr(0xFFFF) + "ome text"); SIGNAL_WATCH(code_edit, "symbol_validate"); #ifdef MACOS_ENABLED - SEND_GUI_KEY_EVENT(code_edit, Key::META); + SEND_GUI_KEY_EVENT(Key::META); #else - SEND_GUI_KEY_EVENT(code_edit, Key::CTRL); + SEND_GUI_KEY_EVENT(Key::CTRL); #endif Array signal_args; @@ -3418,7 +3418,7 @@ TEST_CASE("[SceneTree][CodeEdit] New Line") { code_edit->insert_text_at_caret("test new line"); code_edit->set_caret_line(0); code_edit->set_caret_column(13); - SEND_GUI_ACTION(code_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); CHECK(code_edit->get_line(0) == "test new line"); CHECK(code_edit->get_line(1) == ""); @@ -3427,7 +3427,7 @@ TEST_CASE("[SceneTree][CodeEdit] New Line") { code_edit->insert_text_at_caret("test new line"); code_edit->set_caret_line(0); code_edit->set_caret_column(5); - SEND_GUI_ACTION(code_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); CHECK(code_edit->get_line(0) == "test "); CHECK(code_edit->get_line(1) == "new line"); @@ -3435,7 +3435,7 @@ TEST_CASE("[SceneTree][CodeEdit] New Line") { code_edit->set_text(""); code_edit->insert_text_at_caret("test new line"); code_edit->select(0, 0, 0, 5); - SEND_GUI_ACTION(code_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); CHECK(code_edit->get_line(0) == ""); CHECK(code_edit->get_line(1) == "new line"); @@ -3443,7 +3443,7 @@ TEST_CASE("[SceneTree][CodeEdit] New Line") { code_edit->set_text(""); code_edit->insert_text_at_caret("test new line"); code_edit->select(0, 0, 0, 5); - SEND_GUI_ACTION(code_edit, "ui_text_newline_blank"); + SEND_GUI_ACTION("ui_text_newline_blank"); CHECK(code_edit->get_line(0) == "test new line"); CHECK(code_edit->get_line(1) == ""); @@ -3451,7 +3451,7 @@ TEST_CASE("[SceneTree][CodeEdit] New Line") { code_edit->set_text(""); code_edit->insert_text_at_caret("test new line"); code_edit->select(0, 0, 0, 5); - SEND_GUI_ACTION(code_edit, "ui_text_newline_above"); + SEND_GUI_ACTION("ui_text_newline_above"); CHECK(code_edit->get_line(0) == ""); CHECK(code_edit->get_line(1) == "test new line"); diff --git a/tests/scene/test_text_edit.h b/tests/scene/test_text_edit.h index a9730ce820..64ad3bd5b0 100644 --- a/tests/scene/test_text_edit.h +++ b/tests/scene/test_text_edit.h @@ -607,7 +607,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { ERR_PRINT_ON; text_edit->set_text("test\nselection"); - SEND_GUI_ACTION(text_edit, "ui_text_select_all"); + SEND_GUI_ACTION("ui_text_select_all"); CHECK(text_edit->get_viewport()->is_input_handled()); MessageQueue::get_singleton()->flush(); CHECK(text_edit->get_selected_text() == "test\nselection"); @@ -678,7 +678,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { CHECK_FALSE(text_edit->has_selection()); CHECK(text_edit->get_selected_text() == ""); - SEND_GUI_ACTION(text_edit, "ui_text_select_word_under_caret"); + SEND_GUI_ACTION("ui_text_select_word_under_caret"); CHECK(text_edit->get_viewport()->is_input_handled()); MessageQueue::get_singleton()->flush(); CHECK(text_edit->has_selection(0)); @@ -836,48 +836,48 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { text_edit->set_text("test"); text_edit->grab_focus(); - SEND_GUI_KEY_EVENT(text_edit, Key::RIGHT | KeyModifierMask::SHIFT) + SEND_GUI_KEY_EVENT(Key::RIGHT | KeyModifierMask::SHIFT) CHECK(text_edit->has_selection()); CHECK(text_edit->get_selected_text() == "t"); #ifdef MACOS_ENABLED - SEND_GUI_KEY_EVENT(text_edit, Key::RIGHT | KeyModifierMask::SHIFT | KeyModifierMask::ALT) + SEND_GUI_KEY_EVENT(Key::RIGHT | KeyModifierMask::SHIFT | KeyModifierMask::ALT) #else - SEND_GUI_KEY_EVENT(text_edit, Key::RIGHT | KeyModifierMask::SHIFT | KeyModifierMask::CMD_OR_CTRL) + SEND_GUI_KEY_EVENT(Key::RIGHT | KeyModifierMask::SHIFT | KeyModifierMask::CMD_OR_CTRL) #endif CHECK(text_edit->has_selection()); CHECK(text_edit->get_selected_text() == "test"); - SEND_GUI_KEY_EVENT(text_edit, Key::LEFT | KeyModifierMask::SHIFT) + SEND_GUI_KEY_EVENT(Key::LEFT | KeyModifierMask::SHIFT) CHECK(text_edit->has_selection()); CHECK(text_edit->get_selected_text() == "tes"); #ifdef MACOS_ENABLED - SEND_GUI_KEY_EVENT(text_edit, Key::LEFT | KeyModifierMask::SHIFT | KeyModifierMask::ALT) + SEND_GUI_KEY_EVENT(Key::LEFT | KeyModifierMask::SHIFT | KeyModifierMask::ALT) #else - SEND_GUI_KEY_EVENT(text_edit, Key::LEFT | KeyModifierMask::SHIFT | KeyModifierMask::CMD_OR_CTRL) + SEND_GUI_KEY_EVENT(Key::LEFT | KeyModifierMask::SHIFT | KeyModifierMask::CMD_OR_CTRL) #endif CHECK_FALSE(text_edit->has_selection()); CHECK(text_edit->get_selected_text() == ""); - SEND_GUI_KEY_EVENT(text_edit, Key::RIGHT | KeyModifierMask::SHIFT) + SEND_GUI_KEY_EVENT(Key::RIGHT | KeyModifierMask::SHIFT) CHECK(text_edit->has_selection()); CHECK(text_edit->get_selected_text() == "t"); - SEND_GUI_KEY_EVENT(text_edit, Key::RIGHT) + SEND_GUI_KEY_EVENT(Key::RIGHT) CHECK_FALSE(text_edit->has_selection()); CHECK(text_edit->get_selected_text() == ""); - SEND_GUI_KEY_EVENT(text_edit, Key::LEFT | KeyModifierMask::SHIFT) + SEND_GUI_KEY_EVENT(Key::LEFT | KeyModifierMask::SHIFT) CHECK(text_edit->has_selection()); CHECK(text_edit->get_selected_text() == "t"); - SEND_GUI_KEY_EVENT(text_edit, Key::LEFT) + SEND_GUI_KEY_EVENT(Key::LEFT) CHECK_FALSE(text_edit->has_selection()); CHECK(text_edit->get_selected_text() == ""); text_edit->set_selecting_enabled(false); - SEND_GUI_KEY_EVENT(text_edit, Key::RIGHT | KeyModifierMask::SHIFT) + SEND_GUI_KEY_EVENT(Key::RIGHT | KeyModifierMask::SHIFT) CHECK_FALSE(text_edit->has_selection()); CHECK(text_edit->get_selected_text() == ""); text_edit->set_selecting_enabled(true); @@ -891,8 +891,8 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { text_edit->grab_focus(); MessageQueue::get_singleton()->flush(); - SEND_GUI_MOUSE_BUTTON_EVENT(text_edit, text_edit->get_pos_at_line_column(0, 1), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); - SEND_GUI_MOUSE_MOTION_EVENT(text_edit, text_edit->get_pos_at_line_column(0, 7), MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_pos_at_line_column(0, 1), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_pos_at_line_column(0, 7), MouseButtonMask::LEFT, Key::NONE); CHECK(text_edit->has_selection()); CHECK(text_edit->get_selected_text() == "for s"); CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_POINTER); @@ -903,12 +903,12 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { CHECK(text_edit->get_caret_line() == 1); CHECK(text_edit->get_caret_column() == 5); - SEND_GUI_MOUSE_BUTTON_EVENT(text_edit, text_edit->get_pos_at_line_column(0, 9), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_pos_at_line_column(0, 9), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); CHECK_FALSE(text_edit->has_selection()); text_edit->set_selecting_enabled(false); - SEND_GUI_MOUSE_BUTTON_EVENT(text_edit, text_edit->get_pos_at_line_column(0, 1), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); - SEND_GUI_MOUSE_MOTION_EVENT(text_edit, text_edit->get_pos_at_line_column(0, 7), MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_pos_at_line_column(0, 1), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_pos_at_line_column(0, 7), MouseButtonMask::LEFT, Key::NONE); CHECK_FALSE(text_edit->has_selection()); CHECK(text_edit->get_caret_line() == 1); CHECK(text_edit->get_caret_column() == 5); @@ -923,7 +923,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { MessageQueue::get_singleton()->flush(); SIGNAL_DISCARD("caret_changed"); - SEND_GUI_DOUBLE_CLICK(text_edit, text_edit->get_pos_at_line_column(0, 2), Key::NONE); + SEND_GUI_DOUBLE_CLICK(text_edit->get_pos_at_line_column(0, 2), Key::NONE); CHECK(text_edit->has_selection()); CHECK(text_edit->get_selected_text() == "for"); CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_WORD); @@ -935,7 +935,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { CHECK(text_edit->get_caret_column() == 3); SIGNAL_CHECK("caret_changed", empty_signal_args); - SEND_GUI_MOUSE_MOTION_EVENT(text_edit, text_edit->get_pos_at_line_column(0, 7), MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_pos_at_line_column(0, 7), MouseButtonMask::LEFT, Key::NONE); CHECK(text_edit->has_selection()); CHECK(text_edit->get_selected_text() == "for selection"); CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_WORD); @@ -949,11 +949,11 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { Point2i line_0 = text_edit->get_pos_at_line_column(0, 0); line_0.y /= 2; - SEND_GUI_MOUSE_BUTTON_EVENT(text_edit, line_0, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(line_0, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); CHECK_FALSE(text_edit->has_selection()); text_edit->set_selecting_enabled(false); - SEND_GUI_DOUBLE_CLICK(text_edit, text_edit->get_pos_at_line_column(0, 2), Key::NONE); + SEND_GUI_DOUBLE_CLICK(text_edit->get_pos_at_line_column(0, 2), Key::NONE); CHECK_FALSE(text_edit->has_selection()); CHECK(text_edit->get_caret_line() == 1); CHECK(text_edit->get_caret_column() == 3); @@ -967,8 +967,8 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { text_edit->set_text("this is some text\nfor selection"); MessageQueue::get_singleton()->flush(); - SEND_GUI_DOUBLE_CLICK(text_edit, text_edit->get_pos_at_line_column(0, 2), Key::NONE); - SEND_GUI_MOUSE_BUTTON_EVENT(text_edit, text_edit->get_pos_at_line_column(0, 2), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_DOUBLE_CLICK(text_edit->get_pos_at_line_column(0, 2), Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_pos_at_line_column(0, 2), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); CHECK(text_edit->has_selection()); CHECK(text_edit->get_selected_text() == "for selection"); CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_LINE); @@ -981,12 +981,12 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { Point2i line_0 = text_edit->get_pos_at_line_column(0, 0); line_0.y /= 2; - SEND_GUI_MOUSE_BUTTON_EVENT(text_edit, line_0, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(line_0, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); CHECK_FALSE(text_edit->has_selection()); text_edit->set_selecting_enabled(false); - SEND_GUI_DOUBLE_CLICK(text_edit, text_edit->get_pos_at_line_column(0, 2), Key::NONE); - SEND_GUI_MOUSE_BUTTON_EVENT(text_edit, text_edit->get_pos_at_line_column(0, 2), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_DOUBLE_CLICK(text_edit->get_pos_at_line_column(0, 2), Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_pos_at_line_column(0, 2), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); CHECK_FALSE(text_edit->has_selection()); CHECK(text_edit->get_caret_line() == 1); CHECK(text_edit->get_caret_column() == 0); @@ -1000,8 +1000,8 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { text_edit->set_text("this is some text\nfor selection"); MessageQueue::get_singleton()->flush(); - SEND_GUI_MOUSE_BUTTON_EVENT(text_edit, text_edit->get_pos_at_line_column(0, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); - SEND_GUI_MOUSE_BUTTON_EVENT(text_edit, text_edit->get_pos_at_line_column(0, 7), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE | KeyModifierMask::SHIFT); + SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_pos_at_line_column(0, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_pos_at_line_column(0, 7), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE | KeyModifierMask::SHIFT); CHECK(text_edit->has_selection()); CHECK(text_edit->get_selected_text() == "for s"); CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_POINTER); @@ -1012,12 +1012,12 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { CHECK(text_edit->get_caret_line() == 1); CHECK(text_edit->get_caret_column() == 5); - SEND_GUI_MOUSE_BUTTON_EVENT(text_edit, text_edit->get_pos_at_line_column(0, 9), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_pos_at_line_column(0, 9), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); CHECK_FALSE(text_edit->has_selection()); text_edit->set_selecting_enabled(false); - SEND_GUI_MOUSE_BUTTON_EVENT(text_edit, text_edit->get_pos_at_line_column(0, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); - SEND_GUI_MOUSE_BUTTON_EVENT(text_edit, text_edit->get_pos_at_line_column(0, 7), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE | KeyModifierMask::SHIFT); + SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_pos_at_line_column(0, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_pos_at_line_column(0, 7), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE | KeyModifierMask::SHIFT); CHECK_FALSE(text_edit->has_selection()); CHECK(text_edit->get_caret_line() == 1); CHECK(text_edit->get_caret_column() == 5); @@ -1061,7 +1061,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { text_edit->select(0, 8, 0, 4); CHECK(text_edit->has_selection()); - SEND_GUI_ACTION(text_edit, "ui_text_caret_right"); + SEND_GUI_ACTION("ui_text_caret_right"); CHECK_FALSE(text_edit->has_selection()); text_edit->delete_selection(); @@ -1071,7 +1071,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { text_edit->select(0, 8, 0, 4); CHECK(text_edit->has_selection()); - SEND_GUI_ACTION(text_edit, "ui_text_backspace"); + SEND_GUI_ACTION("ui_text_backspace"); CHECK(text_edit->get_text() == "thissome text\nfor selection"); CHECK(text_edit->get_caret_line() == 0); CHECK(text_edit->get_caret_column() == 4); @@ -1134,7 +1134,6 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SUBCASE("[TextEdit] text drag") { TextEdit *target_text_edit = memnew(TextEdit); SceneTree::get_singleton()->get_root()->add_child(target_text_edit); - text_edit->get_viewport()->set_embedding_subwindows(true); // Bypass display server for drop handling. target_text_edit->set_size(Size2(200, 200)); target_text_edit->set_position(Point2(400, 0)); @@ -1149,19 +1148,19 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { Point2i line_0 = text_edit->get_pos_at_line_column(0, 0); line_0.y /= 2; - SEND_GUI_MOUSE_BUTTON_EVENT(text_edit, line_0, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(line_0, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); CHECK(text_edit->is_mouse_over_selection()); - SEND_GUI_MOUSE_MOTION_EVENT(text_edit, text_edit->get_pos_at_line_column(0, 7), MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_pos_at_line_column(0, 7), MouseButtonMask::LEFT, Key::NONE); CHECK(text_edit->get_viewport()->gui_is_dragging()); CHECK(text_edit->get_viewport()->gui_get_drag_data() == "drag me"); line_0 = target_text_edit->get_pos_at_line_column(0, 0); line_0.y /= 2; line_0.x += 401; // As empty add one. - SEND_GUI_MOUSE_MOTION_EVENT(target_text_edit, line_0, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_MOTION_EVENT(line_0, MouseButtonMask::LEFT, Key::NONE); CHECK(text_edit->get_viewport()->gui_is_dragging()); - SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(target_text_edit, line_0, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(line_0, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); CHECK_FALSE(text_edit->get_viewport()->gui_is_dragging()); CHECK(text_edit->get_text() == ""); @@ -1324,7 +1323,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { ((Array)lines_edited_args[0])[0] = 0; text_edit->select(0, 5, 0, 7); ERR_PRINT_OFF; - SEND_GUI_ACTION(text_edit, "ui_cut"); + SEND_GUI_ACTION("ui_cut"); CHECK(text_edit->get_viewport()->is_input_handled()); MessageQueue::get_singleton()->flush(); ERR_PRINT_ON; // Can't check display server content. @@ -1401,7 +1400,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { lines_edited_args.push_front(args2); ((Array)lines_edited_args[1])[1] = 1; - SEND_GUI_ACTION(text_edit, "ui_text_newline_above"); + SEND_GUI_ACTION("ui_text_newline_above"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == "\nthis is some test text.\n\nthis is some test text."); CHECK(text_edit->get_caret_line() == 0); @@ -1424,7 +1423,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_DISCARD("caret_changed"); text_edit->set_editable(false); - SEND_GUI_ACTION(text_edit, "ui_text_newline_above"); + SEND_GUI_ACTION("ui_text_newline_above"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == "\nthis is some test text.\n\nthis is some test text."); CHECK(text_edit->get_caret_line() == 1); @@ -1442,7 +1441,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { ((Array)lines_edited_args[0])[0] = 2; ((Array)lines_edited_args[0])[1] = 3; - SEND_GUI_ACTION(text_edit, "ui_text_newline_above"); + SEND_GUI_ACTION("ui_text_newline_above"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == "\n\nthis is some test text.\n\n\nthis is some test text."); CHECK(text_edit->get_caret_line() == 1); @@ -1480,7 +1479,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { lines_edited_args.push_front(args2); ((Array)lines_edited_args[1])[1] = 1; - SEND_GUI_ACTION(text_edit, "ui_text_newline_blank"); + SEND_GUI_ACTION("ui_text_newline_blank"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == "this is some test text.\n\nthis is some test text.\n"); CHECK(text_edit->get_caret_line() == 1); @@ -1495,7 +1494,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK("lines_edited_from", lines_edited_args); text_edit->set_editable(false); - SEND_GUI_ACTION(text_edit, "ui_text_newline_blank"); + SEND_GUI_ACTION("ui_text_newline_blank"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == "this is some test text.\n\nthis is some test text.\n"); CHECK(text_edit->get_caret_line() == 1); @@ -1538,7 +1537,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { lines_edited_args.push_back(lines_edited_args[2].duplicate()); ((Array)lines_edited_args[3])[1] = 1; - SEND_GUI_ACTION(text_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == "\n is some test text.\n\n is some test text."); CHECK(text_edit->get_caret_line() == 1); @@ -1553,7 +1552,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK("lines_edited_from", lines_edited_args); text_edit->set_editable(false); - SEND_GUI_ACTION(text_edit, "ui_text_newline"); + SEND_GUI_ACTION("ui_text_newline"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == "\n is some test text.\n\n is some test text."); CHECK(text_edit->get_caret_line() == 1); @@ -1599,7 +1598,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { ((Array)lines_edited_args[1])[0] = 1; ((Array)lines_edited_args[1])[1] = 1; - SEND_GUI_ACTION(text_edit, "ui_text_backspace_all_to_left"); + SEND_GUI_ACTION("ui_text_backspace_all_to_left"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == "\n is some test text.\n\n is some test text."); CHECK(text_edit->get_caret_line() == 1); @@ -1617,7 +1616,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { ((Array)lines_edited_args[1])[1] = 0; // Start of line should also be a normal backspace. - SEND_GUI_ACTION(text_edit, "ui_text_backspace_all_to_left"); + SEND_GUI_ACTION("ui_text_backspace_all_to_left"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == " is some test text.\n is some test text."); CHECK(text_edit->get_caret_line() == 0); @@ -1641,7 +1640,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_DISCARD("caret_changed"); text_edit->set_editable(false); - SEND_GUI_ACTION(text_edit, "ui_text_backspace_all_to_left"); + SEND_GUI_ACTION("ui_text_backspace_all_to_left"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == " is some test text.\n is some test text."); CHECK(text_edit->get_caret_line() == 0); @@ -1660,7 +1659,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { ((Array)lines_edited_args[0])[1] = 1; ((Array)lines_edited_args[1])[0] = 0; - SEND_GUI_ACTION(text_edit, "ui_text_backspace_all_to_left"); + SEND_GUI_ACTION("ui_text_backspace_all_to_left"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == "\n"); CHECK(text_edit->get_caret_line() == 0); @@ -1703,7 +1702,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { ((Array)lines_edited_args[1])[0] = 1; ((Array)lines_edited_args[1])[1] = 1; - SEND_GUI_ACTION(text_edit, "ui_text_backspace_word"); + SEND_GUI_ACTION("ui_text_backspace_word"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == "\n is some test text.\n\n is some test text."); CHECK(text_edit->get_caret_line() == 1); @@ -1722,7 +1721,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { ((Array)lines_edited_args[1])[1] = 0; // Start of line should also be a normal backspace. - SEND_GUI_ACTION(text_edit, "ui_text_backspace_word"); + SEND_GUI_ACTION("ui_text_backspace_word"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == " is some test text.\n is some test text."); CHECK(text_edit->get_caret_line() == 0); @@ -1737,7 +1736,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK("lines_edited_from", lines_edited_args); text_edit->set_editable(false); - SEND_GUI_ACTION(text_edit, "ui_text_backspace_word"); + SEND_GUI_ACTION("ui_text_backspace_word"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == " is some test text.\n is some test text."); CHECK(text_edit->get_caret_line() == 0); @@ -1765,7 +1764,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { ((Array)lines_edited_args[0])[1] = 1; ((Array)lines_edited_args[1])[0] = 0; - SEND_GUI_ACTION(text_edit, "ui_text_backspace_word"); + SEND_GUI_ACTION("ui_text_backspace_word"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == " is some test \n is some test "); CHECK(text_edit->get_caret_line() == 0); @@ -1807,7 +1806,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { ((Array)lines_edited_args[1])[0] = 1; ((Array)lines_edited_args[1])[1] = 1; - SEND_GUI_ACTION(text_edit, "ui_text_backspace"); + SEND_GUI_ACTION("ui_text_backspace"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == "\n is some test text.\n\n is some test text."); CHECK(text_edit->get_caret_line() == 1); @@ -1825,7 +1824,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { ((Array)lines_edited_args[1])[1] = 0; // Start of line should also be a normal backspace. - SEND_GUI_ACTION(text_edit, "ui_text_backspace"); + SEND_GUI_ACTION("ui_text_backspace"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == " is some test text.\n is some test text."); CHECK(text_edit->get_caret_line() == 0); @@ -1849,7 +1848,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_DISCARD("caret_changed"); text_edit->set_editable(false); - SEND_GUI_ACTION(text_edit, "ui_text_backspace"); + SEND_GUI_ACTION("ui_text_backspace"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == " is some test text.\n is some test text."); CHECK(text_edit->get_caret_line() == 0); @@ -1868,7 +1867,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { ((Array)lines_edited_args[0])[1] = 1; ((Array)lines_edited_args[1])[0] = 0; - SEND_GUI_ACTION(text_edit, "ui_text_backspace"); + SEND_GUI_ACTION("ui_text_backspace"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == " is some test text\n is some test text"); CHECK(text_edit->get_caret_line() == 0); @@ -1897,7 +1896,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_DISCARD("lines_edited_from"); SIGNAL_DISCARD("caret_changed"); - SEND_GUI_ACTION(text_edit, "ui_text_backspace"); + SEND_GUI_ACTION("ui_text_backspace"); CHECK(text_edit->get_text() == "\n"); CHECK(text_edit->get_caret_line() == 0); CHECK(text_edit->get_caret_column() == 0); @@ -1935,7 +1934,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { lines_edited_args.push_front(args2); // With selection should be a normal delete. - SEND_GUI_ACTION(text_edit, "ui_text_delete_all_to_right"); + SEND_GUI_ACTION("ui_text_delete_all_to_right"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == " is some test text.\n is some test text.\n"); CHECK(text_edit->get_caret_line() == 0); @@ -1959,7 +1958,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_DISCARD("lines_edited_from"); SIGNAL_DISCARD("caret_changed"); - SEND_GUI_ACTION(text_edit, "ui_text_delete_all_to_right"); + SEND_GUI_ACTION("ui_text_delete_all_to_right"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == " is some test text.\n is some test text.\n"); CHECK(text_edit->get_caret_line() == 0); @@ -1983,7 +1982,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_DISCARD("caret_changed"); text_edit->set_editable(false); - SEND_GUI_ACTION(text_edit, "ui_text_delete_all_to_right"); + SEND_GUI_ACTION("ui_text_delete_all_to_right"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == " is some test text.\n is some test text.\n"); CHECK(text_edit->get_caret_line() == 0); @@ -1998,7 +1997,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK_FALSE("lines_edited_from"); text_edit->set_editable(true); - SEND_GUI_ACTION(text_edit, "ui_text_delete_all_to_right"); + SEND_GUI_ACTION("ui_text_delete_all_to_right"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == "\n\n"); CHECK(text_edit->get_caret_line() == 0); @@ -2042,7 +2041,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { lines_edited_args.push_front(args2); // With selection should be a normal delete. - SEND_GUI_ACTION(text_edit, "ui_text_delete_word"); + SEND_GUI_ACTION("ui_text_delete_word"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == " ffi some test text.\n\n ffi some test text.\n"); CHECK(text_edit->get_caret_line() == 0); @@ -2068,7 +2067,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_DISCARD("lines_edited_from"); SIGNAL_DISCARD("caret_changed"); - SEND_GUI_ACTION(text_edit, "ui_text_delete_word"); + SEND_GUI_ACTION("ui_text_delete_word"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == " ffi some test text.\n ffi some test text."); CHECK(text_edit->get_caret_line() == 0); @@ -2095,7 +2094,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_DISCARD("caret_changed"); text_edit->set_editable(false); - SEND_GUI_ACTION(text_edit, "ui_text_delete_word"); + SEND_GUI_ACTION("ui_text_delete_word"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == " ffi some test text.\n ffi some test text."); CHECK(text_edit->get_caret_line() == 0); @@ -2110,7 +2109,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK_FALSE("lines_edited_from"); text_edit->set_editable(true); - SEND_GUI_ACTION(text_edit, "ui_text_delete_word"); + SEND_GUI_ACTION("ui_text_delete_word"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == " some test text.\n some test text."); CHECK(text_edit->get_caret_line() == 0); @@ -2152,7 +2151,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { lines_edited_args.push_front(args2); // With selection should be a normal delete. - SEND_GUI_ACTION(text_edit, "ui_text_delete"); + SEND_GUI_ACTION("ui_text_delete"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == " ffi some test text.\n ffi some test text."); CHECK(text_edit->get_caret_line() == 0); @@ -2178,7 +2177,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_DISCARD("lines_edited_from"); SIGNAL_DISCARD("caret_changed"); - SEND_GUI_ACTION(text_edit, "ui_text_delete"); + SEND_GUI_ACTION("ui_text_delete"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == " ffi some test text. ffi some test text."); CHECK(text_edit->get_caret_line() == 0); @@ -2207,7 +2206,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_DISCARD("caret_changed"); text_edit->set_editable(false); - SEND_GUI_ACTION(text_edit, "ui_text_delete"); + SEND_GUI_ACTION("ui_text_delete"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == " ffi some test text. ffi some test text."); CHECK(text_edit->get_caret_line() == 0); @@ -2224,7 +2223,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { text_edit->start_action(TextEdit::EditAction::ACTION_NONE); - SEND_GUI_ACTION(text_edit, "ui_text_delete"); + SEND_GUI_ACTION("ui_text_delete"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == "ffi some test text.ffi some test text."); CHECK(text_edit->get_caret_line() == 0); @@ -2240,7 +2239,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { text_edit->start_action(TextEdit::EditAction::ACTION_NONE); - SEND_GUI_ACTION(text_edit, "ui_text_delete"); + SEND_GUI_ACTION("ui_text_delete"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == "fi some test text.fi some test text."); CHECK(text_edit->get_caret_line() == 0); @@ -2268,7 +2267,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_DISCARD("lines_edited_from"); SIGNAL_DISCARD("caret_changed"); - SEND_GUI_ACTION(text_edit, "ui_text_delete"); + SEND_GUI_ACTION("ui_text_delete"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == " some test text. some test text."); CHECK(text_edit->get_caret_line() == 0); @@ -2299,9 +2298,9 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { // Shift should select. #ifdef MACOS_ENABLED - SEND_GUI_KEY_EVENT(text_edit, Key::LEFT | KeyModifierMask::ALT | KeyModifierMask::SHIFT); + SEND_GUI_KEY_EVENT(Key::LEFT | KeyModifierMask::ALT | KeyModifierMask::SHIFT); #else - SEND_GUI_KEY_EVENT(text_edit, Key::LEFT | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); + SEND_GUI_KEY_EVENT(Key::LEFT | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); #endif CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 1); @@ -2319,7 +2318,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK_FALSE("lines_edited_from"); // Should still move caret with selection. - SEND_GUI_ACTION(text_edit, "ui_text_caret_word_left"); + SEND_GUI_ACTION("ui_text_caret_word_left"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 1); CHECK(text_edit->get_caret_column() == 0); @@ -2334,7 +2333,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK_FALSE("lines_edited_from"); // Normal word left. - SEND_GUI_ACTION(text_edit, "ui_text_caret_word_left"); + SEND_GUI_ACTION("ui_text_caret_word_left"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 0); CHECK(text_edit->get_caret_column() == 0); @@ -2366,7 +2365,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_DISCARD("caret_changed"); // Normal left should deselect and place at selection start. - SEND_GUI_ACTION(text_edit, "ui_text_caret_left"); + SEND_GUI_ACTION("ui_text_caret_left"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 1); @@ -2382,7 +2381,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK_FALSE("lines_edited_from"); // With shift should select. - SEND_GUI_KEY_EVENT(text_edit, Key::LEFT | KeyModifierMask::SHIFT); + SEND_GUI_KEY_EVENT(Key::LEFT | KeyModifierMask::SHIFT); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 1); CHECK(text_edit->get_caret_column() == 1); @@ -2399,7 +2398,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK_FALSE("lines_edited_from"); // All ready at select left, should only deselect. - SEND_GUI_ACTION(text_edit, "ui_text_caret_left"); + SEND_GUI_ACTION("ui_text_caret_left"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 1); CHECK(text_edit->get_caret_column() == 1); @@ -2414,7 +2413,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK_FALSE("lines_edited_from"); // Normal left. - SEND_GUI_ACTION(text_edit, "ui_text_caret_left"); + SEND_GUI_ACTION("ui_text_caret_left"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 1); CHECK(text_edit->get_caret_column() == 0); @@ -2428,7 +2427,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK_FALSE("lines_edited_from"); // Left at col 0 should go up a line. - SEND_GUI_ACTION(text_edit, "ui_text_caret_left"); + SEND_GUI_ACTION("ui_text_caret_left"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 0); CHECK(text_edit->get_caret_column() == 0); @@ -2459,9 +2458,9 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { // Shift should select. #ifdef MACOS_ENABLED - SEND_GUI_KEY_EVENT(text_edit, Key::RIGHT | KeyModifierMask::ALT | KeyModifierMask::SHIFT); + SEND_GUI_KEY_EVENT(Key::RIGHT | KeyModifierMask::ALT | KeyModifierMask::SHIFT); #else - SEND_GUI_KEY_EVENT(text_edit, Key::RIGHT | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); + SEND_GUI_KEY_EVENT(Key::RIGHT | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); #endif CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 0); @@ -2479,7 +2478,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK_FALSE("lines_edited_from"); // Should still move caret with selection. - SEND_GUI_ACTION(text_edit, "ui_text_caret_word_right"); + SEND_GUI_ACTION("ui_text_caret_word_right"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 0); CHECK(text_edit->get_caret_column() == 22); @@ -2494,7 +2493,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK_FALSE("lines_edited_from"); // Normal word right. - SEND_GUI_ACTION(text_edit, "ui_text_caret_word_right"); + SEND_GUI_ACTION("ui_text_caret_word_right"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 1); CHECK(text_edit->get_caret_column() == 0); @@ -2526,7 +2525,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_DISCARD("caret_changed"); // Normal right should deselect and place at selection start. - SEND_GUI_ACTION(text_edit, "ui_text_caret_right"); + SEND_GUI_ACTION("ui_text_caret_right"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 0); CHECK(text_edit->get_caret_column() == 20); @@ -2541,7 +2540,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK_FALSE("lines_edited_from"); // With shift should select. - SEND_GUI_KEY_EVENT(text_edit, Key::RIGHT | KeyModifierMask::SHIFT); + SEND_GUI_KEY_EVENT(Key::RIGHT | KeyModifierMask::SHIFT); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 0); CHECK(text_edit->get_caret_column() == 21); @@ -2558,7 +2557,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK_FALSE("lines_edited_from"); // All ready at select right, should only deselect. - SEND_GUI_ACTION(text_edit, "ui_text_caret_right"); + SEND_GUI_ACTION("ui_text_caret_right"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 0); CHECK(text_edit->get_caret_column() == 21); @@ -2572,7 +2571,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK_FALSE("lines_edited_from"); // Normal right. - SEND_GUI_ACTION(text_edit, "ui_text_caret_right"); + SEND_GUI_ACTION("ui_text_caret_right"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 0); CHECK(text_edit->get_caret_column() == 22); @@ -2586,7 +2585,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK_FALSE("lines_edited_from"); // Right at end col should go down a line. - SEND_GUI_ACTION(text_edit, "ui_text_caret_right"); + SEND_GUI_ACTION("ui_text_caret_right"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 1); CHECK(text_edit->get_caret_column() == 0); @@ -2620,7 +2619,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_DISCARD("caret_changed"); // Select + up should select everything to the left on that line. - SEND_GUI_KEY_EVENT(text_edit, Key::UP | KeyModifierMask::SHIFT); + SEND_GUI_KEY_EVENT(Key::UP | KeyModifierMask::SHIFT); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 2); CHECK(text_edit->get_caret_column() == 5); @@ -2636,7 +2635,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK_FALSE("lines_edited_from"); // Should deselect and move up. - SEND_GUI_ACTION(text_edit, "ui_text_caret_up"); + SEND_GUI_ACTION("ui_text_caret_up"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 1); CHECK(text_edit->get_caret_column() == 8); @@ -2650,7 +2649,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK_FALSE("lines_edited_from"); // Normal up over wrapped line. - SEND_GUI_ACTION(text_edit, "ui_text_caret_up"); + SEND_GUI_ACTION("ui_text_caret_up"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 0); CHECK(text_edit->get_caret_column() == 12); @@ -2665,7 +2664,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { text_edit->set_caret_column(12, false); // Normal up over wrapped line to line 0. - SEND_GUI_ACTION(text_edit, "ui_text_caret_up"); + SEND_GUI_ACTION("ui_text_caret_up"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 0); CHECK(text_edit->get_caret_column() == 7); @@ -2699,7 +2698,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_DISCARD("caret_changed"); // Select + down should select everything to the right on that line. - SEND_GUI_KEY_EVENT(text_edit, Key::DOWN | KeyModifierMask::SHIFT); + SEND_GUI_KEY_EVENT(Key::DOWN | KeyModifierMask::SHIFT); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 1); CHECK(text_edit->get_caret_column() == 5); @@ -2715,7 +2714,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK_FALSE("lines_edited_from"); // Should deselect and move down. - SEND_GUI_ACTION(text_edit, "ui_text_caret_down"); + SEND_GUI_ACTION("ui_text_caret_down"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 2); CHECK(text_edit->get_caret_column() == 8); @@ -2729,7 +2728,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK_FALSE("lines_edited_from"); // Normal down over wrapped line. - SEND_GUI_ACTION(text_edit, "ui_text_caret_down"); + SEND_GUI_ACTION("ui_text_caret_down"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 3); CHECK(text_edit->get_caret_column() == 7); @@ -2744,7 +2743,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { text_edit->set_caret_column(7, false); // Normal down over wrapped line to last wrapped line. - SEND_GUI_ACTION(text_edit, "ui_text_caret_down"); + SEND_GUI_ACTION("ui_text_caret_down"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 3); CHECK(text_edit->get_caret_column() == 12); @@ -2778,9 +2777,9 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_DISCARD("caret_changed"); #ifdef MACOS_ENABLED - SEND_GUI_KEY_EVENT(text_edit, Key::UP | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); + SEND_GUI_KEY_EVENT(Key::UP | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); #else - SEND_GUI_KEY_EVENT(text_edit, Key::HOME | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); + SEND_GUI_KEY_EVENT(Key::HOME | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); #endif CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == "this is some\nother test\nlines\ngo here"); @@ -2793,7 +2792,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK_FALSE("lines_edited_from"); CHECK(text_edit->get_caret_count() == 1); - SEND_GUI_ACTION(text_edit, "ui_text_caret_document_start"); + SEND_GUI_ACTION("ui_text_caret_document_start"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == "this is some\nother test\nlines\ngo here"); CHECK(text_edit->get_caret_line() == 0); @@ -2823,9 +2822,9 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_DISCARD("caret_changed"); #ifdef MACOS_ENABLED - SEND_GUI_KEY_EVENT(text_edit, Key::DOWN | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); + SEND_GUI_KEY_EVENT(Key::DOWN | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); #else - SEND_GUI_KEY_EVENT(text_edit, Key::END | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); + SEND_GUI_KEY_EVENT(Key::END | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); #endif CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == "go here\nlines\nother test\nthis is some"); @@ -2838,7 +2837,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK_FALSE("lines_edited_from"); CHECK(text_edit->get_caret_count() == 1); - SEND_GUI_ACTION(text_edit, "ui_text_caret_document_end"); + SEND_GUI_ACTION("ui_text_caret_document_end"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == "go here\nlines\nother test\nthis is some"); CHECK(text_edit->get_caret_line() == 3); @@ -2868,9 +2867,9 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_DISCARD("caret_changed"); #ifdef MACOS_ENABLED - SEND_GUI_KEY_EVENT(text_edit, Key::LEFT | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); + SEND_GUI_KEY_EVENT(Key::LEFT | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); #else - SEND_GUI_KEY_EVENT(text_edit, Key::HOME | KeyModifierMask::SHIFT); + SEND_GUI_KEY_EVENT(Key::HOME | KeyModifierMask::SHIFT); #endif CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 0); @@ -2886,7 +2885,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK_FALSE("text_changed"); SIGNAL_CHECK_FALSE("lines_edited_from"); - SEND_GUI_ACTION(text_edit, "ui_text_caret_line_start"); + SEND_GUI_ACTION("ui_text_caret_line_start"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 0); CHECK(text_edit->get_caret_column() == 2); @@ -2899,7 +2898,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK_FALSE("text_changed"); SIGNAL_CHECK_FALSE("lines_edited_from"); - SEND_GUI_ACTION(text_edit, "ui_text_caret_line_start"); + SEND_GUI_ACTION("ui_text_caret_line_start"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 0); CHECK(text_edit->get_caret_column() == 0); @@ -2912,7 +2911,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK_FALSE("text_changed"); SIGNAL_CHECK_FALSE("lines_edited_from"); - SEND_GUI_ACTION(text_edit, "ui_text_caret_line_start"); + SEND_GUI_ACTION("ui_text_caret_line_start"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 0); CHECK(text_edit->get_caret_column() == 2); @@ -2945,9 +2944,9 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_DISCARD("caret_changed"); #ifdef MACOS_ENABLED - SEND_GUI_KEY_EVENT(text_edit, Key::RIGHT | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); + SEND_GUI_KEY_EVENT(Key::RIGHT | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); #else - SEND_GUI_KEY_EVENT(text_edit, Key::END | KeyModifierMask::SHIFT); + SEND_GUI_KEY_EVENT(Key::END | KeyModifierMask::SHIFT); #endif CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 0); @@ -2963,7 +2962,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK_FALSE("text_changed"); SIGNAL_CHECK_FALSE("lines_edited_from"); - SEND_GUI_ACTION(text_edit, "ui_text_caret_line_end"); + SEND_GUI_ACTION("ui_text_caret_line_end"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 0); CHECK(text_edit->get_caret_column() == text_edit->get_line(0).length()); @@ -2999,7 +2998,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { args2.push_back(1); lines_edited_args.push_front(args2); - SEND_GUI_KEY_EVENT(text_edit, Key::A); + SEND_GUI_KEY_EVENT(Key::A); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == "aA\naA"); CHECK(text_edit->get_caret_column() == 2); @@ -3009,7 +3008,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK("lines_edited_from", lines_edited_args); text_edit->set_editable(false); - SEND_GUI_KEY_EVENT(text_edit, Key::A); + SEND_GUI_KEY_EVENT(Key::A); CHECK_FALSE(text_edit->get_viewport()->is_input_handled()); // Should this be handled? CHECK(text_edit->get_text() == "aA\naA"); CHECK(text_edit->get_caret_column() == 2); @@ -3024,7 +3023,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { text_edit->select(0, 0, 0, 1); text_edit->select(1, 0, 1, 1, 1); - SEND_GUI_KEY_EVENT(text_edit, Key::B); + SEND_GUI_KEY_EVENT(Key::B); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == "BA\nBA"); CHECK(text_edit->get_caret_column() == 1); @@ -3033,10 +3032,10 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { SIGNAL_CHECK("text_changed", empty_signal_args); SIGNAL_CHECK("lines_edited_from", lines_edited_args); - SEND_GUI_ACTION(text_edit, "ui_text_toggle_insert_mode"); + SEND_GUI_ACTION("ui_text_toggle_insert_mode"); CHECK(text_edit->is_overtype_mode_enabled()); - SEND_GUI_KEY_EVENT(text_edit, Key::B); + SEND_GUI_KEY_EVENT(Key::B); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == "BB\nBB"); CHECK(text_edit->get_caret_column() == 2); @@ -3046,7 +3045,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { text_edit->select(0, 0, 0, 1); text_edit->select(1, 0, 1, 1, 1); - SEND_GUI_KEY_EVENT(text_edit, Key::A); + SEND_GUI_KEY_EVENT(Key::A); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == "AB\nAB"); CHECK(text_edit->get_caret_column() == 1); @@ -3060,7 +3059,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") { lines_edited_args.remove_at(0); lines_edited_args.remove_at(1); - SEND_GUI_KEY_EVENT(text_edit, Key::TAB); + SEND_GUI_KEY_EVENT(Key::TAB); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_text() == "A\tB\nA\tB"); CHECK(text_edit->get_caret_column() == 2); @@ -3083,8 +3082,6 @@ TEST_CASE("[SceneTree][TextEdit] context menu") { TextEdit *text_edit = memnew(TextEdit); SceneTree::get_singleton()->get_root()->add_child(text_edit); - text_edit->get_viewport()->set_embedding_subwindows(true); // Bypass display server for drop handling. - text_edit->set_size(Size2(800, 200)); text_edit->set_line(0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vasius mattis leo, sed porta ex lacinia bibendum. Nunc bibendum pellentesque."); MessageQueue::get_singleton()->flush(); @@ -3093,14 +3090,14 @@ TEST_CASE("[SceneTree][TextEdit] context menu") { CHECK_FALSE(text_edit->is_context_menu_enabled()); CHECK_FALSE(text_edit->is_menu_visible()); - SEND_GUI_MOUSE_BUTTON_EVENT(text_edit, Point2i(600, 10), MouseButton::RIGHT, MouseButtonMask::RIGHT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(600, 10), MouseButton::RIGHT, MouseButtonMask::RIGHT, Key::NONE); CHECK_FALSE(text_edit->is_menu_visible()); text_edit->set_context_menu_enabled(true); CHECK(text_edit->is_context_menu_enabled()); CHECK_FALSE(text_edit->is_menu_visible()); - SEND_GUI_MOUSE_BUTTON_EVENT(text_edit, Point2i(700, 10), MouseButton::RIGHT, MouseButtonMask::RIGHT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(700, 10), MouseButton::RIGHT, MouseButtonMask::RIGHT, Key::NONE); CHECK(text_edit->is_menu_visible()); memdelete(text_edit); @@ -3281,28 +3278,28 @@ TEST_CASE("[SceneTree][TextEdit] caret") { text_edit->set_caret_mid_grapheme_enabled(true); CHECK(text_edit->is_caret_mid_grapheme_enabled()); - SEND_GUI_ACTION(text_edit, "ui_text_caret_right"); + SEND_GUI_ACTION("ui_text_caret_right"); CHECK(text_edit->get_caret_column() == 1); - SEND_GUI_ACTION(text_edit, "ui_text_caret_right"); + SEND_GUI_ACTION("ui_text_caret_right"); CHECK(text_edit->get_caret_column() == 2); - SEND_GUI_ACTION(text_edit, "ui_text_caret_right"); + SEND_GUI_ACTION("ui_text_caret_right"); CHECK(text_edit->get_caret_column() == 3); - SEND_GUI_ACTION(text_edit, "ui_text_caret_left"); + SEND_GUI_ACTION("ui_text_caret_left"); CHECK(text_edit->get_caret_column() == 2); text_edit->set_caret_mid_grapheme_enabled(false); CHECK_FALSE(text_edit->is_caret_mid_grapheme_enabled()); - SEND_GUI_ACTION(text_edit, "ui_text_caret_left"); + SEND_GUI_ACTION("ui_text_caret_left"); CHECK(text_edit->get_caret_column() == 0); - SEND_GUI_ACTION(text_edit, "ui_text_caret_right"); + SEND_GUI_ACTION("ui_text_caret_right"); CHECK(text_edit->get_caret_column() == 3); - SEND_GUI_ACTION(text_edit, "ui_text_caret_left"); + SEND_GUI_ACTION("ui_text_caret_left"); CHECK(text_edit->get_caret_column() == 0); text_edit->set_line(0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vasius mattis leo, sed porta ex lacinia bibendum. Nunc bibendum pellentesque."); @@ -3341,13 +3338,13 @@ TEST_CASE("[SceneTree][TextEdit] caret") { text_edit->set_move_caret_on_right_click_enabled(false); CHECK_FALSE(text_edit->is_move_caret_on_right_click_enabled()); - SEND_GUI_MOUSE_BUTTON_EVENT(text_edit, Point2i(100, 1), MouseButton::RIGHT, MouseButtonMask::RIGHT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(100, 1), MouseButton::RIGHT, MouseButtonMask::RIGHT, Key::NONE); CHECK(text_edit->get_caret_column() == caret_col); text_edit->set_move_caret_on_right_click_enabled(true); CHECK(text_edit->is_move_caret_on_right_click_enabled()); - SEND_GUI_MOUSE_BUTTON_EVENT(text_edit, Point2i(100, 1), MouseButton::RIGHT, MouseButtonMask::RIGHT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(100, 1), MouseButton::RIGHT, MouseButtonMask::RIGHT, Key::NONE); CHECK(text_edit->get_caret_column() != caret_col); text_edit->set_move_caret_on_right_click_enabled(false); @@ -3861,28 +3858,28 @@ TEST_CASE("[SceneTree][TextEdit] viewport") { // Scroll. int v_scroll = text_edit->get_v_scroll(); - SEND_GUI_MOUSE_BUTTON_EVENT(text_edit, Point2i(10, 10), MouseButton::WHEEL_DOWN, 0, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(10, 10), MouseButton::WHEEL_DOWN, 0, Key::NONE); CHECK(text_edit->get_v_scroll() > v_scroll); - SEND_GUI_MOUSE_BUTTON_EVENT(text_edit, Point2i(10, 10), MouseButton::WHEEL_UP, 0, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(10, 10), MouseButton::WHEEL_UP, 0, Key::NONE); CHECK(text_edit->get_v_scroll() == v_scroll); // smooth scroll speed. text_edit->set_smooth_scroll_enabled(true); v_scroll = text_edit->get_v_scroll(); - SEND_GUI_MOUSE_BUTTON_EVENT(text_edit, Point2i(10, 10), MouseButton::WHEEL_DOWN, 0, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(10, 10), MouseButton::WHEEL_DOWN, 0, Key::NONE); text_edit->notification(TextEdit::NOTIFICATION_INTERNAL_PHYSICS_PROCESS); CHECK(text_edit->get_v_scroll() >= v_scroll); - SEND_GUI_MOUSE_BUTTON_EVENT(text_edit, Point2i(10, 10), MouseButton::WHEEL_UP, 0, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(10, 10), MouseButton::WHEEL_UP, 0, Key::NONE); text_edit->notification(TextEdit::NOTIFICATION_INTERNAL_PHYSICS_PROCESS); CHECK(text_edit->get_v_scroll() == v_scroll); v_scroll = text_edit->get_v_scroll(); text_edit->set_v_scroll_speed(10000); - SEND_GUI_MOUSE_BUTTON_EVENT(text_edit, Point2i(10, 10), MouseButton::WHEEL_DOWN, 0, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(10, 10), MouseButton::WHEEL_DOWN, 0, Key::NONE); text_edit->notification(TextEdit::NOTIFICATION_INTERNAL_PHYSICS_PROCESS); CHECK(text_edit->get_v_scroll() >= v_scroll); - SEND_GUI_MOUSE_BUTTON_EVENT(text_edit, Point2i(10, 10), MouseButton::WHEEL_UP, 0, Key::NONE); + SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(10, 10), MouseButton::WHEEL_UP, 0, Key::NONE); text_edit->notification(TextEdit::NOTIFICATION_INTERNAL_PHYSICS_PROCESS); CHECK(text_edit->get_v_scroll() == v_scroll); @@ -3910,7 +3907,7 @@ TEST_CASE("[SceneTree][TextEdit] viewport") { CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); text_edit->grab_focus(); - SEND_GUI_ACTION(text_edit, "ui_text_scroll_down"); + SEND_GUI_ACTION("ui_text_scroll_down"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 1); CHECK(text_edit->get_first_visible_line() == 1); @@ -3919,7 +3916,7 @@ TEST_CASE("[SceneTree][TextEdit] viewport") { CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); CHECK(text_edit->get_caret_wrap_index() == 0); - SEND_GUI_ACTION(text_edit, "ui_text_scroll_up"); + SEND_GUI_ACTION("ui_text_scroll_up"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 1); CHECK(text_edit->get_first_visible_line() == 0); @@ -3929,7 +3926,7 @@ TEST_CASE("[SceneTree][TextEdit] viewport") { CHECK(text_edit->get_caret_wrap_index() == 0); // Page down, similar to VSCode, to end of page then scroll. - SEND_GUI_ACTION(text_edit, "ui_text_caret_page_down"); + SEND_GUI_ACTION("ui_text_caret_page_down"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 21); CHECK(text_edit->get_first_visible_line() == 0); @@ -3938,7 +3935,7 @@ TEST_CASE("[SceneTree][TextEdit] viewport") { CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); CHECK(text_edit->get_caret_wrap_index() == 0); - SEND_GUI_ACTION(text_edit, "ui_text_caret_page_down"); + SEND_GUI_ACTION("ui_text_caret_page_down"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 41); CHECK(text_edit->get_first_visible_line() == 20); @@ -3947,7 +3944,7 @@ TEST_CASE("[SceneTree][TextEdit] viewport") { CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); CHECK(text_edit->get_caret_wrap_index() == 0); - SEND_GUI_ACTION(text_edit, "ui_text_caret_page_up"); + SEND_GUI_ACTION("ui_text_caret_page_up"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 21); CHECK(text_edit->get_first_visible_line() == 20); @@ -3956,7 +3953,7 @@ TEST_CASE("[SceneTree][TextEdit] viewport") { CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); CHECK(text_edit->get_caret_wrap_index() == 0); - SEND_GUI_ACTION(text_edit, "ui_text_caret_page_up"); + SEND_GUI_ACTION("ui_text_caret_page_up"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 1); CHECK(text_edit->get_first_visible_line() == 1); @@ -3969,7 +3966,7 @@ TEST_CASE("[SceneTree][TextEdit] viewport") { MessageQueue::get_singleton()->flush(); text_edit->grab_focus(); - SEND_GUI_ACTION(text_edit, "ui_text_scroll_down"); + SEND_GUI_ACTION("ui_text_scroll_down"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 2); CHECK(text_edit->get_first_visible_line() == 2); @@ -3978,7 +3975,7 @@ TEST_CASE("[SceneTree][TextEdit] viewport") { CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); CHECK(text_edit->get_caret_wrap_index() == 0); - SEND_GUI_ACTION(text_edit, "ui_text_scroll_up"); + SEND_GUI_ACTION("ui_text_scroll_up"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 2); CHECK(text_edit->get_first_visible_line() == 1); @@ -3988,7 +3985,7 @@ TEST_CASE("[SceneTree][TextEdit] viewport") { CHECK(text_edit->get_caret_wrap_index() == 0); // Page down, similar to VSCode, to end of page then scroll. - SEND_GUI_ACTION(text_edit, "ui_text_caret_page_down"); + SEND_GUI_ACTION("ui_text_caret_page_down"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 22); CHECK(text_edit->get_first_visible_line() == 1); @@ -3997,7 +3994,7 @@ TEST_CASE("[SceneTree][TextEdit] viewport") { CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); CHECK(text_edit->get_caret_wrap_index() == 0); - SEND_GUI_ACTION(text_edit, "ui_text_caret_page_down"); + SEND_GUI_ACTION("ui_text_caret_page_down"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 42); CHECK(text_edit->get_first_visible_line() == 21); @@ -4006,7 +4003,7 @@ TEST_CASE("[SceneTree][TextEdit] viewport") { CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); CHECK(text_edit->get_caret_wrap_index() == 0); - SEND_GUI_ACTION(text_edit, "ui_text_caret_page_up"); + SEND_GUI_ACTION("ui_text_caret_page_up"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 22); CHECK(text_edit->get_first_visible_line() == 21); @@ -4015,7 +4012,7 @@ TEST_CASE("[SceneTree][TextEdit] viewport") { CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); CHECK(text_edit->get_caret_wrap_index() == 0); - SEND_GUI_ACTION(text_edit, "ui_text_caret_page_up"); + SEND_GUI_ACTION("ui_text_caret_page_up"); CHECK(text_edit->get_viewport()->is_input_handled()); CHECK(text_edit->get_caret_line() == 2); CHECK(text_edit->get_first_visible_line() == 2); @@ -4031,7 +4028,7 @@ TEST_CASE("[SceneTree][TextEdit] viewport") { MessageQueue::get_singleton()->flush(); CHECK(text_edit->get_first_visible_line() == 5); - SEND_GUI_KEY_EVENT(text_edit, Key::A); + SEND_GUI_KEY_EVENT(Key::A); CHECK(text_edit->get_first_visible_line() == 0); text_edit->set_line_as_first_visible(5); diff --git a/tests/scene/test_viewport.h b/tests/scene/test_viewport.h new file mode 100644 index 0000000000..62f4635927 --- /dev/null +++ b/tests/scene/test_viewport.h @@ -0,0 +1,718 @@ +/**************************************************************************/ +/* test_viewport.h */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#ifndef TEST_VIEWPORT_H +#define TEST_VIEWPORT_H + +#include "scene/2d/node_2d.h" +#include "scene/gui/control.h" +#include "scene/main/window.h" + +#include "tests/test_macros.h" + +namespace TestViewport { + +class NotificationControl : public Control { + GDCLASS(NotificationControl, Control); + +protected: + void _notification(int p_what) { + switch (p_what) { + case NOTIFICATION_MOUSE_ENTER: { + mouse_over = true; + } break; + + case NOTIFICATION_MOUSE_EXIT: { + mouse_over = false; + } break; + } + } + +public: + bool mouse_over = false; +}; + +// `NotificationControl`-derived class that additionally +// - allows start Dragging +// - stores mouse information of last event +class DragStart : public NotificationControl { + GDCLASS(DragStart, NotificationControl); + +public: + MouseButton last_mouse_button; + Point2i last_mouse_move_position; + StringName drag_data_name = SNAME("Drag Data"); + + virtual Variant get_drag_data(const Point2 &p_point) override { + return drag_data_name; + } + + virtual void gui_input(const Ref<InputEvent> &p_event) override { + Ref<InputEventMouseButton> mb = p_event; + if (mb.is_valid()) { + last_mouse_button = mb->get_button_index(); + return; + } + + Ref<InputEventMouseMotion> mm = p_event; + if (mm.is_valid()) { + last_mouse_move_position = mm->get_position(); + return; + } + } +}; + +// `NotificationControl`-derived class that acts as a Drag and Drop target. +class DragTarget : public NotificationControl { + GDCLASS(DragTarget, NotificationControl); + +public: + Variant drag_data; + virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const override { + StringName string_data = p_data; + // Verify drag data is compatible. + if (string_data != SNAME("Drag Data")) { + return false; + } + // Only the left half is droppable area. + if (p_point.x * 2 > get_size().x) { + return false; + } + return true; + } + + virtual void drop_data(const Point2 &p_point, const Variant &p_data) override { + drag_data = p_data; + } +}; + +TEST_CASE("[SceneTree][Viewport] Controls and InputEvent handling") { + DragStart *node_a = memnew(DragStart); + Control *node_b = memnew(Control); + Node2D *node_c = memnew(Node2D); + DragTarget *node_d = memnew(DragTarget); + Control *node_e = memnew(Control); + Node *node_f = memnew(Node); + Control *node_g = memnew(Control); + + node_a->set_name(SNAME("NodeA")); + node_b->set_name(SNAME("NodeB")); + node_c->set_name(SNAME("NodeC")); + node_d->set_name(SNAME("NodeD")); + node_e->set_name(SNAME("NodeE")); + node_f->set_name(SNAME("NodeF")); + node_g->set_name(SNAME("NodeG")); + + node_a->set_position(Point2i(0, 0)); + node_b->set_position(Point2i(10, 10)); + node_c->set_position(Point2i(0, 0)); + node_d->set_position(Point2i(10, 10)); + node_e->set_position(Point2i(10, 100)); + node_g->set_position(Point2i(10, 100)); + node_a->set_size(Point2i(30, 30)); + node_b->set_size(Point2i(30, 30)); + node_d->set_size(Point2i(30, 30)); + node_e->set_size(Point2i(10, 10)); + node_g->set_size(Point2i(10, 10)); + node_a->set_focus_mode(Control::FOCUS_CLICK); + node_b->set_focus_mode(Control::FOCUS_CLICK); + node_d->set_focus_mode(Control::FOCUS_CLICK); + node_e->set_focus_mode(Control::FOCUS_CLICK); + node_g->set_focus_mode(Control::FOCUS_CLICK); + Window *root = SceneTree::get_singleton()->get_root(); + DisplayServerMock *DS = (DisplayServerMock *)(DisplayServer::get_singleton()); + + // Scene tree: + // - root + // - a (Control) + // - b (Control) + // - c (Node2D) + // - d (Control) + // - e (Control) + // - f (Node) + // - g (Control) + root->add_child(node_a); + root->add_child(node_b); + node_b->add_child(node_c); + node_c->add_child(node_d); + root->add_child(node_e); + node_e->add_child(node_f); + node_f->add_child(node_g); + + Point2i on_a = Point2i(5, 5); + Point2i on_b = Point2i(15, 15); + Point2i on_d = Point2i(25, 25); + Point2i on_e = Point2i(15, 105); + Point2i on_g = Point2i(15, 105); + Point2i on_background = Point2i(500, 500); + Point2i on_outside = Point2i(-1, -1); + + // Unit tests for Viewport::gui_find_control and Viewport::_gui_find_control_at_pos + SUBCASE("[VIEWPORT][GuiFindControl] Finding Controls at a Viewport-position") { + // FIXME: It is extremely difficult to create a situation where the Control has a zero determinant. + // Leaving that if-branch untested. + + SUBCASE("[VIEWPORT][GuiFindControl] Basic position tests") { + CHECK(root->gui_find_control(on_a) == node_a); + CHECK(root->gui_find_control(on_b) == node_b); + CHECK(root->gui_find_control(on_d) == node_d); + CHECK(root->gui_find_control(on_e) == node_g); // Node F makes G a Root Control at the same position as E + CHECK(root->gui_find_control(on_g) == node_g); + CHECK_FALSE(root->gui_find_control(on_background)); + } + + SUBCASE("[VIEWPORT][GuiFindControl] Invisible nodes are not considered as results.") { + // Non-Root Control + node_d->hide(); + CHECK(root->gui_find_control(on_d) == node_b); + // Root Control + node_b->hide(); + CHECK(root->gui_find_control(on_b) == node_a); + } + + SUBCASE("[VIEWPORT][GuiFindControl] Root Control with CanvasItem as parent is affected by parent's transform.") { + node_b->remove_child(node_c); + node_c->set_position(Point2i(50, 50)); + root->add_child(node_c); + CHECK(root->gui_find_control(Point2i(65, 65)) == node_d); + } + + SUBCASE("[VIEWPORT][GuiFindControl] Control Contents Clipping clips accessible position of children.") { + CHECK_FALSE(node_b->is_clipping_contents()); + CHECK(root->gui_find_control(on_d + Point2i(20, 20)) == node_d); + node_b->set_clip_contents(true); + CHECK(root->gui_find_control(on_d) == node_d); + CHECK_FALSE(root->gui_find_control(on_d + Point2i(20, 20))); + } + + SUBCASE("[VIEWPORT][GuiFindControl] Top Level Control as descendant of CanvasItem isn't affected by parent's transform.") { + CHECK(root->gui_find_control(on_d + Point2i(20, 20)) == node_d); + node_d->set_as_top_level(true); + CHECK_FALSE(root->gui_find_control(on_d + Point2i(20, 20))); + CHECK(root->gui_find_control(on_b) == node_d); + } + } + + SUBCASE("[Viewport][GuiInputEvent] nullptr as argument doesn't lead to a crash.") { + CHECK_NOTHROW(root->push_input(nullptr)); + } + + // Unit tests for Viewport::_gui_input_event (Mouse Buttons) + SUBCASE("[Viewport][GuiInputEvent] Mouse Button Down/Up.") { + SUBCASE("[Viewport][GuiInputEvent] Mouse Button Control Focus Change.") { + SUBCASE("[Viewport][GuiInputEvent] Grab Focus while no Control has focus.") { + CHECK_FALSE(root->gui_get_focus_owner()); + + // Click on A + SEND_GUI_MOUSE_BUTTON_EVENT(on_a, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + CHECK(node_a->has_focus()); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_a, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + } + + SUBCASE("[Viewport][GuiInputEvent] Grab Focus from other Control.") { + node_a->grab_focus(); + CHECK(node_a->has_focus()); + + // Click on D + SEND_GUI_MOUSE_BUTTON_EVENT(on_d, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + CHECK(node_d->has_focus()); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_d, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + } + + SUBCASE("[Viewport][GuiInputEvent] Non-CanvasItem breaks Transform hierarchy.") { + CHECK_FALSE(root->gui_get_focus_owner()); + + // Click on G absolute coordinates + SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(15, 105), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + CHECK(node_g->has_focus()); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(Point2i(15, 105), MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + } + + SUBCASE("[Viewport][GuiInputEvent] No Focus change when clicking in background.") { + CHECK_FALSE(root->gui_get_focus_owner()); + + SEND_GUI_MOUSE_BUTTON_EVENT(on_background, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + CHECK_FALSE(root->gui_get_focus_owner()); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_background, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + + node_a->grab_focus(); + CHECK(node_a->has_focus()); + + SEND_GUI_MOUSE_BUTTON_EVENT(on_background, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_background, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + CHECK(node_a->has_focus()); + } + + SUBCASE("[Viewport][GuiInputEvent] Mouse Button No Focus Steal while other Mouse Button is pressed.") { + CHECK_FALSE(root->gui_get_focus_owner()); + + SEND_GUI_MOUSE_BUTTON_EVENT(on_a, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + CHECK(node_a->has_focus()); + + SEND_GUI_MOUSE_BUTTON_EVENT(on_b, MouseButton::RIGHT, (int)MouseButtonMask::LEFT | (int)MouseButtonMask::RIGHT, Key::NONE); + CHECK(node_a->has_focus()); + + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_b, MouseButton::RIGHT, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_b, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + CHECK(node_a->has_focus()); + } + + SUBCASE("[Viewport][GuiInputEvent] Allow Focus Steal with LMB while other Mouse Button is held down and was initially pressed without being over a Control.") { + // TODO: Not sure, if this is intended behavior, but this is an edge case. + CHECK_FALSE(root->gui_get_focus_owner()); + + SEND_GUI_MOUSE_BUTTON_EVENT(on_background, MouseButton::RIGHT, MouseButtonMask::RIGHT, Key::NONE); + CHECK_FALSE(root->gui_get_focus_owner()); + + SEND_GUI_MOUSE_BUTTON_EVENT(on_a, MouseButton::LEFT, (int)MouseButtonMask::LEFT | (int)MouseButtonMask::RIGHT, Key::NONE); + CHECK(node_a->has_focus()); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_a, MouseButton::LEFT, MouseButtonMask::RIGHT, Key::NONE); + CHECK(node_a->has_focus()); + + SEND_GUI_MOUSE_BUTTON_EVENT(on_b, MouseButton::LEFT, (int)MouseButtonMask::LEFT | (int)MouseButtonMask::RIGHT, Key::NONE); + CHECK(node_b->has_focus()); + + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_d, MouseButton::LEFT, MouseButtonMask::RIGHT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_d, MouseButton::RIGHT, MouseButtonMask::NONE, Key::NONE); + CHECK(node_b->has_focus()); + } + + SUBCASE("[Viewport][GuiInputEvent] Ignore Focus from Mouse Buttons when mouse-filter is set to ignore.") { + node_d->grab_focus(); + node_d->set_mouse_filter(Control::MOUSE_FILTER_IGNORE); + CHECK(node_d->has_focus()); + + // Click on overlapping area B&D. + SEND_GUI_MOUSE_BUTTON_EVENT(on_d, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + CHECK(node_b->has_focus()); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_d, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + } + + SUBCASE("[Viewport][GuiInputEvent] RMB doesn't grab focus.") { + node_a->grab_focus(); + CHECK(node_a->has_focus()); + + SEND_GUI_MOUSE_BUTTON_EVENT(on_d, MouseButton::RIGHT, MouseButtonMask::RIGHT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_d, MouseButton::RIGHT, MouseButtonMask::NONE, Key::NONE); + CHECK(node_a->has_focus()); + } + + SUBCASE("[Viewport][GuiInputEvent] LMB on unfocusable Control doesn't grab focus.") { + CHECK_FALSE(node_g->has_focus()); + node_g->set_focus_mode(Control::FOCUS_NONE); + + SEND_GUI_MOUSE_BUTTON_EVENT(on_g, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_g, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + CHECK_FALSE(node_g->has_focus()); + + // Now verify the opposite with FOCUS_CLICK + node_g->set_focus_mode(Control::FOCUS_CLICK); + SEND_GUI_MOUSE_BUTTON_EVENT(on_g, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_g, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + CHECK(node_g->has_focus()); + node_g->set_focus_mode(Control::FOCUS_CLICK); + } + + SUBCASE("[Viewport][GuiInputEvent] Signal 'gui_focus_changed' is only emitted if a previously unfocused Control grabs focus.") { + SIGNAL_WATCH(root, SNAME("gui_focus_changed")); + Array node_array; + node_array.push_back(node_a); + Array signal_args; + signal_args.push_back(node_array); + + SEND_GUI_MOUSE_BUTTON_EVENT(on_a, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_a, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + SIGNAL_CHECK(SNAME("gui_focus_changed"), signal_args); + + SEND_GUI_MOUSE_BUTTON_EVENT(on_a, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_a, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + CHECK(node_a->has_focus()); + SIGNAL_CHECK_FALSE(SNAME("gui_focus_changed")); + + SIGNAL_UNWATCH(root, SNAME("gui_focus_changed")); + } + + SUBCASE("[Viewport][GuiInputEvent] Focus Propagation to parent items.") { + SUBCASE("[Viewport][GuiInputEvent] Unfocusable Control with MOUSE_FILTER_PASS propagates focus to parent CanvasItem.") { + node_d->set_focus_mode(Control::FOCUS_NONE); + node_d->set_mouse_filter(Control::MOUSE_FILTER_PASS); + + SEND_GUI_MOUSE_BUTTON_EVENT(on_d + Point2i(20, 20), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + CHECK(node_b->has_focus()); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_d + Point2i(20, 20), MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + + // Verify break condition for Root Control. + node_a->set_focus_mode(Control::FOCUS_NONE); + node_a->set_mouse_filter(Control::MOUSE_FILTER_PASS); + + SEND_GUI_MOUSE_BUTTON_EVENT(on_a, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_a, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + CHECK(node_b->has_focus()); + } + + SUBCASE("[Viewport][GuiInputEvent] Top Level CanvasItem stops focus propagation.") { + node_d->set_focus_mode(Control::FOCUS_NONE); + node_d->set_mouse_filter(Control::MOUSE_FILTER_PASS); + node_c->set_as_top_level(true); + + SEND_GUI_MOUSE_BUTTON_EVENT(on_b, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_b, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + CHECK_FALSE(root->gui_get_focus_owner()); + + node_d->set_focus_mode(Control::FOCUS_CLICK); + SEND_GUI_MOUSE_BUTTON_EVENT(on_b, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_b, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + CHECK(node_d->has_focus()); + } + } + } + + SUBCASE("[Viewport][GuiInputEvent] Process-Mode affects, if GUI Mouse Button Events are processed.") { + node_a->last_mouse_button = MouseButton::NONE; + node_a->set_process_mode(Node::PROCESS_MODE_DISABLED); + SEND_GUI_MOUSE_BUTTON_EVENT(on_a, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_a, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + CHECK(node_a->last_mouse_button == MouseButton::NONE); + + // Now verify that with allowed processing the event is processed. + node_a->set_process_mode(Node::PROCESS_MODE_ALWAYS); + SEND_GUI_MOUSE_BUTTON_EVENT(on_a, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_a, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + CHECK(node_a->last_mouse_button == MouseButton::LEFT); + } + } + + // Unit tests for Viewport::_gui_input_event (Mouse Motion) + SUBCASE("[Viewport][GuiInputEvent] Mouse Motion") { + // FIXME: Tooltips are not yet tested. They likely require an internal clock. + + SUBCASE("[Viewport][GuiInputEvent] Mouse Motion changes the Control, that it is over.") { + SEND_GUI_MOUSE_MOTION_EVENT(on_background, MouseButtonMask::NONE, Key::NONE); + CHECK_FALSE(node_a->mouse_over); + + // Move over Control. + SEND_GUI_MOUSE_MOTION_EVENT(on_a, MouseButtonMask::NONE, Key::NONE); + CHECK(node_a->mouse_over); + + // No change. + SEND_GUI_MOUSE_MOTION_EVENT(on_a + Point2i(1, 1), MouseButtonMask::NONE, Key::NONE); + CHECK(node_a->mouse_over); + + // Move over other Control. + SEND_GUI_MOUSE_MOTION_EVENT(on_d, MouseButtonMask::NONE, Key::NONE); + CHECK_FALSE(node_a->mouse_over); + CHECK(node_d->mouse_over); + + // Move to background + SEND_GUI_MOUSE_MOTION_EVENT(on_background, MouseButtonMask::NONE, Key::NONE); + CHECK_FALSE(node_d->mouse_over); + } + + SUBCASE("[Viewport][GuiInputEvent] Window Mouse Enter/Exit signals.") { + SIGNAL_WATCH(root, SNAME("mouse_entered")); + SIGNAL_WATCH(root, SNAME("mouse_exited")); + Array signal_args; + signal_args.push_back(Array()); + + SEND_GUI_MOUSE_MOTION_EVENT(on_outside, MouseButtonMask::NONE, Key::NONE); + SIGNAL_CHECK_FALSE(SNAME("mouse_entered")); + SIGNAL_CHECK(SNAME("mouse_exited"), signal_args); + + SEND_GUI_MOUSE_MOTION_EVENT(on_a, MouseButtonMask::NONE, Key::NONE); + SIGNAL_CHECK(SNAME("mouse_entered"), signal_args); + SIGNAL_CHECK_FALSE(SNAME("mouse_exited")); + + SIGNAL_UNWATCH(root, SNAME("mouse_entered")); + SIGNAL_UNWATCH(root, SNAME("mouse_exited")); + } + + SUBCASE("[Viewport][GuiInputEvent] Process-Mode affects, if GUI Mouse Motion Events are processed.") { + node_a->last_mouse_move_position = on_outside; + node_a->set_process_mode(Node::PROCESS_MODE_DISABLED); + SEND_GUI_MOUSE_MOTION_EVENT(on_a, MouseButtonMask::NONE, Key::NONE); + CHECK(node_a->last_mouse_move_position == on_outside); + + // Now verify that with allowed processing the event is processed. + node_a->set_process_mode(Node::PROCESS_MODE_ALWAYS); + SEND_GUI_MOUSE_MOTION_EVENT(on_a, MouseButtonMask::NONE, Key::NONE); + CHECK(node_a->last_mouse_move_position == on_a); + } + } + + // Unit tests for Viewport::_gui_input_event (Drag and Drop) + SUBCASE("[Viewport][GuiInputEvent] Drag and Drop") { + // FIXME: Drag-Preview will likely change. Tests for this part would have to be rewritten anyway. + // See https://github.com/godotengine/godot/pull/67531#issuecomment-1385353430 for details. + // FIXME: Testing Drag and Drop with non-embedded windows would require DisplayServerMock additions + // FIXME: Drag and Drop currently doesn't work with embedded Windows and SubViewports - not testing. + // See https://github.com/godotengine/godot/issues/28522 for example. + int min_grab_movement = 11; + SUBCASE("[Viewport][GuiInputEvent] Drag from one Control to another in the same viewport.") { + SUBCASE("[Viewport][GuiInputEvent] Perform successful Drag and Drop on a different Control.") { + SEND_GUI_MOUSE_BUTTON_EVENT(on_a, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + CHECK_FALSE(root->gui_is_dragging()); + + SEND_GUI_MOUSE_MOTION_EVENT(on_a + Point2i(min_grab_movement, 0), MouseButtonMask::LEFT, Key::NONE); + CHECK(root->gui_is_dragging()); + + // Move above a Control, that is a Drop target and allows dropping at this point. + SEND_GUI_MOUSE_MOTION_EVENT(on_d, MouseButtonMask::LEFT, Key::NONE); + CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_CAN_DROP); + + CHECK(root->gui_is_dragging()); + CHECK_FALSE(root->gui_is_drag_successful()); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_d, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + CHECK_FALSE(root->gui_is_dragging()); + CHECK(root->gui_is_drag_successful()); + CHECK((StringName)node_d->drag_data == SNAME("Drag Data")); + } + + SUBCASE("[Viewport][GuiInputEvent] Perform unsuccessful drop on Control.") { + SEND_GUI_MOUSE_BUTTON_EVENT(on_a, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + CHECK_FALSE(root->gui_is_dragging()); + + // Move, but don't trigger DnD yet. + SEND_GUI_MOUSE_MOTION_EVENT(on_a + Point2i(0, min_grab_movement - 1), MouseButtonMask::LEFT, Key::NONE); + CHECK_FALSE(root->gui_is_dragging()); + + // Move and trigger DnD. + SEND_GUI_MOUSE_MOTION_EVENT(on_a + Point2i(0, min_grab_movement), MouseButtonMask::LEFT, Key::NONE); + CHECK(root->gui_is_dragging()); + + // Move above a Control, that is not a Drop target. + SEND_GUI_MOUSE_MOTION_EVENT(on_a, MouseButtonMask::LEFT, Key::NONE); + CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_FORBIDDEN); + + // Move above a Control, that is a Drop target, but has disallowed this point. + SEND_GUI_MOUSE_MOTION_EVENT(on_d + Point2i(20, 0), MouseButtonMask::LEFT, Key::NONE); + CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_FORBIDDEN); + CHECK(root->gui_is_dragging()); + + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_d + Point2i(20, 0), MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + CHECK_FALSE(root->gui_is_dragging()); + CHECK_FALSE(root->gui_is_drag_successful()); + } + + SUBCASE("[Viewport][GuiInputEvent] Perform unsuccessful drop on No-Control.") { + SEND_GUI_MOUSE_BUTTON_EVENT(on_a, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + CHECK_FALSE(root->gui_is_dragging()); + + // Move, but don't trigger DnD yet. + SEND_GUI_MOUSE_MOTION_EVENT(on_a + Point2i(min_grab_movement - 1, 0), MouseButtonMask::LEFT, Key::NONE); + CHECK_FALSE(root->gui_is_dragging()); + + // Move and trigger DnD. + SEND_GUI_MOUSE_MOTION_EVENT(on_a + Point2i(min_grab_movement, 0), MouseButtonMask::LEFT, Key::NONE); + CHECK(root->gui_is_dragging()); + + // Move away from Controls. + SEND_GUI_MOUSE_MOTION_EVENT(on_background, MouseButtonMask::LEFT, Key::NONE); + CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_ARROW); // This could also be CURSOR_FORBIDDEN. + + CHECK(root->gui_is_dragging()); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_background, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + CHECK_FALSE(root->gui_is_dragging()); + CHECK_FALSE(root->gui_is_drag_successful()); + } + + SUBCASE("[Viewport][GuiInputEvent] Perform unsuccessful drop outside of window.") { + SEND_GUI_MOUSE_BUTTON_EVENT(on_a, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + CHECK_FALSE(root->gui_is_dragging()); + + // Move and trigger DnD. + SEND_GUI_MOUSE_MOTION_EVENT(on_a + Point2i(min_grab_movement, 0), MouseButtonMask::LEFT, Key::NONE); + CHECK(root->gui_is_dragging()); + + SEND_GUI_MOUSE_MOTION_EVENT(on_d, MouseButtonMask::LEFT, Key::NONE); + CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_CAN_DROP); + + // Move outside of window. + SEND_GUI_MOUSE_MOTION_EVENT(on_outside, MouseButtonMask::LEFT, Key::NONE); + CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_ARROW); + CHECK(root->gui_is_dragging()); + + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_outside, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + CHECK_FALSE(root->gui_is_dragging()); + CHECK_FALSE(root->gui_is_drag_successful()); + } + + SUBCASE("[Viewport][GuiInputEvent] Drag and Drop doesn't work with other Mouse Buttons than LMB.") { + SEND_GUI_MOUSE_BUTTON_EVENT(on_a, MouseButton::MIDDLE, MouseButtonMask::MIDDLE, Key::NONE); + CHECK_FALSE(root->gui_is_dragging()); + + SEND_GUI_MOUSE_MOTION_EVENT(on_a + Point2i(min_grab_movement, 0), MouseButtonMask::MIDDLE, Key::NONE); + CHECK_FALSE(root->gui_is_dragging()); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_a, MouseButton::MIDDLE, MouseButtonMask::NONE, Key::NONE); + } + + SUBCASE("[Viewport][GuiInputEvent] Drag and Drop parent propagation.") { + Node2D *node_aa = memnew(Node2D); + Control *node_aaa = memnew(Control); + Node2D *node_dd = memnew(Node2D); + Control *node_ddd = memnew(Control); + node_aaa->set_size(Size2i(10, 10)); + node_aaa->set_position(Point2i(0, 5)); + node_ddd->set_size(Size2i(10, 10)); + node_ddd->set_position(Point2i(0, 5)); + node_a->add_child(node_aa); + node_aa->add_child(node_aaa); + node_d->add_child(node_dd); + node_dd->add_child(node_ddd); + Point2i on_aaa = on_a + Point2i(-2, 2); + Point2i on_ddd = on_d + Point2i(-2, 2); + + SUBCASE("[Viewport][GuiInputEvent] Drag and Drop propagation to parent Controls.") { + node_aaa->set_mouse_filter(Control::MOUSE_FILTER_PASS); + node_ddd->set_mouse_filter(Control::MOUSE_FILTER_PASS); + + SEND_GUI_MOUSE_BUTTON_EVENT(on_aaa, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + CHECK_FALSE(root->gui_is_dragging()); + + SEND_GUI_MOUSE_MOTION_EVENT(on_aaa + Point2i(0, min_grab_movement), MouseButtonMask::LEFT, Key::NONE); + CHECK(root->gui_is_dragging()); + + SEND_GUI_MOUSE_MOTION_EVENT(on_ddd, MouseButtonMask::LEFT, Key::NONE); + + CHECK(root->gui_is_dragging()); + CHECK_FALSE(root->gui_is_drag_successful()); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_ddd, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + CHECK_FALSE(root->gui_is_dragging()); + CHECK(root->gui_is_drag_successful()); + + node_aaa->set_mouse_filter(Control::MOUSE_FILTER_STOP); + node_ddd->set_mouse_filter(Control::MOUSE_FILTER_STOP); + } + + SUBCASE("[Viewport][GuiInputEvent] Drag and Drop grab-propagation stopped by Top Level.") { + node_aaa->set_mouse_filter(Control::MOUSE_FILTER_PASS); + node_aaa->set_as_top_level(true); + + SEND_GUI_MOUSE_BUTTON_EVENT(on_aaa, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + CHECK_FALSE(root->gui_is_dragging()); + + SEND_GUI_MOUSE_MOTION_EVENT(on_aaa + Point2i(0, min_grab_movement), MouseButtonMask::LEFT, Key::NONE); + CHECK_FALSE(root->gui_is_dragging()); + + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_background, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + node_aaa->set_as_top_level(false); + node_aaa->set_mouse_filter(Control::MOUSE_FILTER_STOP); + } + + SUBCASE("[Viewport][GuiInputEvent] Drag and Drop target-propagation stopped by Top Level.") { + node_aaa->set_mouse_filter(Control::MOUSE_FILTER_PASS); + node_ddd->set_mouse_filter(Control::MOUSE_FILTER_PASS); + node_ddd->set_as_top_level(true); + node_ddd->set_position(Point2i(30, 100)); + + SEND_GUI_MOUSE_BUTTON_EVENT(on_aaa, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + CHECK_FALSE(root->gui_is_dragging()); + + SEND_GUI_MOUSE_MOTION_EVENT(on_aaa + Point2i(0, min_grab_movement), MouseButtonMask::LEFT, Key::NONE); + CHECK(root->gui_is_dragging()); + + SEND_GUI_MOUSE_MOTION_EVENT(Point2i(35, 105), MouseButtonMask::LEFT, Key::NONE); + + CHECK(root->gui_is_dragging()); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(Point2i(35, 105), MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + CHECK_FALSE(root->gui_is_dragging()); + CHECK_FALSE(root->gui_is_drag_successful()); + + node_ddd->set_position(Point2i(0, 5)); + node_ddd->set_as_top_level(false); + node_aaa->set_mouse_filter(Control::MOUSE_FILTER_STOP); + node_ddd->set_mouse_filter(Control::MOUSE_FILTER_STOP); + } + + SUBCASE("[Viewport][GuiInputEvent] Drag and Drop grab-propagation stopped by non-CanvasItem.") { + node_g->set_mouse_filter(Control::MOUSE_FILTER_PASS); + + SEND_GUI_MOUSE_BUTTON_EVENT(on_g, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_MOTION_EVENT(on_g + Point2i(0, min_grab_movement), MouseButtonMask::LEFT, Key::NONE); + CHECK_FALSE(root->gui_is_dragging()); + + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_background, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + node_g->set_mouse_filter(Control::MOUSE_FILTER_STOP); + } + + SUBCASE("[Viewport][GuiInputEvent] Drag and Drop target-propagation stopped by non-CanvasItem.") { + node_g->set_mouse_filter(Control::MOUSE_FILTER_PASS); + + SEND_GUI_MOUSE_BUTTON_EVENT(on_a - Point2i(1, 1), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); // Offset for node_aaa. + SEND_GUI_MOUSE_MOTION_EVENT(on_a + Point2i(0, min_grab_movement), MouseButtonMask::LEFT, Key::NONE); + CHECK(root->gui_is_dragging()); + + SEND_GUI_MOUSE_MOTION_EVENT(on_g, MouseButtonMask::LEFT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_g, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + CHECK_FALSE(root->gui_is_dragging()); + + node_g->set_mouse_filter(Control::MOUSE_FILTER_STOP); + } + + memdelete(node_ddd); + memdelete(node_dd); + memdelete(node_aaa); + memdelete(node_aa); + } + + SUBCASE("[Viewport][GuiInputEvent] Force Drag and Drop.") { + SEND_GUI_MOUSE_MOTION_EVENT(on_background, MouseButtonMask::NONE, Key::NONE); + CHECK_FALSE(root->gui_is_dragging()); + node_a->force_drag(SNAME("Drag Data"), nullptr); + CHECK(root->gui_is_dragging()); + + SEND_GUI_MOUSE_MOTION_EVENT(on_d, MouseButtonMask::NONE, Key::NONE); + + // Force Drop doesn't get triggered by mouse Buttons other than LMB. + SEND_GUI_MOUSE_BUTTON_EVENT(on_d, MouseButton::RIGHT, MouseButtonMask::RIGHT, Key::NONE); + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_a, MouseButton::RIGHT, MouseButtonMask::NONE, Key::NONE); + CHECK(root->gui_is_dragging()); + + // Force Drop with LMB-Down. + SEND_GUI_MOUSE_BUTTON_EVENT(on_d, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); + CHECK_FALSE(root->gui_is_dragging()); + CHECK(root->gui_is_drag_successful()); + + SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(on_d, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); + } + } + } + + memdelete(node_g); + memdelete(node_f); + memdelete(node_e); + memdelete(node_d); + memdelete(node_c); + memdelete(node_b); + memdelete(node_a); +} + +} // namespace TestViewport + +#endif // TEST_VIEWPORT_H diff --git a/tests/test_macros.h b/tests/test_macros.h index 80a93c8327..5d1bcdecf4 100644 --- a/tests/test_macros.h +++ b/tests/test_macros.h @@ -134,16 +134,16 @@ int register_test_command(String p_command, TestFunc p_function); // Utility macros to send an event actions to a given object // Requires Message Queue and InputMap to be setup. -// SEND_GUI_ACTION - takes an object and a input map key. e.g SEND_GUI_ACTION(code_edit, "ui_text_newline"). -// SEND_GUI_KEY_EVENT - takes an object and a keycode set. e.g SEND_GUI_KEY_EVENT(code_edit, Key::A | KeyModifierMask::META). -// SEND_GUI_MOUSE_BUTTON_EVENT - takes an object, position, mouse button, mouse mask and modifiers e.g SEND_GUI_MOUSE_BUTTON_EVENT(code_edit, Vector2(50, 50), MOUSE_BUTTON_NONE, MOUSE_BUTTON_NONE, Key::None); -// SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT - takes an object, position, mouse button, mouse mask and modifiers e.g SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(code_edit, Vector2(50, 50), MOUSE_BUTTON_NONE, MOUSE_BUTTON_NONE, Key::None); -// SEND_GUI_MOUSE_MOTION_EVENT - takes an object, position, mouse mask and modifiers e.g SEND_GUI_MOUSE_MOTION_EVENT(code_edit, Vector2(50, 50), MouseButtonMask::LEFT, KeyModifierMask::META); -// SEND_GUI_DOUBLE_CLICK - takes an object, position and modifiers. e.g SEND_GUI_DOUBLE_CLICK(code_edit, Vector2(50, 50), KeyModifierMask::META); +// SEND_GUI_ACTION - takes an input map key. e.g SEND_GUI_ACTION("ui_text_newline"). +// SEND_GUI_KEY_EVENT - takes a keycode set. e.g SEND_GUI_KEY_EVENT(Key::A | KeyModifierMask::META). +// SEND_GUI_MOUSE_BUTTON_EVENT - takes a position, mouse button, mouse mask and modifiers e.g SEND_GUI_MOUSE_BUTTON_EVENT(Vector2(50, 50), MOUSE_BUTTON_NONE, MOUSE_BUTTON_NONE, Key::None); +// SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT - takes a position, mouse button, mouse mask and modifiers e.g SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(Vector2(50, 50), MOUSE_BUTTON_NONE, MOUSE_BUTTON_NONE, Key::None); +// SEND_GUI_MOUSE_MOTION_EVENT - takes a position, mouse mask and modifiers e.g SEND_GUI_MOUSE_MOTION_EVENT(Vector2(50, 50), MouseButtonMask::LEFT, KeyModifierMask::META); +// SEND_GUI_DOUBLE_CLICK - takes a position and modifiers. e.g SEND_GUI_DOUBLE_CLICK(Vector2(50, 50), KeyModifierMask::META); #define _SEND_DISPLAYSERVER_EVENT(m_event) ((DisplayServerMock *)(DisplayServer::get_singleton()))->simulate_event(m_event); -#define SEND_GUI_ACTION(m_object, m_action) \ +#define SEND_GUI_ACTION(m_action) \ { \ const List<Ref<InputEvent>> *events = InputMap::get_singleton()->action_get_events(m_action); \ const List<Ref<InputEvent>>::Element *first_event = events->front(); \ @@ -153,7 +153,7 @@ int register_test_command(String p_command, TestFunc p_function); MessageQueue::get_singleton()->flush(); \ } -#define SEND_GUI_KEY_EVENT(m_object, m_input) \ +#define SEND_GUI_KEY_EVENT(m_input) \ { \ Ref<InputEventKey> event = InputEventKey::create_reference(m_input); \ event->set_pressed(true); \ @@ -167,53 +167,52 @@ int register_test_command(String p_command, TestFunc p_function); m_event->set_ctrl_pressed(((m_modifers)&KeyModifierMask::CTRL) != Key::NONE); \ m_event->set_meta_pressed(((m_modifers)&KeyModifierMask::META) != Key::NONE); -#define _CREATE_GUI_MOUSE_EVENT(m_object, m_local_pos, m_input, m_mask, m_modifers) \ - Ref<InputEventMouseButton> event; \ - event.instantiate(); \ - event->set_position(m_local_pos); \ - event->set_button_index(m_input); \ - event->set_button_mask(m_mask); \ - event->set_factor(1); \ - _UPDATE_EVENT_MODIFERS(event, m_modifers); \ +#define _CREATE_GUI_MOUSE_EVENT(m_screen_pos, m_input, m_mask, m_modifers) \ + Ref<InputEventMouseButton> event; \ + event.instantiate(); \ + event->set_position(m_screen_pos); \ + event->set_button_index(m_input); \ + event->set_button_mask(m_mask); \ + event->set_factor(1); \ + _UPDATE_EVENT_MODIFERS(event, m_modifers); \ event->set_pressed(true); -#define SEND_GUI_MOUSE_BUTTON_EVENT(m_object, m_local_pos, m_input, m_mask, m_modifers) \ +#define SEND_GUI_MOUSE_BUTTON_EVENT(m_screen_pos, m_input, m_mask, m_modifers) \ + { \ + _CREATE_GUI_MOUSE_EVENT(m_screen_pos, m_input, m_mask, m_modifers); \ + _SEND_DISPLAYSERVER_EVENT(event); \ + MessageQueue::get_singleton()->flush(); \ + } + +#define SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(m_screen_pos, m_input, m_mask, m_modifers) \ { \ - _CREATE_GUI_MOUSE_EVENT(m_object, m_local_pos, m_input, m_mask, m_modifers); \ + _CREATE_GUI_MOUSE_EVENT(m_screen_pos, m_input, m_mask, m_modifers); \ + event->set_pressed(false); \ _SEND_DISPLAYSERVER_EVENT(event); \ MessageQueue::get_singleton()->flush(); \ } -#define SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(m_object, m_local_pos, m_input, m_mask, m_modifers) \ - { \ - _CREATE_GUI_MOUSE_EVENT(m_object, m_local_pos, m_input, m_mask, m_modifers); \ - event->set_pressed(false); \ - _SEND_DISPLAYSERVER_EVENT(event); \ - MessageQueue::get_singleton()->flush(); \ - } - -#define SEND_GUI_DOUBLE_CLICK(m_object, m_local_pos, m_modifers) \ - { \ - _CREATE_GUI_MOUSE_EVENT(m_object, m_local_pos, MouseButton::LEFT, 0, m_modifers); \ - event->set_double_click(true); \ - _SEND_DISPLAYSERVER_EVENT(event); \ - MessageQueue::get_singleton()->flush(); \ +#define SEND_GUI_DOUBLE_CLICK(m_screen_pos, m_modifers) \ + { \ + _CREATE_GUI_MOUSE_EVENT(m_screen_pos, MouseButton::LEFT, 0, m_modifers); \ + event->set_double_click(true); \ + _SEND_DISPLAYSERVER_EVENT(event); \ + MessageQueue::get_singleton()->flush(); \ } // We toggle _print_error_enabled to prevent display server not supported warnings. -#define SEND_GUI_MOUSE_MOTION_EVENT(m_object, m_local_pos, m_mask, m_modifers) \ - { \ - bool errors_enabled = CoreGlobals::print_error_enabled; \ - CoreGlobals::print_error_enabled = false; \ - Ref<InputEventMouseMotion> event; \ - event.instantiate(); \ - event->set_position(m_local_pos); \ - event->set_button_mask(m_mask); \ - event->set_relative(Vector2(10, 10)); \ - _UPDATE_EVENT_MODIFERS(event, m_modifers); \ - _SEND_DISPLAYSERVER_EVENT(event); \ - MessageQueue::get_singleton()->flush(); \ - CoreGlobals::print_error_enabled = errors_enabled; \ +#define SEND_GUI_MOUSE_MOTION_EVENT(m_screen_pos, m_mask, m_modifers) \ + { \ + bool errors_enabled = CoreGlobals::print_error_enabled; \ + CoreGlobals::print_error_enabled = false; \ + Ref<InputEventMouseMotion> event; \ + event.instantiate(); \ + event->set_position(m_screen_pos); \ + event->set_button_mask(m_mask); \ + _UPDATE_EVENT_MODIFERS(event, m_modifers); \ + _SEND_DISPLAYSERVER_EVENT(event); \ + MessageQueue::get_singleton()->flush(); \ + CoreGlobals::print_error_enabled = errors_enabled; \ } // Utility class / macros for testing signals diff --git a/tests/test_main.cpp b/tests/test_main.cpp index ea6058f707..e029ea7190 100644 --- a/tests/test_main.cpp +++ b/tests/test_main.cpp @@ -101,6 +101,7 @@ #include "tests/scene/test_sprite_frames.h" #include "tests/scene/test_text_edit.h" #include "tests/scene/test_theme.h" +#include "tests/scene/test_viewport.h" #include "tests/scene/test_visual_shader.h" #include "tests/servers/test_text_server.h" #include "tests/test_validate_testing.h" @@ -233,6 +234,9 @@ struct GodotTestCaseListener : public doctest::IReporter { memnew(SceneTree); SceneTree::get_singleton()->initialize(); + if (!DisplayServer::get_singleton()->has_feature(DisplayServer::Feature::FEATURE_SUBWINDOWS)) { + SceneTree::get_singleton()->get_root()->set_embedding_subwindows(true); + } return; } |