16#include "RNA_prototypes.hh"
19#include "testing/testing.h"
55 Slot &cube_slot = action->slot_add();
56 Slot &monkey_slot = action->slot_add();
57 EXPECT_TRUE(action->is_action_layered());
62 *action, cube_slot.
handle, [&](
FCurve &fcurve) { no_fcurves.append(&fcurve); });
66 Layer &layer = action->layer_add(
"Layer One");
72 for (
int i = 0;
i < 3;
i++) {
74 bmain, cube_slot, {
"location",
i}, {1.0f, 0.0f}, settings);
76 <<
"Expected keyframe insertion to be successful";
79 bmain, monkey_slot, {
"rotation",
i}, {1.0f, 0.0f}, settings);
81 <<
"Expected keyframe insertion to be successful";
87 *action, cube_slot.
handle, [&](
FCurve &fcurve) { cube_fcurves.append(&fcurve); });
89 ASSERT_EQ(cube_fcurves.
size(), 3);
90 for (
FCurve *fcurve : cube_fcurves) {
91 ASSERT_STREQ(fcurve->
rna_path,
"location");
97 if (fcurve.array_index == 0) {
98 monkey_fcurves.append(&fcurve);
102 ASSERT_EQ(monkey_fcurves.size(), 1);
103 ASSERT_STREQ(monkey_fcurves[0]->rna_path,
"rotation");
109 monkey_slot.handle + cube_slot.handle,
110 [&](
FCurve &fcurve) { invalid_slot_fcurves.append(&fcurve); });
111 ASSERT_TRUE(invalid_slot_fcurves.
is_empty());
119 ASSERT_NE(slot_cube,
nullptr);
125 std::optional<ActionSlotAssignmentResult> slot_assignment_result;
127 bool all_assigns_ok =
true;
128 const auto assign_other_action = [&](
ID & ,
131 char *last_slot_identifier) ->
bool {
134 cube->id, &other_action, action_ptr_ref, slot_handle_ref, last_slot_identifier);
138 &another_slot, cube->id, action_ptr_ref, slot_handle_ref, last_slot_identifier);
144 ASSERT_TRUE(all_assigns_ok);
147 ASSERT_TRUE(slot_assignment_result.has_value());
152 ASSERT_TRUE(action_and_slot.has_value());
153 EXPECT_EQ(&other_action, action_and_slot->first)
154 <<
"Expected Action " << other_action.
id.
name <<
" but found "
155 << action_and_slot->first->id.name;
156 EXPECT_EQ(&another_slot, action_and_slot->second)
157 <<
"Expected Slot " << another_slot.
identifier <<
" but found "
158 << action_and_slot->second->identifier;
166 ASSERT_NE(slot_cube,
nullptr);
167 Slot &another_slot = action->slot_add();
169 const auto assign_other_slot = [&](
ID & ,
184 ASSERT_TRUE(action_and_slot.has_value());
185 EXPECT_EQ(action, action_and_slot->first)
186 <<
"Expected Action " << action->id.name <<
" but found " << action_and_slot->first->id.name;
187 EXPECT_EQ(&another_slot, action_and_slot->second)
188 <<
"Expected Slot " << another_slot.
identifier <<
" but found "
189 << action_and_slot->second->identifier;
Functions and classes to work with Actions.
Functionality to iterate an Action in various ways.
void * BKE_id_new(Main *bmain, short type, const char *name)
void BKE_main_free(Main *bmain)
General operations, lookup, etc. for blender objects.
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
Object is a sort of wrapper for general info.
TEST_F(BrushTest, deep_copy)
Strip & strip_add(Action &owning_action, Strip::Type strip_type)
SingleKeyingResult keyframe_insert(Main *bmain, const Slot &slot, const FCurveDescriptor &fcurve_descriptor, float2 time_value, const KeyframeSettings &settings, eInsertKeyFlags insert_key_flags=INSERTKEY_NOFLAGS, std::optional< float2 > cycle_range=std::nullopt)
const T & data(const Action &owning_action) const
static void TearDownTestSuite()
static void SetUpTestSuite()
TEST_F(ActionIteratorsTest, iterate_all_fcurves_of_slot)
void foreach_fcurve_in_action_slot(Action &action, slot_handle_t handle, FunctionRef< void(FCurve &fcurve)> callback)
KeyframeSettings get_keyframe_settings(bool from_userprefs)
Slot * assign_action_ensure_slot_for_keying(Action &action, ID &animated_id)
bool generic_assign_action(ID &animated_id, bAction *action_to_assign, bAction *&action_ptr_ref, slot_handle_t &slot_handle_ref, char *slot_identifier)
ActionSlotAssignmentResult generic_assign_action_slot(Slot *slot_to_assign, ID &animated_id, bAction *&action_ptr_ref, slot_handle_t &slot_handle_ref, char *slot_identifier)
decltype(::ActionSlot::handle) slot_handle_t
bool foreach_action_slot_use_with_rna(ID &animated_id, FunctionRef< bool(ID &animated_id, bAction *action, PointerRNA &action_slot_owner_ptr, PropertyRNA &action_slot_prop, char *last_slot_identifier)> callback)
std::optional< std::pair< Action *, Slot * > > get_action_slot_pair(ID &animated_id)
bool foreach_action_slot_use_with_references(ID &animated_id, FunctionRef< bool(ID &animated_id, bAction *&action_ptr_ref, slot_handle_t &slot_handle_ref, char *last_slot_identifier)> callback)
void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA ptr_value, ReportList *reports)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)