summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRedworkDE <10944644+RedworkDE@users.noreply.github.com>2023-05-09 15:50:48 +0200
committerRedworkDE <10944644+RedworkDE@users.noreply.github.com>2023-05-09 18:40:56 +0200
commit8e7afec479b29bfe7f6d33ca9bce70c9d1abf7cf (patch)
tree04bf8cc8c930f47c5793811aed5483b0fd7ff3bb
parent668cf3c66f42989949399f36e9faa29426e37416 (diff)
downloadredot-engine-8e7afec479b29bfe7f6d33ca9bce70c9d1abf7cf.tar.gz
Fix various errors when running the unit tests
Co-authored-by: bruvzg <7645683+bruvzg@users.noreply.github.com>
-rw-r--r--core/input/input_event.cpp5
-rw-r--r--main/main.cpp12
-rw-r--r--modules/text_server_fb/text_server_fb.cpp2
-rw-r--r--scene/3d/path_3d.cpp3
-rw-r--r--tests/core/object/test_class_db.h11
-rw-r--r--tests/scene/test_code_edit.h4
-rw-r--r--tests/scene/test_viewport.h2
-rw-r--r--tests/test_macros.h2
-rw-r--r--tests/test_main.cpp2
9 files changed, 22 insertions, 21 deletions
diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp
index 46f07fe041..19e4d6182a 100644
--- a/core/input/input_event.cpp
+++ b/core/input/input_event.cpp
@@ -484,7 +484,10 @@ Ref<InputEventKey> InputEventKey::create_reference(Key p_keycode, bool p_physica
ie->set_keycode(p_keycode & KeyModifierMask::CODE_MASK);
}
- ie->set_unicode(char32_t(p_keycode & KeyModifierMask::CODE_MASK));
+ char32_t ch = char32_t(p_keycode & KeyModifierMask::CODE_MASK);
+ if (ch < 0xd800 || (ch > 0xdfff && ch <= 0x10ffff)) {
+ ie->set_unicode(ch);
+ }
if ((p_keycode & KeyModifierMask::SHIFT) != Key::NONE) {
ie->set_shift_pressed(true);
diff --git a/main/main.cpp b/main/main.cpp
index 0a6c7d5f97..24673cda31 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -581,8 +581,6 @@ void Main::test_cleanup() {
TextServerManager::get_singleton()->get_interface(i)->cleanup();
}
- EngineDebugger::deinitialize();
-
ResourceLoader::remove_custom_loaders();
ResourceSaver::remove_custom_savers();
@@ -594,6 +592,7 @@ void Main::test_cleanup() {
GDExtensionManager::get_singleton()->deinitialize_extensions(GDExtension::INITIALIZATION_LEVEL_SCENE);
uninitialize_modules(MODULE_INITIALIZATION_LEVEL_SCENE);
+
unregister_platform_apis();
unregister_driver_types();
unregister_scene_types();
@@ -604,8 +603,12 @@ void Main::test_cleanup() {
uninitialize_modules(MODULE_INITIALIZATION_LEVEL_SERVERS);
unregister_server_types();
+ EngineDebugger::deinitialize();
OS::get_singleton()->finalize();
+ if (packed_data) {
+ memdelete(packed_data);
+ }
if (translation_server) {
memdelete(translation_server);
}
@@ -621,16 +624,13 @@ void Main::test_cleanup() {
if (globals) {
memdelete(globals);
}
- if (packed_data) {
- memdelete(packed_data);
- }
if (engine) {
memdelete(engine);
}
unregister_core_driver_types();
- uninitialize_modules(MODULE_INITIALIZATION_LEVEL_CORE);
unregister_core_extensions();
+ uninitialize_modules(MODULE_INITIALIZATION_LEVEL_CORE);
unregister_core_types();
OS::get_singleton()->finalize_core();
diff --git a/modules/text_server_fb/text_server_fb.cpp b/modules/text_server_fb/text_server_fb.cpp
index 8b210bdc38..b76214cf94 100644
--- a/modules/text_server_fb/text_server_fb.cpp
+++ b/modules/text_server_fb/text_server_fb.cpp
@@ -3865,8 +3865,8 @@ bool TextServerFallback::_shaped_text_shape(const RID &p_shaped) {
}
prev_font = gl.font_rid;
- double scale = _font_get_scale(gl.font_rid, gl.font_size);
if (gl.font_rid.is_valid()) {
+ double scale = _font_get_scale(gl.font_rid, gl.font_size);
bool subpos = (scale != 1.0) || (_font_get_subpixel_positioning(gl.font_rid) == SUBPIXEL_POSITIONING_ONE_HALF) || (_font_get_subpixel_positioning(gl.font_rid) == SUBPIXEL_POSITIONING_ONE_QUARTER) || (_font_get_subpixel_positioning(gl.font_rid) == SUBPIXEL_POSITIONING_AUTO && gl.font_size <= SUBPIXEL_POSITIONING_ONE_HALF_MAX_SIZE);
if (sd->text[j - sd->start] != 0 && !is_linebreak(sd->text[j - sd->start])) {
if (sd->orientation == ORIENTATION_HORIZONTAL) {
diff --git a/scene/3d/path_3d.cpp b/scene/3d/path_3d.cpp
index 04ac01a085..f02826b1c4 100644
--- a/scene/3d/path_3d.cpp
+++ b/scene/3d/path_3d.cpp
@@ -40,11 +40,12 @@ Path3D::Path3D() {
}
Path3D::~Path3D() {
- ERR_FAIL_NULL(RenderingServer::get_singleton());
if (debug_instance.is_valid()) {
+ ERR_FAIL_NULL(RenderingServer::get_singleton());
RS::get_singleton()->free(debug_instance);
}
if (debug_mesh.is_valid()) {
+ ERR_FAIL_NULL(RenderingServer::get_singleton());
RS::get_singleton()->free(debug_mesh->get_rid());
}
}
diff --git a/tests/core/object/test_class_db.h b/tests/core/object/test_class_db.h
index e68995e539..3f091fd2fe 100644
--- a/tests/core/object/test_class_db.h
+++ b/tests/core/object/test_class_db.h
@@ -487,13 +487,13 @@ void add_exposed_classes(Context &r_context) {
}
if (!ClassDB::is_class_exposed(class_name)) {
- MESSAGE(vformat("Ignoring class '%s' because it's not exposed.", class_name));
+ INFO(vformat("Ignoring class '%s' because it's not exposed.", class_name));
class_list.pop_front();
continue;
}
if (!ClassDB::is_class_enabled(class_name)) {
- MESSAGE(vformat("Ignoring class '%s' because it's not enabled.", class_name));
+ INFO(vformat("Ignoring class '%s' because it's not enabled.", class_name));
class_list.pop_front();
continue;
}
@@ -717,15 +717,10 @@ void add_exposed_classes(Context &r_context) {
bool method_conflict = exposed_class.find_property_by_name(signal.name);
- // TODO:
- // ClassDB allows signal names that conflict with method or property names.
- // However registering a signal with a conflicting name is still considered wrong.
- // Unfortunately there are some existing cases that are yet to be fixed.
- // Until those are fixed we will print a warning instead of failing the test.
String warn_msg = vformat(
"Signal name conflicts with %s: '%s.%s.",
method_conflict ? "method" : "property", class_name, signal.name);
- TEST_FAIL_COND_WARN((method_conflict || exposed_class.find_method_by_name(signal.name)),
+ TEST_FAIL_COND((method_conflict || exposed_class.find_method_by_name(signal.name)),
warn_msg.utf8().get_data());
exposed_class.signals_.push_back(signal);
diff --git a/tests/scene/test_code_edit.h b/tests/scene/test_code_edit.h
index 9b8ad32e32..a201f0f3b0 100644
--- a/tests/scene/test_code_edit.h
+++ b/tests/scene/test_code_edit.h
@@ -3482,9 +3482,9 @@ TEST_CASE("[SceneTree][CodeEdit] symbol lookup") {
SIGNAL_CHECK("symbol_validate", signal_args);
SIGNAL_UNWATCH(code_edit, "symbol_validate");
-
- memdelete(code_edit);
}
+
+ memdelete(code_edit);
}
TEST_CASE("[SceneTree][CodeEdit] line length guidelines") {
diff --git a/tests/scene/test_viewport.h b/tests/scene/test_viewport.h
index 62f4635927..d76fc40125 100644
--- a/tests/scene/test_viewport.h
+++ b/tests/scene/test_viewport.h
@@ -221,7 +221,9 @@ TEST_CASE("[SceneTree][Viewport] Controls and InputEvent handling") {
}
SUBCASE("[Viewport][GuiInputEvent] nullptr as argument doesn't lead to a crash.") {
+ ERR_PRINT_OFF;
CHECK_NOTHROW(root->push_input(nullptr));
+ ERR_PRINT_ON;
}
// Unit tests for Viewport::_gui_input_event (Mouse Buttons)
diff --git a/tests/test_macros.h b/tests/test_macros.h
index 5d1bcdecf4..d39da7f8e8 100644
--- a/tests/test_macros.h
+++ b/tests/test_macros.h
@@ -147,7 +147,7 @@ int register_test_command(String p_command, TestFunc p_function);
{ \
const List<Ref<InputEvent>> *events = InputMap::get_singleton()->action_get_events(m_action); \
const List<Ref<InputEvent>>::Element *first_event = events->front(); \
- Ref<InputEventKey> event = first_event->get(); \
+ Ref<InputEventKey> event = first_event->get()->duplicate(); \
event->set_pressed(true); \
_SEND_DISPLAYSERVER_EVENT(event); \
MessageQueue::get_singleton()->flush(); \
diff --git a/tests/test_main.cpp b/tests/test_main.cpp
index 291321a45e..a0359162d9 100644
--- a/tests/test_main.cpp
+++ b/tests/test_main.cpp
@@ -255,8 +255,8 @@ struct GodotTestCaseListener : public doctest::IReporter {
}
if (suite_name.find("[Navigation]") != -1 && navigation_server_2d == nullptr && navigation_server_3d == nullptr) {
- navigation_server_2d = memnew(NavigationServer2D);
navigation_server_3d = NavigationServer3DManager::new_default_server();
+ navigation_server_2d = memnew(NavigationServer2D);
return;
}
}