summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/core/string/test_string.h16
-rw-r--r--tests/scene/test_viewport.h16
-rw-r--r--tests/scene/test_window.h6
-rw-r--r--tests/servers/test_text_server.h6
-rw-r--r--tests/test_main.cpp19
5 files changed, 40 insertions, 23 deletions
diff --git a/tests/core/string/test_string.h b/tests/core/string/test_string.h
index 659fb003d3..c10ad6e13d 100644
--- a/tests/core/string/test_string.h
+++ b/tests/core/string/test_string.h
@@ -805,6 +805,22 @@ TEST_CASE("[String] sprintf") {
REQUIRE(error == false);
CHECK(output == String("fish +99.990000 frog"));
+ // Real with sign (negative zero).
+ format = "fish %+f frog";
+ args.clear();
+ args.push_back(-0.0);
+ output = format.sprintf(args, &error);
+ REQUIRE(error == false);
+ CHECK(output == String("fish -0.000000 frog"));
+
+ // Real with sign (positive zero).
+ format = "fish %+f frog";
+ args.clear();
+ args.push_back(0.0);
+ output = format.sprintf(args, &error);
+ REQUIRE(error == false);
+ CHECK(output == String("fish +0.000000 frog"));
+
// Real with 1 decimal.
format = "fish %.1f frog";
args.clear();
diff --git a/tests/scene/test_viewport.h b/tests/scene/test_viewport.h
index dd4786977e..0c53668c6d 100644
--- a/tests/scene/test_viewport.h
+++ b/tests/scene/test_viewport.h
@@ -43,8 +43,8 @@
namespace TestViewport {
-class NotificationControl : public Control {
- GDCLASS(NotificationControl, Control);
+class NotificationControlViewport : public Control {
+ GDCLASS(NotificationControlViewport, Control);
protected:
void _notification(int p_what) {
@@ -63,11 +63,11 @@ public:
bool mouse_over = false;
};
-// `NotificationControl`-derived class that additionally
+// `NotificationControlViewport`-derived class that additionally
// - allows start Dragging
// - stores mouse information of last event
-class DragStart : public NotificationControl {
- GDCLASS(DragStart, NotificationControl);
+class DragStart : public NotificationControlViewport {
+ GDCLASS(DragStart, NotificationControlViewport);
public:
MouseButton last_mouse_button;
@@ -93,9 +93,9 @@ public:
}
};
-// `NotificationControl`-derived class that acts as a Drag and Drop target.
-class DragTarget : public NotificationControl {
- GDCLASS(DragTarget, NotificationControl);
+// `NotificationControlViewport`-derived class that acts as a Drag and Drop target.
+class DragTarget : public NotificationControlViewport {
+ GDCLASS(DragTarget, NotificationControlViewport);
public:
Variant drag_data;
diff --git a/tests/scene/test_window.h b/tests/scene/test_window.h
index e0c55101de..592cccfd7e 100644
--- a/tests/scene/test_window.h
+++ b/tests/scene/test_window.h
@@ -38,8 +38,8 @@
namespace TestWindow {
-class NotificationControl : public Control {
- GDCLASS(NotificationControl, Control);
+class NotificationControlWindow : public Control {
+ GDCLASS(NotificationControlWindow, Control);
protected:
void _notification(int p_what) {
@@ -69,7 +69,7 @@ TEST_CASE("[SceneTree][Window]") {
w->set_content_scale_size(Size2i(200, 200));
w->set_content_scale_mode(Window::CONTENT_SCALE_MODE_CANVAS_ITEMS);
w->set_content_scale_aspect(Window::CONTENT_SCALE_ASPECT_KEEP);
- NotificationControl *c = memnew(NotificationControl);
+ NotificationControlWindow *c = memnew(NotificationControlWindow);
w->add_child(c);
c->set_size(Size2i(100, 100));
c->set_position(Size2i(-50, -50));
diff --git a/tests/servers/test_text_server.h b/tests/servers/test_text_server.h
index eef5b850ca..0f23929e1e 100644
--- a/tests/servers/test_text_server.h
+++ b/tests/servers/test_text_server.h
@@ -70,7 +70,7 @@ TEST_SUITE("[TextServer]") {
ts->font_set_data_ptr(font1, _font_NotoSans_Regular, _font_NotoSans_Regular_size);
ts->font_set_allow_system_fallback(font1, false);
RID font2 = ts->create_font();
- ts->font_set_data_ptr(font2, _font_NotoSansThaiUI_Regular, _font_NotoSansThaiUI_Regular_size);
+ ts->font_set_data_ptr(font2, _font_NotoSansThai_Regular, _font_NotoSansThai_Regular_size);
ts->font_set_allow_system_fallback(font2, false);
Array font;
@@ -177,7 +177,7 @@ TEST_SUITE("[TextServer]") {
ts->font_set_data_ptr(font1, _font_NotoSans_Regular, _font_NotoSans_Regular_size);
ts->font_set_allow_system_fallback(font1, false);
RID font2 = ts->create_font();
- ts->font_set_data_ptr(font2, _font_NotoSansThaiUI_Regular, _font_NotoSansThaiUI_Regular_size);
+ ts->font_set_data_ptr(font2, _font_NotoSansThai_Regular, _font_NotoSansThai_Regular_size);
ts->font_set_allow_system_fallback(font2, false);
RID font3 = ts->create_font();
ts->font_set_data_ptr(font3, _font_NotoNaskhArabicUI_Regular, _font_NotoNaskhArabicUI_Regular_size);
@@ -511,7 +511,7 @@ TEST_SUITE("[TextServer]") {
RID font1 = ts->create_font();
ts->font_set_data_ptr(font1, _font_NotoSans_Regular, _font_NotoSans_Regular_size);
RID font2 = ts->create_font();
- ts->font_set_data_ptr(font2, _font_NotoSansThaiUI_Regular, _font_NotoSansThaiUI_Regular_size);
+ ts->font_set_data_ptr(font2, _font_NotoSansThai_Regular, _font_NotoSansThai_Regular_size);
Array font;
font.push_back(font1);
diff --git a/tests/test_main.cpp b/tests/test_main.cpp
index 6cc7aad48e..3a80fc8c00 100644
--- a/tests/test_main.cpp
+++ b/tests/test_main.cpp
@@ -212,7 +212,6 @@ struct GodotTestCaseListener : public doctest::IReporter {
PhysicsServer2D *physics_server_2d = nullptr;
NavigationServer3D *navigation_server_3d = nullptr;
NavigationServer2D *navigation_server_2d = nullptr;
- ThemeDB *theme_db = nullptr;
void test_case_start(const doctest::TestCaseData &p_in) override {
reinitialize();
@@ -238,6 +237,12 @@ struct GodotTestCaseListener : public doctest::IReporter {
RenderingServerDefault::get_singleton()->init();
RenderingServerDefault::get_singleton()->set_render_loop_enabled(false);
+ // ThemeDB requires RenderingServer to initialize the default theme.
+ // So we have to do this for each test case. Also make sure there is
+ // no residual theme from something else.
+ ThemeDB::get_singleton()->finalize_theme();
+ ThemeDB::get_singleton()->initialize_theme_noproject();
+
physics_server_3d = PhysicsServer3DManager::get_singleton()->new_default_server();
physics_server_3d->init();
@@ -252,9 +257,6 @@ struct GodotTestCaseListener : public doctest::IReporter {
memnew(InputMap);
InputMap::get_singleton()->load_default();
- theme_db = memnew(ThemeDB);
- theme_db->initialize_theme_noproject();
-
memnew(SceneTree);
SceneTree::get_singleton()->initialize();
if (!DisplayServer::get_singleton()->has_feature(DisplayServer::Feature::FEATURE_SUBWINDOWS)) {
@@ -294,11 +296,6 @@ struct GodotTestCaseListener : public doctest::IReporter {
memdelete(SceneTree::get_singleton());
}
- if (theme_db) {
- memdelete(theme_db);
- theme_db = nullptr;
- }
-
if (navigation_server_3d) {
memdelete(navigation_server_3d);
navigation_server_3d = nullptr;
@@ -326,6 +323,10 @@ struct GodotTestCaseListener : public doctest::IReporter {
}
if (RenderingServer::get_singleton()) {
+ // ThemeDB requires RenderingServer to finalize the default theme.
+ // So we have to do this for each test case.
+ ThemeDB::get_singleton()->finalize_theme();
+
RenderingServer::get_singleton()->sync();
RenderingServer::get_singleton()->global_shader_parameters_clear();
RenderingServer::get_singleton()->finish();