AssetRegistry.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <AzCore/UnitTest/TestTypes.h>
  9. #include <AzFramework/Asset/AssetRegistry.h>
  10. namespace UnitTest
  11. {
  12. using AssetRegistry = LeakDetectionFixture;
  13. TEST_F(AssetRegistry, LegacyIdMappingTest)
  14. {
  15. using namespace ::testing;
  16. AzFramework::AssetRegistry registry;
  17. AZ::Data::AssetId realId("{914F8E72-5EBB-461E-A029-90B07DD7D0E4}", 1);
  18. AZ::Data::AssetId legacyId1("{C94A4B65-5F1E-48C6-9704-42BB6CF61E11}", 2);
  19. AZ::Data::AssetId legacyId2("{9CF3C5F2-62AF-4B87-A26E-F8714AB91D38}", 3);
  20. AZ::Data::AssetId realId2("{8735EA11-CB48-41D5-8D63-2A5AFB269952}", 4);
  21. AZ::Data::AssetId legacyId3("{153CC980-91FC-4766-92CE-67222DF91F3C}", 5);
  22. registry.RegisterLegacyAssetMapping(legacyId1, realId);
  23. registry.RegisterLegacyAssetMapping(legacyId2, realId);
  24. registry.RegisterLegacyAssetMapping(legacyId3, realId2);
  25. auto fullSet = registry.GetLegacyMappingSubsetFromRealIds({ realId, realId2 });
  26. EXPECT_THAT(fullSet, ::testing::UnorderedElementsAre(Pair(legacyId1, realId), Pair(legacyId2, realId), Pair(legacyId3, realId2)));
  27. auto id1Set = registry.GetLegacyMappingSubsetFromRealIds({ realId });
  28. EXPECT_THAT(id1Set, ::testing::UnorderedElementsAre(Pair(legacyId1, realId), Pair(legacyId2, realId)));
  29. auto id2Set = registry.GetLegacyMappingSubsetFromRealIds({ realId2 });
  30. EXPECT_THAT(id2Set, ::testing::UnorderedElementsAre(Pair(legacyId3, realId2)));
  31. registry.UnregisterLegacyAssetMappingsForAsset(realId);
  32. id1Set = registry.GetLegacyMappingSubsetFromRealIds({ realId });
  33. EXPECT_THAT(id1Set, ::testing::UnorderedElementsAre());
  34. registry.UnregisterLegacyAssetMappingsForAsset(realId2);
  35. id2Set = registry.GetLegacyMappingSubsetFromRealIds({ realId2 });
  36. EXPECT_THAT(id2Set, ::testing::UnorderedElementsAre());
  37. }
  38. }