Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/build_profile.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"OS",
"TileMap",
"TileSet",
"Tween",
"Viewport"
]
}
3 changes: 3 additions & 0 deletions test/project/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ func _ready():
assert_equal(new_tilemap.tile_set, new_tileset)
new_tilemap.queue_free()

# Creates a Tween and checks that it's valid. Improper refcount handling will crash now or at shutdown.
assert_equal(example.test_tween_smoke_test(), true)

# Test variant call.
var test_obj = TestClass.new()
assert_equal(example.test_variant_call(test_obj), "hello world")
Expand Down
6 changes: 6 additions & 0 deletions test/src/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ void Example::_bind_methods() {

ClassDB::bind_method(D_METHOD("test_add_child", "node"), &Example::test_add_child);
ClassDB::bind_method(D_METHOD("test_set_tileset", "tilemap", "tileset"), &Example::test_set_tileset);
ClassDB::bind_method(D_METHOD("test_tween_smoke_test"), &Example::test_tween_smoke_test);

ClassDB::bind_method(D_METHOD("test_variant_call", "variant"), &Example::test_variant_call);

Expand Down Expand Up @@ -616,6 +617,11 @@ void Example::test_set_tileset(TileMap *p_tilemap, const Ref<TileSet> &p_tileset
p_tilemap->set_tileset(p_tileset);
}

bool Example::test_tween_smoke_test() {
Ref<Tween> tween = create_tween();
return tween.is_valid() && tween->is_class("Tween") && tween->get_reference_count() > 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume > 1 means "1 reference by this function, one by the tween owner"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. In current Godot the reference count is 2, one for this function and the other is SceneTree::tweens

}

Variant Example::test_variant_call(Variant p_variant) {
return p_variant.call("test", "hello");
}
Expand Down
2 changes: 2 additions & 0 deletions test/src/example.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <godot_cpp/classes/input_event_key.hpp>
#include <godot_cpp/classes/tile_map.hpp>
#include <godot_cpp/classes/tile_set.hpp>
#include <godot_cpp/classes/tween.hpp>
#include <godot_cpp/classes/viewport.hpp>
#include <godot_cpp/variant/typed_dictionary.hpp>
#include <godot_cpp/variant/variant.hpp>
Expand Down Expand Up @@ -154,6 +155,7 @@ class Example : public Control {

void test_add_child(Node *p_node);
void test_set_tileset(TileMap *p_tilemap, const Ref<TileSet> &p_tileset) const;
bool test_tween_smoke_test();

Variant test_variant_call(Variant p_variant);

Expand Down
Loading