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");
1133 constexpr char id_name_max[] =
1134 "name_for_an_action_that_is_exactly_255_bytes_MAX_ID_NAME-3______"
1135 "name_for_an_action_that_is_exactly_255_bytes_MAX_ID_NAME-3______"
1136 "name_for_an_action_that_is_exactly_255_bytes_MAX_ID_NAME-3______"
1137 "name_for_an_action_that_is_exactly_255_bytes_MAX_ID_NAME-3_____";
1139 "Wrong 'max length' name");
1143 constexpr char id_name_max_converted[] =
1144 "name_for_an_action_that_is_exactly_255_bytes_MAX_ID_NAME-3______"
1145 "name_for_an_action_that_is_exactly_255_bytes_MAX_ID_NAME-3______"
1146 "name_for_an_action_that_is_exactly_255_bytes_MAX_ID_NAME-3______"
1147 "name_for_an_action_that_is_exactly_255_bytes_MAX_ID_NAM_layered";
1149 "Wrong 'max length' name");
1151 EXPECT_STREQ(
BKE_id_name(converted->
id), id_name_max_converted);
1156 EXPECT_TRUE(action->is_empty());
1164 ASSERT_NE(rename_group,
nullptr);
1165 ASSERT_STREQ(rename_group->name,
"Test_Rename");
1178 EXPECT_STREQ(test_group->
name,
"Test");
1182 EXPECT_STREQ(test_two_group->
name,
"Test_Two");
1187 EXPECT_STREQ(test_three_group->
name,
"Test_Three");
1192 EXPECT_STREQ(test_rename_group->
name,
"Test.001");
1196 ASSERT_NE(converted, action);
1201 ASSERT_TRUE(action->is_empty());
1203 ASSERT_TRUE(converted != action);
1211 EXPECT_TRUE(action->is_empty());
1213 Slot &slot_cube = action->slot_add();
1228 ASSERT_EQ(action->layer_array_num, 1);
1231 Layer *layer_1 = action->layer(0);
1249 move_slot(*bmain, slot_suzanne, *action_2, *action);
1254 ASSERT_EQ(action->slot_array_num, 2);
1258 ASSERT_EQ(action, cube->adt->action);
1259 ASSERT_EQ(action, suzanne->adt->action);
1265 EXPECT_TRUE(action->is_empty());
1267 Slot &slot_cube = action->slot_add();
1282 ASSERT_EQ(action->layer_array_num, 1);
1285 Layer *layer_1 = action->layer(0);
1296 <<
"the keyframe strip of action_2 should NOT have a channelbag in this test";
1301 move_slot(*bmain, slot_suzanne, *action_2, *action);
1306 ASSERT_EQ(action->slot_array_num, 2);
1310 ASSERT_EQ(action, cube->adt->action);
1311 ASSERT_EQ(action, suzanne->adt->action);
1316 ASSERT_TRUE(action->is_empty());
1318 Slot &slot_cube = action->slot_add();
1326 ASSERT_EQ(action->layer_array_num, 1);
1327 Layer *layer = action->layer(0);
1340 ASSERT_EQ(action->slot_array_num, 2);
1341 EXPECT_EQ(&dupli_slot, action->slot(1));
1360 ASSERT_TRUE(action->is_empty());
1362 Slot &slot_cube = action->slot_add();
1366 action->layer_keystrip_ensure();
1368 ASSERT_EQ(action->layer_array_num, 1);
1369 Layer *layer = action->layer(0);
1380 ASSERT_EQ(action->slot_array_num, 2);
1381 EXPECT_EQ(&dupli_slot, action->slot(1));
1406 the_keyframe.
vec[0][0] =
x - 1.0f;
1407 the_keyframe.
vec[0][1] =
y;
1408 the_keyframe.
vec[1][0] =
x;
1409 the_keyframe.
vec[1][1] =
y;
1410 the_keyframe.
vec[2][0] =
x + 1.0f;
1411 the_keyframe.
vec[2][1] =
y;
1413 memcpy(&fcu.
bezt[fcu.
totvert], &the_keyframe,
sizeof(the_keyframe));
1464 const Action &empty = action_new();
1474 Action &action = action_new();
1478 EXPECT_FLOAT_EQ(frame_range[0], 1.0f);
1479 EXPECT_FLOAT_EQ(frame_range[1], 1.0f);
1491 Action &action = action_new();
1496 EXPECT_FLOAT_EQ(frame_range[0], 1.0f);
1497 EXPECT_FLOAT_EQ(frame_range[1], 1.5f);
1507 Action &action = action_new();
1511 EXPECT_FLOAT_EQ(frame_range[0], 1.0f);
1512 EXPECT_FLOAT_EQ(frame_range[1], 1.5f);
1541 FCurve &existing1 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0, {}, {},
"group0"});
1542 FCurve &existing2 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 1, {}, {},
"group0"});
1543 FCurve &existing3 = channelbag->fcurve_ensure(
nullptr, {
"fcu1", 1, {}, {},
"group1"});
1544 FCurve &existing4 = channelbag->fcurve_ensure(
nullptr, {
"fcu_", 0});
1545 ASSERT_EQ(2, channelbag->channel_groups().size());
1546 ASSERT_EQ(4, channelbag->fcurves().size());
1550 {
"fcu2", 0, {}, {},
"group2"},
1551 {
"fcu2", 1, {}, {},
"group2"},
1552 {
"fcu2", 2, {}, {},
"group2"},
1554 {
"fcu3", 0, {}, {},
"group1"},
1555 {
"fcu4", 0, {}, {},
"group0"},
1556 {
"fcu5", 0, {}, {},
"group1"},
1557 {
"fcu6", 0, {}, {},
"group0"},
1558 {
"fcu7", 0, {}, {},
"group2"},
1563 {
"", 0, {}, {},
"irrelevant"},
1565 {
"fcu0", 1, {}, {},
"irrelevant"},
1566 {
"fcu5", 0, {}, {},
"also unused"},
1567 {
"fcu2", 0, {}, {},
"group2"},
1571 ASSERT_EQ(15, fcurves.
size());
1573 EXPECT_STREQ(
"group2", fcurves[0]->grp->name);
1574 EXPECT_STREQ(
"group2", fcurves[1]->grp->name);
1575 EXPECT_STREQ(
"group2", fcurves[2]->grp->name);
1576 EXPECT_STREQ(
"group1", fcurves[3]->grp->name);
1577 EXPECT_STREQ(
"group0", fcurves[4]->grp->name);
1578 EXPECT_STREQ(
"group1", fcurves[5]->grp->name);
1579 EXPECT_STREQ(
"group0", fcurves[6]->grp->name);
1580 EXPECT_STREQ(
"group2", fcurves[7]->grp->name);
1589 EXPECT_EQ(3, channelbag->channel_groups().size());
1590 EXPECT_EQ(14, channelbag->fcurves().size());
1592 EXPECT_STREQ(
"group0", existing1.
grp->
name);
1593 EXPECT_STREQ(
"group0", existing2.
grp->
name);
1594 EXPECT_STREQ(
"group1", existing3.
grp->
name);
1600 FCurve &fcu0 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0, {}, {},
"group0"});
1601 FCurve &fcu1 = channelbag->fcurve_ensure(
nullptr, {
"fcu1", 0, {}, {},
"group0"});
1602 FCurve &fcu2 = channelbag->fcurve_ensure(
nullptr, {
"fcu2", 0, {}, {},
"group1"});
1603 FCurve &fcu3 = channelbag->fcurve_ensure(
nullptr, {
"fcu3", 0, {}, {},
"group1"});
1604 FCurve &fcu4 = channelbag->fcurve_ensure(
nullptr, {
"fcu4", 0});
1606 ASSERT_EQ(5, channelbag->fcurves().size());
1607 ASSERT_EQ(2, channelbag->channel_groups().size());
1613 channelbag->fcurve_move_to_index(fcu0, 0);
1614 EXPECT_EQ(&fcu0, channelbag->fcurve(0));
1615 EXPECT_EQ(&fcu1, channelbag->fcurve(1));
1616 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
1617 EXPECT_EQ(&fcu3, channelbag->fcurve(3));
1618 EXPECT_EQ(&fcu4, channelbag->fcurve(4));
1626 channelbag->fcurve_move_to_index(fcu4, 0);
1631 EXPECT_EQ(&fcu4, channelbag->fcurve(0));
1632 EXPECT_EQ(&fcu0, channelbag->fcurve(1));
1633 EXPECT_EQ(&fcu1, channelbag->fcurve(2));
1634 EXPECT_EQ(&fcu2, channelbag->fcurve(3));
1635 EXPECT_EQ(&fcu3, channelbag->fcurve(4));
1643 channelbag->fcurve_move_to_index(fcu1, 4);
1648 EXPECT_EQ(&fcu4, channelbag->fcurve(0));
1649 EXPECT_EQ(&fcu0, channelbag->fcurve(1));
1650 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
1651 EXPECT_EQ(&fcu3, channelbag->fcurve(3));
1652 EXPECT_EQ(&fcu1, channelbag->fcurve(4));
1660 channelbag->fcurve_move_to_index(fcu4, 2);
1665 EXPECT_EQ(&fcu0, channelbag->fcurve(0));
1666 EXPECT_EQ(&fcu2, channelbag->fcurve(1));
1667 EXPECT_EQ(&fcu4, channelbag->fcurve(2));
1668 EXPECT_EQ(&fcu3, channelbag->fcurve(3));
1669 EXPECT_EQ(&fcu1, channelbag->fcurve(4));
1679 ASSERT_TRUE(channelbag->channel_groups().is_empty());
1681 bActionGroup &group0 = channelbag->channel_group_create(
"Foo");
1682 ASSERT_EQ(channelbag->channel_groups().size(), 1);
1686 EXPECT_EQ(&group0, channelbag->channel_group(0));
1691 bActionGroup &group1 = channelbag->channel_group_create(
"Bar");
1692 ASSERT_EQ(channelbag->channel_groups().size(), 2);
1696 EXPECT_EQ(&group0, channelbag->channel_group(0));
1697 EXPECT_EQ(&group1, channelbag->channel_group(1));
1702 bActionGroup &group2 = channelbag->channel_group_create(
"Yar");
1703 ASSERT_EQ(channelbag->channel_groups().size(), 3);
1707 EXPECT_EQ(&group0, channelbag->channel_group(0));
1708 EXPECT_EQ(&group1, channelbag->channel_group(1));
1709 EXPECT_EQ(&group2, channelbag->channel_group(2));
1714 bActionGroup &group0 = channelbag->channel_group_create(
"Group0");
1715 bActionGroup &group1 = channelbag->channel_group_create(
"Group1");
1716 bActionGroup &group2 = channelbag->channel_group_create(
"Group2");
1718 FCurve &fcu0 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0, {}, {},
"Group0"});
1719 FCurve &fcu1 = channelbag->fcurve_ensure(
nullptr, {
"fcu1", 0, {}, {},
"Group0"});
1720 FCurve &fcu2 = channelbag->fcurve_ensure(
nullptr, {
"fcu2", 0, {}, {},
"Group2"});
1721 FCurve &fcu3 = channelbag->fcurve_ensure(
nullptr, {
"fcu3", 0, {}, {},
"Group2"});
1722 FCurve &fcu4 = channelbag->fcurve_ensure(
nullptr, {
"fcu4", 0});
1724 ASSERT_EQ(3, channelbag->channel_groups().size());
1725 ASSERT_EQ(5, channelbag->fcurves().size());
1730 EXPECT_EQ(
false, channelbag->channel_group_remove(bogus));
1731 ASSERT_EQ(3, channelbag->channel_groups().size());
1732 ASSERT_EQ(5, channelbag->fcurves().size());
1733 EXPECT_EQ(&group0, channelbag->channel_group(0));
1734 EXPECT_EQ(&group1, channelbag->channel_group(1));
1735 EXPECT_EQ(&group2, channelbag->channel_group(2));
1736 EXPECT_EQ(&fcu0, channelbag->fcurve(0));
1737 EXPECT_EQ(&fcu1, channelbag->fcurve(1));
1738 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
1739 EXPECT_EQ(&fcu3, channelbag->fcurve(3));
1740 EXPECT_EQ(&fcu4, channelbag->fcurve(4));
1748 EXPECT_EQ(
true, channelbag->channel_group_remove(group1));
1749 ASSERT_EQ(2, channelbag->channel_groups().size());
1750 ASSERT_EQ(5, channelbag->fcurves().size());
1751 EXPECT_EQ(&group0, channelbag->channel_group(0));
1752 EXPECT_EQ(&group2, channelbag->channel_group(1));
1753 EXPECT_EQ(&fcu0, channelbag->fcurve(0));
1754 EXPECT_EQ(&fcu1, channelbag->fcurve(1));
1755 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
1756 EXPECT_EQ(&fcu3, channelbag->fcurve(3));
1757 EXPECT_EQ(&fcu4, channelbag->fcurve(4));
1766 EXPECT_EQ(
true, channelbag->channel_group_remove(group0));
1767 ASSERT_EQ(1, channelbag->channel_groups().size());
1768 ASSERT_EQ(5, channelbag->fcurves().size());
1769 EXPECT_EQ(&group2, channelbag->channel_group(0));
1770 EXPECT_EQ(&fcu2, channelbag->fcurve(0));
1771 EXPECT_EQ(&fcu3, channelbag->fcurve(1));
1772 EXPECT_EQ(&fcu0, channelbag->fcurve(2));
1773 EXPECT_EQ(&fcu1, channelbag->fcurve(3));
1774 EXPECT_EQ(&fcu4, channelbag->fcurve(4));
1783 EXPECT_EQ(
true, channelbag->channel_group_remove(group2));
1784 ASSERT_EQ(0, channelbag->channel_groups().size());
1785 ASSERT_EQ(5, channelbag->fcurves().size());
1786 EXPECT_EQ(&fcu2, channelbag->fcurve(0));
1787 EXPECT_EQ(&fcu3, channelbag->fcurve(1));
1788 EXPECT_EQ(&fcu0, channelbag->fcurve(2));
1789 EXPECT_EQ(&fcu1, channelbag->fcurve(3));
1790 EXPECT_EQ(&fcu4, channelbag->fcurve(4));
1800 bActionGroup &group0a = channelbag->channel_group_create(
"Foo");
1801 bActionGroup &group1a = channelbag->channel_group_create(
"Bar");
1802 bActionGroup &group2a = channelbag->channel_group_create(
"Yar");
1804 bActionGroup *group0b = channelbag->channel_group_find(
"Foo");
1805 bActionGroup *group1b = channelbag->channel_group_find(
"Bar");
1806 bActionGroup *group2b = channelbag->channel_group_find(
"Yar");
1812 EXPECT_EQ(
nullptr, channelbag->channel_group_find(
"Wat"));
1817 bActionGroup &group0 = channelbag->channel_group_create(
"Foo");
1818 bActionGroup &group1 = channelbag->channel_group_create(
"Bar");
1819 EXPECT_EQ(channelbag->channel_groups().size(), 2);
1821 EXPECT_EQ(&group0, &channelbag->channel_group_ensure(
"Foo"));
1822 EXPECT_EQ(channelbag->channel_groups().size(), 2);
1824 EXPECT_EQ(&group1, &channelbag->channel_group_ensure(
"Bar"));
1825 EXPECT_EQ(channelbag->channel_groups().size(), 2);
1827 bActionGroup &group2 = channelbag->channel_group_ensure(
"Yar");
1828 ASSERT_EQ(channelbag->channel_groups().size(), 3);
1829 EXPECT_EQ(&group2, channelbag->channel_group(2));
1834 FCurve &fcu0 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0});
1835 EXPECT_EQ(1, channelbag->fcurves().size());
1836 EXPECT_TRUE(channelbag->channel_groups().is_empty());
1841 channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0, {}, {},
"group0"});
1842 EXPECT_EQ(1, channelbag->fcurves().size());
1844 EXPECT_TRUE(channelbag->channel_groups().is_empty());
1849 FCurve &fcu1 = channelbag->fcurve_ensure(
nullptr, {
"fcu1", 0, {}, {},
"group0"});
1850 ASSERT_EQ(2, channelbag->fcurves().size());
1851 ASSERT_EQ(1, channelbag->channel_groups().size());
1853 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
1854 EXPECT_EQ(&fcu0, channelbag->fcurve(1));
1864 FCurve &fcu2 = channelbag->fcurve_ensure(
nullptr, {
"fcu2", 0, {}, {},
"group1"});
1865 ASSERT_EQ(3, channelbag->fcurves().size());
1866 ASSERT_EQ(2, channelbag->channel_groups().size());
1867 EXPECT_EQ(&group0, channelbag->channel_group(0));
1869 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
1870 EXPECT_EQ(&fcu2, channelbag->fcurve(1));
1871 EXPECT_EQ(&fcu0, channelbag->fcurve(2));
1882 FCurve &fcu3 = channelbag->fcurve_ensure(
nullptr, {
"fcu3", 0, {}, {},
"group0"});
1883 ASSERT_EQ(4, channelbag->fcurves().size());
1884 ASSERT_EQ(2, channelbag->channel_groups().size());
1885 EXPECT_EQ(&group0, channelbag->channel_group(0));
1886 EXPECT_EQ(&group1, channelbag->channel_group(1));
1887 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
1888 EXPECT_EQ(&fcu3, channelbag->fcurve(1));
1889 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
1890 EXPECT_EQ(&fcu0, channelbag->fcurve(3));
1902 FCurve &fcu4 = channelbag->fcurve_ensure(
nullptr, {
"fcu4", 0, {}, {},
"group1"});
1903 ASSERT_EQ(5, channelbag->fcurves().size());
1904 ASSERT_EQ(2, channelbag->channel_groups().size());
1905 EXPECT_EQ(&group0, channelbag->channel_group(0));
1906 EXPECT_EQ(&group1, channelbag->channel_group(1));
1907 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
1908 EXPECT_EQ(&fcu3, channelbag->fcurve(1));
1909 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
1910 EXPECT_EQ(&fcu4, channelbag->fcurve(3));
1911 EXPECT_EQ(&fcu0, channelbag->fcurve(4));
1925 FCurve &fcu0 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0, {}, {},
"group0"});
1926 FCurve &fcu1 = channelbag->fcurve_ensure(
nullptr, {
"fcu1", 0, {}, {},
"group0"});
1927 FCurve &fcu2 = channelbag->fcurve_ensure(
nullptr, {
"fcu2", 0, {}, {},
"group1"});
1928 FCurve &fcu3 = channelbag->fcurve_ensure(
nullptr, {
"fcu3", 0, {}, {},
"group1"});
1929 FCurve &fcu4 = channelbag->fcurve_ensure(
nullptr, {
"fcu4", 0});
1931 ASSERT_EQ(5, channelbag->fcurves().size());
1932 ASSERT_EQ(2, channelbag->channel_groups().size());
1947 channelbag->fcurve_remove(fcu3);
1948 ASSERT_EQ(4, channelbag->fcurves().size());
1949 ASSERT_EQ(2, channelbag->channel_groups().size());
1950 EXPECT_EQ(&group0, channelbag->channel_group(0));
1951 EXPECT_EQ(&group1, channelbag->channel_group(1));
1961 channelbag->fcurve_remove(fcu0);
1962 ASSERT_EQ(3, channelbag->fcurves().size());
1963 ASSERT_EQ(2, channelbag->channel_groups().size());
1964 EXPECT_EQ(&group0, channelbag->channel_group(0));
1965 EXPECT_EQ(&group1, channelbag->channel_group(1));
1974 channelbag->fcurve_remove(fcu1);
1975 ASSERT_EQ(2, channelbag->fcurves().size());
1976 ASSERT_EQ(1, channelbag->channel_groups().size());
1977 EXPECT_EQ(&group1, channelbag->channel_group(0));
1983 channelbag->fcurve_remove(fcu4);
1984 ASSERT_EQ(1, channelbag->fcurves().size());
1985 ASSERT_EQ(1, channelbag->channel_groups().size());
1986 EXPECT_EQ(&group1, channelbag->channel_group(0));
1991 channelbag->fcurve_remove(fcu2);
1992 ASSERT_EQ(0, channelbag->fcurves().size());
1993 ASSERT_EQ(0, channelbag->channel_groups().size());
1998 FCurve &fcu0 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0, {}, {},
"group0"});
1999 FCurve &fcu1 = channelbag->fcurve_ensure(
nullptr, {
"fcu1", 0, {}, {},
"group1"});
2000 FCurve &fcu2 = channelbag->fcurve_ensure(
nullptr, {
"fcu2", 0, {}, {},
"group1"});
2001 FCurve &fcu3 = channelbag->fcurve_ensure(
nullptr, {
"fcu3", 0, {}, {},
"group2"});
2002 FCurve &fcu4 = channelbag->fcurve_ensure(
nullptr, {
"fcu4", 0});
2004 ASSERT_EQ(5, channelbag->fcurves().size());
2005 ASSERT_EQ(3, channelbag->channel_groups().size());
2011 channelbag->channel_group_move_to_index(group0, 2);
2012 EXPECT_EQ(&group1, channelbag->channel_group(0));
2013 EXPECT_EQ(&group2, channelbag->channel_group(1));
2014 EXPECT_EQ(&group0, channelbag->channel_group(2));
2021 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
2022 EXPECT_EQ(&fcu2, channelbag->fcurve(1));
2023 EXPECT_EQ(&fcu3, channelbag->fcurve(2));
2024 EXPECT_EQ(&fcu0, channelbag->fcurve(3));
2025 EXPECT_EQ(&fcu4, channelbag->fcurve(4));
2032 channelbag->channel_group_move_to_index(group1, 1);
2033 EXPECT_EQ(&group2, channelbag->channel_group(0));
2034 EXPECT_EQ(&group1, channelbag->channel_group(1));
2035 EXPECT_EQ(&group0, channelbag->channel_group(2));
2042 EXPECT_EQ(&fcu3, channelbag->fcurve(0));
2043 EXPECT_EQ(&fcu1, channelbag->fcurve(1));
2044 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
2045 EXPECT_EQ(&fcu0, channelbag->fcurve(3));
2046 EXPECT_EQ(&fcu4, channelbag->fcurve(4));
2053 channelbag->channel_group_move_to_index(group0, 0);
2054 EXPECT_EQ(&group0, channelbag->channel_group(0));
2055 EXPECT_EQ(&group2, channelbag->channel_group(1));
2056 EXPECT_EQ(&group1, channelbag->channel_group(2));
2063 EXPECT_EQ(&fcu0, channelbag->fcurve(0));
2064 EXPECT_EQ(&fcu3, channelbag->fcurve(1));
2065 EXPECT_EQ(&fcu1, channelbag->fcurve(2));
2066 EXPECT_EQ(&fcu2, channelbag->fcurve(3));
2067 EXPECT_EQ(&fcu4, channelbag->fcurve(4));
2077 FCurve &fcu0 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0});
2078 FCurve &fcu1 = channelbag->fcurve_ensure(
nullptr, {
"fcu1", 0});
2079 FCurve &fcu2 = channelbag->fcurve_ensure(
nullptr, {
"fcu2", 0});
2080 bActionGroup &group0 = channelbag->channel_group_create(
"group0");
2081 bActionGroup &group1 = channelbag->channel_group_create(
"group1");
2083 ASSERT_EQ(3, channelbag->fcurves().size());
2084 EXPECT_EQ(&fcu0, channelbag->fcurve(0));
2085 EXPECT_EQ(&fcu1, channelbag->fcurve(1));
2086 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
2087 ASSERT_EQ(2, channelbag->channel_groups().size());
2088 EXPECT_EQ(&group0, channelbag->channel_group(0));
2089 EXPECT_EQ(&group1, channelbag->channel_group(1));
2095 channelbag->fcurve_assign_to_channel_group(fcu2, group1);
2096 EXPECT_EQ(&fcu2, channelbag->fcurve(0));
2097 EXPECT_EQ(&fcu0, channelbag->fcurve(1));
2098 EXPECT_EQ(&fcu1, channelbag->fcurve(2));
2104 channelbag->fcurve_assign_to_channel_group(fcu1, group0);
2105 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
2106 EXPECT_EQ(&fcu2, channelbag->fcurve(1));
2107 EXPECT_EQ(&fcu0, channelbag->fcurve(2));
2113 channelbag->fcurve_assign_to_channel_group(fcu0, group1);
2114 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
2115 EXPECT_EQ(&fcu2, channelbag->fcurve(1));
2116 EXPECT_EQ(&fcu0, channelbag->fcurve(2));
2122 channelbag->fcurve_assign_to_channel_group(fcu0, group0);
2123 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
2124 EXPECT_EQ(&fcu0, channelbag->fcurve(1));
2125 EXPECT_EQ(&fcu2, channelbag->fcurve(2));
2131 channelbag->fcurve_assign_to_channel_group(fcu1, group1);
2132 EXPECT_EQ(&fcu0, channelbag->fcurve(0));
2133 EXPECT_EQ(&fcu2, channelbag->fcurve(1));
2134 EXPECT_EQ(&fcu1, channelbag->fcurve(2));
2143 FCurve &fcu0 = channelbag->fcurve_ensure(
nullptr, {
"fcu0", 0, {}, {},
"group0"});
2144 FCurve &fcu1 = channelbag->fcurve_ensure(
nullptr, {
"fcu1", 0, {}, {},
"group0"});
2145 FCurve &fcu2 = channelbag->fcurve_ensure(
nullptr, {
"fcu2", 0, {}, {},
"group1"});
2146 FCurve &fcu3 = channelbag->fcurve_ensure(
nullptr, {
"fcu3", 0, {}, {},
"group1"});
2147 FCurve &fcu4 = channelbag->fcurve_ensure(
nullptr, {
"fcu4", 0});
2149 ASSERT_EQ(5, channelbag->fcurves().size());
2150 ASSERT_EQ(2, channelbag->channel_groups().size());
2157 EXPECT_FALSE(channelbag->fcurve_ungroup(bogus));
2160 EXPECT_TRUE(channelbag->fcurve_ungroup(fcu4));
2164 EXPECT_TRUE(channelbag->fcurve_ungroup(fcu0));
2169 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
2170 EXPECT_EQ(&fcu2, channelbag->fcurve(1));
2171 EXPECT_EQ(&fcu3, channelbag->fcurve(2));
2172 EXPECT_EQ(&fcu4, channelbag->fcurve(3));
2173 EXPECT_EQ(&fcu0, channelbag->fcurve(4));
2180 EXPECT_TRUE(channelbag->fcurve_ungroup(fcu3));
2185 EXPECT_EQ(&fcu1, channelbag->fcurve(0));
2186 EXPECT_EQ(&fcu2, channelbag->fcurve(1));
2187 EXPECT_EQ(&fcu4, channelbag->fcurve(2));
2188 EXPECT_EQ(&fcu0, channelbag->fcurve(3));
2189 EXPECT_EQ(&fcu3, channelbag->fcurve(4));
2196 EXPECT_TRUE(channelbag->fcurve_ungroup(fcu1));
2197 EXPECT_EQ(1, channelbag->channel_groups().size());
2198 EXPECT_EQ(&group1, channelbag->channel_group(0));
2201 EXPECT_EQ(&fcu2, channelbag->fcurve(0));
2202 EXPECT_EQ(&fcu4, channelbag->fcurve(1));
2203 EXPECT_EQ(&fcu0, channelbag->fcurve(2));
2204 EXPECT_EQ(&fcu3, channelbag->fcurve(3));
2205 EXPECT_EQ(&fcu1, channelbag->fcurve(4));
2212 EXPECT_TRUE(channelbag->fcurve_ungroup(fcu2));
2213 EXPECT_EQ(0, channelbag->channel_groups().size());
2214 EXPECT_EQ(&fcu4, channelbag->fcurve(0));
2215 EXPECT_EQ(&fcu0, channelbag->fcurve(1));
2216 EXPECT_EQ(&fcu3, channelbag->fcurve(2));
2217 EXPECT_EQ(&fcu1, channelbag->fcurve(3));
2218 EXPECT_EQ(&fcu2, channelbag->fcurve(4));
2271 FCurve *fcurve_to_move = fcurve_create(
"source_prop", 2);
2286 <<
"F-Curve should no longer exist in source Action";
2288 <<
"F-Curve should exist in destination Action";
2291 <<
"Source Action should still have the other F-Curve";
2293 <<
"Destination Action should have its original and the moved F-Curve";
2309 FCurve &fcurve_to_move = cbag_src.fcurve_ensure(this->bmain, {
"source_prop", 2});
2310 bActionGroup &group_src = cbag_src.channel_group_create(
"Gröpje");
2311 cbag_src.fcurve_assign_to_channel_group(fcurve_to_move, group_src);
2330 EXPECT_EQ(
nullptr, cbag_src.fcurve_find({fcurve_to_move.rna_path, fcurve_to_move.array_index}))
2331 <<
"F-Curve should no longer exist in source Action";
2333 cbag_dst.fcurve_find({fcurve_to_move.rna_path, fcurve_to_move.array_index}))
2334 <<
"F-Curve should exist in destination Action";
2336 EXPECT_EQ(1, cbag_src.fcurves().size()) <<
"Source Action should still have the other F-Curve";
2338 <<
"Destination Action should have its original and the moved F-Curve";
2340 bActionGroup *group_dst = cbag_dst.channel_group_find(
"Gröpje");
2341 ASSERT_NE(
nullptr, group_dst) <<
"Expected channel group to be created";
2342 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)
const char * BKE_id_name(const ID &id)
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
#define BLI_STATIC_ASSERT(a, msg)
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[258]