summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/core/config/test_project_settings.h7
-rw-r--r--tests/core/math/test_aabb.h14
-rw-r--r--tests/core/math/test_rect2.h22
-rw-r--r--tests/core/string/test_string.h2
-rw-r--r--tests/scene/test_code_edit.h20
-rw-r--r--tests/scene/test_text_edit.h66
6 files changed, 115 insertions, 16 deletions
diff --git a/tests/core/config/test_project_settings.h b/tests/core/config/test_project_settings.h
index 8fc2489f8b..0e1058a626 100644
--- a/tests/core/config/test_project_settings.h
+++ b/tests/core/config/test_project_settings.h
@@ -126,10 +126,9 @@ TEST_CASE("[ProjectSettings] localize_path") {
CHECK_EQ(ProjectSettings::get_singleton()->localize_path("path\\.\\filename"), "res://path/filename");
#endif
- // FIXME?: These checks pass, but that doesn't seems correct
- CHECK_EQ(ProjectSettings::get_singleton()->localize_path("../filename"), "res://filename");
- CHECK_EQ(ProjectSettings::get_singleton()->localize_path("../path/filename"), "res://path/filename");
- CHECK_EQ(ProjectSettings::get_singleton()->localize_path("..\\path\\filename"), "res://path/filename");
+ CHECK_EQ(ProjectSettings::get_singleton()->localize_path("../filename"), "../filename");
+ CHECK_EQ(ProjectSettings::get_singleton()->localize_path("../path/filename"), "../path/filename");
+ CHECK_EQ(ProjectSettings::get_singleton()->localize_path("..\\path\\filename"), "../path/filename");
CHECK_EQ(ProjectSettings::get_singleton()->localize_path("/testroot/filename"), "/testroot/filename");
CHECK_EQ(ProjectSettings::get_singleton()->localize_path("/testroot/path/filename"), "/testroot/path/filename");
diff --git a/tests/core/math/test_aabb.h b/tests/core/math/test_aabb.h
index dbc62bc248..741e6af5d4 100644
--- a/tests/core/math/test_aabb.h
+++ b/tests/core/math/test_aabb.h
@@ -377,23 +377,23 @@ TEST_CASE("[AABB] Get longest/shortest axis") {
TEST_CASE("[AABB] Get support") {
const AABB aabb = AABB(Vector3(-1.5, 2, -2.5), Vector3(4, 5, 6));
CHECK_MESSAGE(
- aabb.get_support(Vector3(1, 0, 0)).is_equal_approx(Vector3(2.5, 2, -2.5)),
+ aabb.get_support(Vector3(1, 0, 0)) == Vector3(2.5, 2, -2.5),
"get_support() should return the expected value.");
CHECK_MESSAGE(
- aabb.get_support(Vector3(0.5, 1, 0)).is_equal_approx(Vector3(2.5, 7, -2.5)),
+ aabb.get_support(Vector3(0.5, 1, 1)) == Vector3(2.5, 7, 3.5),
"get_support() should return the expected value.");
CHECK_MESSAGE(
- aabb.get_support(Vector3(0.5, 1, -400)).is_equal_approx(Vector3(2.5, 7, -2.5)),
+ aabb.get_support(Vector3(0.5, 1, -400)) == Vector3(2.5, 7, -2.5),
"get_support() should return the expected value.");
CHECK_MESSAGE(
- aabb.get_support(Vector3(0, -1, 0)).is_equal_approx(Vector3(-1.5, 2, -2.5)),
+ aabb.get_support(Vector3(0, -1, 0)) == Vector3(-1.5, 2, -2.5),
"get_support() should return the expected value.");
CHECK_MESSAGE(
- aabb.get_support(Vector3(0, -0.1, 0)).is_equal_approx(Vector3(-1.5, 2, -2.5)),
+ aabb.get_support(Vector3(0, -0.1, 0)) == Vector3(-1.5, 2, -2.5),
"get_support() should return the expected value.");
CHECK_MESSAGE(
- aabb.get_support(Vector3()).is_equal_approx(Vector3(-1.5, 2, -2.5)),
- "get_support() should return the expected value with a null vector.");
+ aabb.get_support(Vector3()) == Vector3(-1.5, 2, -2.5),
+ "get_support() should return the AABB position when given a zero vector.");
}
TEST_CASE("[AABB] Grow") {
diff --git a/tests/core/math/test_rect2.h b/tests/core/math/test_rect2.h
index 26ab185aa2..c4368808a6 100644
--- a/tests/core/math/test_rect2.h
+++ b/tests/core/math/test_rect2.h
@@ -180,6 +180,28 @@ TEST_CASE("[Rect2] Expanding") {
"expand() with non-contained Vector2 should return the expected result.");
}
+TEST_CASE("[Rect2] Get support") {
+ const Rect2 rect = Rect2(Vector2(-1.5, 2), Vector2(4, 5));
+ CHECK_MESSAGE(
+ rect.get_support(Vector2(1, 0)) == Vector2(2.5, 2),
+ "get_support() should return the expected value.");
+ CHECK_MESSAGE(
+ rect.get_support(Vector2(0.5, 1)) == Vector2(2.5, 7),
+ "get_support() should return the expected value.");
+ CHECK_MESSAGE(
+ rect.get_support(Vector2(0.5, 1)) == Vector2(2.5, 7),
+ "get_support() should return the expected value.");
+ CHECK_MESSAGE(
+ rect.get_support(Vector2(0, -1)) == Vector2(-1.5, 2),
+ "get_support() should return the expected value.");
+ CHECK_MESSAGE(
+ rect.get_support(Vector2(0, -0.1)) == Vector2(-1.5, 2),
+ "get_support() should return the expected value.");
+ CHECK_MESSAGE(
+ rect.get_support(Vector2()) == Vector2(-1.5, 2),
+ "get_support() should return the Rect2 position when given a zero vector.");
+}
+
TEST_CASE("[Rect2] Growing") {
CHECK_MESSAGE(
Rect2(0, 100, 1280, 720).grow(100).is_equal_approx(Rect2(-100, 0, 1480, 920)),
diff --git a/tests/core/string/test_string.h b/tests/core/string/test_string.h
index 393ae16d0a..933eeff524 100644
--- a/tests/core/string/test_string.h
+++ b/tests/core/string/test_string.h
@@ -1620,7 +1620,7 @@ TEST_CASE("[String] Path functions") {
static const char *base_name[8] = { "C:\\Godot\\project\\test", "/Godot/project/test", "../Godot/project/test", "Godot\\test", "C:\\test", "res://test", "user://test", "/" };
static const char *ext[8] = { "tscn", "xscn", "scn", "doc", "", "", "", "test" };
static const char *file[8] = { "test.tscn", "test.xscn", "test.scn", "test.doc", "test.", "test", "test", ".test" };
- static const char *simplified[8] = { "C:/Godot/project/test.tscn", "/Godot/project/test.xscn", "Godot/project/test.scn", "Godot/test.doc", "C:/test.", "res://test", "user://test", "/.test" };
+ static const char *simplified[8] = { "C:/Godot/project/test.tscn", "/Godot/project/test.xscn", "../Godot/project/test.scn", "Godot/test.doc", "C:/test.", "res://test", "user://test", "/.test" };
static const bool abs[8] = { true, true, false, false, true, true, true, true };
for (int i = 0; i < 8; i++) {
diff --git a/tests/scene/test_code_edit.h b/tests/scene/test_code_edit.h
index a166002cdd..9ec1b812df 100644
--- a/tests/scene/test_code_edit.h
+++ b/tests/scene/test_code_edit.h
@@ -4609,6 +4609,26 @@ TEST_CASE("[SceneTree][CodeEdit] text manipulation") {
CHECK(code_edit->get_text() == "line 1\nline 2\nline 3");
CHECK(code_edit->get_caret_line() == 0);
CHECK(code_edit->get_caret_column() == 0);
+
+ // Unfold previous folded line on backspace if the caret is at the first column.
+ code_edit->set_line_folding_enabled(true);
+ code_edit->set_text("line 1\n\tline 2\nline 3");
+ code_edit->set_caret_line(2);
+ code_edit->set_caret_column(0);
+ code_edit->fold_line(0);
+ code_edit->backspace();
+ CHECK_FALSE(code_edit->is_line_folded(0));
+ code_edit->set_line_folding_enabled(false);
+
+ // Do not unfold previous line on backspace if the caret is not at the first column.
+ code_edit->set_line_folding_enabled(true);
+ code_edit->set_text("line 1\n\tline 2\nline 3");
+ code_edit->set_caret_line(2);
+ code_edit->set_caret_column(4);
+ code_edit->fold_line(0);
+ code_edit->backspace();
+ CHECK(code_edit->is_line_folded(0));
+ code_edit->set_line_folding_enabled(false);
}
SUBCASE("[TextEdit] cut") {
diff --git a/tests/scene/test_text_edit.h b/tests/scene/test_text_edit.h
index b2d9f5100e..69e27fe7a0 100644
--- a/tests/scene/test_text_edit.h
+++ b/tests/scene/test_text_edit.h
@@ -1763,6 +1763,28 @@ TEST_CASE("[SceneTree][TextEdit] text entry") {
CHECK_FALSE(text_edit->has_selection());
CHECK(text_edit->get_caret_line() == 0);
CHECK(text_edit->get_caret_column() == 4);
+
+ // Wrapped lines.
+ text_edit->set_line_wrapping_mode(TextEdit::LineWrappingMode::LINE_WRAPPING_BOUNDARY);
+ text_edit->set_text("this is some text\nfor selection");
+ text_edit->set_size(Size2(110, 100));
+ MessageQueue::get_singleton()->flush();
+
+ // Line 0 wraps: 'this is ', 'some text'.
+ // Line 1 wraps: 'for ', 'selection'.
+ CHECK(text_edit->is_line_wrapped(0));
+
+ // Select to the first character of a wrapped line.
+ SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(0, 11).get_center(), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE);
+ SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(0, 8).get_center(), MouseButtonMask::LEFT, Key::NONE);
+ CHECK(text_edit->has_selection());
+ CHECK(text_edit->get_selected_text() == "so");
+ CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_POINTER);
+ CHECK(text_edit->get_selection_origin_line() == 0);
+ CHECK(text_edit->get_selection_origin_column() == 10);
+ CHECK(text_edit->get_caret_line() == 0);
+ CHECK(text_edit->get_caret_column() == 8);
+ CHECK(text_edit->is_dragging_cursor());
}
SUBCASE("[TextEdit] mouse word select") {
@@ -5713,6 +5735,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") {
CHECK(text_edit->get_caret_count() == 2);
MessageQueue::get_singleton()->flush();
+ // Lines 0 and 4 are wrapped into 2 parts: 'this is ' and 'some'.
CHECK(text_edit->is_line_wrapped(0));
SIGNAL_DISCARD("text_set");
SIGNAL_DISCARD("text_changed");
@@ -5762,9 +5785,9 @@ TEST_CASE("[SceneTree][TextEdit] text entry") {
SIGNAL_CHECK("caret_changed", empty_signal_args);
SIGNAL_CHECK_FALSE("text_changed");
SIGNAL_CHECK_FALSE("lines_edited_from");
- text_edit->set_caret_column(12, false);
// Normal up over wrapped line to line 0.
+ text_edit->set_caret_column(12, false);
SEND_GUI_ACTION("ui_text_caret_up");
CHECK(text_edit->get_viewport()->is_input_handled());
CHECK(text_edit->get_caret_line() == 0);
@@ -5777,6 +5800,23 @@ TEST_CASE("[SceneTree][TextEdit] text entry") {
SIGNAL_CHECK("caret_changed", empty_signal_args);
SIGNAL_CHECK_FALSE("text_changed");
SIGNAL_CHECK_FALSE("lines_edited_from");
+
+ // Normal up from column 0 to a wrapped line.
+ text_edit->remove_secondary_carets();
+ text_edit->set_caret_line(5);
+ text_edit->set_caret_column(0);
+ SEND_GUI_ACTION("ui_text_caret_up");
+ CHECK(text_edit->get_viewport()->is_input_handled());
+ CHECK(text_edit->get_caret_line() == 4);
+ CHECK(text_edit->get_caret_column() == 8);
+ CHECK_FALSE(text_edit->has_selection(0));
+
+ // Normal up to column 0 of a wrapped line.
+ SEND_GUI_ACTION("ui_text_caret_up");
+ CHECK(text_edit->get_viewport()->is_input_handled());
+ CHECK(text_edit->get_caret_line() == 4);
+ CHECK(text_edit->get_caret_column() == 0);
+ CHECK_FALSE(text_edit->has_selection(0));
}
SUBCASE("[TextEdit] ui_text_caret_down") {
@@ -5792,6 +5832,7 @@ TEST_CASE("[SceneTree][TextEdit] text entry") {
MessageQueue::get_singleton()->flush();
+ // Lines 3 and 7 are wrapped into 2 parts: 'this is ' and 'some'.
CHECK(text_edit->is_line_wrapped(3));
SIGNAL_DISCARD("text_set");
SIGNAL_DISCARD("text_changed");
@@ -5841,9 +5882,9 @@ TEST_CASE("[SceneTree][TextEdit] text entry") {
SIGNAL_CHECK("caret_changed", empty_signal_args);
SIGNAL_CHECK_FALSE("text_changed");
SIGNAL_CHECK_FALSE("lines_edited_from");
- text_edit->set_caret_column(7, false);
// Normal down over wrapped line to last wrapped line.
+ text_edit->set_caret_column(7, false);
SEND_GUI_ACTION("ui_text_caret_down");
CHECK(text_edit->get_viewport()->is_input_handled());
CHECK(text_edit->get_caret_line() == 3);
@@ -5856,6 +5897,23 @@ TEST_CASE("[SceneTree][TextEdit] text entry") {
SIGNAL_CHECK("caret_changed", empty_signal_args);
SIGNAL_CHECK_FALSE("text_changed");
SIGNAL_CHECK_FALSE("lines_edited_from");
+
+ // Normal down to column 0 of a wrapped line.
+ text_edit->remove_secondary_carets();
+ text_edit->set_caret_line(3);
+ text_edit->set_caret_column(0);
+ 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() == 8);
+ CHECK_FALSE(text_edit->has_selection(0));
+
+ // Normal down out of visual column 0 of a wrapped line moves to start of next line.
+ SEND_GUI_ACTION("ui_text_caret_down");
+ CHECK(text_edit->get_viewport()->is_input_handled());
+ CHECK(text_edit->get_caret_line() == 4);
+ CHECK(text_edit->get_caret_column() == 0);
+ CHECK_FALSE(text_edit->has_selection(0));
}
SUBCASE("[TextEdit] ui_text_caret_document_start") {
@@ -7162,7 +7220,7 @@ TEST_CASE("[SceneTree][TextEdit] multicaret") {
CHECK(text_edit->get_caret_line(0) == 2);
CHECK(text_edit->get_caret_column(0) == 5);
CHECK(text_edit->get_caret_line(1) == 2);
- CHECK(text_edit->get_caret_column(1) == 10);
+ CHECK(text_edit->get_caret_column(1) == 6);
// Cannot add caret below from last line last line wrap.
text_edit->add_caret_at_carets(true);
@@ -7171,7 +7229,7 @@ TEST_CASE("[SceneTree][TextEdit] multicaret") {
CHECK(text_edit->get_caret_line(0) == 2);
CHECK(text_edit->get_caret_column(0) == 5);
CHECK(text_edit->get_caret_line(1) == 2);
- CHECK(text_edit->get_caret_column(1) == 10);
+ CHECK(text_edit->get_caret_column(1) == 6);
// Add caret above from not first line wrap.
text_edit->remove_secondary_carets();