Blender  V3.3
usd_stage_creation_test.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2019 Blender Foundation. All rights reserved. */
3 #include "testing/testing.h"
4 
5 #include "usd_tests_common.h"
6 
7 #include <pxr/base/plug/registry.h>
8 #include <pxr/usd/usd/stage.h>
9 
10 #include <string>
11 
12 #include "BLI_path_util.h"
13 #include "BLI_utildefines.h"
14 
15 #include "BKE_appdir.h"
16 
17 namespace blender::io::usd {
18 
19 class USDStageCreationTest : public testing::Test {
20 };
21 
22 TEST_F(USDStageCreationTest, JSONFileLoadingTest)
23 {
24  std::string usd_datafiles_dir = register_usd_plugins_for_tests();
25  if (usd_datafiles_dir.empty()) {
26  FAIL();
27  return;
28  }
29 
30  /* Simply the ability to create a USD Stage for a specific filename means that the extension
31  * has been recognized by the USD library, and that a USD plugin has been loaded to write such
32  * files. Practically, this is a test to see whether the USD JSON files can be found and
33  * loaded. */
34  std::string filename = "usd-stage-creation-test.usdc";
35  pxr::UsdStageRefPtr usd_stage = pxr::UsdStage::CreateNew(filename);
36  if (usd_stage != nullptr) {
37  /* Even though we don't call `usd_stage->SaveFile()`, a file is still created on the
38  * file-system when we call CreateNew(). It's immediately closed, though,
39  * so we can safely call `unlink()` here. */
40  unlink(filename.c_str());
41  }
42  else {
43  FAIL() << "unable to find suitable USD plugin to write " << filename << "; looked in "
44  << usd_datafiles_dir;
45  }
46 }
47 
48 } // namespace blender::io::usd
TEST_F(USDImagingTest, CapsuleAdapterTest)
std::string register_usd_plugins_for_tests()