Asset Catalogs: add test for proper shortening of simple names
Catalog simple names are supposed to fit into the DNA field `char AssetMetaData::catalog_simple_name[64]`, and thus should be shortened appropriately. This was already happening, but is now also covered by a test. No functional changes.
This commit is contained in:
@@ -429,7 +429,9 @@ class AssetCatalog {
|
||||
* Simple, human-readable name for the asset catalog. This is stored on assets alongside the
|
||||
* catalog ID; the catalog ID is a UUID that is not human-readable,
|
||||
* so to avoid complete data-loss when the catalog definition file gets lost,
|
||||
* we also store a human-readable simple name for the catalog. */
|
||||
* we also store a human-readable simple name for the catalog.
|
||||
*
|
||||
* It should fit in sizeof(AssetMetaData::catalog_simple_name) bytes. */
|
||||
std::string simple_name;
|
||||
|
||||
struct Flags {
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include "BLI_fileops.h"
|
||||
#include "BLI_path_util.h"
|
||||
|
||||
#include "DNA_asset_types.h"
|
||||
#include "DNA_userdef_types.h"
|
||||
|
||||
#include "testing/testing.h"
|
||||
@@ -930,6 +931,28 @@ TEST_F(AssetCatalogTest, update_catalog_path_simple_name)
|
||||
<< "Changing the path should update the simplename of children.";
|
||||
}
|
||||
|
||||
TEST_F(AssetCatalogTest, update_catalog_path_longer_than_simplename)
|
||||
{
|
||||
AssetCatalogService service(asset_library_root_);
|
||||
service.load_from_disk(asset_library_root_ + "/" +
|
||||
AssetCatalogService::DEFAULT_CATALOG_FILENAME);
|
||||
const std::string new_path =
|
||||
"this/is/a/very/long/path/that/exceeds/the/simple-name/length/of/assets";
|
||||
ASSERT_GT(new_path.length(), sizeof(AssetMetaData::catalog_simple_name))
|
||||
<< "This test case should work with paths longer than AssetMetaData::catalog_simple_name";
|
||||
|
||||
service.update_catalog_path(UUID_POSES_RUZENA, new_path);
|
||||
|
||||
const std::string new_simple_name = service.find_catalog(UUID_POSES_RUZENA)->simple_name;
|
||||
EXPECT_LT(new_simple_name.length(), sizeof(AssetMetaData::catalog_simple_name))
|
||||
<< "The new simple name should fit in the asset metadata.";
|
||||
EXPECT_EQ("...very-long-path-that-exceeds-the-simple-name-length-of-assets", new_simple_name)
|
||||
<< "Changing the path should update the simplename.";
|
||||
EXPECT_EQ("...long-path-that-exceeds-the-simple-name-length-of-assets-face",
|
||||
service.find_catalog(UUID_POSES_RUZENA_FACE)->simple_name)
|
||||
<< "Changing the path should update the simplename of children.";
|
||||
}
|
||||
|
||||
TEST_F(AssetCatalogTest, update_catalog_path_add_slashes)
|
||||
{
|
||||
AssetCatalogService service(asset_library_root_);
|
||||
|
Reference in New Issue
Block a user