Blender V5.3
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 "BKE_gtest_base.hh"
13
14#include "BLI_listbase.hh"
15
16#include "testing/testing.h"
17
19
21
23{
24 /* This unit test doesn't put valid data in the action under test. Since action_is_layered()
25 * only looks at the length of lists, and not their contents, that should be fine. */
26
27 { /* Animato Action only fcurves / Blender version [2.5, 4.4) */
28 bAction action = {};
29 Link /* FCurve */ fake_fcurve = {};
30
31 BLI_addtail(&action.curves, &fake_fcurve);
33 << "Animato Actions should NOT be considered 'layered'";
34 }
35
36 { /* Animato Action with fcurves + groups / Blender version [2.5, 4.4) */
37 bAction action = {};
38 Link /* FCurve */ fake_fcurve = {};
39 Link /* bActionGroup */ fake_group = {};
40
41 BLI_addtail(&action.curves, &fake_fcurve);
42 BLI_addtail(&action.groups, &fake_group);
44 << "Animato Actions should NOT be considered 'layered'";
45 }
46
47 { /* Animato Action with only groups / Blender version [2.5, 4.4) */
48 bAction action = {};
49 Link /* bActionGroup */ fake_group = {};
50
51 BLI_addtail(&action.groups, &fake_group);
53 << "Animato Actions should NOT be considered 'layered'";
54 }
55
56 { /* Layered Action with only layers / Blender version 4.4 and newer. */
57 bAction action = {};
58 action.layer_array_num = 1;
59
60 EXPECT_TRUE(action_is_layered(action)) << "Layered Actions should be considered 'layered'";
61 }
62
63 { /* Layered Action with only slots / Blender version 4.4 and newer. */
64 bAction action = {};
65 action.slot_array_num = 1;
66
67 EXPECT_TRUE(action_is_layered(action)) << "Layered Actions should be considered 'layered'";
68 }
69
70 { /* Layered Action as it exists on disk, with forward-compatible info in there. */
71 bAction action = {};
72 Link /* FCurve */ fake_fcurve = {};
73 action.layer_array_num = 1;
74
75 BLI_addtail(&action.curves, &fake_fcurve);
77 << "Layered Actions with forward-compat data should be considered 'layered'";
78 }
79
80 { /* Completely zeroed out Action. */
81 bAction action = {};
82 EXPECT_TRUE(action_is_layered(action)) << "Zero'ed-out Actions should be considered 'layered'";
83 }
84}
85
86} // namespace blender::animrig::versioning::tests
Versioning of old animation data. Most animation versioning code lives in the versioning_xxx....
#define EXPECT_FALSE(result)
#define EXPECT_TRUE(result)
TEST_F(AnimrigVersioninTest, action_is_layered)
bool action_is_layered(const bAction &dna_action)
Definition versioning.cc:38
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
ListBaseT< FCurve > curves
ListBaseT< bActionGroup > groups