Debian Codegraph @

tests/scene/test_decal.h

raw symbols SCIP
1 /**************************************************************************/
2 /* test_decal.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #include "scene/3d/decal.h"
34
35 #include "tests/test_macros.h"
36
37 namespace TestDecal {
38 TEST_CASE("[SceneTree][Decal] Getters/Setters") {
39 Decal *decal = memnew(Decal);
40 AABB default_aabb{
41 Vector3(-1.0f, -1.0f, -1.0f),
42 Vector3(2.0f, 2.0f, 2.0f)
43 };
44 SUBCASE("Default values") {
45 CHECK_MESSAGE(decal->get_aabb() == default_aabb, "get_aabb() returns the expected values for the default.");
46 }
47
48 SUBCASE("Set and Get Size") {
49 Vector3 size = Vector3(2.0f, 3.0f, 4.0f);
50
51 decal->set_size(size);
52 AABB expected_aabb{
53 Vector3(-1.0f, -1.5f, -2.0f),
54 Vector3(2.0f, 3.0f, 4.0f)
55 };
56 CHECK_MESSAGE(decal->get_aabb() == expected_aabb, "get_aabb() returns the expected values after setting.");
57 //default back the size in order to use the default_aabb for future assertions
58 decal->set_size(Vector3(2.0f, 2.0f, 2.0f));
59 }
60
61 SUBCASE("Set and Get Texture") {
62 Ref<Texture2D> albedo_texture;
63 albedo_texture.instantiate();
64 decal->set_texture(Decal::TEXTURE_ALBEDO, albedo_texture);
65 CHECK_MESSAGE(decal->get_texture(Decal::TEXTURE_ALBEDO) == albedo_texture, "get_texture() returns the expected texture after setting.");
66 CHECK_MESSAGE(default_aabb == decal->get_aabb(), "get_aabb() remains unchanged after setting texture.");
67 }
68
69 SUBCASE("Set and Get Emission Energy") {
70 decal->set_emission_energy(2.0f);
71 CHECK_MESSAGE(decal->get_emission_energy() == 2.0, "get_emission_energy() returns the expected value after setting.");
72 CHECK_MESSAGE(default_aabb == decal->get_aabb(), "get_aabb() remains unchanged after setting emission energy.");
73 }
74
75 SUBCASE("Set and Get Albedo Mix") {
76 decal->set_albedo_mix(0.5);
77 CHECK_MESSAGE(decal->get_albedo_mix() == 0.5f, "get_albedo_mix() returns the expected value after setting.");
78 CHECK_MESSAGE(default_aabb == decal->get_aabb(), "get_aabb() remains unchanged after setting albedo mix.");
79 }
80
81 SUBCASE("Set and Get Modulate") {
82 Color new_color(0.5f, 0.5f, 0.5f, 1.0f);
83 decal->set_modulate(new_color);
84 CHECK_MESSAGE(decal->get_modulate() == new_color, "get_modulate() returns the expected value after setting.");
85 CHECK_MESSAGE(default_aabb == decal->get_aabb(), "get_aabb() remains unchanged after setting modulate.");
86 }
87
88 SUBCASE("Set and Get Upper Fade") {
89 decal->set_upper_fade(0.4f);
90 CHECK_MESSAGE(decal->get_upper_fade() == 0.4f, "get_upper_fade() returns the expected value after setting.");
91 CHECK_MESSAGE(default_aabb == decal->get_aabb(), "get_aabb() remains unchanged after setting upper fade.");
92 }
93
94 SUBCASE("Set and Get Lower Fade") {
95 decal->set_lower_fade(0.2f);
96 CHECK_MESSAGE(decal->get_lower_fade() == 0.2f, "get_lower_fade() returns the expected value after setting.");
97 CHECK_MESSAGE(default_aabb == decal->get_aabb(), "get_aabb() remains unchanged after setting lower fade.");
98 }
99
100 SUBCASE("Set and Get Normal Fade") {
101 decal->set_normal_fade(0.1f);
102 CHECK_MESSAGE(decal->get_normal_fade() == 0.1f, "get_normal_fade() returns the expected value after setting.");
103 CHECK_MESSAGE(default_aabb == decal->get_aabb(), "get_aabb() remains unchanged after setting normal fade.");
104 }
105
106 SUBCASE("Enable and Check Distance Fade") {
107 decal->set_enable_distance_fade(true);
108 CHECK_MESSAGE(decal->is_distance_fade_enabled() == true, "is_distance_fade_enabled() returns the expected value after setting.");
109 CHECK_MESSAGE(default_aabb == decal->get_aabb(), "get_aabb() remains unchanged after enabling distance fade.");
110 }
111
112 SUBCASE("Set and Get Distance Fade Begin") {
113 decal->set_distance_fade_begin(50.0f);
114 CHECK_MESSAGE(decal->get_distance_fade_begin() == 50.0f, "get_distance_fade_begin() returns the expected value after setting.");
115 CHECK_MESSAGE(default_aabb == decal->get_aabb(), "get_aabb() remains unchanged after setting distance fade begin.");
116 }
117
118 SUBCASE("Set and Get Distance Fade Length") {
119 decal->set_distance_fade_length(15.0f);
120 CHECK_MESSAGE(decal->get_distance_fade_length() == 15.0f, "get_distance_fade_length() returns the expected value after setting.");
121 CHECK_MESSAGE(default_aabb == decal->get_aabb(), "get_aabb() remains unchanged after setting distance fade length.");
122 }
123
124 SUBCASE("Set and Get Cull Mask") {
125 decal->set_cull_mask(0xFF);
126 CHECK_MESSAGE(decal->get_cull_mask() == 0xFF, "get_cull_mask() returns the expected value after setting.");
127 CHECK_MESSAGE(default_aabb == decal->get_aabb(), "get_aabb() remains unchanged after setting cull mask.");
128 }
129
130 memdelete(decal);
131 }
132
133 } //namespace TestDecal