Przeglądaj źródła

Add a test to ensure that library path is absolute

(cherry picked from commit 92ace04989bdf8d7d94846f059eeccd723f9b885)
David Snopek 1 rok temu
rodzic
commit
fd31fabcfc
3 zmienionych plików z 16 dodań i 0 usunięć
  1. 6 0
      test/project/main.gd
  2. 8 0
      test/src/example.cpp
  3. 2 0
      test/src/example.h

+ 6 - 0
test/project/main.gd

@@ -257,6 +257,12 @@ func _ready():
 	assert_equal(example_child.get_value1(), 11)
 	assert_equal(example_child.get_value2(), 22)
 
+	# Test that the extension's library path is absolute and valid.
+	var library_path = Example.test_library_path()
+	assert_equal(library_path.begins_with("res://"), false)
+	assert_equal(library_path, ProjectSettings.globalize_path(library_path))
+	assert_equal(FileAccess.file_exists(library_path), true)
+
 	exit_with_status()
 
 func _on_Example_custom_signal(signal_name, value):

+ 8 - 0
test/src/example.cpp

@@ -238,6 +238,8 @@ void Example::_bind_methods() {
 	ClassDB::bind_static_method("Example", D_METHOD("test_static", "a", "b"), &Example::test_static);
 	ClassDB::bind_static_method("Example", D_METHOD("test_static2"), &Example::test_static2);
 
+	ClassDB::bind_static_method("Example", D_METHOD("test_library_path"), &Example::test_library_path);
+
 	{
 		MethodInfo mi;
 		mi.arguments.push_back(PropertyInfo(Variant::STRING, "some_argument"));
@@ -675,3 +677,9 @@ void ExampleChild::_notification(int p_what) {
 String Example::test_use_engine_singleton() const {
 	return OS::get_singleton()->get_name();
 }
+
+String Example::test_library_path() {
+	String library_path;
+	internal::gdextension_interface_get_library_path(internal::library, library_path._native_ptr());
+	return library_path;
+}

+ 2 - 0
test/src/example.h

@@ -185,6 +185,8 @@ public:
 	virtual void _input(const Ref<InputEvent> &event) override;
 
 	String test_use_engine_singleton() const;
+
+	static String test_library_path();
 };
 
 VARIANT_ENUM_CAST(Example::Constants);