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-21 16:06:49 +0300
committerSybren A. Stüvel <sybren@blender.org>2021-10-21 16:53:16 +0300
commit9a1fce698bc6dd51c66464f9dcccfb89d0432823 (patch)
treebaf16b2137a3f36a4f1ded27de26c507b11bfb02 /source/blender/blenkernel/intern/asset_catalog_test.cc
parent090be2775e3d7c0dc3f7956b05c7fb9a72c4bdfc (diff)
Cleanup: rename & restructure `AssetCatalogPathCmp`
Rename `AssetCatalogPathCmp` to `AssetCatalogLessThan`: - it compares more than paths (so no more `Path` in the name), and - performs a less-than operation (so no more `Cmp` in the name). Also restructure its code to make an extra upcoming comparison easier to add. No functional changes.
Diffstat (limited to 'source/blender/blenkernel/intern/asset_catalog_test.cc')
-rw-r--r--source/blender/blenkernel/intern/asset_catalog_test.cc44
1 files changed, 44 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/asset_catalog_test.cc b/source/blender/blenkernel/intern/asset_catalog_test.cc
index d743d250c1d..478d2d2b31e 100644
--- a/source/blender/blenkernel/intern/asset_catalog_test.cc
+++ b/source/blender/blenkernel/intern/asset_catalog_test.cc
@@ -954,6 +954,50 @@ TEST_F(AssetCatalogTest, order_by_path)
}
}
+TEST_F(AssetCatalogTest, order_by_path_and_first_seen)
+{
+ AssetCatalogService service;
+ service.load_from_disk(asset_library_root_);
+
+ const bUUID first_seen_uuid("3d451c87-27d1-40fd-87fc-f4c9e829c848");
+ const bUUID first_sorted_uuid("00000000-0000-0000-0000-000000000001");
+ const bUUID last_sorted_uuid("ffffffff-ffff-ffff-ffff-ffffffffffff");
+
+ AssetCatalog first_seen_cat(first_seen_uuid, "simple/path/child", "");
+ const AssetCatalog first_sorted_cat(first_sorted_uuid, "simple/path/child", "");
+ const AssetCatalog last_sorted_cat(last_sorted_uuid, "simple/path/child", "");
+
+ /* Mimick that this catalog was first-seen when loading from disk. */
+ first_seen_cat.flags.is_first_loaded = true;
+
+ /* Just an assertion of the defaults; this is more to avoid confusing errors later on than an
+ * actual test of these defaults. */
+ ASSERT_FALSE(first_sorted_cat.flags.is_first_loaded);
+ ASSERT_FALSE(last_sorted_cat.flags.is_first_loaded);
+
+ AssetCatalogOrderedSet by_path;
+ by_path.insert(&first_seen_cat);
+ by_path.insert(&first_sorted_cat);
+ by_path.insert(&last_sorted_cat);
+
+ AssetCatalogOrderedSet::const_iterator set_iter = by_path.begin();
+
+ EXPECT_EQ(1, by_path.count(&first_seen_cat));
+ EXPECT_EQ(1, by_path.count(&first_sorted_cat));
+ EXPECT_EQ(1, by_path.count(&last_sorted_cat));
+ ASSERT_EQ(3, by_path.size());
+
+ EXPECT_EQ(first_seen_uuid, (*(set_iter++))->catalog_id);
+ EXPECT_EQ(first_sorted_uuid, (*(set_iter++))->catalog_id);
+ EXPECT_EQ(last_sorted_uuid, (*(set_iter++))->catalog_id);
+
+ if (set_iter != by_path.end()) {
+ const AssetCatalog *next_cat = *set_iter;
+ FAIL() << "Did not expect more items in the set, had at least " << next_cat->catalog_id << ":"
+ << next_cat->path;
+ }
+}
+
TEST_F(AssetCatalogTest, create_missing_catalogs)
{
TestableAssetCatalogService new_service;