Blender V4.5
versioning_test.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5/* The tests in this file need to be able to test deprecated data as well. */
6#define DNA_DEPRECATED_ALLOW
7
8#include "ANIM_versioning.hh"
9
10#include "DNA_action_types.h"
11
12#include "BLI_listbase.h"
13
14#include "testing/testing.h"
15
17
18TEST(animrig_versioning, action_is_layered)
19{
20 /* This unit test doesn't put valid data in the action under test. Since action_is_layered()
21 * only looks at the length of lists, and not their contents, that should be fine. */
22
23 { /* Pre-Animato Action / Blender version 2.49 and older. */
24 bAction action = {};
25 Link /* Ipo */ fake_ipo = {};
26
27 BLI_addtail(&action.chanbase, &fake_ipo);
28 EXPECT_FALSE(action_is_layered(action))
29 << "Pre-2.5 Actions should NOT be considered 'layered'";
30 }
31
32 { /* Animato Action only fcurves / Blender version [2.5, 4.4) */
33 bAction action = {};
34 Link /* FCurve */ fake_fcurve = {};
35
36 BLI_addtail(&action.curves, &fake_fcurve);
37 EXPECT_FALSE(action_is_layered(action))
38 << "Animato Actions should NOT be considered 'layered'";
39 }
40
41 { /* Animato Action with fcurves + groups / Blender version [2.5, 4.4) */
42 bAction action = {};
43 Link /* FCurve */ fake_fcurve = {};
44 Link /* bActionGroup */ fake_group = {};
45
46 BLI_addtail(&action.curves, &fake_fcurve);
47 BLI_addtail(&action.groups, &fake_group);
48 EXPECT_FALSE(action_is_layered(action))
49 << "Animato Actions should NOT be considered 'layered'";
50 }
51
52 { /* Animato Action with only groups / Blender version [2.5, 4.4) */
53 bAction action = {};
54 Link /* bActionGroup */ fake_group = {};
55
56 BLI_addtail(&action.groups, &fake_group);
57 EXPECT_FALSE(action_is_layered(action))
58 << "Animato Actions should NOT be considered 'layered'";
59 }
60
61 { /* Layered Action with only layers / Blender version 4.4 and newer. */
62 bAction action = {};
63 action.layer_array_num = 1;
64
65 EXPECT_TRUE(action_is_layered(action)) << "Layered Actions should be considered 'layered'";
66 }
67
68 { /* Layered Action with only slots / Blender version 4.4 and newer. */
69 bAction action = {};
70 action.slot_array_num = 1;
71
72 EXPECT_TRUE(action_is_layered(action)) << "Layered Actions should be considered 'layered'";
73 }
74
75 { /* Layered Action as it exists on disk, with forward-compatible info in there. */
76 bAction action = {};
77 Link /* FCurve */ fake_fcurve = {};
78 action.layer_array_num = 1;
79
80 BLI_addtail(&action.curves, &fake_fcurve);
81 EXPECT_TRUE(action_is_layered(action))
82 << "Layered Actions with forward-compat data should be considered 'layered'";
83 }
84
85 { /* Completely zeroed out Action. */
86 bAction action = {};
87 EXPECT_TRUE(action_is_layered(action)) << "Zero'ed-out Actions should be considered 'layered'";
88 }
89}
90
91} // namespace blender::animrig::versioning::tests
Versioning of old animation data. Most animation versioning code lives in the versioning_xxx....
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:111
TEST(animrig_versioning, action_is_layered)
bool action_is_layered(const bAction &dna_action)
Definition versioning.cc:37
ListBase curves
ListBase groups