Fix ThemeDB initialization in tests
Also fixes class name shadowing in Viewport/Window tests.
This commit is contained in:
parent
75de1ca768
commit
4328ffcc79
|
@ -570,9 +570,15 @@ Error Main::test_setup() {
|
||||||
|
|
||||||
ResourceLoader::load_path_remaps();
|
ResourceLoader::load_path_remaps();
|
||||||
|
|
||||||
|
// Initialize ThemeDB early so that scene types can register their theme items.
|
||||||
|
// Default theme will be initialized later, after modules and ScriptServer are ready.
|
||||||
|
initialize_theme_db();
|
||||||
|
|
||||||
register_scene_types();
|
register_scene_types();
|
||||||
register_driver_types();
|
register_driver_types();
|
||||||
|
|
||||||
|
register_scene_singletons();
|
||||||
|
|
||||||
initialize_modules(MODULE_INITIALIZATION_LEVEL_SCENE);
|
initialize_modules(MODULE_INITIALIZATION_LEVEL_SCENE);
|
||||||
GDExtensionManager::get_singleton()->initialize_extensions(GDExtension::INITIALIZATION_LEVEL_SCENE);
|
GDExtensionManager::get_singleton()->initialize_extensions(GDExtension::INITIALIZATION_LEVEL_SCENE);
|
||||||
|
|
||||||
|
@ -588,9 +594,7 @@ Error Main::test_setup() {
|
||||||
register_platform_apis();
|
register_platform_apis();
|
||||||
|
|
||||||
// Theme needs modules to be initialized so that sub-resources can be loaded.
|
// Theme needs modules to be initialized so that sub-resources can be loaded.
|
||||||
initialize_theme_db();
|
theme_db->initialize_theme_noproject();
|
||||||
theme_db->initialize_theme();
|
|
||||||
register_scene_singletons();
|
|
||||||
|
|
||||||
initialize_navigation_server();
|
initialize_navigation_server();
|
||||||
|
|
||||||
|
@ -2561,9 +2565,15 @@ Error Main::setup2() {
|
||||||
|
|
||||||
OS::get_singleton()->benchmark_begin_measure("scene");
|
OS::get_singleton()->benchmark_begin_measure("scene");
|
||||||
|
|
||||||
|
// Initialize ThemeDB early so that scene types can register their theme items.
|
||||||
|
// Default theme will be initialized later, after modules and ScriptServer are ready.
|
||||||
|
initialize_theme_db();
|
||||||
|
|
||||||
register_scene_types();
|
register_scene_types();
|
||||||
register_driver_types();
|
register_driver_types();
|
||||||
|
|
||||||
|
register_scene_singletons();
|
||||||
|
|
||||||
initialize_modules(MODULE_INITIALIZATION_LEVEL_SCENE);
|
initialize_modules(MODULE_INITIALIZATION_LEVEL_SCENE);
|
||||||
GDExtensionManager::get_singleton()->initialize_extensions(GDExtension::INITIALIZATION_LEVEL_SCENE);
|
GDExtensionManager::get_singleton()->initialize_extensions(GDExtension::INITIALIZATION_LEVEL_SCENE);
|
||||||
|
|
||||||
|
@ -2581,11 +2591,6 @@ Error Main::setup2() {
|
||||||
|
|
||||||
register_platform_apis();
|
register_platform_apis();
|
||||||
|
|
||||||
// Theme needs modules to be initialized so that sub-resources can be loaded.
|
|
||||||
// Default theme is initialized later, after ScriptServer is ready.
|
|
||||||
initialize_theme_db();
|
|
||||||
register_scene_singletons();
|
|
||||||
|
|
||||||
GLOBAL_DEF_BASIC(PropertyInfo(Variant::STRING, "display/mouse_cursor/custom_image", PROPERTY_HINT_FILE, "*.png,*.webp"), String());
|
GLOBAL_DEF_BASIC(PropertyInfo(Variant::STRING, "display/mouse_cursor/custom_image", PROPERTY_HINT_FILE, "*.png,*.webp"), String());
|
||||||
GLOBAL_DEF_BASIC("display/mouse_cursor/custom_image_hotspot", Vector2());
|
GLOBAL_DEF_BASIC("display/mouse_cursor/custom_image_hotspot", Vector2());
|
||||||
GLOBAL_DEF_BASIC("display/mouse_cursor/tooltip_position_offset", Point2(10, 10));
|
GLOBAL_DEF_BASIC("display/mouse_cursor/tooltip_position_offset", Point2(10, 10));
|
||||||
|
|
|
@ -91,6 +91,18 @@ void ThemeDB::initialize_theme_noproject() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ThemeDB::finalize_theme() {
|
||||||
|
if (!RenderingServer::get_singleton()) {
|
||||||
|
WARN_PRINT("Finalizing theme when there is no RenderingServer is an error; check the order of operations.");
|
||||||
|
}
|
||||||
|
|
||||||
|
default_theme.unref();
|
||||||
|
|
||||||
|
fallback_font.unref();
|
||||||
|
fallback_icon.unref();
|
||||||
|
fallback_stylebox.unref();
|
||||||
|
}
|
||||||
|
|
||||||
// Universal fallback Theme resources.
|
// Universal fallback Theme resources.
|
||||||
|
|
||||||
void ThemeDB::set_default_theme(const Ref<Theme> &p_default) {
|
void ThemeDB::set_default_theme(const Ref<Theme> &p_default) {
|
||||||
|
|
|
@ -61,6 +61,7 @@ protected:
|
||||||
public:
|
public:
|
||||||
void initialize_theme();
|
void initialize_theme();
|
||||||
void initialize_theme_noproject();
|
void initialize_theme_noproject();
|
||||||
|
void finalize_theme();
|
||||||
|
|
||||||
// Universal Theme resources
|
// Universal Theme resources
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,8 @@
|
||||||
|
|
||||||
namespace TestViewport {
|
namespace TestViewport {
|
||||||
|
|
||||||
class NotificationControl : public Control {
|
class NotificationControlViewport : public Control {
|
||||||
GDCLASS(NotificationControl, Control);
|
GDCLASS(NotificationControlViewport, Control);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _notification(int p_what) {
|
void _notification(int p_what) {
|
||||||
|
@ -63,11 +63,11 @@ public:
|
||||||
bool mouse_over = false;
|
bool mouse_over = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
// `NotificationControl`-derived class that additionally
|
// `NotificationControlViewport`-derived class that additionally
|
||||||
// - allows start Dragging
|
// - allows start Dragging
|
||||||
// - stores mouse information of last event
|
// - stores mouse information of last event
|
||||||
class DragStart : public NotificationControl {
|
class DragStart : public NotificationControlViewport {
|
||||||
GDCLASS(DragStart, NotificationControl);
|
GDCLASS(DragStart, NotificationControlViewport);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MouseButton last_mouse_button;
|
MouseButton last_mouse_button;
|
||||||
|
@ -93,9 +93,9 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// `NotificationControl`-derived class that acts as a Drag and Drop target.
|
// `NotificationControlViewport`-derived class that acts as a Drag and Drop target.
|
||||||
class DragTarget : public NotificationControl {
|
class DragTarget : public NotificationControlViewport {
|
||||||
GDCLASS(DragTarget, NotificationControl);
|
GDCLASS(DragTarget, NotificationControlViewport);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Variant drag_data;
|
Variant drag_data;
|
||||||
|
|
|
@ -38,8 +38,8 @@
|
||||||
|
|
||||||
namespace TestWindow {
|
namespace TestWindow {
|
||||||
|
|
||||||
class NotificationControl : public Control {
|
class NotificationControlWindow : public Control {
|
||||||
GDCLASS(NotificationControl, Control);
|
GDCLASS(NotificationControlWindow, Control);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _notification(int p_what) {
|
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_size(Size2i(200, 200));
|
||||||
w->set_content_scale_mode(Window::CONTENT_SCALE_MODE_CANVAS_ITEMS);
|
w->set_content_scale_mode(Window::CONTENT_SCALE_MODE_CANVAS_ITEMS);
|
||||||
w->set_content_scale_aspect(Window::CONTENT_SCALE_ASPECT_KEEP);
|
w->set_content_scale_aspect(Window::CONTENT_SCALE_ASPECT_KEEP);
|
||||||
NotificationControl *c = memnew(NotificationControl);
|
NotificationControlWindow *c = memnew(NotificationControlWindow);
|
||||||
w->add_child(c);
|
w->add_child(c);
|
||||||
c->set_size(Size2i(100, 100));
|
c->set_size(Size2i(100, 100));
|
||||||
c->set_position(Size2i(-50, -50));
|
c->set_position(Size2i(-50, -50));
|
||||||
|
|
|
@ -212,7 +212,6 @@ struct GodotTestCaseListener : public doctest::IReporter {
|
||||||
PhysicsServer2D *physics_server_2d = nullptr;
|
PhysicsServer2D *physics_server_2d = nullptr;
|
||||||
NavigationServer3D *navigation_server_3d = nullptr;
|
NavigationServer3D *navigation_server_3d = nullptr;
|
||||||
NavigationServer2D *navigation_server_2d = nullptr;
|
NavigationServer2D *navigation_server_2d = nullptr;
|
||||||
ThemeDB *theme_db = nullptr;
|
|
||||||
|
|
||||||
void test_case_start(const doctest::TestCaseData &p_in) override {
|
void test_case_start(const doctest::TestCaseData &p_in) override {
|
||||||
reinitialize();
|
reinitialize();
|
||||||
|
@ -238,6 +237,10 @@ struct GodotTestCaseListener : public doctest::IReporter {
|
||||||
RenderingServerDefault::get_singleton()->init();
|
RenderingServerDefault::get_singleton()->init();
|
||||||
RenderingServerDefault::get_singleton()->set_render_loop_enabled(false);
|
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.
|
||||||
|
ThemeDB::get_singleton()->initialize_theme_noproject();
|
||||||
|
|
||||||
physics_server_3d = PhysicsServer3DManager::get_singleton()->new_default_server();
|
physics_server_3d = PhysicsServer3DManager::get_singleton()->new_default_server();
|
||||||
physics_server_3d->init();
|
physics_server_3d->init();
|
||||||
|
|
||||||
|
@ -252,9 +255,6 @@ struct GodotTestCaseListener : public doctest::IReporter {
|
||||||
memnew(InputMap);
|
memnew(InputMap);
|
||||||
InputMap::get_singleton()->load_default();
|
InputMap::get_singleton()->load_default();
|
||||||
|
|
||||||
theme_db = memnew(ThemeDB);
|
|
||||||
theme_db->initialize_theme_noproject();
|
|
||||||
|
|
||||||
memnew(SceneTree);
|
memnew(SceneTree);
|
||||||
SceneTree::get_singleton()->initialize();
|
SceneTree::get_singleton()->initialize();
|
||||||
if (!DisplayServer::get_singleton()->has_feature(DisplayServer::Feature::FEATURE_SUBWINDOWS)) {
|
if (!DisplayServer::get_singleton()->has_feature(DisplayServer::Feature::FEATURE_SUBWINDOWS)) {
|
||||||
|
@ -294,11 +294,6 @@ struct GodotTestCaseListener : public doctest::IReporter {
|
||||||
memdelete(SceneTree::get_singleton());
|
memdelete(SceneTree::get_singleton());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theme_db) {
|
|
||||||
memdelete(theme_db);
|
|
||||||
theme_db = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (navigation_server_3d) {
|
if (navigation_server_3d) {
|
||||||
memdelete(navigation_server_3d);
|
memdelete(navigation_server_3d);
|
||||||
navigation_server_3d = nullptr;
|
navigation_server_3d = nullptr;
|
||||||
|
@ -326,6 +321,10 @@ struct GodotTestCaseListener : public doctest::IReporter {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RenderingServer::get_singleton()) {
|
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()->sync();
|
||||||
RenderingServer::get_singleton()->global_shader_parameters_clear();
|
RenderingServer::get_singleton()->global_shader_parameters_clear();
|
||||||
RenderingServer::get_singleton()->finish();
|
RenderingServer::get_singleton()->finish();
|
||||||
|
|
Loading…
Reference in New Issue