Blender  V3.3
blendfile_loading_base_test.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2019 Blender Foundation. */
3 
4 #pragma once
5 
6 #include "DEG_depsgraph.h"
7 #include "testing/testing.h"
8 
9 struct BlendFileData;
10 struct Depsgraph;
11 
12 class BlendfileLoadingBaseTest : public testing::Test {
13  protected:
14  struct BlendFileData *bfile = nullptr;
15  struct Depsgraph *depsgraph = nullptr;
16 
17  public:
18  /* Sets up Blender just enough to not crash on loading
19  * a blendfile and constructing a depsgraph. */
20  static void SetUpTestCase();
21  static void TearDownTestCase();
22 
23  protected:
24  /* Frees the depsgraph & blendfile. */
25  virtual void TearDown();
26 
27  /* Loads a blend file from the tests/data directory from SVN.
28  * Returns 'ok' flag (true=good, false=bad) and sets this->bfile.
29  * Fails the test if the file cannot be loaded (still returns though).
30  * Requires the CLI argument --test-asset-dir to point to ../tests/data.
31  *
32  * WARNING: only files saved with Blender 2.80+ can be loaded. Since Blender
33  * is only partially initialized (most importantly, without window manager),
34  * the space types are not registered, so any versioning code that handles
35  * those will SEGFAULT.
36  */
37  bool blendfile_load(const char *filepath);
38  /* Free bfile if it is not nullptr. */
39  void blendfile_free();
40 
41  /* Create a depsgraph. Assumes a blend file has been loaded to this->bfile. */
42  virtual void depsgraph_create(eEvaluationMode depsgraph_evaluation_mode);
43  /* Free the depsgraph if it's not nullptr. */
44  virtual void depsgraph_free();
45 };
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
eEvaluationMode
Definition: DEG_depsgraph.h:44
virtual void depsgraph_create(eEvaluationMode depsgraph_evaluation_mode)
bool blendfile_load(const char *filepath)