diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2021-09-30 17:29:14 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2021-09-30 17:29:14 +0300 |
commit | 628fab696cfaefdd2ac758849c8a1e9a3a0beef0 (patch) | |
tree | d24db3bab2e501ef702dc87cddb732ffd61fb1a4 /source/blender/blenkernel/intern/asset_catalog_test.cc | |
parent | 5d42ea036999a7e82dbc03947968f4ad61093d06 (diff) |
Asset Catalog: introduce `AssetCatalogPath` class
So far we have used `std::string` for asset catalog paths. Some
operations are better described on a dedicated class for this, though.
This commits switches catalog paths from using `std::string` to a
dedicated `blender::bke::AssetCatalogPath` class.
The `using CatalogPath = AssetCatalogPath` alias is still there, and
will be removed in a following cleanup commit.
New `AssetCatalogPath` code reviewed by @severin in D12710.
Diffstat (limited to 'source/blender/blenkernel/intern/asset_catalog_test.cc')
-rw-r--r-- | source/blender/blenkernel/intern/asset_catalog_test.cc | 39 |
1 files changed, 11 insertions, 28 deletions
diff --git a/source/blender/blenkernel/intern/asset_catalog_test.cc b/source/blender/blenkernel/intern/asset_catalog_test.cc index 5b94f021797..cde16b97b5d 100644 --- a/source/blender/blenkernel/intern/asset_catalog_test.cc +++ b/source/blender/blenkernel/intern/asset_catalog_test.cc @@ -106,7 +106,7 @@ class AssetCatalogTest : public testing::Test { EXPECT_EQ(expected_filename, actual_item.get_name()); /* Does the computed number of parents match? */ EXPECT_EQ(expected_path.parent_count, actual_item.count_parents()); - EXPECT_EQ(expected_path.name, actual_item.catalog_path()); + EXPECT_EQ(expected_path.name, actual_item.catalog_path().str()); } /** @@ -186,21 +186,21 @@ TEST_F(AssetCatalogTest, load_single_file) AssetCatalog *poses_ellie = service.find_catalog(UUID_POSES_ELLIE); ASSERT_NE(nullptr, poses_ellie); EXPECT_EQ(UUID_POSES_ELLIE, poses_ellie->catalog_id); - EXPECT_EQ("character/Ellie/poselib", poses_ellie->path); + EXPECT_EQ("character/Ellie/poselib", poses_ellie->path.str()); EXPECT_EQ("POSES_ELLIE", poses_ellie->simple_name); /* Test white-space stripping and support in the path. */ AssetCatalog *poses_whitespace = service.find_catalog(UUID_POSES_ELLIE_WHITESPACE); ASSERT_NE(nullptr, poses_whitespace); EXPECT_EQ(UUID_POSES_ELLIE_WHITESPACE, poses_whitespace->catalog_id); - EXPECT_EQ("character/Ellie/poselib/white space", poses_whitespace->path); + EXPECT_EQ("character/Ellie/poselib/white space", poses_whitespace->path.str()); EXPECT_EQ("POSES_ELLIE WHITESPACE", poses_whitespace->simple_name); /* Test getting a UTF-8 catalog ID. */ AssetCatalog *poses_ruzena = service.find_catalog(UUID_POSES_RUZENA); ASSERT_NE(nullptr, poses_ruzena); EXPECT_EQ(UUID_POSES_RUZENA, poses_ruzena->catalog_id); - EXPECT_EQ("character/Ružena/poselib", poses_ruzena->path); + EXPECT_EQ("character/Ružena/poselib", poses_ruzena->path.str()); EXPECT_EQ("POSES_RUŽENA", poses_ruzena->simple_name); } @@ -588,7 +588,7 @@ TEST_F(AssetCatalogTest, create_first_catalog_from_scratch) AssetCatalog *written_cat = loaded_service.find_catalog(cat->catalog_id); ASSERT_NE(nullptr, written_cat); EXPECT_EQ(written_cat->catalog_id, cat->catalog_id); - EXPECT_EQ(written_cat->path, cat->path); + EXPECT_EQ(written_cat->path, cat->path.str()); } TEST_F(AssetCatalogTest, create_catalog_after_loading_file) @@ -640,7 +640,7 @@ TEST_F(AssetCatalogTest, create_catalog_path_cleanup) AssetCatalog *cat = service.create_catalog(" /some/path / "); EXPECT_FALSE(BLI_uuid_is_nil(cat->catalog_id)); - EXPECT_EQ("some/path", cat->path); + EXPECT_EQ("some/path", cat->path.str()); EXPECT_EQ("some-path", cat->simple_name); } @@ -652,7 +652,7 @@ TEST_F(AssetCatalogTest, create_catalog_simple_name) EXPECT_FALSE(BLI_uuid_is_nil(cat->catalog_id)); EXPECT_EQ("production/Spite Fright/Characters/Victora/Pose Library/Approved/Body Parts/Hands", - cat->path); + cat->path.str()); EXPECT_EQ("...ht-Characters-Victora-Pose Library-Approved-Body Parts-Hands", cat->simple_name); } @@ -733,12 +733,12 @@ TEST_F(AssetCatalogTest, update_catalog_path) EXPECT_EQ(orig_cat->catalog_id, renamed_cat->catalog_id) << "Changing the path should not change the catalog ID."; - EXPECT_EQ("charlib/Ružena", renamed_cat->path) + EXPECT_EQ("charlib/Ružena", renamed_cat->path.str()) << "Changing the path should change the path. Surprise."; - EXPECT_EQ("charlib/Ružena/hand", service.find_catalog(UUID_POSES_RUZENA_HAND)->path) + EXPECT_EQ("charlib/Ružena/hand", service.find_catalog(UUID_POSES_RUZENA_HAND)->path.str()) << "Changing the path should update children."; - EXPECT_EQ("charlib/Ružena/face", service.find_catalog(UUID_POSES_RUZENA_FACE)->path) + EXPECT_EQ("charlib/Ružena/face", service.find_catalog(UUID_POSES_RUZENA_FACE)->path.str()) << "Changing the path should update children."; } @@ -775,7 +775,7 @@ TEST_F(AssetCatalogTest, merge_catalog_files) /* When there are overlaps, the in-memory (i.e. last-saved) paths should win. */ const AssetCatalog *ruzena_face = loaded_service.find_catalog(UUID_POSES_RUZENA_FACE); - EXPECT_EQ("character/Ružena/poselib/face", ruzena_face->path); + EXPECT_EQ("character/Ružena/poselib/face", ruzena_face->path.str()); } TEST_F(AssetCatalogTest, backups) @@ -846,21 +846,4 @@ TEST_F(AssetCatalogTest, order_by_path) } } -TEST_F(AssetCatalogTest, is_contained_in) -{ - const AssetCatalog cat(BLI_uuid_generate_random(), "simple/path/child", ""); - - EXPECT_FALSE(cat.is_contained_in("unrelated")); - EXPECT_FALSE(cat.is_contained_in("sim")); - EXPECT_FALSE(cat.is_contained_in("simple/pathx")); - EXPECT_FALSE(cat.is_contained_in("simple/path/c")); - EXPECT_FALSE(cat.is_contained_in("simple/path/child/grandchild")); - EXPECT_FALSE(cat.is_contained_in("simple/path/")) - << "Non-normalized paths are not expected to work."; - - EXPECT_TRUE(cat.is_contained_in("")); - EXPECT_TRUE(cat.is_contained_in("simple")); - EXPECT_TRUE(cat.is_contained_in("simple/path")); -} - } // namespace blender::bke::tests |