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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2021-10-01 11:58:16 +0300
committerSybren A. Stüvel <sybren@blender.org>2021-10-01 11:58:16 +0300
commit2e6c6426d3662302e7a9832d59f4d3bf20bf1ef2 (patch)
tree784c39eaf7acc630038f4dc84f065c8c96c16d98 /source/blender/blenkernel/intern/asset_catalog_test.cc
parentbdb7d262aadb2685f0cb7ef73840e479252e70d4 (diff)
Asset Catalogs: test that missing catalogs are created once
Add asset catalogs test, to ensure missing catalogs are only created once, and not for every originally defined catalog. No functional changes to Blender (the code was already doing the right thing).
Diffstat (limited to 'source/blender/blenkernel/intern/asset_catalog_test.cc')
-rw-r--r--source/blender/blenkernel/intern/asset_catalog_test.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/asset_catalog_test.cc b/source/blender/blenkernel/intern/asset_catalog_test.cc
index 836b681c950..f3e1f7984a4 100644
--- a/source/blender/blenkernel/intern/asset_catalog_test.cc
+++ b/source/blender/blenkernel/intern/asset_catalog_test.cc
@@ -62,6 +62,17 @@ class TestableAssetCatalogService : public AssetCatalogService {
{
AssetCatalogService::create_missing_catalogs();
}
+
+ int64_t count_catalogs_with_path(const CatalogFilePath &path)
+ {
+ int64_t count = 0;
+ for (auto &catalog_uptr : catalogs_.values()) {
+ if (catalog_uptr->path == path) {
+ count++;
+ }
+ }
+ return count;
+ }
};
class AssetCatalogTest : public testing::Test {
@@ -887,6 +898,12 @@ TEST_F(AssetCatalogTest, create_missing_catalogs_after_loading)
EXPECT_TRUE(cdf->contains(cat_ellie->catalog_id)) << "Missing parents should be saved to a CDF.";
EXPECT_TRUE(cdf->contains(cat_ruzena->catalog_id))
<< "Missing parents should be saved to a CDF.";
+
+ /* Check that each missing parent is only created once. The CDF contains multiple paths that
+ * could trigger the creation of missing parents, so this test makes sense. */
+ EXPECT_EQ(1, loaded_service.count_catalogs_with_path("character"));
+ EXPECT_EQ(1, loaded_service.count_catalogs_with_path("character/Ellie"));
+ EXPECT_EQ(1, loaded_service.count_catalogs_with_path("character/Ružena"));
}
} // namespace blender::bke::tests