16#include "testing/testing.h"
52 Slot &cube_slot = action->slot_add();
53 Slot &monkey_slot = action->slot_add();
54 EXPECT_TRUE(action->is_action_layered());
59 *action, cube_slot.
handle, [&](
FCurve &fcurve) { no_fcurves.append(&fcurve); });
63 Layer &layer = action->layer_add(
"Layer One");
64 Strip &strip = layer.strip_add(*action, Strip::Type::Keyframe);
69 for (
int i = 0; i < 3; i++) {
71 bmain, cube_slot, {
"location", i}, {1.0f, 0.0f}, settings);
73 <<
"Expected keyframe insertion to be successful";
76 bmain, monkey_slot, {
"rotation", i}, {1.0f, 0.0f}, settings);
78 <<
"Expected keyframe insertion to be successful";
84 *action, cube_slot.
handle, [&](
FCurve &fcurve) { cube_fcurves.append(&fcurve); });
86 ASSERT_EQ(cube_fcurves.
size(), 3);
87 for (
FCurve *fcurve : cube_fcurves) {
88 ASSERT_STREQ(fcurve->
rna_path,
"location");
94 if (fcurve.array_index == 0) {
95 monkey_fcurves.append(&fcurve);
99 ASSERT_EQ(monkey_fcurves.size(), 1);
100 ASSERT_STREQ(monkey_fcurves[0]->rna_path,
"rotation");
106 monkey_slot.handle + cube_slot.handle,
107 [&](
FCurve &fcurve) { invalid_slot_fcurves.append(&fcurve); });
108 ASSERT_TRUE(invalid_slot_fcurves.
is_empty());
116 ASSERT_NE(slot_cube,
nullptr);
123 std::optional<ActionSlotAssignmentResult> slot_assignment_result;
125 bool all_assigns_ok =
true;
126 const auto assign_other_action =
130 cube->
id, &other_action, action_ptr_ref, slot_handle_ref, slot_name);
134 &another_slot, cube->
id, action_ptr_ref, slot_handle_ref, slot_name);
140 ASSERT_TRUE(all_assigns_ok);
143 ASSERT_TRUE(slot_assignment_result.has_value());
144 EXPECT_EQ(ActionSlotAssignmentResult::OK, slot_assignment_result.value());
148 ASSERT_TRUE(action_and_slot.has_value());
149 EXPECT_EQ(&other_action, action_and_slot->first)
150 <<
"Expected Action " << other_action.
id.
name <<
" but found "
151 << action_and_slot->first->id.name;
152 EXPECT_EQ(&another_slot, action_and_slot->second)
153 <<
"Expected Slot " << another_slot.
name <<
" but found " << action_and_slot->second->name;
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)
Main * BKE_main_new(void)
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)
TEST_F(StringFindSplitWords, Simple)
Object is a sort of wrapper for general info.
SingleKeyingResult keyframe_insert(Main *bmain, const Slot &slot, FCurveDescriptor fcurve_descriptor, float2 time_value, const KeyframeSettings &settings, eInsertKeyFlags insert_key_flags=INSERTKEY_NOFLAGS)
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)
bool foreach_action_slot_use_with_references(ID &animated_id, FunctionRef< bool(bAction *&action_ptr_ref, slot_handle_t &slot_handle_ref, char *slot_name)> callback)
KeyframeSettings get_keyframe_settings(bool from_userprefs)
Slot * assign_action_ensure_slot_for_keying(Action &action, ID &animated_id)
ActionSlotAssignmentResult generic_assign_action_slot(Slot *slot_to_assign, ID &animated_id, bAction *&action_ptr_ref, slot_handle_t &slot_handle_ref, char *slot_name) ATTR_WARN_UNUSED_RESULT
bool generic_assign_action(ID &animated_id, bAction *action_to_assign, bAction *&action_ptr_ref, slot_handle_t &slot_handle_ref, char *slot_name)
decltype(::ActionSlot::handle) slot_handle_t
std::optional< std::pair< Action *, Slot * > > get_action_slot_pair(ID &animated_id)
float wrap(float value, float max, float min)