28#include "testing/testing.h"
32TEST(action, low_level_initialisation)
37 <<
"bAction::last_slot_handle should not be initialised to 0";
81 Layer &layer = action->layer_add(
"layer name");
87 <<
"Expected newly added layer to become the active layer.";
88 ASSERT_EQ(0, layer.
strips().size()) <<
"Expected newly added layer to have no strip.";
96 action->idroot =
ID_CA;
97 ASSERT_NE(0, action->idroot) <<
"action->idroot should not be zero at the start of this test.";
99 action->layer_add(
"layer name");
102 <<
"action->idroot should get reset when the Action becomes layered.";
107 Layer &layer0 = action->layer_add(
"Test Læür nul");
108 Layer &layer1 = action->layer_add(
"Test Læür één");
109 Layer &layer2 = action->layer_add(
"Test Læür twee");
113 layer0.
strip_add(*action, Strip::Type::Keyframe);
114 layer1.
strip_add(*action, Strip::Type::Keyframe);
115 layer2.
strip_add(*action, Strip::Type::Keyframe);
120 EXPECT_FALSE(action->layer_remove(other_layer))
121 <<
"Removing a layer not owned by the Action should be gracefully rejected";
125 EXPECT_TRUE(action->layer_remove(layer1));
127 EXPECT_STREQ(layer0.
name, action->layer(0)->name);
128 EXPECT_STREQ(layer2.
name, action->layer(1)->name);
130 EXPECT_TRUE(action->layer_remove(layer2));
132 EXPECT_STREQ(layer0.
name, action->layer(0)->name);
134 EXPECT_TRUE(action->layer_remove(layer0));
140 Layer &layer = action->layer_add(
"Test Læür");
143 ASSERT_EQ(1, layer.
strips().size());
146 constexpr float inf = std::numeric_limits<float>::infinity();
151 Strip &another_strip = layer.
strip_add(*action, Strip::Type::Keyframe);
152 ASSERT_EQ(2, layer.
strips().size());
161 Slot &slot = action->slot_add();
163 bmain, slot, {
"location", 0}, {1.0f, 47.0f}, settings);
165 bmain, slot, {
"location", 0}, {1.0f, 47.0f}, settings);
170 Layer &layer = action->layer_add(
"Test Læür");
182 Slot &slot = action->slot_add();
183 strip_data0.
keyframe_insert(bmain, slot, {
"location", 0}, {1.0f, 47.0f}, settings);
184 strip_data1.
keyframe_insert(bmain, slot, {
"location", 0}, {1.0f, 48.0f}, settings);
185 strip_data2.
keyframe_insert(bmain, slot, {
"location", 0}, {1.0f, 49.0f}, settings);
186 strip_data3.
keyframe_insert(bmain, slot, {
"location", 0}, {1.0f, 50.0f}, settings);
188 EXPECT_EQ(4, action->strip_keyframe_data().size());
195 EXPECT_EQ(3, action->strip_keyframe_data().size());
208 EXPECT_EQ(2, action->strip_keyframe_data().size());
218 EXPECT_EQ(1, action->strip_keyframe_data().size());
225 EXPECT_EQ(0, action->strip_keyframe_data().size());
229 Layer &other_layer = action->layer_add(
"Another Layer");
230 Strip &other_strip = other_layer.
strip_add(*action, Strip::Type::Keyframe);
233 <<
"Removing a strip not owned by the layer should be gracefully rejected";
243 Layer &layer = action->layer_add(
"Test Læür");
256 Slot &slot = action->slot_add();
257 strip_data_0_1.
keyframe_insert(bmain, slot, {
"location", 0}, {1.0f, 47.0f}, settings);
258 strip_data_2.
keyframe_insert(bmain, slot, {
"location", 0}, {1.0f, 48.0f}, settings);
260 EXPECT_EQ(3, action->strip_keyframe_data().size());
268 EXPECT_EQ(3, action->strip_keyframe_data().size());
279 EXPECT_EQ(2, action->strip_keyframe_data().size());
289 Slot &slot = action->slot_add();
298 Slot &slot = action->slot_add_for_id(cube->id);
311 Slot &slot = action->slot_add_for_id(cube->id);
316 <<
"The last-assigned slot name should be reused";
318 <<
"The ID type encoded in the slot identifier should be correct";
328 action->idroot =
ID_CA;
329 ASSERT_NE(0, action->idroot) <<
"action->idroot should not be zero at the start of this test.";
334 <<
"action->idroot should get reset when the Action becomes layered.";
339 Slot &slot_cube = action->slot_add();
340 Slot &slot_suzanne = action->slot_add();
354 Slot &slot = action->slot_add();
358 EXPECT_TRUE(action->slot_remove(slot));
360 <<
"Removing a slot should not change the last-used slot handle.";
366 EXPECT_FALSE(action->slot_remove(slot));
370 Slot &slot = action->slot_add();
376 action->layer_keystrip_ensure();
382 EXPECT_TRUE(action->slot_remove(slot));
384 <<
"Removing a slot should not change the last-used slot handle.";
393 Slot &slot1 = action->slot_add();
394 Slot &slot2 = action->slot_add();
395 Slot &slot3 = action->slot_add();
405 action->layer_keystrip_ensure();
412 EXPECT_TRUE(action->slot_remove(slot2));
417 EXPECT_EQ(action->slot_for_handle(slot2_handle),
nullptr);
427 Slot &slot = action->slot_add_for_id(cube->id);
431 ASSERT_EQ(cube->adt->slot_handle, slot.
handle);
434 ASSERT_TRUE(action->slot_remove(slot));
435 EXPECT_EQ(cube->adt->slot_handle, removed_slot_handle);
439 action->last_slot_handle = 3;
440 Slot &slot1 = action->slot_add();
441 ASSERT_EQ(4, slot1.
handle);
442 ASSERT_EQ(4, action->last_slot_handle);
443 ASSERT_TRUE(action->slot_remove(slot1));
445 Slot &slot2 = action->slot_add();
453 Slot &slot_a = action->slot_add_for_id_type(
ID_ME);
454 Slot &slot_b = action->slot_add_for_id_type(
ID_CA);
455 Slot &slot_cube = action->slot_add_for_id(cube->id);
456 Slot &slot_suzanne = action->slot_add_for_id(suzanne->id);
466 ASSERT_EQ(action->slot(0)->handle, handle_a);
467 ASSERT_EQ(action->slot(0)->idtype_string(),
"ME");
468 ASSERT_EQ(action->slot(1)->handle, handle_b);
469 ASSERT_EQ(action->slot(1)->idtype_string(),
"CA");
470 ASSERT_EQ(action->slot(2)->handle, handle_cube);
471 ASSERT_EQ(action->slot(2)->idtype_string(),
"OB");
472 ASSERT_EQ(action->slot(2)->users(*bmain)[0], &cube->id);
473 ASSERT_EQ(action->slot(3)->handle, handle_suzanne);
474 ASSERT_EQ(action->slot(3)->idtype_string(),
"OB");
475 ASSERT_EQ(action->slot(3)->users(*bmain)[0], &suzanne->id);
478 action->slot_move_to_index(slot_b, 1);
479 EXPECT_EQ(action->slot(0)->handle, handle_a);
480 EXPECT_EQ(action->slot(0)->idtype_string(),
"ME");
481 EXPECT_EQ(action->slot(1)->handle, handle_b);
482 EXPECT_EQ(action->slot(1)->idtype_string(),
"CA");
483 EXPECT_EQ(action->slot(2)->handle, handle_cube);
484 EXPECT_EQ(action->slot(2)->idtype_string(),
"OB");
485 EXPECT_EQ(action->slot(2)->users(*bmain)[0], &cube->id);
486 EXPECT_EQ(action->slot(3)->handle, handle_suzanne);
487 EXPECT_EQ(action->slot(3)->idtype_string(),
"OB");
488 EXPECT_EQ(action->slot(3)->users(*bmain)[0], &suzanne->id);
492 action->slot_move_to_index(slot_a, 2);
493 EXPECT_EQ(action->slot(0)->handle, handle_b);
494 EXPECT_EQ(action->slot(0)->idtype_string(),
"CA");
495 EXPECT_EQ(action->slot(1)->handle, handle_cube);
496 EXPECT_EQ(action->slot(1)->idtype_string(),
"OB");
497 EXPECT_EQ(action->slot(1)->users(*bmain)[0], &cube->id);
498 EXPECT_EQ(action->slot(2)->handle, handle_a);
499 EXPECT_EQ(action->slot(2)->idtype_string(),
"ME");
500 EXPECT_EQ(action->slot(3)->handle, handle_suzanne);
501 EXPECT_EQ(action->slot(3)->idtype_string(),
"OB");
502 EXPECT_EQ(action->slot(3)->users(*bmain)[0], &suzanne->id);
504 action->slot_move_to_index(slot_suzanne, 1);
505 EXPECT_EQ(action->slot(0)->handle, handle_b);
506 EXPECT_EQ(action->slot(0)->idtype_string(),
"CA");
507 EXPECT_EQ(action->slot(1)->handle, handle_suzanne);
508 EXPECT_EQ(action->slot(1)->idtype_string(),
"OB");
509 EXPECT_EQ(action->slot(1)->users(*bmain)[0], &suzanne->id);
510 EXPECT_EQ(action->slot(2)->handle, handle_cube);
511 EXPECT_EQ(action->slot(2)->idtype_string(),
"OB");
512 EXPECT_EQ(action->slot(2)->users(*bmain)[0], &cube->id);
513 EXPECT_EQ(action->slot(3)->handle, handle_a);
514 EXPECT_EQ(action->slot(3)->idtype_string(),
"ME");
516 action->slot_move_to_index(slot_cube, 3);
517 EXPECT_EQ(action->slot(0)->handle, handle_b);
518 EXPECT_EQ(action->slot(0)->idtype_string(),
"CA");
519 EXPECT_EQ(action->slot(1)->handle, handle_suzanne);
520 EXPECT_EQ(action->slot(1)->idtype_string(),
"OB");
521 EXPECT_EQ(action->slot(1)->users(*bmain)[0], &suzanne->id);
522 EXPECT_EQ(action->slot(2)->handle, handle_a);
523 EXPECT_EQ(action->slot(2)->idtype_string(),
"ME");
524 EXPECT_EQ(action->slot(3)->handle, handle_cube);
525 EXPECT_EQ(action->slot(3)->idtype_string(),
"OB");
526 EXPECT_EQ(action->slot(3)->users(*bmain)[0], &cube->id);
528 action->slot_move_to_index(slot_suzanne, 0);
529 EXPECT_EQ(action->slot(0)->handle, handle_suzanne);
530 EXPECT_EQ(action->slot(0)->idtype_string(),
"OB");
531 EXPECT_EQ(action->slot(0)->users(*bmain)[0], &suzanne->id);
532 EXPECT_EQ(action->slot(1)->handle, handle_b);
533 EXPECT_EQ(action->slot(1)->idtype_string(),
"CA");
534 EXPECT_EQ(action->slot(2)->handle, handle_a);
535 EXPECT_EQ(action->slot(2)->idtype_string(),
"ME");
536 EXPECT_EQ(action->slot(3)->handle, handle_cube);
537 EXPECT_EQ(action->slot(3)->idtype_string(),
"OB");
538 EXPECT_EQ(action->slot(3)->users(*bmain)[0], &cube->id);
544 Slot &slot_cube = action->slot_add();
545 ASSERT_NE(
nullptr, slot_cube.
runtime);
551 EXPECT_STREQ(slot_cube.
identifier, cube->adt->last_slot_identifier)
552 <<
"The slot identifier should be copied to the adt";
555 <<
"Expecting Cube to be registered as animated by its slot.";
561 EXPECT_STREQ(slot_cube.
identifier, cube->adt->last_slot_identifier)
562 <<
"The slot identifier should be copied to the adt";
565 <<
"Expecting Suzanne to be registered as animated by the Cube slot.";
573 <<
"Expecting Cube to no longer be registered as user of its old slot.";
575 <<
"Expecting Cube to be registered as user of its new slot.";
581 const int user_count_pre = action->id.us;
582 Slot &slot_cube_2 = action->slot_add();
585 ASSERT_EQ(action->id.us, user_count_pre)
586 <<
"Assigning to a different slot of the same Action should _not_ change the user "
587 "count of that Action";
589 <<
"Expecting Cube to no longer be registered as animated by the Cube slot.";
591 <<
"Expecting Cube to be registered as animated by the 'cube_2' slot.";
595 const int user_count_pre = action->id.us;
597 ASSERT_EQ(action->id.us, user_count_pre - 1)
598 <<
"Unassigning an Action should lower its user count";
600 ASSERT_EQ(2, action->slots().size()) <<
"Expecting the Action to have two Slots";
601 EXPECT_FALSE(action->slot(0)->users(*bmain).contains(&cube->id))
602 <<
"Expecting Cube to no longer be registered as animated by any slot.";
603 EXPECT_FALSE(action->slot(1)->users(*bmain).contains(&cube->id))
604 <<
"Expecting Cube to no longer be registered as animated by any slot.";
609 Slot &another_slot_cube = action->slot_add();
613 EXPECT_STREQ(
"OBSlot.002", another_slot_cube.
identifier) <<
"The slot should be uniquely named";
614 EXPECT_STREQ(
"OBSlot.002", cube->adt->last_slot_identifier)
615 <<
"The slot identifier should be copied to the adt";
616 EXPECT_TRUE(another_slot_cube.
users(*bmain).
contains(&cube->id))
617 <<
"Expecting Cube to be registered as animated by the 'another_slot_cube' slot.";
623 <<
"Mesh should not be animatable by an Object slot";
625 <<
"Expecting Mesh to not be registered as animated by the 'slot_cube' slot.";
631 Slot &slot_cube = action->slot_add();
635 EXPECT_STREQ(slot_cube.
identifier, cube->adt->last_slot_identifier)
636 <<
"The slot identifier should be copied to the adt";
638 action->slot_identifier_define(slot_cube,
"OBNew Slot Name");
639 EXPECT_STREQ(
"OBNew Slot Name", slot_cube.
identifier);
645 action->slot_identifier_propagate(*bmain, slot_cube);
646 EXPECT_STREQ(
"OBNew Slot Name", cube->adt->last_slot_identifier);
649 action->slot_display_name_set(*bmain, slot_cube,
"Slot's New Display Name");
650 EXPECT_STREQ(
"OBSlot's New Display Name", slot_cube.
identifier);
651 EXPECT_STREQ(
"OBSlot's New Display Name", cube->adt->last_slot_identifier);
656 action->slot_identifier_define(slot_cube,
"OBEven Newer Name");
658 EXPECT_STREQ(
"OBEven Newer Name", cube->adt->last_slot_identifier);
663 class AccessibleSlot :
public Slot {
665 void identifier_ensure_prefix()
671 Slot &raw_slot = action->slot_add();
672 AccessibleSlot &slot =
static_cast<AccessibleSlot &
>(raw_slot);
673 ASSERT_STREQ(
"XXSlot", slot.identifier);
674 ASSERT_EQ(0, slot.idtype);
677 slot.identifier_ensure_prefix();
678 EXPECT_STREQ(
"XXSlot", slot.identifier);
682 slot.identifier_ensure_prefix();
683 EXPECT_STREQ(
"CASlot", slot.identifier);
686 action->slot_identifier_define(slot,
"CANewName");
688 slot.identifier_ensure_prefix();
689 EXPECT_STREQ(
"MENewName", slot.identifier);
693 slot.identifier_ensure_prefix();
694 EXPECT_STREQ(
"XXNewName", slot.identifier);
699 Slot &slot = action->slot_add();
714 Slot &slot1 = action->slot_add();
715 Slot &slot2 = action->slot_add();
717 action->slot_identifier_define(slot1,
"New Slot Name");
718 action->slot_identifier_define(slot2,
"New Slot Name");
719 EXPECT_STREQ(
"New Slot Name", slot1.
identifier);
720 EXPECT_STREQ(
"New Slot Name.001", slot2.
identifier);
732 Slot &slot = action->slot_add();
745 Slot &other_slot = action->slot_add();
774 Slot &ob_slot = action->slot_add_for_id_type(
ID_OB);
775 action->slot_identifier_define(ob_slot,
"OBSlot");
782 Slot &xx_slot = action->slot_add();
783 action->slot_identifier_define(xx_slot,
"XXSlot");
798 action->slot_remove(ob_slot);
807 EXPECT_EQ(
nullptr, action->slot_active_get());
810 EXPECT_EQ(
nullptr, action->slot_active_get());
815 EXPECT_EQ(
nullptr, action->slot_active_get())
816 <<
"Adding the first slot should not change what is the active slot.";
818 action->slot_active_set(slot_cube.
handle);
819 EXPECT_EQ(&slot_cube, action->slot_active_get())
820 <<
"It should be possible to activate the only available slot";
824 EXPECT_EQ(
nullptr, action->slot_active_get())
825 <<
"It should be possible to de-activate the only available slot";
831 Slot &slot_cube = *action->slot(0);
832 action->slot_active_set(slot_cube.
handle);
836 EXPECT_EQ(&slot_cube, action->slot_active_get())
837 <<
"Adding a subsequent slot should not change what is the active slot.";
840 action->slot_active_set(slot_suz.
handle);
841 EXPECT_EQ(&slot_suz, action->slot_active_get());
846 action->slot_active_set(slot_bob.
handle);
847 EXPECT_EQ(&slot_bob, action->slot_active_get());
853 EXPECT_EQ(
nullptr, action->slot_active_get());
865 ASSERT_NE(
nullptr, chosen_slot);
867 EXPECT_STREQ(
"OBKüüübus", chosen_slot->
identifier);
875 ASSERT_NE(
nullptr, chosen_slot);
876 EXPECT_EQ(&slot_for_id, chosen_slot) <<
"The expected slot should be chosen";
877 EXPECT_EQ(cube->adt->action, &action) <<
"The Action should be assigned";
878 EXPECT_EQ(cube->adt->slot_handle, chosen_slot->
handle) <<
"The chosen slot should be assigned";
888 ASSERT_NE(
nullptr, chosen_slot);
889 EXPECT_NE(&slot_for_id, chosen_slot) <<
"A new slot should be chosen";
890 EXPECT_STREQ(
"OBKüüübus.001", chosen_slot->
identifier);
891 EXPECT_EQ(cube->adt->action, &action) <<
"The Action should be assigned";
892 EXPECT_EQ(cube->adt->slot_handle, chosen_slot->
handle) <<
"The chosen slot should be assigned";
908 ASSERT_NE(
nullptr, chosen_slot);
909 EXPECT_EQ(&untyped_slot, chosen_slot) <<
"The untyped slot should be chosen";
910 EXPECT_TRUE(untyped_slot.
has_idtype()) <<
"Slot should have gotten an ID type";
911 EXPECT_STREQ(
"OBJust A Slot", untyped_slot.
identifier);
912 EXPECT_EQ(cube->adt->action, &action) <<
"The Action should be assigned";
913 EXPECT_EQ(cube->adt->slot_handle, chosen_slot->
handle) <<
"The chosen slot should be assigned";
919 constexpr float inf = std::numeric_limits<float>::infinity();
920 Layer &layer0 = action->layer_add(
"Test Læür nul");
931 <<
"Strip should not contain frames before its first frame";
932 EXPECT_TRUE(strip.
contains_frame(1.0f)) <<
"Strip should contain its first frame.";
933 EXPECT_TRUE(strip.
contains_frame(2.0f)) <<
"Strip should contain its last frame.";
935 <<
"Strip should not contain frames after its last frame";
944 strip.
resize(1.0f, 172800.0f);
945 EXPECT_TRUE(strip.
contains_frame(172800.0f)) <<
"Strip should contain its last frame.";
947 <<
"Strip should not contain frames after its last frame";
957 Slot &slot = action->slot_add();
959 Layer &layer = action->layer_add(
"Kübus layer");
966 bmain, slot, {
"location", 0}, {1.0f, 47.0f}, settings);
968 <<
"Expected keyframe insertion to be successful";
977 bmain, slot, {
"location", 0}, {5.0f, 47.1f}, settings);
979 ASSERT_EQ(1, channels->
fcurves().size()) <<
"Expect insertion with the same (slot/rna "
980 "path/array index) tuple to go into the same FCurve";
982 <<
"Expect insertion with the same (slot/rna path/array index) tuple to go into the same "
990 bmain, slot, {
"rotation_quaternion", 0}, {1.0f, 0.25f}, settings);
992 ASSERT_EQ(2, channels->
fcurves().size()) <<
"Expected a second FCurve to be created.";
1000 <<
"nullptr Actions should be assignable to any type.";
1002 <<
"nullptr Actions should be assignable to any type.";
1005 <<
"Empty Actions should be assignable to any type.";
1007 <<
"Empty Actions should be assignable to any type.";
1012 ASSERT_FALSE(action->is_empty());
1013 ASSERT_TRUE(action->is_action_legacy());
1014 ASSERT_EQ(0, action->idroot);
1017 <<
"Legacy Actions with idroot=0 should be assignable to any type.";
1019 <<
"Legacy Actions with idroot=0 should be assignable to any type.";
1022 action->idroot =
ID_CA;
1024 <<
"Legacy Actions with idroot=ID_CA should NOT be assignable to ID_OB.";
1026 <<
"Legacy Actions with idroot=CA should be assignable to ID_CA.";
1030 action->layer_add(
"layer");
1031 ASSERT_EQ(0, action->idroot) <<
"Adding a layer should clear the idroot.";
1034 <<
"Layered Actions should be assignable to any type.";
1036 <<
"Layered Actions should be assignable to any type.";
1044 EXPECT_TRUE(action->is_empty());
1056 EXPECT_FALSE(fcurve ==
nullptr);
1061 EXPECT_TRUE(action->is_action_legacy());
1072 Slot &slot = action->slot_add();
1075 EXPECT_TRUE(action->is_action_layered());
1099 EXPECT_TRUE(action->is_empty());
1101 bmain, action,
"Test",
nullptr, {
"location", 0});
1103 bmain, action,
"Test",
nullptr, {
"location", 1});
1114 ASSERT_TRUE(converted != action);
1115 EXPECT_STREQ(converted->
id.
name,
"ACACÄnimåtië_layered");
1128 ASSERT_STREQ(group->
name,
"Test");
1134 bmain,
"name_for_an_action_that_is_exactly_64_chars_which_is_MAX_ID_NAME");
1139 EXPECT_STREQ(converted->
id.
name,
1140 "ACname_for_an_action_that_is_exactly_64_chars_which_is_MA_layered");
1145 EXPECT_TRUE(action->is_empty());
1153 ASSERT_NE(rename_group,
nullptr);
1154 ASSERT_STREQ(rename_group->name,
"Test_Rename");
1167 EXPECT_STREQ(test_group->
name,
"Test");
1171 EXPECT_STREQ(test_two_group->
name,
"Test_Two");
1176 EXPECT_STREQ(test_three_group->
name,
"Test_Three");
1181 EXPECT_STREQ(test_rename_group->
name,
"Test.001");
1185 ASSERT_NE(converted, action);
1190 ASSERT_TRUE(action->is_empty());
1192 ASSERT_TRUE(converted != action);
1200 EXPECT_TRUE(action->is_empty());
1202 Slot &slot_cube = action->slot_add();
1217 ASSERT_EQ(action->layer_array_num, 1);
1220 Layer *layer_1 = action->layer(0);
1238 move_slot(*bmain, slot_suzanne, *action_2, *action);
1243 ASSERT_EQ(action->slot_array_num, 2);
1247 ASSERT_EQ(action, cube->adt->action);
1248 ASSERT_EQ(action, suzanne->adt->action);
1254 EXPECT_TRUE(action->is_empty());
1256 Slot &slot_cube = action->slot_add();
1271 ASSERT_EQ(action->layer_array_num, 1);
1274 Layer *layer_1 = action->layer(0);
1285 <<
"the keyframe strip of action_2 should NOT have a channelbag in this test";
1290 move_slot(*bmain, slot_suzanne, *action_2, *action);
1295 ASSERT_EQ(action->slot_array_num, 2);
1299 ASSERT_EQ(action, cube->adt->action);
1300 ASSERT_EQ(action, suzanne->adt->action);
1305 ASSERT_TRUE(action->is_empty());
1307 Slot &slot_cube = action->slot_add();
1315 ASSERT_EQ(action->layer_array_num, 1);
1316 Layer *layer = action->layer(0);
1329 ASSERT_EQ(action->slot_array_num, 2);
1330 EXPECT_EQ(&dupli_slot, action->slot(1));
1349 ASSERT_TRUE(action->is_empty());
1351 Slot &slot_cube = action->slot_add();
1355 action->layer_keystrip_ensure();
1357 ASSERT_EQ(action->layer_array_num, 1);
1358 Layer *layer = action->layer(0);
1369 ASSERT_EQ(action->slot_array_num, 2);
1370 EXPECT_EQ(&dupli_slot, action->slot(1));
1395 the_keyframe.
vec[0][0] =
x - 1.0f;
1396 the_keyframe.
vec[0][1] =
y;
1397 the_keyframe.
vec[1][0] =
x;
1398 the_keyframe.
vec[1][1] =
y;
1399 the_keyframe.
vec[2][0] =
x + 1.0f;
1400 the_keyframe.
vec[2][1] =
y;
1402 memcpy(&fcu.
bezt[fcu.
totvert], &the_keyframe,
sizeof(the_keyframe));
1453 const Action &empty = action_new();
1463 Action &action = action_new();
1467 EXPECT_FLOAT_EQ(frame_range[0], 1.0f);
1468 EXPECT_FLOAT_EQ(frame_range[1], 1.0f);
1480 Action &action = action_new();
1485 EXPECT_FLOAT_EQ(frame_range[0], 1.0f);
1486 EXPECT_FLOAT_EQ(frame_range[1], 1.5f);
1496 Action &action = action_new();
1500 EXPECT_FLOAT_EQ(frame_range[0], 1.0f);
1501 EXPECT_FLOAT_EQ(frame_range[1], 1.5f);
1530 FCurve &existing1 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0, {}, {},
"group0"});
1531 FCurve &existing2 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 1, {}, {},
"group0"});
1532 FCurve &existing3 = channelbag->fcurve_ensure(
nullptr, {
"fcu1", 1, {}, {},
"group1"});
1533 FCurve &existing4 = channelbag->fcurve_ensure(
nullptr, {
"fcu_", 0});
1534 ASSERT_EQ(2, channelbag->channel_groups().size());
1535 ASSERT_EQ(4, channelbag->fcurves().size());
1539 {
"fcu2", 0, {}, {},
"group2"},
1540 {
"fcu2", 1, {}, {},
"group2"},
1541 {
"fcu2", 2, {}, {},
"group2"},
1543 {
"fcu3", 0, {}, {},
"group1"},
1544 {
"fcu4", 0, {}, {},
"group0"},
1545 {
"fcu5", 0, {}, {},
"group1"},
1546 {
"fcu6", 0, {}, {},
"group0"},
1547 {
"fcu7", 0, {}, {},
"group2"},
1552 {
"", 0, {}, {},
"irrelevant"},
1554 {
"fcu0", 1, {}, {},
"irrelevant"},
1555 {
"fcu5", 0, {}, {},
"also unused"},
1556 {
"fcu2", 0, {}, {},
"group2"},
1560 ASSERT_EQ(15, fcurves.
size());
1562 EXPECT_STREQ(
"group2", fcurves[0]->grp->name);
1563 EXPECT_STREQ(
"group2", fcurves[1]->grp->name);
1564 EXPECT_STREQ(
"group2", fcurves[2]->grp->name);
1565 EXPECT_STREQ(
"group1", fcurves[3]->grp->name);
1566 EXPECT_STREQ(
"group0", fcurves[4]->grp->name);
1567 EXPECT_STREQ(
"group1", fcurves[5]->grp->name);
1568 EXPECT_STREQ(
"group0", fcurves[6]->grp->name);
1569 EXPECT_STREQ(
"group2", fcurves[7]->grp->name);
1578 EXPECT_EQ(3, channelbag->channel_groups().size());
1579 EXPECT_EQ(14, channelbag->fcurves().size());
1581 EXPECT_STREQ(
"group0", existing1.
grp->
name);
1582 EXPECT_STREQ(
"group0", existing2.
grp->
name);
1583 EXPECT_STREQ(
"group1", existing3.
grp->
name);
1589 FCurve &fcu0 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0, {}, {},
"group0"});
1590 FCurve &fcu1 = channelbag->fcurve_ensure(
nullptr, {
"fcu1", 0, {}, {},
"group0"});
1591 FCurve &fcu2 = channelbag->fcurve_ensure(
nullptr, {
"fcu2", 0, {}, {},
"group1"});
1592 FCurve &fcu3 = channelbag->fcurve_ensure(
nullptr, {
"fcu3", 0, {}, {},
"group1"});
1593 FCurve &fcu4 = channelbag->fcurve_ensure(
nullptr, {
"fcu4", 0});
1595 ASSERT_EQ(5, channelbag->fcurves().size());
1596 ASSERT_EQ(2, channelbag->channel_groups().size());
1602 channelbag->fcurve_move_to_index(fcu0, 0);
1603 EXPECT_EQ(&fcu0, channelbag->fcurve(0));
1604 EXPECT_EQ(&fcu1, channelbag->fcurve(1));
1605 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
1606 EXPECT_EQ(&fcu3, channelbag->fcurve(3));
1607 EXPECT_EQ(&fcu4, channelbag->fcurve(4));
1615 channelbag->fcurve_move_to_index(fcu4, 0);
1620 EXPECT_EQ(&fcu4, channelbag->fcurve(0));
1621 EXPECT_EQ(&fcu0, channelbag->fcurve(1));
1622 EXPECT_EQ(&fcu1, channelbag->fcurve(2));
1623 EXPECT_EQ(&fcu2, channelbag->fcurve(3));
1624 EXPECT_EQ(&fcu3, channelbag->fcurve(4));
1632 channelbag->fcurve_move_to_index(fcu1, 4);
1637 EXPECT_EQ(&fcu4, channelbag->fcurve(0));
1638 EXPECT_EQ(&fcu0, channelbag->fcurve(1));
1639 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
1640 EXPECT_EQ(&fcu3, channelbag->fcurve(3));
1641 EXPECT_EQ(&fcu1, channelbag->fcurve(4));
1649 channelbag->fcurve_move_to_index(fcu4, 2);
1654 EXPECT_EQ(&fcu0, channelbag->fcurve(0));
1655 EXPECT_EQ(&fcu2, channelbag->fcurve(1));
1656 EXPECT_EQ(&fcu4, channelbag->fcurve(2));
1657 EXPECT_EQ(&fcu3, channelbag->fcurve(3));
1658 EXPECT_EQ(&fcu1, channelbag->fcurve(4));
1668 ASSERT_TRUE(channelbag->channel_groups().is_empty());
1670 bActionGroup &group0 = channelbag->channel_group_create(
"Foo");
1671 ASSERT_EQ(channelbag->channel_groups().size(), 1);
1675 EXPECT_EQ(&group0, channelbag->channel_group(0));
1680 bActionGroup &group1 = channelbag->channel_group_create(
"Bar");
1681 ASSERT_EQ(channelbag->channel_groups().size(), 2);
1685 EXPECT_EQ(&group0, channelbag->channel_group(0));
1686 EXPECT_EQ(&group1, channelbag->channel_group(1));
1691 bActionGroup &group2 = channelbag->channel_group_create(
"Yar");
1692 ASSERT_EQ(channelbag->channel_groups().size(), 3);
1696 EXPECT_EQ(&group0, channelbag->channel_group(0));
1697 EXPECT_EQ(&group1, channelbag->channel_group(1));
1698 EXPECT_EQ(&group2, channelbag->channel_group(2));
1703 bActionGroup &group0 = channelbag->channel_group_create(
"Group0");
1704 bActionGroup &group1 = channelbag->channel_group_create(
"Group1");
1705 bActionGroup &group2 = channelbag->channel_group_create(
"Group2");
1707 FCurve &fcu0 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0, {}, {},
"Group0"});
1708 FCurve &fcu1 = channelbag->fcurve_ensure(
nullptr, {
"fcu1", 0, {}, {},
"Group0"});
1709 FCurve &fcu2 = channelbag->fcurve_ensure(
nullptr, {
"fcu2", 0, {}, {},
"Group2"});
1710 FCurve &fcu3 = channelbag->fcurve_ensure(
nullptr, {
"fcu3", 0, {}, {},
"Group2"});
1711 FCurve &fcu4 = channelbag->fcurve_ensure(
nullptr, {
"fcu4", 0});
1713 ASSERT_EQ(3, channelbag->channel_groups().size());
1714 ASSERT_EQ(5, channelbag->fcurves().size());
1719 EXPECT_EQ(
false, channelbag->channel_group_remove(bogus));
1720 ASSERT_EQ(3, channelbag->channel_groups().size());
1721 ASSERT_EQ(5, channelbag->fcurves().size());
1722 EXPECT_EQ(&group0, channelbag->channel_group(0));
1723 EXPECT_EQ(&group1, channelbag->channel_group(1));
1724 EXPECT_EQ(&group2, channelbag->channel_group(2));
1725 EXPECT_EQ(&fcu0, channelbag->fcurve(0));
1726 EXPECT_EQ(&fcu1, channelbag->fcurve(1));
1727 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
1728 EXPECT_EQ(&fcu3, channelbag->fcurve(3));
1729 EXPECT_EQ(&fcu4, channelbag->fcurve(4));
1737 EXPECT_EQ(
true, channelbag->channel_group_remove(group1));
1738 ASSERT_EQ(2, channelbag->channel_groups().size());
1739 ASSERT_EQ(5, channelbag->fcurves().size());
1740 EXPECT_EQ(&group0, channelbag->channel_group(0));
1741 EXPECT_EQ(&group2, channelbag->channel_group(1));
1742 EXPECT_EQ(&fcu0, channelbag->fcurve(0));
1743 EXPECT_EQ(&fcu1, channelbag->fcurve(1));
1744 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
1745 EXPECT_EQ(&fcu3, channelbag->fcurve(3));
1746 EXPECT_EQ(&fcu4, channelbag->fcurve(4));
1755 EXPECT_EQ(
true, channelbag->channel_group_remove(group0));
1756 ASSERT_EQ(1, channelbag->channel_groups().size());
1757 ASSERT_EQ(5, channelbag->fcurves().size());
1758 EXPECT_EQ(&group2, channelbag->channel_group(0));
1759 EXPECT_EQ(&fcu2, channelbag->fcurve(0));
1760 EXPECT_EQ(&fcu3, channelbag->fcurve(1));
1761 EXPECT_EQ(&fcu0, channelbag->fcurve(2));
1762 EXPECT_EQ(&fcu1, channelbag->fcurve(3));
1763 EXPECT_EQ(&fcu4, channelbag->fcurve(4));
1772 EXPECT_EQ(
true, channelbag->channel_group_remove(group2));
1773 ASSERT_EQ(0, channelbag->channel_groups().size());
1774 ASSERT_EQ(5, channelbag->fcurves().size());
1775 EXPECT_EQ(&fcu2, channelbag->fcurve(0));
1776 EXPECT_EQ(&fcu3, channelbag->fcurve(1));
1777 EXPECT_EQ(&fcu0, channelbag->fcurve(2));
1778 EXPECT_EQ(&fcu1, channelbag->fcurve(3));
1779 EXPECT_EQ(&fcu4, channelbag->fcurve(4));
1789 bActionGroup &group0a = channelbag->channel_group_create(
"Foo");
1790 bActionGroup &group1a = channelbag->channel_group_create(
"Bar");
1791 bActionGroup &group2a = channelbag->channel_group_create(
"Yar");
1793 bActionGroup *group0b = channelbag->channel_group_find(
"Foo");
1794 bActionGroup *group1b = channelbag->channel_group_find(
"Bar");
1795 bActionGroup *group2b = channelbag->channel_group_find(
"Yar");
1801 EXPECT_EQ(
nullptr, channelbag->channel_group_find(
"Wat"));
1806 bActionGroup &group0 = channelbag->channel_group_create(
"Foo");
1807 bActionGroup &group1 = channelbag->channel_group_create(
"Bar");
1808 EXPECT_EQ(channelbag->channel_groups().size(), 2);
1810 EXPECT_EQ(&group0, &channelbag->channel_group_ensure(
"Foo"));
1811 EXPECT_EQ(channelbag->channel_groups().size(), 2);
1813 EXPECT_EQ(&group1, &channelbag->channel_group_ensure(
"Bar"));
1814 EXPECT_EQ(channelbag->channel_groups().size(), 2);
1816 bActionGroup &group2 = channelbag->channel_group_ensure(
"Yar");
1817 ASSERT_EQ(channelbag->channel_groups().size(), 3);
1818 EXPECT_EQ(&group2, channelbag->channel_group(2));
1823 FCurve &fcu0 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0});
1824 EXPECT_EQ(1, channelbag->fcurves().size());
1825 EXPECT_TRUE(channelbag->channel_groups().is_empty());
1830 channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0, {}, {},
"group0"});
1831 EXPECT_EQ(1, channelbag->fcurves().size());
1833 EXPECT_TRUE(channelbag->channel_groups().is_empty());
1838 FCurve &fcu1 = channelbag->fcurve_ensure(
nullptr, {
"fcu1", 0, {}, {},
"group0"});
1839 ASSERT_EQ(2, channelbag->fcurves().size());
1840 ASSERT_EQ(1, channelbag->channel_groups().size());
1842 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
1843 EXPECT_EQ(&fcu0, channelbag->fcurve(1));
1853 FCurve &fcu2 = channelbag->fcurve_ensure(
nullptr, {
"fcu2", 0, {}, {},
"group1"});
1854 ASSERT_EQ(3, channelbag->fcurves().size());
1855 ASSERT_EQ(2, channelbag->channel_groups().size());
1856 EXPECT_EQ(&group0, channelbag->channel_group(0));
1858 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
1859 EXPECT_EQ(&fcu2, channelbag->fcurve(1));
1860 EXPECT_EQ(&fcu0, channelbag->fcurve(2));
1871 FCurve &fcu3 = channelbag->fcurve_ensure(
nullptr, {
"fcu3", 0, {}, {},
"group0"});
1872 ASSERT_EQ(4, channelbag->fcurves().size());
1873 ASSERT_EQ(2, channelbag->channel_groups().size());
1874 EXPECT_EQ(&group0, channelbag->channel_group(0));
1875 EXPECT_EQ(&group1, channelbag->channel_group(1));
1876 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
1877 EXPECT_EQ(&fcu3, channelbag->fcurve(1));
1878 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
1879 EXPECT_EQ(&fcu0, channelbag->fcurve(3));
1891 FCurve &fcu4 = channelbag->fcurve_ensure(
nullptr, {
"fcu4", 0, {}, {},
"group1"});
1892 ASSERT_EQ(5, channelbag->fcurves().size());
1893 ASSERT_EQ(2, channelbag->channel_groups().size());
1894 EXPECT_EQ(&group0, channelbag->channel_group(0));
1895 EXPECT_EQ(&group1, channelbag->channel_group(1));
1896 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
1897 EXPECT_EQ(&fcu3, channelbag->fcurve(1));
1898 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
1899 EXPECT_EQ(&fcu4, channelbag->fcurve(3));
1900 EXPECT_EQ(&fcu0, channelbag->fcurve(4));
1914 FCurve &fcu0 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0, {}, {},
"group0"});
1915 FCurve &fcu1 = channelbag->fcurve_ensure(
nullptr, {
"fcu1", 0, {}, {},
"group0"});
1916 FCurve &fcu2 = channelbag->fcurve_ensure(
nullptr, {
"fcu2", 0, {}, {},
"group1"});
1917 FCurve &fcu3 = channelbag->fcurve_ensure(
nullptr, {
"fcu3", 0, {}, {},
"group1"});
1918 FCurve &fcu4 = channelbag->fcurve_ensure(
nullptr, {
"fcu4", 0});
1920 ASSERT_EQ(5, channelbag->fcurves().size());
1921 ASSERT_EQ(2, channelbag->channel_groups().size());
1936 channelbag->fcurve_remove(fcu3);
1937 ASSERT_EQ(4, channelbag->fcurves().size());
1938 ASSERT_EQ(2, channelbag->channel_groups().size());
1939 EXPECT_EQ(&group0, channelbag->channel_group(0));
1940 EXPECT_EQ(&group1, channelbag->channel_group(1));
1950 channelbag->fcurve_remove(fcu0);
1951 ASSERT_EQ(3, channelbag->fcurves().size());
1952 ASSERT_EQ(2, channelbag->channel_groups().size());
1953 EXPECT_EQ(&group0, channelbag->channel_group(0));
1954 EXPECT_EQ(&group1, channelbag->channel_group(1));
1963 channelbag->fcurve_remove(fcu1);
1964 ASSERT_EQ(2, channelbag->fcurves().size());
1965 ASSERT_EQ(1, channelbag->channel_groups().size());
1966 EXPECT_EQ(&group1, channelbag->channel_group(0));
1972 channelbag->fcurve_remove(fcu4);
1973 ASSERT_EQ(1, channelbag->fcurves().size());
1974 ASSERT_EQ(1, channelbag->channel_groups().size());
1975 EXPECT_EQ(&group1, channelbag->channel_group(0));
1980 channelbag->fcurve_remove(fcu2);
1981 ASSERT_EQ(0, channelbag->fcurves().size());
1982 ASSERT_EQ(0, channelbag->channel_groups().size());
1987 FCurve &fcu0 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0, {}, {},
"group0"});
1988 FCurve &fcu1 = channelbag->fcurve_ensure(
nullptr, {
"fcu1", 0, {}, {},
"group1"});
1989 FCurve &fcu2 = channelbag->fcurve_ensure(
nullptr, {
"fcu2", 0, {}, {},
"group1"});
1990 FCurve &fcu3 = channelbag->fcurve_ensure(
nullptr, {
"fcu3", 0, {}, {},
"group2"});
1991 FCurve &fcu4 = channelbag->fcurve_ensure(
nullptr, {
"fcu4", 0});
1993 ASSERT_EQ(5, channelbag->fcurves().size());
1994 ASSERT_EQ(3, channelbag->channel_groups().size());
2000 channelbag->channel_group_move_to_index(group0, 2);
2001 EXPECT_EQ(&group1, channelbag->channel_group(0));
2002 EXPECT_EQ(&group2, channelbag->channel_group(1));
2003 EXPECT_EQ(&group0, channelbag->channel_group(2));
2010 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
2011 EXPECT_EQ(&fcu2, channelbag->fcurve(1));
2012 EXPECT_EQ(&fcu3, channelbag->fcurve(2));
2013 EXPECT_EQ(&fcu0, channelbag->fcurve(3));
2014 EXPECT_EQ(&fcu4, channelbag->fcurve(4));
2021 channelbag->channel_group_move_to_index(group1, 1);
2022 EXPECT_EQ(&group2, channelbag->channel_group(0));
2023 EXPECT_EQ(&group1, channelbag->channel_group(1));
2024 EXPECT_EQ(&group0, channelbag->channel_group(2));
2031 EXPECT_EQ(&fcu3, channelbag->fcurve(0));
2032 EXPECT_EQ(&fcu1, channelbag->fcurve(1));
2033 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
2034 EXPECT_EQ(&fcu0, channelbag->fcurve(3));
2035 EXPECT_EQ(&fcu4, channelbag->fcurve(4));
2042 channelbag->channel_group_move_to_index(group0, 0);
2043 EXPECT_EQ(&group0, channelbag->channel_group(0));
2044 EXPECT_EQ(&group2, channelbag->channel_group(1));
2045 EXPECT_EQ(&group1, channelbag->channel_group(2));
2052 EXPECT_EQ(&fcu0, channelbag->fcurve(0));
2053 EXPECT_EQ(&fcu3, channelbag->fcurve(1));
2054 EXPECT_EQ(&fcu1, channelbag->fcurve(2));
2055 EXPECT_EQ(&fcu2, channelbag->fcurve(3));
2056 EXPECT_EQ(&fcu4, channelbag->fcurve(4));
2066 FCurve &fcu0 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0});
2067 FCurve &fcu1 = channelbag->fcurve_ensure(
nullptr, {
"fcu1", 0});
2068 FCurve &fcu2 = channelbag->fcurve_ensure(
nullptr, {
"fcu2", 0});
2069 bActionGroup &group0 = channelbag->channel_group_create(
"group0");
2070 bActionGroup &group1 = channelbag->channel_group_create(
"group1");
2072 ASSERT_EQ(3, channelbag->fcurves().size());
2073 EXPECT_EQ(&fcu0, channelbag->fcurve(0));
2074 EXPECT_EQ(&fcu1, channelbag->fcurve(1));
2075 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
2076 ASSERT_EQ(2, channelbag->channel_groups().size());
2077 EXPECT_EQ(&group0, channelbag->channel_group(0));
2078 EXPECT_EQ(&group1, channelbag->channel_group(1));
2084 channelbag->fcurve_assign_to_channel_group(fcu2, group1);
2085 EXPECT_EQ(&fcu2, channelbag->fcurve(0));
2086 EXPECT_EQ(&fcu0, channelbag->fcurve(1));
2087 EXPECT_EQ(&fcu1, channelbag->fcurve(2));
2093 channelbag->fcurve_assign_to_channel_group(fcu1, group0);
2094 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
2095 EXPECT_EQ(&fcu2, channelbag->fcurve(1));
2096 EXPECT_EQ(&fcu0, channelbag->fcurve(2));
2102 channelbag->fcurve_assign_to_channel_group(fcu0, group1);
2103 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
2104 EXPECT_EQ(&fcu2, channelbag->fcurve(1));
2105 EXPECT_EQ(&fcu0, channelbag->fcurve(2));
2111 channelbag->fcurve_assign_to_channel_group(fcu0, group0);
2112 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
2113 EXPECT_EQ(&fcu0, channelbag->fcurve(1));
2114 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
2120 channelbag->fcurve_assign_to_channel_group(fcu1, group1);
2121 EXPECT_EQ(&fcu0, channelbag->fcurve(0));
2122 EXPECT_EQ(&fcu2, channelbag->fcurve(1));
2123 EXPECT_EQ(&fcu1, channelbag->fcurve(2));
2132 FCurve &fcu0 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0, {}, {},
"group0"});
2133 FCurve &fcu1 = channelbag->fcurve_ensure(
nullptr, {
"fcu1", 0, {}, {},
"group0"});
2134 FCurve &fcu2 = channelbag->fcurve_ensure(
nullptr, {
"fcu2", 0, {}, {},
"group1"});
2135 FCurve &fcu3 = channelbag->fcurve_ensure(
nullptr, {
"fcu3", 0, {}, {},
"group1"});
2136 FCurve &fcu4 = channelbag->fcurve_ensure(
nullptr, {
"fcu4", 0});
2138 ASSERT_EQ(5, channelbag->fcurves().size());
2139 ASSERT_EQ(2, channelbag->channel_groups().size());
2146 EXPECT_FALSE(channelbag->fcurve_ungroup(bogus));
2149 EXPECT_TRUE(channelbag->fcurve_ungroup(fcu4));
2153 EXPECT_TRUE(channelbag->fcurve_ungroup(fcu0));
2158 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
2159 EXPECT_EQ(&fcu2, channelbag->fcurve(1));
2160 EXPECT_EQ(&fcu3, channelbag->fcurve(2));
2161 EXPECT_EQ(&fcu4, channelbag->fcurve(3));
2162 EXPECT_EQ(&fcu0, channelbag->fcurve(4));
2169 EXPECT_TRUE(channelbag->fcurve_ungroup(fcu3));
2174 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
2175 EXPECT_EQ(&fcu2, channelbag->fcurve(1));
2176 EXPECT_EQ(&fcu4, channelbag->fcurve(2));
2177 EXPECT_EQ(&fcu0, channelbag->fcurve(3));
2178 EXPECT_EQ(&fcu3, channelbag->fcurve(4));
2185 EXPECT_TRUE(channelbag->fcurve_ungroup(fcu1));
2186 EXPECT_EQ(1, channelbag->channel_groups().size());
2187 EXPECT_EQ(&group1, channelbag->channel_group(0));
2190 EXPECT_EQ(&fcu2, channelbag->fcurve(0));
2191 EXPECT_EQ(&fcu4, channelbag->fcurve(1));
2192 EXPECT_EQ(&fcu0, channelbag->fcurve(2));
2193 EXPECT_EQ(&fcu3, channelbag->fcurve(3));
2194 EXPECT_EQ(&fcu1, channelbag->fcurve(4));
2201 EXPECT_TRUE(channelbag->fcurve_ungroup(fcu2));
2202 EXPECT_EQ(0, channelbag->channel_groups().size());
2203 EXPECT_EQ(&fcu4, channelbag->fcurve(0));
2204 EXPECT_EQ(&fcu0, channelbag->fcurve(1));
2205 EXPECT_EQ(&fcu3, channelbag->fcurve(2));
2206 EXPECT_EQ(&fcu1, channelbag->fcurve(3));
2207 EXPECT_EQ(&fcu2, channelbag->fcurve(4));
2260 FCurve *fcurve_to_move = fcurve_create(
"source_prop", 2);
2275 <<
"F-Curve should no longer exist in source Action";
2277 <<
"F-Curve should exist in destination Action";
2280 <<
"Source Action should still have the other F-Curve";
2282 <<
"Destination Action should have its original and the moved F-Curve";
2298 FCurve &fcurve_to_move = cbag_src.fcurve_ensure(this->bmain, {
"source_prop", 2});
2299 bActionGroup &group_src = cbag_src.channel_group_create(
"Gröpje");
2300 cbag_src.fcurve_assign_to_channel_group(fcurve_to_move, group_src);
2319 EXPECT_EQ(
nullptr, cbag_src.fcurve_find({fcurve_to_move.rna_path, fcurve_to_move.array_index}))
2320 <<
"F-Curve should no longer exist in source Action";
2322 cbag_dst.fcurve_find({fcurve_to_move.rna_path, fcurve_to_move.array_index}))
2323 <<
"F-Curve should exist in destination Action";
2325 EXPECT_EQ(1, cbag_src.fcurves().size()) <<
"Source Action should still have the other F-Curve";
2327 <<
"Destination Action should have its original and the moved F-Curve";
2329 bActionGroup *group_dst = cbag_dst.channel_group_find(
"Gröpje");
2330 ASSERT_NE(
nullptr, group_dst) <<
"Expected channel group to be created";
2331 ASSERT_EQ(group_dst, fcurve_to_move.
grp) <<
"Expected group membership to move as well";
Functions and classes to work with Actions.
Blender kernel action and pose functionality.
AnimData * BKE_animdata_ensure_id(ID *id)
FCurve * BKE_fcurve_create()
FModifier * add_fmodifier(ListBase *modifiers, int type, FCurve *owner_fcu)
float evaluate_fcurve(const FCurve *fcu, float evaltime)
void BKE_id_free(Main *bmain, void *idv)
void * BKE_id_new(Main *bmain, short type, const char *name)
void * BKE_id_new_nomain(short type, const char *name)
void BKE_main_free(Main *bmain)
General operations, lookup, etc. for blender objects.
Object * BKE_object_add_only_object(Main *bmain, int type, const char *name) ATTR_RETURNS_NONNULL
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_poptail(ListBase *listbase) ATTR_NONNULL(1)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
int BLI_listbase_count(const ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
char * BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define STRNCPY_UTF8(dst, src)
#define DNA_DEFAULT_ACTION_LAST_SLOT_HANDLE
Object is a sort of wrapper for general info.
constexpr bool contains(const T &value) const
bool contains(const T &value) const
constexpr const char * c_str() const
Slot & slot_add_for_id(const ID &animated_id)
void layer_keystrip_ensure()
const Layer * layer(int64_t index) const
const Slot * slot(int64_t index) const
bool is_action_legacy() const
bool is_action_layered() const
float2 get_frame_range_of_keys(bool include_modifiers) const ATTR_WARN_UNUSED_RESULT
void slot_identifier_define(Slot &slot, StringRefNull new_identifier)
Layer & layer_add(std::optional< StringRefNull > name)
const bActionGroup * channel_group(int64_t index) const
FCurve & fcurve_ensure(Main *bmain, const FCurveDescriptor &fcurve_descriptor)
FCurve * fcurve_create_unique(Main *bmain, const FCurveDescriptor &fcurve_descriptor)
void fcurve_append(FCurve &fcurve)
blender::Span< const FCurve * > fcurves() const
blender::Span< const bActionGroup * > channel_groups() const
bool strip_remove(Action &owning_action, Strip &strip)
blender::Span< const Strip * > strips() const
const Strip * strip(int64_t index) const
Strip & strip_add(Action &owning_action, Strip::Type strip_type)
Vector< ID * > runtime_users()
StringRef identifier_prefix() const
void identifier_ensure_prefix()
std::string idtype_string() const
Span< ID * > users(Main &bmain) const
static constexpr slot_handle_t unassigned
const Channelbag * channelbag_for_slot(const Slot &slot) const
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)
Channelbag & channelbag_for_slot_ensure(const Slot &slot)
blender::Span< const Channelbag * > channelbags() const
const Channelbag * channelbag(int64_t index) const
bool is_last_frame(float frame_time) const
void resize(float frame_start, float frame_end)
const T & data(const Action &owning_action) const
bool contains_frame(float frame_time) const
static FCurve * fcurve_create(const StringRefNull rna_path, const int array_index)
static void TearDownTestSuite()
static void SetUpTestSuite()
static void SetUpTestSuite()
static void TearDownTestSuite()
static void TearDownTestSuite()
static void SetUpTestSuite()
static void SetUpTestSuite()
static void TearDownTestSuite()
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void * MEM_callocN(size_t len, const char *str)
static void add_fcurve_to_action(Action &action, FCurve &fcu)
static void allocate_keyframes(FCurve &fcu, const size_t num_keyframes)
TEST_F(ActionIteratorsTest, iterate_all_fcurves_of_slot)
TEST(action, low_level_initialisation)
static void add_keyframe(FCurve &fcu, float x, float y)
KeyframeSettings get_keyframe_settings(bool from_userprefs)
Slot * assign_action_ensure_slot_for_keying(Action &action, ID &animated_id)
void action_fcurve_move(Action &action_dst, slot_handle_t action_slot_dst, Action &action_src, FCurve &fcurve)
Action & action_add(Main &bmain, StringRefNull name)
Slot & duplicate_slot(Action &action, const Slot &slot)
FCurve * action_fcurve_ensure_legacy(Main *bmain, bAction *act, const char group[], PointerRNA *ptr, const FCurveDescriptor &fcurve_descriptor)
ActionSlotAssignmentResult assign_action_and_slot(Action *action, Slot *slot_to_assign, ID &animated_id)
decltype(::ActionSlot::handle) slot_handle_t
bool is_action_assignable_to(const bAction *dna_action, ID_Type id_code)
SingleKeyingResult insert_vert_fcurve(FCurve *fcu, const float2 position, const KeyframeSettings &settings, eInsertKeyFlags flag)
Main Key-framing API call.
ID * action_slot_get_id_for_keying(Main &bmain, Action &action, slot_handle_t slot_handle, ID *primary_id)
FCurve * action_fcurve_ensure_ex(Main *bmain, bAction *act, const char group[], PointerRNA *ptr, const FCurveDescriptor &fcurve_descriptor)
Action * convert_to_layered_action(Main &bmain, const Action &legacy_action)
bool unassign_action(ID &animated_id)
bool assign_action(bAction *action, ID &animated_id)
ActionSlotAssignmentResult assign_action_slot(Slot *slot_to_assign, ID &animated_id)
void move_slot(Main &bmain, Slot &slot, Action &from_action, Action &to_action)
Slot * generic_slot_for_autoassign(const ID &animated_id, Action &action, StringRefNull last_slot_identifier)
VecBase< float, 2 > float2
PointerRNA RNA_id_pointer_create(ID *id)
struct FCurve ** fcurve_array
ActionSlotRuntimeHandle * runtime
char last_slot_identifier[66]