Blender V5.0
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 { /* Animato Action only fcurves / Blender version [2.5, 4.4) */
24 bAction action = {};
25 Link /* FCurve */ fake_fcurve = {};
26
27 BLI_addtail(&action.curves, &fake_fcurve);
28 EXPECT_FALSE(action_is_layered(action))
29 << "Animato Actions should NOT be considered 'layered'";
30 }
31
32 { /* Animato Action with fcurves + groups / Blender version [2.5, 4.4) */
33 bAction action = {};
34 Link /* FCurve */ fake_fcurve = {};
35 Link /* bActionGroup */ fake_group = {};
36
37 BLI_addtail(&action.curves, &fake_fcurve);
38 BLI_addtail(&action.groups, &fake_group);
39 EXPECT_FALSE(action_is_layered(action))
40 << "Animato Actions should NOT be considered 'layered'";
41 }
42
43 { /* Animato Action with only groups / Blender version [2.5, 4.4) */
44 bAction action = {};
45 Link /* bActionGroup */ fake_group = {};
46
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 { /* Layered Action with only layers / Blender version 4.4 and newer. */
53 bAction action = {};
54 action.layer_array_num = 1;
55
56 EXPECT_TRUE(action_is_layered(action)) << "Layered Actions should be considered 'layered'";
57 }
58
59 { /* Layered Action with only slots / Blender version 4.4 and newer. */
60 bAction action = {};
61 action.slot_array_num = 1;
62
63 EXPECT_TRUE(action_is_layered(action)) << "Layered Actions should be considered 'layered'";
64 }
65
66 { /* Layered Action as it exists on disk, with forward-compatible info in there. */
67 bAction action = {};
68 Link /* FCurve */ fake_fcurve = {};
69 action.layer_array_num = 1;
70
71 BLI_addtail(&action.curves, &fake_fcurve);
72 EXPECT_TRUE(action_is_layered(action))
73 << "Layered Actions with forward-compat data should be considered 'layered'";
74 }
75
76 { /* Completely zeroed out Action. */
77 bAction action = {};
78 EXPECT_TRUE(action_is_layered(action)) << "Zero'ed-out Actions should be considered 'layered'";
79 }
80}
81
82} // 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:38
ListBase curves
ListBase groups