Welcome to mirror list, hosted at ThFree Co, Russian Federation.

blendfile_loading_base_test.h « tests « blenloader « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 86fa51fdfccfbe08f90169cfc82024642a215d71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* SPDX-License-Identifier: GPL-2.0-or-later
 * Copyright 2019 Blender Foundation. */

#pragma once

#include "DEG_depsgraph.h"
#include "testing/testing.h"

struct BlendFileData;
struct Depsgraph;

class BlendfileLoadingBaseTest : public testing::Test {
 protected:
  struct BlendFileData *bfile = nullptr;
  struct Depsgraph *depsgraph = nullptr;

 public:
  /* Sets up Blender just enough to not crash on loading
   * a blendfile and constructing a depsgraph. */
  static void SetUpTestCase();
  static void TearDownTestCase();

 protected:
  /* Frees the depsgraph & blendfile. */
  virtual void TearDown();

  /* Loads a blend file from the lib/tests directory from SVN.
   * Returns 'ok' flag (true=good, false=bad) and sets this->bfile.
   * Fails the test if the file cannot be loaded (still returns though).
   * Requires the CLI argument --test-asset-dir to point to ../../lib/tests.
   *
   * WARNING: only files saved with Blender 2.80+ can be loaded. Since Blender
   * is only partially initialized (most importantly, without window manager),
   * the space types are not registered, so any versioning code that handles
   * those will SEGFAULT.
   */
  bool blendfile_load(const char *filepath);
  /* Free bfile if it is not nullptr. */
  void blendfile_free();

  /* Create a depsgraph. Assumes a blend file has been loaded to this->bfile. */
  virtual void depsgraph_create(eEvaluationMode depsgraph_evaluation_mode);
  /* Free the depsgraph if it's not nullptr. */
  virtual void depsgraph_free();
};