/**************************************************************************/1/* test_skeleton_3d.cpp */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#include "tests/test_macros.h"3132TEST_FORCE_LINK(test_skeleton_3d)3334#ifndef _3D_DISABLED3536#include "scene/3d/skeleton_3d.h"3738namespace TestSkeleton3D {3940TEST_CASE("[Skeleton3D] Test per-bone meta") {41Skeleton3D *skeleton = memnew(Skeleton3D);42skeleton->add_bone("root");43skeleton->set_bone_rest(0, Transform3D());4445// Adding meta to bone.46skeleton->set_bone_meta(0, "key1", "value1");47skeleton->set_bone_meta(0, "key2", 12345);48CHECK_MESSAGE(skeleton->get_bone_meta(0, "key1") == "value1", "Bone meta missing.");49CHECK_MESSAGE(skeleton->get_bone_meta(0, "key2") == Variant(12345), "Bone meta missing.");5051// Rename bone and check if meta persists.52skeleton->set_bone_name(0, "renamed_root");53CHECK_MESSAGE(skeleton->get_bone_meta(0, "key1") == "value1", "Bone meta missing.");54CHECK_MESSAGE(skeleton->get_bone_meta(0, "key2") == Variant(12345), "Bone meta missing.");5556// Retrieve list of keys.57List<StringName> keys;58skeleton->get_bone_meta_list(0, &keys);59CHECK_MESSAGE(keys.size() == 2, "Wrong number of bone meta keys.");60CHECK_MESSAGE(keys.find("key1"), "key1 not found in bone meta list");61CHECK_MESSAGE(keys.find("key2"), "key2 not found in bone meta list");6263// Removing meta.64skeleton->set_bone_meta(0, "key1", Variant());65skeleton->set_bone_meta(0, "key2", Variant());66CHECK_MESSAGE(!skeleton->has_bone_meta(0, "key1"), "Bone meta key1 should be deleted.");67CHECK_MESSAGE(!skeleton->has_bone_meta(0, "key2"), "Bone meta key2 should be deleted.");68List<StringName> should_be_empty_keys;69skeleton->get_bone_meta_list(0, &should_be_empty_keys);70CHECK_MESSAGE(should_be_empty_keys.size() == 0, "Wrong number of bone meta keys.");7172// Deleting non-existing key should succeed.73skeleton->set_bone_meta(0, "non-existing-key", Variant());74memdelete(skeleton);75}7677} // namespace TestSkeleton3D7879#endif // _3D_DISABLED808182