Blender  V2.93
blendfile_loading_base_test.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2019 by Blender Foundation.
17  */
18 
19 #pragma once
20 
21 #include "DEG_depsgraph.h"
22 #include "testing/testing.h"
23 
24 struct BlendFileData;
25 struct Depsgraph;
26 
27 class BlendfileLoadingBaseTest : public testing::Test {
28  protected:
29  struct BlendFileData *bfile = nullptr;
30  struct Depsgraph *depsgraph = nullptr;
31 
32  public:
33  /* Sets up Blender just enough to not crash on loading
34  * a blendfile and constructing a depsgraph. */
35  static void SetUpTestCase();
36  static void TearDownTestCase();
37 
38  protected:
39  /* Frees the depsgraph & blendfile. */
40  virtual void TearDown();
41 
42  /* Loads a blend file from the lib/tests directory from SVN.
43  * Returns 'ok' flag (true=good, false=bad) and sets this->bfile.
44  * Fails the test if the file cannot be loaded (still returns though).
45  * Requires the CLI argument --test-asset-dir to point to ../../lib/tests.
46  *
47  * WARNING: only files saved with Blender 2.80+ can be loaded. Since Blender
48  * is only partially initialized (most importantly, without window manager),
49  * the space types are not registered, so any versioning code that handles
50  * those will SEGFAULT.
51  */
52  bool blendfile_load(const char *filepath);
53  /* Free bfile if it is not nullptr. */
54  void blendfile_free();
55 
56  /* Create a depsgraph. Assumes a blend file has been loaded to this->bfile. */
57  virtual void depsgraph_create(eEvaluationMode depsgraph_evaluation_mode);
58  /* Free the depsgraph if it's not nullptr. */
59  virtual void depsgraph_free();
60 };
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
eEvaluationMode
Definition: DEG_depsgraph.h:60
virtual void depsgraph_create(eEvaluationMode depsgraph_evaluation_mode)
bool blendfile_load(const char *filepath)