diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/SCsub | 5 | ||||
| -rw-r--r-- | tests/core/io/test_config_file.h (renamed from tests/test_config_file.h) | 1 | ||||
| -rw-r--r-- | tests/core/io/test_file_access.h (renamed from tests/test_file_access.h) | 3 | ||||
| -rw-r--r-- | tests/core/io/test_image.h (renamed from tests/test_image.h) | 4 | ||||
| -rw-r--r-- | tests/core/io/test_json.h (renamed from tests/test_json.h) | 0 | ||||
| -rw-r--r-- | tests/core/io/test_marshalls.h (renamed from tests/test_marshalls.h) | 0 | ||||
| -rw-r--r-- | tests/core/io/test_pck_packer.h (renamed from tests/test_pck_packer.h) | 30 | ||||
| -rw-r--r-- | tests/core/io/test_resource.h (renamed from tests/test_resource.h) | 0 | ||||
| -rw-r--r-- | tests/core/io/test_xml_parser.h (renamed from tests/test_xml_parser.h) | 3 | ||||
| -rw-r--r-- | tests/core/math/test_aabb.h (renamed from tests/test_aabb.h) | 34 | ||||
| -rw-r--r-- | tests/core/math/test_astar.h (renamed from tests/test_astar.h) | 5 | ||||
| -rw-r--r-- | tests/core/math/test_basis.h (renamed from tests/test_basis.h) | 3 | ||||
| -rw-r--r-- | tests/core/math/test_color.h (renamed from tests/test_color.h) | 2 | ||||
| -rw-r--r-- | tests/core/math/test_expression.h (renamed from tests/test_expression.h) | 0 | ||||
| -rw-r--r-- | tests/core/math/test_geometry_2d.h (renamed from tests/test_geometry_2d.h) | 1 | ||||
| -rw-r--r-- | tests/core/math/test_geometry_3d.h (renamed from tests/test_geometry_3d.h) | 4 | ||||
| -rw-r--r-- | tests/core/math/test_math.cpp (renamed from tests/test_math.cpp) | 14 | ||||
| -rw-r--r-- | tests/core/math/test_math.h (renamed from tests/test_math.h) | 2 | ||||
| -rw-r--r-- | tests/core/math/test_random_number_generator.h (renamed from tests/test_random_number_generator.h) | 0 | ||||
| -rw-r--r-- | tests/core/math/test_rect2.h (renamed from tests/test_rect2.h) | 136 | ||||
| -rw-r--r-- | tests/core/object/test_class_db.h (renamed from tests/test_class_db.h) | 9 | ||||
| -rw-r--r-- | tests/core/object/test_method_bind.h (renamed from tests/test_method_bind.h) | 4 | ||||
| -rw-r--r-- | tests/core/object/test_object.h (renamed from tests/test_object.h) | 4 | ||||
| -rw-r--r-- | tests/core/string/test_node_path.h (renamed from tests/test_node_path.h) | 2 | ||||
| -rw-r--r-- | tests/core/string/test_string.h (renamed from tests/test_string.h) | 14 | ||||
| -rw-r--r-- | tests/core/string/test_translation.h (renamed from tests/test_translation.h) | 3 | ||||
| -rw-r--r-- | tests/core/templates/test_command_queue.h (renamed from tests/test_command_queue.h) | 4 | ||||
| -rw-r--r-- | tests/core/templates/test_list.h (renamed from tests/test_list.h) | 0 | ||||
| -rw-r--r-- | tests/core/templates/test_local_vector.h (renamed from tests/test_local_vector.h) | 0 | ||||
| -rw-r--r-- | tests/core/templates/test_lru.h (renamed from tests/test_lru.h) | 1 | ||||
| -rw-r--r-- | tests/core/templates/test_oa_hash_map.cpp (renamed from tests/test_oa_hash_map.cpp) | 0 | ||||
| -rw-r--r-- | tests/core/templates/test_oa_hash_map.h (renamed from tests/test_oa_hash_map.h) | 2 | ||||
| -rw-r--r-- | tests/core/templates/test_ordered_hash_map.h (renamed from tests/test_ordered_hash_map.h) | 3 | ||||
| -rw-r--r-- | tests/core/templates/test_paged_array.h (renamed from tests/test_paged_array.h) | 0 | ||||
| -rw-r--r-- | tests/core/templates/test_vector.h (renamed from tests/test_vector.h) | 0 | ||||
| -rw-r--r-- | tests/core/test_crypto.h (renamed from tests/test_crypto.h) | 1 | ||||
| -rw-r--r-- | tests/core/test_hashing_context.h (renamed from tests/test_hashing_context.h) | 0 | ||||
| -rw-r--r-- | tests/core/test_time.h (renamed from tests/test_time.h) | 0 | ||||
| -rw-r--r-- | tests/core/variant/test_array.h (renamed from tests/test_array.h) | 6 | ||||
| -rw-r--r-- | tests/core/variant/test_dictionary.h (renamed from tests/test_dictionary.h) | 3 | ||||
| -rw-r--r-- | tests/core/variant/test_variant.h (renamed from tests/test_variant.h) | 0 | ||||
| -rw-r--r-- | tests/scene/test_code_edit.h (renamed from tests/test_code_edit.h) | 41 | ||||
| -rw-r--r-- | tests/scene/test_curve.h (renamed from tests/test_curve.h) | 2 | ||||
| -rw-r--r-- | tests/scene/test_gradient.h (renamed from tests/test_gradient.h) | 2 | ||||
| -rw-r--r-- | tests/scene/test_gui.cpp (renamed from tests/test_gui.cpp) | 13 | ||||
| -rw-r--r-- | tests/scene/test_gui.h (renamed from tests/test_gui.h) | 2 | ||||
| -rw-r--r-- | tests/scene/test_path_3d.h (renamed from tests/test_path_3d.h) | 1 | ||||
| -rw-r--r-- | tests/scene/test_path_follow_2d.h (renamed from tests/test_path_follow_2d.h) | 1 | ||||
| -rw-r--r-- | tests/scene/test_path_follow_3d.h (renamed from tests/test_path_follow_3d.h) | 1 | ||||
| -rw-r--r-- | tests/servers/test_physics_2d.cpp (renamed from tests/test_physics_2d.cpp) | 13 | ||||
| -rw-r--r-- | tests/servers/test_physics_2d.h (renamed from tests/test_physics_2d.h) | 2 | ||||
| -rw-r--r-- | tests/servers/test_physics_3d.cpp (renamed from tests/test_physics_3d.cpp) | 10 | ||||
| -rw-r--r-- | tests/servers/test_physics_3d.h (renamed from tests/test_physics_3d.h) | 2 | ||||
| -rw-r--r-- | tests/servers/test_render.cpp (renamed from tests/test_render.cpp) | 5 | ||||
| -rw-r--r-- | tests/servers/test_render.h (renamed from tests/test_render.h) | 4 | ||||
| -rw-r--r-- | tests/servers/test_shader_lang.cpp (renamed from tests/test_shader_lang.cpp) | 5 | ||||
| -rw-r--r-- | tests/servers/test_shader_lang.h (renamed from tests/test_shader_lang.h) | 2 | ||||
| -rw-r--r-- | tests/servers/test_text_server.h (renamed from tests/test_text_server.h) | 0 | ||||
| -rw-r--r-- | tests/test_macros.h | 10 | ||||
| -rw-r--r-- | tests/test_main.cpp | 102 | ||||
| -rw-r--r-- | tests/test_tools.h | 2 | ||||
| -rw-r--r-- | tests/test_utils.cpp | 2 | ||||
| -rw-r--r-- | tests/test_utils.h | 2 |
63 files changed, 265 insertions, 262 deletions
diff --git a/tests/SCsub b/tests/SCsub index 0f3c14f0bd..31466fffc1 100644 --- a/tests/SCsub +++ b/tests/SCsub @@ -22,6 +22,11 @@ if env_tests["platform"] == "windows": if env_tests.msvc: env_tests.Append(CCFLAGS=["/bigobj"]) +env_tests.add_source_files(env.tests_sources, "core/*.cpp") +env_tests.add_source_files(env.tests_sources, "core/math/*.cpp") +env_tests.add_source_files(env.tests_sources, "core/templates/*.cpp") +env_tests.add_source_files(env.tests_sources, "scene/*.cpp") +env_tests.add_source_files(env.tests_sources, "servers/*.cpp") env_tests.add_source_files(env.tests_sources, "*.cpp") lib = env_tests.add_library("tests", env.tests_sources) diff --git a/tests/test_config_file.h b/tests/core/io/test_config_file.h index e3f40e16fd..f6fbaf9a88 100644 --- a/tests/test_config_file.h +++ b/tests/core/io/test_config_file.h @@ -32,6 +32,7 @@ #define TEST_CONFIG_FILE_H #include "core/io/config_file.h" +#include "core/os/os.h" #include "tests/test_macros.h" diff --git a/tests/test_file_access.h b/tests/core/io/test_file_access.h index b3da16c1d1..4ffc57afe4 100644 --- a/tests/test_file_access.h +++ b/tests/core/io/test_file_access.h @@ -32,7 +32,8 @@ #define TEST_FILE_ACCESS_H #include "core/io/file_access.h" -#include "test_utils.h" +#include "tests/test_macros.h" +#include "tests/test_utils.h" namespace TestFileAccess { diff --git a/tests/test_image.h b/tests/core/io/test_image.h index 99c2a9380d..c4c5f1e18b 100644 --- a/tests/test_image.h +++ b/tests/core/io/test_image.h @@ -31,10 +31,10 @@ #ifndef TEST_IMAGE_H #define TEST_IMAGE_H -#include "core/io/file_access_pack.h" #include "core/io/image.h" -#include "test_utils.h" +#include "core/os/os.h" +#include "tests/test_utils.h" #include "thirdparty/doctest/doctest.h" namespace TestImage { diff --git a/tests/test_json.h b/tests/core/io/test_json.h index 3af58dfa1c..3af58dfa1c 100644 --- a/tests/test_json.h +++ b/tests/core/io/test_json.h diff --git a/tests/test_marshalls.h b/tests/core/io/test_marshalls.h index 6bd916164e..6bd916164e 100644 --- a/tests/test_marshalls.h +++ b/tests/core/io/test_marshalls.h diff --git a/tests/test_pck_packer.h b/tests/core/io/test_pck_packer.h index 06e4e64963..75a4abffbe 100644 --- a/tests/test_pck_packer.h +++ b/tests/core/io/test_pck_packer.h @@ -35,21 +35,16 @@ #include "core/io/pck_packer.h" #include "core/os/os.h" +#include "tests/test_utils.h" #include "thirdparty/doctest/doctest.h" namespace TestPCKPacker { -// Dummy 64-character encryption key (since it's required). -constexpr const char *ENCRYPTION_KEY = "0000000000000000000000000000000000000000000000000000000000000000"; - TEST_CASE("[PCKPacker] Pack an empty PCK file") { PCKPacker pck_packer; const String output_pck_path = OS::get_singleton()->get_cache_path().plus_file("output_empty.pck"); CHECK_MESSAGE( - pck_packer.pck_start( - output_pck_path, - 32, - ENCRYPTION_KEY) == OK, + pck_packer.pck_start(output_pck_path) == OK, "Starting a PCK file should return an OK error code."); CHECK_MESSAGE( @@ -69,14 +64,27 @@ TEST_CASE("[PCKPacker] Pack an empty PCK file") { "The generated empty PCK file shouldn't be too large."); } +TEST_CASE("[PCKPacker] Pack empty with zero alignment invalid") { + PCKPacker pck_packer; + const String output_pck_path = OS::get_singleton()->get_cache_path().plus_file("output_empty.pck"); + ERR_PRINT_OFF; + CHECK_MESSAGE(pck_packer.pck_start(output_pck_path, 0) != OK, "PCK with zero alignment should fail."); + ERR_PRINT_ON; +} + +TEST_CASE("[PCKPacker] Pack empty with invalid key") { + PCKPacker pck_packer; + const String output_pck_path = OS::get_singleton()->get_cache_path().plus_file("output_empty.pck"); + ERR_PRINT_OFF; + CHECK_MESSAGE(pck_packer.pck_start(output_pck_path, 32, "") != OK, "PCK with invalid key should fail."); + ERR_PRINT_ON; +} + TEST_CASE("[PCKPacker] Pack a PCK file with some files and directories") { PCKPacker pck_packer; const String output_pck_path = OS::get_singleton()->get_cache_path().plus_file("output_with_files.pck"); CHECK_MESSAGE( - pck_packer.pck_start( - output_pck_path, - 32, - ENCRYPTION_KEY) == OK, + pck_packer.pck_start(output_pck_path) == OK, "Starting a PCK file should return an OK error code."); const String base_dir = OS::get_singleton()->get_executable_path().get_base_dir(); diff --git a/tests/test_resource.h b/tests/core/io/test_resource.h index cee3281995..cee3281995 100644 --- a/tests/test_resource.h +++ b/tests/core/io/test_resource.h diff --git a/tests/test_xml_parser.h b/tests/core/io/test_xml_parser.h index 55de048d6a..2d00f29ddf 100644 --- a/tests/test_xml_parser.h +++ b/tests/core/io/test_xml_parser.h @@ -31,10 +31,7 @@ #ifndef TEST_XML_PARSER_H #define TEST_XML_PARSER_H -#include <inttypes.h> - #include "core/io/xml_parser.h" -#include "core/string/ustring.h" #include "tests/test_macros.h" diff --git a/tests/test_aabb.h b/tests/core/math/test_aabb.h index 2724d9481a..b838bed171 100644 --- a/tests/test_aabb.h +++ b/tests/core/math/test_aabb.h @@ -32,10 +32,8 @@ #define TEST_AABB_H #include "core/math/aabb.h" -#include "core/string/print_string.h" -#include "tests/test_macros.h" -#include "thirdparty/doctest/doctest.h" +#include "tests/test_macros.h" namespace TestAABB { @@ -90,38 +88,38 @@ TEST_CASE("[AABB] Basic setters") { "set_size() should result in the expected AABB."); } -TEST_CASE("[AABB] Area getters") { +TEST_CASE("[AABB] Volume getters") { AABB aabb = AABB(Vector3(-1.5, 2, -2.5), Vector3(4, 5, 6)); CHECK_MESSAGE( - Math::is_equal_approx(aabb.get_area(), 120), - "get_area() should return the expected value with positive size."); + Math::is_equal_approx(aabb.get_volume(), 120), + "get_volume() should return the expected value with positive size."); CHECK_MESSAGE( - !aabb.has_no_area(), - "Non-empty volumetric AABB should have an area."); + !aabb.has_no_volume(), + "Non-empty volumetric AABB should have a volume."); aabb = AABB(Vector3(-1.5, 2, -2.5), Vector3(-4, 5, 6)); CHECK_MESSAGE( - Math::is_equal_approx(aabb.get_area(), -120), - "get_area() should return the expected value with negative size (1 component)."); + Math::is_equal_approx(aabb.get_volume(), -120), + "get_volume() should return the expected value with negative size (1 component)."); aabb = AABB(Vector3(-1.5, 2, -2.5), Vector3(-4, -5, 6)); CHECK_MESSAGE( - Math::is_equal_approx(aabb.get_area(), 120), - "get_area() should return the expected value with negative size (2 components)."); + Math::is_equal_approx(aabb.get_volume(), 120), + "get_volume() should return the expected value with negative size (2 components)."); aabb = AABB(Vector3(-1.5, 2, -2.5), Vector3(-4, -5, -6)); CHECK_MESSAGE( - Math::is_equal_approx(aabb.get_area(), -120), - "get_area() should return the expected value with negative size (3 components)."); + Math::is_equal_approx(aabb.get_volume(), -120), + "get_volume() should return the expected value with negative size (3 components)."); aabb = AABB(Vector3(-1.5, 2, -2.5), Vector3(4, 0, 6)); CHECK_MESSAGE( - aabb.has_no_area(), - "Non-empty flat AABB should not have an area."); + aabb.has_no_volume(), + "Non-empty flat AABB should not have a volume."); CHECK_MESSAGE( - AABB().has_no_area(), - "Empty AABB should not have an area."); + AABB().has_no_volume(), + "Empty AABB should not have a volume."); } TEST_CASE("[AABB] Surface getters") { diff --git a/tests/test_astar.h b/tests/core/math/test_astar.h index 137c477946..2c183374ac 100644 --- a/tests/test_astar.h +++ b/tests/core/math/test_astar.h @@ -32,11 +32,6 @@ #define TEST_ASTAR_H #include "core/math/a_star.h" -#include "core/math/math_funcs.h" -#include "core/os/os.h" - -#include <math.h> -#include <stdio.h> #include "tests/test_macros.h" diff --git a/tests/test_basis.h b/tests/core/math/test_basis.h index b254d9fb7f..500c069a33 100644 --- a/tests/test_basis.h +++ b/tests/core/math/test_basis.h @@ -31,9 +31,8 @@ #ifndef TEST_BASIS_H #define TEST_BASIS_H +#include "core/math/basis.h" #include "core/math/random_number_generator.h" -#include "core/os/os.h" -#include "core/string/ustring.h" #include "tests/test_macros.h" diff --git a/tests/test_color.h b/tests/core/math/test_color.h index bffa890ae2..82cf786f7a 100644 --- a/tests/test_color.h +++ b/tests/core/math/test_color.h @@ -33,7 +33,7 @@ #include "core/math/color.h" -#include "thirdparty/doctest/doctest.h" +#include "tests/test_macros.h" namespace TestColor { diff --git a/tests/test_expression.h b/tests/core/math/test_expression.h index cb1d29389f..cb1d29389f 100644 --- a/tests/test_expression.h +++ b/tests/core/math/test_expression.h diff --git a/tests/test_geometry_2d.h b/tests/core/math/test_geometry_2d.h index 25af8c355e..8f6669b572 100644 --- a/tests/test_geometry_2d.h +++ b/tests/core/math/test_geometry_2d.h @@ -32,7 +32,6 @@ #define TEST_GEOMETRY_2D_H #include "core/math/geometry_2d.h" -#include "core/templates/vector.h" #include "thirdparty/doctest/doctest.h" diff --git a/tests/test_geometry_3d.h b/tests/core/math/test_geometry_3d.h index ae30737fe2..f42003ffcf 100644 --- a/tests/test_geometry_3d.h +++ b/tests/core/math/test_geometry_3d.h @@ -32,11 +32,7 @@ #define TEST_GEOMETRY_3D_H #include "core/math/geometry_3d.h" -#include "core/math/plane.h" -#include "core/math/random_number_generator.h" -#include "core/math/vector3.h" #include "tests/test_macros.h" -#include "vector" namespace TestGeometry3D { TEST_CASE("[Geometry3D] Closest Points Between Segments") { diff --git a/tests/test_math.cpp b/tests/core/math/test_math.cpp index 72272382ce..6ec9bc2473 100644 --- a/tests/test_math.cpp +++ b/tests/core/math/test_math.cpp @@ -30,23 +30,11 @@ #include "test_math.h" -#include "core/io/file_access.h" -#include "core/math/basis.h" #include "core/math/camera_matrix.h" #include "core/math/delaunay_3d.h" #include "core/math/geometry_2d.h" -#include "core/math/math_funcs.h" -#include "core/math/transform_3d.h" -#include "core/os/keyboard.h" +#include "core/os/main_loop.h" #include "core/os/os.h" -#include "core/string/print_string.h" -#include "core/string/ustring.h" -#include "core/templates/vmap.h" -#include "core/variant/method_ptrcall.h" -#include "core/variant/variant.h" -#include "scene/main/node.h" -#include "scene/resources/texture.h" -#include "servers/rendering/shader_language.h" namespace TestMath { diff --git a/tests/test_math.h b/tests/core/math/test_math.h index 4375925bd5..ab5fb6a050 100644 --- a/tests/test_math.h +++ b/tests/core/math/test_math.h @@ -31,7 +31,7 @@ #ifndef TEST_MATH_H #define TEST_MATH_H -#include "core/os/main_loop.h" +class MainLoop; namespace TestMath { diff --git a/tests/test_random_number_generator.h b/tests/core/math/test_random_number_generator.h index 39c4771c19..39c4771c19 100644 --- a/tests/test_random_number_generator.h +++ b/tests/core/math/test_random_number_generator.h diff --git a/tests/test_rect2.h b/tests/core/math/test_rect2.h index 3d9fe5a32e..aabb950461 100644 --- a/tests/test_rect2.h +++ b/tests/core/math/test_rect2.h @@ -211,26 +211,74 @@ TEST_CASE("[Rect2] Growing") { } TEST_CASE("[Rect2] Has point") { + Rect2 rect = Rect2(0, 100, 1280, 720); CHECK_MESSAGE( - Rect2(0, 100, 1280, 720).has_point(Vector2(500, 600)), + rect.has_point(Vector2(500, 600)), "has_point() with contained Vector2 should return the expected result."); CHECK_MESSAGE( - !Rect2(0, 100, 1280, 720).has_point(Vector2(0, 0)), + !rect.has_point(Vector2(0, 0)), "has_point() with non-contained Vector2 should return the expected result."); CHECK_MESSAGE( - Rect2(0, 100, 1280, 720).has_point(Vector2(0, 110)), - "has_point() with positive Vector2 on left edge should return the expected result."); + rect.has_point(rect.position), + "has_point() with positive size should include `position`."); + CHECK_MESSAGE( + rect.has_point(rect.position + Vector2(1, 1)), + "has_point() with positive size should include `position + (1, 1)`."); + CHECK_MESSAGE( + !rect.has_point(rect.position + Vector2(1, -1)), + "has_point() with positive size should not include `position + (1, -1)`."); + CHECK_MESSAGE( + !rect.has_point(rect.position + rect.size), + "has_point() with positive size should not include `position + size`."); + CHECK_MESSAGE( + !rect.has_point(rect.position + rect.size + Vector2(1, 1)), + "has_point() with positive size should not include `position + size + (1, 1)`."); + CHECK_MESSAGE( + rect.has_point(rect.position + rect.size + Vector2(-1, -1)), + "has_point() with positive size should include `position + size + (-1, -1)`."); + CHECK_MESSAGE( + !rect.has_point(rect.position + rect.size + Vector2(-1, 1)), + "has_point() with positive size should not include `position + size + (-1, 1)`."); + + CHECK_MESSAGE( + rect.has_point(rect.position + Vector2(0, 10)), + "has_point() with point located on left edge should return true."); + CHECK_MESSAGE( + !rect.has_point(rect.position + Vector2(rect.size.x, 10)), + "has_point() with point located on right edge should return false."); + CHECK_MESSAGE( + rect.has_point(rect.position + Vector2(10, 0)), + "has_point() with point located on top edge should return true."); + CHECK_MESSAGE( + !rect.has_point(rect.position + Vector2(10, rect.size.y)), + "has_point() with point located on bottom edge should return false."); + + /* + // FIXME: Disabled for now until GH-37617 is fixed one way or another. + // More tests should then be written like for the positive size case. + rect = Rect2(0, 100, -1280, -720); + CHECK_MESSAGE( + rect.has_point(rect.position), + "has_point() with negative size should include `position`."); CHECK_MESSAGE( - !Rect2(0, 100, 1280, 720).has_point(Vector2(1280, 110)), - "has_point() with positive Vector2 on right edge should return the expected result."); + !rect.has_point(rect.position + rect.size), + "has_point() with negative size should not include `position + size`."); + */ + rect = Rect2(-4000, -200, 1280, 720); + CHECK_MESSAGE( + rect.has_point(rect.position + Vector2(0, 10)), + "has_point() with negative position and point located on left edge should return true."); + CHECK_MESSAGE( + !rect.has_point(rect.position + Vector2(rect.size.x, 10)), + "has_point() with negative position and point located on right edge should return false."); CHECK_MESSAGE( - Rect2(-4000, 100, 1280, 720).has_point(Vector2(-4000, 110)), - "has_point() with negative Vector2 on left edge should return the expected result."); + rect.has_point(rect.position + Vector2(10, 0)), + "has_point() with negative position and point located on top edge should return true."); CHECK_MESSAGE( - !Rect2(-4000, 100, 1280, 720).has_point(Vector2(-2720, 110)), - "has_point() with negative Vector2 on right edge should return the expected result."); + !rect.has_point(rect.position + Vector2(10, rect.size.y)), + "has_point() with negative position and point located on bottom edge should return false."); } TEST_CASE("[Rect2] Intersection") { @@ -429,26 +477,74 @@ TEST_CASE("[Rect2i] Growing") { } TEST_CASE("[Rect2i] Has point") { + Rect2i rect = Rect2i(0, 100, 1280, 720); CHECK_MESSAGE( - Rect2i(0, 100, 1280, 720).has_point(Vector2i(500, 600)), + rect.has_point(Vector2i(500, 600)), "has_point() with contained Vector2i should return the expected result."); CHECK_MESSAGE( - !Rect2i(0, 100, 1280, 720).has_point(Vector2i(0, 0)), + !rect.has_point(Vector2i(0, 0)), "has_point() with non-contained Vector2i should return the expected result."); CHECK_MESSAGE( - Rect2i(0, 100, 1280, 720).has_point(Vector2(0, 110)), - "has_point() with positive Vector2 on left edge should return the expected result."); + rect.has_point(rect.position), + "has_point() with positive size should include `position`."); + CHECK_MESSAGE( + rect.has_point(rect.position + Vector2i(1, 1)), + "has_point() with positive size should include `position + (1, 1)`."); + CHECK_MESSAGE( + !rect.has_point(rect.position + Vector2i(1, -1)), + "has_point() with positive size should not include `position + (1, -1)`."); + CHECK_MESSAGE( + !rect.has_point(rect.position + rect.size), + "has_point() with positive size should not include `position + size`."); + CHECK_MESSAGE( + !rect.has_point(rect.position + rect.size + Vector2i(1, 1)), + "has_point() with positive size should not include `position + size + (1, 1)`."); + CHECK_MESSAGE( + rect.has_point(rect.position + rect.size + Vector2i(-1, -1)), + "has_point() with positive size should include `position + size + (-1, -1)`."); + CHECK_MESSAGE( + !rect.has_point(rect.position + rect.size + Vector2i(-1, 1)), + "has_point() with positive size should not include `position + size + (-1, 1)`."); + + CHECK_MESSAGE( + rect.has_point(rect.position + Vector2i(0, 10)), + "has_point() with point located on left edge should return true."); + CHECK_MESSAGE( + !rect.has_point(rect.position + Vector2i(rect.size.x, 10)), + "has_point() with point located on right edge should return false."); + CHECK_MESSAGE( + rect.has_point(rect.position + Vector2i(10, 0)), + "has_point() with point located on top edge should return true."); + CHECK_MESSAGE( + !rect.has_point(rect.position + Vector2i(10, rect.size.y)), + "has_point() with point located on bottom edge should return false."); + + /* + // FIXME: Disabled for now until GH-37617 is fixed one way or another. + // More tests should then be written like for the positive size case. + rect = Rect2i(0, 100, -1280, -720); + CHECK_MESSAGE( + rect.has_point(rect.position), + "has_point() with negative size should include `position`."); CHECK_MESSAGE( - !Rect2i(0, 100, 1280, 720).has_point(Vector2(1280, 110)), - "has_point() with positive Vector2 on right edge should return the expected result."); + !rect.has_point(rect.position + rect.size), + "has_point() with negative size should not include `position + size`."); + */ + rect = Rect2i(-4000, -200, 1280, 720); + CHECK_MESSAGE( + rect.has_point(rect.position + Vector2i(0, 10)), + "has_point() with negative position and point located on left edge should return true."); + CHECK_MESSAGE( + !rect.has_point(rect.position + Vector2i(rect.size.x, 10)), + "has_point() with negative position and point located on right edge should return false."); CHECK_MESSAGE( - Rect2i(-4000, 100, 1280, 720).has_point(Vector2(-4000, 110)), - "has_point() with negative Vector2 on left edge should return the expected result."); + rect.has_point(rect.position + Vector2i(10, 0)), + "has_point() with negative position and point located on top edge should return true."); CHECK_MESSAGE( - !Rect2i(-4000, 100, 1280, 720).has_point(Vector2(-2720, 110)), - "has_point() with negative Vector2 on right edge should return the expected result."); + !rect.has_point(rect.position + Vector2i(10, rect.size.y)), + "has_point() with negative position and point located on bottom edge should return false."); } TEST_CASE("[Rect2i] Intersection") { diff --git a/tests/test_class_db.h b/tests/core/object/test_class_db.h index 4b058a4c67..4b27905485 100644 --- a/tests/test_class_db.h +++ b/tests/core/object/test_class_db.h @@ -31,14 +31,9 @@ #ifndef TEST_CLASS_DB_H #define TEST_CLASS_DB_H -#include "core/register_core_types.h" - +#include "core/core_bind.h" #include "core/core_constants.h" -#include "core/os/os.h" -#include "core/string/string_name.h" -#include "core/string/ustring.h" -#include "core/templates/ordered_hash_map.h" -#include "core/variant/variant.h" +#include "core/object/class_db.h" #include "tests/test_macros.h" diff --git a/tests/test_method_bind.h b/tests/core/object/test_method_bind.h index 879e7949e2..c3a869a8a4 100644 --- a/tests/test_method_bind.h +++ b/tests/core/object/test_method_bind.h @@ -35,10 +35,6 @@ #include "tests/test_macros.h" -#include <inttypes.h> -#include <stdio.h> -#include <wchar.h> - namespace TestMethodBind { class MethodBindTester : public Object { diff --git a/tests/test_object.h b/tests/core/object/test_object.h index 8cb7116a20..4109ea521a 100644 --- a/tests/test_object.h +++ b/tests/core/object/test_object.h @@ -32,9 +32,11 @@ #define TEST_OBJECT_H #include "core/core_string_names.h" +#include "core/object/class_db.h" #include "core/object/object.h" +#include "core/object/script_language.h" -#include "thirdparty/doctest/doctest.h" +#include "tests/test_macros.h" // Declared in global namespace because of GDCLASS macro warning (Windows): // "Unqualified friend declaration referring to type outside of the nearest enclosing namespace diff --git a/tests/test_node_path.h b/tests/core/string/test_node_path.h index f30fe53c5a..0216a30f8f 100644 --- a/tests/test_node_path.h +++ b/tests/core/string/test_node_path.h @@ -33,7 +33,7 @@ #include "core/string/node_path.h" -#include "thirdparty/doctest/doctest.h" +#include "tests/test_macros.h" namespace TestNodePath { diff --git a/tests/test_string.h b/tests/core/string/test_string.h index 28d1089d2f..00a9a8779a 100644 --- a/tests/test_string.h +++ b/tests/core/string/test_string.h @@ -31,15 +31,7 @@ #ifndef TEST_STRING_H #define TEST_STRING_H -#include <inttypes.h> -#include <stdio.h> -#include <wchar.h> - -#include "core/io/ip_address.h" -#include "core/os/main_loop.h" -#include "core/os/os.h" #include "core/string/ustring.h" -#include "core/variant/variant.h" #include "tests/test_macros.h" @@ -498,12 +490,6 @@ TEST_CASE("[String] Splitting") { } } -TEST_CASE("[String] Erasing") { - String s = "Josephine is such a cute girl!"; - s.erase(s.find("cute "), String("cute ").length()); - CHECK(s == "Josephine is such a girl!"); -} - struct test_27_data { char const *data; char const *part; diff --git a/tests/test_translation.h b/tests/core/string/test_translation.h index 93c53bbbc9..47e06add40 100644 --- a/tests/test_translation.h +++ b/tests/core/string/test_translation.h @@ -39,7 +39,8 @@ #include "editor/import/resource_importer_csv_translation.h" #endif -#include "thirdparty/doctest/doctest.h" +#include "tests/test_macros.h" +#include "tests/test_utils.h" namespace TestTranslation { diff --git a/tests/test_command_queue.h b/tests/core/templates/test_command_queue.h index f0d4569942..5d228f2bf6 100644 --- a/tests/test_command_queue.h +++ b/tests/core/templates/test_command_queue.h @@ -33,12 +33,10 @@ #include "core/config/project_settings.h" #include "core/math/random_number_generator.h" -#include "core/os/mutex.h" #include "core/os/os.h" -#include "core/os/semaphore.h" #include "core/os/thread.h" #include "core/templates/command_queue_mt.h" -#include "test_macros.h" +#include "tests/test_macros.h" #if !defined(NO_THREADS) diff --git a/tests/test_list.h b/tests/core/templates/test_list.h index 52d5edff70..52d5edff70 100644 --- a/tests/test_list.h +++ b/tests/core/templates/test_list.h diff --git a/tests/test_local_vector.h b/tests/core/templates/test_local_vector.h index eff2a16abc..eff2a16abc 100644 --- a/tests/test_local_vector.h +++ b/tests/core/templates/test_local_vector.h diff --git a/tests/test_lru.h b/tests/core/templates/test_lru.h index 2802754729..9359909c53 100644 --- a/tests/test_lru.h +++ b/tests/core/templates/test_lru.h @@ -32,7 +32,6 @@ #define TEST_LRU_H #include "core/templates/lru.h" -#include "core/templates/vector.h" #include "tests/test_macros.h" diff --git a/tests/test_oa_hash_map.cpp b/tests/core/templates/test_oa_hash_map.cpp index 904c01642d..904c01642d 100644 --- a/tests/test_oa_hash_map.cpp +++ b/tests/core/templates/test_oa_hash_map.cpp diff --git a/tests/test_oa_hash_map.h b/tests/core/templates/test_oa_hash_map.h index 9745802cc0..f229ac94ea 100644 --- a/tests/test_oa_hash_map.h +++ b/tests/core/templates/test_oa_hash_map.h @@ -31,7 +31,7 @@ #ifndef TEST_OA_HASH_MAP_H #define TEST_OA_HASH_MAP_H -#include "core/os/main_loop.h" +class MainLoop; namespace TestOAHashMap { diff --git a/tests/test_ordered_hash_map.h b/tests/core/templates/test_ordered_hash_map.h index fbaaa224cf..35ce0fc656 100644 --- a/tests/test_ordered_hash_map.h +++ b/tests/core/templates/test_ordered_hash_map.h @@ -31,10 +31,7 @@ #ifndef TEST_ORDERED_HASH_MAP_H #define TEST_ORDERED_HASH_MAP_H -#include "core/os/os.h" #include "core/templates/ordered_hash_map.h" -#include "core/templates/pair.h" -#include "core/templates/vector.h" #include "tests/test_macros.h" diff --git a/tests/test_paged_array.h b/tests/core/templates/test_paged_array.h index 7efd3799f3..7efd3799f3 100644 --- a/tests/test_paged_array.h +++ b/tests/core/templates/test_paged_array.h diff --git a/tests/test_vector.h b/tests/core/templates/test_vector.h index bfdf389aa7..bfdf389aa7 100644 --- a/tests/test_vector.h +++ b/tests/core/templates/test_vector.h diff --git a/tests/test_crypto.h b/tests/core/test_crypto.h index 8da8c75544..3b909c7df8 100644 --- a/tests/test_crypto.h +++ b/tests/core/test_crypto.h @@ -33,7 +33,6 @@ #include "core/crypto/crypto.h" #include "tests/test_macros.h" -#include <stdio.h> namespace TestCrypto { diff --git a/tests/test_hashing_context.h b/tests/core/test_hashing_context.h index 728a5f2cfa..728a5f2cfa 100644 --- a/tests/test_hashing_context.h +++ b/tests/core/test_hashing_context.h diff --git a/tests/test_time.h b/tests/core/test_time.h index 28f1cb2f20..28f1cb2f20 100644 --- a/tests/test_time.h +++ b/tests/core/test_time.h diff --git a/tests/test_array.h b/tests/core/variant/test_array.h index 05b4eaea2a..298bd2ff63 100644 --- a/tests/test_array.h +++ b/tests/core/variant/test_array.h @@ -31,13 +31,7 @@ #ifndef TEST_ARRAY_H #define TEST_ARRAY_H -#include "core/object/class_db.h" -#include "core/object/script_language.h" -#include "core/templates/hashfuncs.h" -#include "core/templates/vector.h" #include "core/variant/array.h" -#include "core/variant/container_type_validate.h" -#include "core/variant/variant.h" #include "tests/test_macros.h" #include "tests/test_tools.h" diff --git a/tests/test_dictionary.h b/tests/core/variant/test_dictionary.h index 64d1d68e21..65079698a3 100644 --- a/tests/test_dictionary.h +++ b/tests/core/variant/test_dictionary.h @@ -31,10 +31,7 @@ #ifndef TEST_DICTIONARY_H #define TEST_DICTIONARY_H -#include "core/templates/ordered_hash_map.h" -#include "core/templates/safe_refcount.h" #include "core/variant/dictionary.h" -#include "core/variant/variant.h" #include "tests/test_macros.h" namespace TestDictionary { diff --git a/tests/test_variant.h b/tests/core/variant/test_variant.h index 0d16fa092c..0d16fa092c 100644 --- a/tests/test_variant.h +++ b/tests/core/variant/test_variant.h diff --git a/tests/test_code_edit.h b/tests/scene/test_code_edit.h index 62235ed0ae..a95dd02ba5 100644 --- a/tests/test_code_edit.h +++ b/tests/scene/test_code_edit.h @@ -31,12 +31,7 @@ #ifndef TEST_CODE_EDIT_H #define TEST_CODE_EDIT_H -#include "core/input/input_map.h" -#include "core/object/message_queue.h" -#include "core/os/keyboard.h" -#include "core/string/string_builder.h" #include "scene/gui/code_edit.h" -#include "scene/resources/default_theme/default_theme.h" #include "tests/test_macros.h" @@ -2678,18 +2673,18 @@ 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(code_edit, 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(code_edit, Key::APOSTROPHE); CHECK(code_edit->get_line(0) == "''"); CHECK(code_edit->get_caret_column() == 1); /* Move out from centre, 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_KEY_EVENT(code_edit, Key::APOSTROPHE); CHECK(code_edit->get_line(0) == "''''''"); CHECK(code_edit->get_caret_column() == 3); @@ -2698,30 +2693,30 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { 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(code_edit, 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(code_edit, 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(code_edit, Key::A); + SEND_GUI_KEY_EVENT(code_edit, 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(code_edit, Key::NUMBERSIGN); + SEND_GUI_KEY_EVENT(code_edit, 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(code_edit, Key::APOSTROPHE); + SEND_GUI_KEY_EVENT(code_edit, Key::QUOTEDBL); CHECK(code_edit->get_line(0) == "'\"'"); } @@ -2867,7 +2862,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { SEND_GUI_ACTION(code_edit, "ui_down"); CHECK(code_edit->get_code_completion_selected_index() == 0); - SEND_GUI_KEY_EVENT(code_edit, KEY_T); + SEND_GUI_KEY_EVENT(code_edit, Key::T); CHECK(code_edit->get_code_completion_selected_index() == 0); SEND_GUI_ACTION(code_edit, "ui_left"); @@ -2881,14 +2876,14 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { Point2 caret_pos = code_edit->get_caret_draw_pos(); caret_pos.y -= code_edit->get_line_height(); - SEND_GUI_MOUSE_EVENT(code_edit, caret_pos, MOUSE_BUTTON_WHEEL_DOWN, MOUSE_BUTTON_NONE); + SEND_GUI_MOUSE_EVENT(code_edit, caret_pos, MouseButton::WHEEL_DOWN, MouseButton::NONE); CHECK(code_edit->get_code_completion_selected_index() == 1); - SEND_GUI_MOUSE_EVENT(code_edit, caret_pos, MOUSE_BUTTON_WHEEL_UP, MOUSE_BUTTON_NONE); + SEND_GUI_MOUSE_EVENT(code_edit, caret_pos, MouseButton::WHEEL_UP, MouseButton::NONE); CHECK(code_edit->get_code_completion_selected_index() == 0); /* Single click selects. */ - SEND_GUI_MOUSE_EVENT(code_edit, caret_pos, MOUSE_BUTTON_LEFT, MOUSE_BUTTON_MASK_LEFT); + SEND_GUI_MOUSE_EVENT(code_edit, caret_pos, MouseButton::LEFT, MouseButton::MASK_LEFT); CHECK(code_edit->get_code_completion_selected_index() == 2); /* Double click inserts. */ @@ -3096,15 +3091,15 @@ TEST_CASE("[SceneTree][CodeEdit] symbol lookup") { Point2 caret_pos = code_edit->get_caret_draw_pos(); caret_pos.x += 55; - SEND_GUI_MOUSE_EVENT(code_edit, caret_pos, MOUSE_BUTTON_NONE, MOUSE_BUTTON_NONE); + SEND_GUI_MOUSE_EVENT(code_edit, caret_pos, MouseButton::NONE, MouseButton::NONE); CHECK(code_edit->get_text_for_symbol_lookup() == "this is s" + String::chr(0xFFFF) + "ome text"); SIGNAL_WATCH(code_edit, "symbol_validate"); #ifdef OSX_ENABLED - SEND_GUI_KEY_EVENT(code_edit, KEY_META); + SEND_GUI_KEY_EVENT(code_edit, Key::META); #else - SEND_GUI_KEY_EVENT(code_edit, KEY_CTRL); + SEND_GUI_KEY_EVENT(code_edit, Key::CTRL); #endif Array signal_args; diff --git a/tests/test_curve.h b/tests/scene/test_curve.h index e079905e35..60eafad460 100644 --- a/tests/test_curve.h +++ b/tests/scene/test_curve.h @@ -33,7 +33,7 @@ #include "scene/resources/curve.h" -#include "thirdparty/doctest/doctest.h" +#include "tests/test_macros.h" namespace TestCurve { diff --git a/tests/test_gradient.h b/tests/scene/test_gradient.h index 8eaa6b2b64..fc595b02f2 100644 --- a/tests/test_gradient.h +++ b/tests/scene/test_gradient.h @@ -31,8 +31,6 @@ #ifndef TEST_GRADIENT_H #define TEST_GRADIENT_H -#include "core/math/color.h" -#include "core/object/class_db.h" #include "scene/resources/gradient.h" #include "thirdparty/doctest/doctest.h" diff --git a/tests/test_gui.cpp b/tests/scene/test_gui.cpp index 0ec8aa78c4..5bd9390cb7 100644 --- a/tests/test_gui.cpp +++ b/tests/scene/test_gui.cpp @@ -32,29 +32,18 @@ #include "test_gui.h" -#include "core/io/image_loader.h" -#include "core/os/os.h" -#include "core/string/print_string.h" -#include "scene/2d/sprite_2d.h" #include "scene/gui/button.h" -#include "scene/gui/control.h" #include "scene/gui/label.h" #include "scene/gui/line_edit.h" #include "scene/gui/menu_button.h" #include "scene/gui/option_button.h" #include "scene/gui/panel.h" -#include "scene/gui/popup_menu.h" #include "scene/gui/progress_bar.h" #include "scene/gui/rich_text_label.h" #include "scene/gui/scroll_bar.h" #include "scene/gui/spin_box.h" #include "scene/gui/tab_container.h" -#include "scene/gui/texture_rect.h" #include "scene/gui/tree.h" -#include "scene/main/scene_tree.h" - -#include "scene/3d/camera_3d.h" -#include "scene/main/window.h" namespace TestGUI { @@ -267,4 +256,4 @@ MainLoop *test() { } } // namespace TestGUI -#endif +#endif // _3D_DISABLED diff --git a/tests/test_gui.h b/tests/scene/test_gui.h index e5c40de7e8..84bce620e2 100644 --- a/tests/test_gui.h +++ b/tests/scene/test_gui.h @@ -31,7 +31,7 @@ #ifndef TEST_GUI_H #define TEST_GUI_H -#include "core/os/main_loop.h" +class MainLoop; namespace TestGUI { diff --git a/tests/test_path_3d.h b/tests/scene/test_path_3d.h index 9961ae6e97..1fcef3adde 100644 --- a/tests/test_path_3d.h +++ b/tests/scene/test_path_3d.h @@ -32,7 +32,6 @@ #define TEST_PATH_3D_H #include "scene/3d/path_3d.h" -#include "scene/resources/curve.h" #include "tests/test_macros.h" diff --git a/tests/test_path_follow_2d.h b/tests/scene/test_path_follow_2d.h index 388b690060..ddfcc5552a 100644 --- a/tests/test_path_follow_2d.h +++ b/tests/scene/test_path_follow_2d.h @@ -32,7 +32,6 @@ #define TEST_PATH_FOLLOW_2D_H #include "scene/2d/path_2d.h" -#include "scene/resources/curve.h" #include "tests/test_macros.h" diff --git a/tests/test_path_follow_3d.h b/tests/scene/test_path_follow_3d.h index b6b4c88222..6a505dbb39 100644 --- a/tests/test_path_follow_3d.h +++ b/tests/scene/test_path_follow_3d.h @@ -32,7 +32,6 @@ #define TEST_PATH_FOLLOW_3D_H #include "scene/3d/path_3d.h" -#include "scene/resources/curve.h" #include "tests/test_macros.h" diff --git a/tests/test_physics_2d.cpp b/tests/servers/test_physics_2d.cpp index f6619db8fd..06aa88b5c0 100644 --- a/tests/test_physics_2d.cpp +++ b/tests/servers/test_physics_2d.cpp @@ -31,11 +31,6 @@ #include "test_physics_2d.h" #include "core/os/main_loop.h" -#include "core/os/os.h" -#include "core/string/print_string.h" -#include "core/templates/map.h" -#include "scene/resources/texture.h" -#include "servers/display_server.h" #include "servers/physics_server_2d.h" #include "servers/rendering_server.h" @@ -201,10 +196,10 @@ protected: if (mb->is_pressed()) { Point2 p = mb->get_position(); - if (mb->get_button_index() == 1) { + if (mb->get_button_index() == MouseButton::LEFT) { ray_to = p; _do_ray_query(); - } else if (mb->get_button_index() == 2) { + } else if (mb->get_button_index() == MouseButton::RIGHT) { ray_from = p; _do_ray_query(); } @@ -216,10 +211,10 @@ protected: if (mm.is_valid()) { Point2 p = mm->get_position(); - if (mm->get_button_mask() & MOUSE_BUTTON_MASK_LEFT) { + if ((mm->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE) { ray_to = p; _do_ray_query(); - } else if (mm->get_button_mask() & MOUSE_BUTTON_MASK_RIGHT) { + } else if ((mm->get_button_mask() & MouseButton::MASK_RIGHT) != MouseButton::NONE) { ray_from = p; _do_ray_query(); } diff --git a/tests/test_physics_2d.h b/tests/servers/test_physics_2d.h index 966d49200a..2ae1053a03 100644 --- a/tests/test_physics_2d.h +++ b/tests/servers/test_physics_2d.h @@ -31,7 +31,7 @@ #ifndef TEST_PHYSICS_2D_H #define TEST_PHYSICS_2D_H -#include "core/os/main_loop.h" +class MainLoop; namespace TestPhysics2D { diff --git a/tests/test_physics_3d.cpp b/tests/servers/test_physics_3d.cpp index d839ae26b7..7cb74b1ee3 100644 --- a/tests/test_physics_3d.cpp +++ b/tests/servers/test_physics_3d.cpp @@ -31,12 +31,8 @@ #include "test_physics_3d.h" #include "core/math/convex_hull.h" -#include "core/math/math_funcs.h" +#include "core/math/geometry_3d.h" #include "core/os/main_loop.h" -#include "core/os/os.h" -#include "core/string/print_string.h" -#include "core/templates/map.h" -#include "servers/display_server.h" #include "servers/physics_server_3d.h" #include "servers/rendering_server.h" @@ -249,12 +245,12 @@ protected: public: virtual void input_event(const Ref<InputEvent> &p_event) { Ref<InputEventMouseMotion> mm = p_event; - if (mm.is_valid() && mm->get_button_mask() & 4) { + if (mm.is_valid() && (mm->get_button_mask() & MouseButton::MASK_MIDDLE) != MouseButton::NONE) { ofs_y -= mm->get_relative().y / 200.0; ofs_x += mm->get_relative().x / 200.0; } - if (mm.is_valid() && mm->get_button_mask() & 1) { + if (mm.is_valid() && (mm->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE) { real_t y = -mm->get_relative().y / 20.0; real_t x = mm->get_relative().x / 20.0; diff --git a/tests/test_physics_3d.h b/tests/servers/test_physics_3d.h index b6b66f350e..b86327cdb4 100644 --- a/tests/test_physics_3d.h +++ b/tests/servers/test_physics_3d.h @@ -31,7 +31,7 @@ #ifndef TEST_PHYSICS_H #define TEST_PHYSICS_H -#include "core/os/main_loop.h" +class MainLoop; namespace TestPhysics3D { diff --git a/tests/test_render.cpp b/tests/servers/test_render.cpp index 21b4da9b3b..183f049238 100644 --- a/tests/test_render.cpp +++ b/tests/servers/test_render.cpp @@ -31,12 +31,7 @@ #include "test_render.h" #include "core/math/convex_hull.h" -#include "core/math/math_funcs.h" -#include "core/os/keyboard.h" #include "core/os/main_loop.h" -#include "core/os/os.h" -#include "core/string/print_string.h" -#include "servers/display_server.h" #include "servers/rendering_server.h" #define OBJECT_COUNT 50 diff --git a/tests/test_render.h b/tests/servers/test_render.h index 35bb383773..1d773cb347 100644 --- a/tests/test_render.h +++ b/tests/servers/test_render.h @@ -31,11 +31,11 @@ #ifndef TEST_RENDER_H #define TEST_RENDER_H -#include "core/os/main_loop.h" +class MainLoop; namespace TestRender { MainLoop *test(); } -#endif +#endif // TEST_RENDER_H diff --git a/tests/test_shader_lang.cpp b/tests/servers/test_shader_lang.cpp index 5598852f29..0591bf6adf 100644 --- a/tests/test_shader_lang.cpp +++ b/tests/servers/test_shader_lang.cpp @@ -30,13 +30,8 @@ #include "test_shader_lang.h" -#include "core/io/file_access.h" #include "core/os/main_loop.h" #include "core/os/os.h" - -#include "core/string/print_string.h" -#include "scene/gui/control.h" -#include "scene/gui/text_edit.h" #include "servers/rendering/shader_language.h" typedef ShaderLanguage SL; diff --git a/tests/test_shader_lang.h b/tests/servers/test_shader_lang.h index 46a2e6af35..de7ec002b6 100644 --- a/tests/test_shader_lang.h +++ b/tests/servers/test_shader_lang.h @@ -31,7 +31,7 @@ #ifndef TEST_SHADER_LANG_H #define TEST_SHADER_LANG_H -#include "core/os/main_loop.h" +class MainLoop; namespace TestShaderLang { diff --git a/tests/test_text_server.h b/tests/servers/test_text_server.h index 4edffe3711..4edffe3711 100644 --- a/tests/test_text_server.h +++ b/tests/servers/test_text_server.h diff --git a/tests/test_macros.h b/tests/test_macros.h index 6968f9df1f..b04c2117b7 100644 --- a/tests/test_macros.h +++ b/tests/test_macros.h @@ -31,10 +31,8 @@ #ifndef TEST_MACROS_H #define TEST_MACROS_H -#include "core/object/callable_method_pointer.h" -#include "core/object/class_db.h" -#include "core/string/print_string.h" -#include "core/templates/map.h" +#include "core/input/input_map.h" +#include "core/object/message_queue.h" #include "core/variant/variant.h" // See documentation for doctest at: @@ -135,7 +133,7 @@ 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 | KEY_MASK_CMD). +// SEND_GUI_KEY_EVENT - takes an object and a keycode set. e.g SEND_GUI_KEY_EVENT(code_edit, Key::A | KeyModifierMask::CMD). // SEND_GUI_MOUSE_EVENT - takes an object, position, mouse button and mouse mask e.g SEND_GUI_MOUSE_EVENT(code_edit, Vector2(50, 50), MOUSE_BUTTON_NONE, MOUSE_BUTTON_NONE); // SEND_GUI_DOUBLE_CLICK - takes an object and a postion. e.g SEND_GUI_DOUBLE_CLICK(code_edit, Vector2(50, 50)); @@ -174,7 +172,7 @@ int register_test_command(String p_command, TestFunc p_function); #define SEND_GUI_DOUBLE_CLICK(m_object, m_local_pos) \ { \ - _CREATE_GUI_MOUSE_EVENT(m_object, m_local_pos, MOUSE_BUTTON_LEFT, MOUSE_BUTTON_LEFT); \ + _CREATE_GUI_MOUSE_EVENT(m_object, m_local_pos, MouseButton::LEFT, MouseButton::LEFT); \ event->set_double_click(true); \ m_object->get_viewport()->push_input(event); \ MessageQueue::get_singleton()->flush(); \ diff --git a/tests/test_main.cpp b/tests/test_main.cpp index 341fb1af61..a09be08de8 100644 --- a/tests/test_main.cpp +++ b/tests/test_main.cpp @@ -30,62 +30,62 @@ #include "test_main.h" -#include "core/templates/list.h" - -#include "test_aabb.h" -#include "test_array.h" -#include "test_astar.h" -#include "test_basis.h" -#include "test_class_db.h" -#include "test_code_edit.h" -#include "test_color.h" -#include "test_command_queue.h" -#include "test_config_file.h" -#include "test_crypto.h" -#include "test_curve.h" -#include "test_dictionary.h" -#include "test_expression.h" -#include "test_file_access.h" -#include "test_geometry_2d.h" -#include "test_geometry_3d.h" -#include "test_gradient.h" -#include "test_gui.h" -#include "test_hashing_context.h" -#include "test_image.h" -#include "test_json.h" -#include "test_list.h" -#include "test_local_vector.h" -#include "test_lru.h" -#include "test_marshalls.h" -#include "test_math.h" -#include "test_method_bind.h" -#include "test_node_path.h" -#include "test_oa_hash_map.h" -#include "test_object.h" -#include "test_ordered_hash_map.h" -#include "test_paged_array.h" -#include "test_path_3d.h" -#include "test_pck_packer.h" -#include "test_physics_2d.h" -#include "test_physics_3d.h" -#include "test_random_number_generator.h" -#include "test_rect2.h" -#include "test_render.h" -#include "test_resource.h" -#include "test_shader_lang.h" -#include "test_string.h" -#include "test_text_server.h" -#include "test_time.h" -#include "test_translation.h" -#include "test_validate_testing.h" -#include "test_variant.h" -#include "test_vector.h" -#include "test_xml_parser.h" +#include "tests/core/io/test_config_file.h" +#include "tests/core/io/test_file_access.h" +#include "tests/core/io/test_image.h" +#include "tests/core/io/test_json.h" +#include "tests/core/io/test_marshalls.h" +#include "tests/core/io/test_pck_packer.h" +#include "tests/core/io/test_resource.h" +#include "tests/core/io/test_xml_parser.h" +#include "tests/core/math/test_aabb.h" +#include "tests/core/math/test_astar.h" +#include "tests/core/math/test_basis.h" +#include "tests/core/math/test_color.h" +#include "tests/core/math/test_expression.h" +#include "tests/core/math/test_geometry_2d.h" +#include "tests/core/math/test_geometry_3d.h" +#include "tests/core/math/test_math.h" +#include "tests/core/math/test_random_number_generator.h" +#include "tests/core/math/test_rect2.h" +#include "tests/core/object/test_class_db.h" +#include "tests/core/object/test_method_bind.h" +#include "tests/core/object/test_object.h" +#include "tests/core/string/test_node_path.h" +#include "tests/core/string/test_string.h" +#include "tests/core/string/test_translation.h" +#include "tests/core/templates/test_command_queue.h" +#include "tests/core/templates/test_list.h" +#include "tests/core/templates/test_local_vector.h" +#include "tests/core/templates/test_lru.h" +#include "tests/core/templates/test_oa_hash_map.h" +#include "tests/core/templates/test_ordered_hash_map.h" +#include "tests/core/templates/test_paged_array.h" +#include "tests/core/templates/test_vector.h" +#include "tests/core/test_crypto.h" +#include "tests/core/test_hashing_context.h" +#include "tests/core/test_time.h" +#include "tests/core/variant/test_array.h" +#include "tests/core/variant/test_dictionary.h" +#include "tests/core/variant/test_variant.h" +#include "tests/scene/test_code_edit.h" +#include "tests/scene/test_curve.h" +#include "tests/scene/test_gradient.h" +#include "tests/scene/test_gui.h" +#include "tests/scene/test_path_3d.h" +#include "tests/servers/test_physics_2d.h" +#include "tests/servers/test_physics_3d.h" +#include "tests/servers/test_render.h" +#include "tests/servers/test_shader_lang.h" +#include "tests/servers/test_text_server.h" +#include "tests/test_validate_testing.h" #include "modules/modules_tests.gen.h" #include "tests/test_macros.h" +#include "scene/resources/default_theme/default_theme.h" + int test_main(int argc, char *argv[]) { bool run_tests = true; diff --git a/tests/test_tools.h b/tests/test_tools.h index ec18610f04..e1192458d0 100644 --- a/tests/test_tools.h +++ b/tests/test_tools.h @@ -31,8 +31,6 @@ #ifndef TEST_TOOLS_H #define TEST_TOOLS_H -#include "core/error/error_macros.h" - struct ErrorDetector { ErrorDetector() { eh.errfunc = _detect_error; diff --git a/tests/test_utils.cpp b/tests/test_utils.cpp index 1666a257a9..890dea3ee1 100644 --- a/tests/test_utils.cpp +++ b/tests/test_utils.cpp @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "test_utils.h" +#include "tests/test_utils.h" #include "core/os/os.h" diff --git a/tests/test_utils.h b/tests/test_utils.h index f05ab0bdb1..ccebe2e449 100644 --- a/tests/test_utils.h +++ b/tests/test_utils.h @@ -31,7 +31,7 @@ #ifndef TEST_UTILS_H #define TEST_UTILS_H -#include "core/string/ustring.h" +class String; namespace TestUtils { |