2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
* Copyright 2019 Blender Foundation. */
|
2021-01-04 13:10:22 +11:00
|
|
|
|
|
|
|
|
#pragma once
|
2019-11-28 17:37:27 +01:00
|
|
|
|
|
|
|
|
#include "DEG_depsgraph.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "testing/testing.h"
|
2019-11-28 17:37:27 +01:00
|
|
|
|
|
|
|
|
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
|
2020-08-01 13:18:47 +10:00
|
|
|
* is only partially initialized (most importantly, without window manager),
|
2019-11-28 17:37:27 +01:00
|
|
|
* 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. */
|
2020-08-17 16:55:31 +02:00
|
|
|
virtual void depsgraph_create(eEvaluationMode depsgraph_evaluation_mode);
|
2019-11-28 17:37:27 +01:00
|
|
|
/* Free the depsgraph if it's not nullptr. */
|
2020-08-17 16:55:31 +02:00
|
|
|
virtual void depsgraph_free();
|
2019-11-28 17:37:27 +01:00
|
|
|
};
|