diff --git a/Gems/Prefab/PrefabBuilder/PrefabGroup/PrefabBehaviorTests.cpp b/Gems/Prefab/PrefabBuilder/PrefabGroup/PrefabBehaviorTests.cpp index 631c6a1596..7187bdf081 100644 --- a/Gems/Prefab/PrefabBuilder/PrefabGroup/PrefabBehaviorTests.cpp +++ b/Gems/Prefab/PrefabBuilder/PrefabGroup/PrefabBehaviorTests.cpp @@ -138,14 +138,17 @@ namespace UnitTest return true; } - AZStd::shared_ptr CreateMockScene() + AZStd::shared_ptr CreateMockScene( + const AZStd::string manifestFilename = "ManifestFilename", + const AZStd::string sourceFileName = "Source", + const AZStd::string watchFolder = "WatchFolder") { using namespace AZ::SceneAPI; auto scene = AZStd::make_shared("mock_scene"); - scene->SetManifestFilename("ManifestFilename"); - scene->SetSource("Source", AZ::Uuid::CreateRandom()); - scene->SetWatchFolder("WatchFolder"); + scene->SetManifestFilename(manifestFilename); + scene->SetSource(sourceFileName, AZ::Uuid::CreateRandom()); + scene->SetWatchFolder(watchFolder); /*---------------------------------------\ Root @@ -319,18 +322,35 @@ namespace UnitTest using namespace AZ::SceneAPI; using namespace AZ::SceneAPI::Events; - auto scene = CreateMockScene(); + #if AZ_TRAIT_OS_USE_WINDOWS_FILE_PATHS + auto scene = CreateMockScene("Manifest", "C:/o3de/watch.folder/manifest_src_file.xml", "C:/o3de/watch.folder"); + #else + auto scene = CreateMockScene("Manifest", "//o3de/watch.folder/manifest_src_file.xml", "//o3de/watch.folder"); + #endif AssetImportRequest::ManifestAction action = AssetImportRequest::ManifestAction::ConstructDefault; AssetImportRequest::RequestingApplication requester = {}; Behaviors::PrefabGroupBehavior prefabGroupBehavior; ProcessingResult result = ProcessingResult::Failure; AssetImportRequestBus::BroadcastResult(result, &AssetImportRequestBus::Events::UpdateManifest, *scene, action, requester); + EXPECT_EQ(result, ProcessingResult::Success); EXPECT_EQ(scene->GetManifest().GetEntryCount(), 3); + EXPECT_TRUE(azrtti_istypeof(scene->GetManifest().GetValue(0).get())); EXPECT_TRUE(azrtti_istypeof(scene->GetManifest().GetValue(1).get())); EXPECT_TRUE(azrtti_istypeof(scene->GetManifest().GetValue(2).get())); + + // The mesh group names are expected to be just the file name relative to the watch folder and not any absolute path + for (size_t i = 0; i < scene->GetManifest().GetEntryCount(); i++) + { + if (azrtti_istypeof(scene->GetManifest().GetValue(i).get())) + { + AZ::SceneAPI::DataTypes::IMeshGroup* meshGroup = reinterpret_cast(scene->GetManifest().GetValue(i).get()); + AZStd::string groupName = meshGroup->GetName(); + EXPECT_TRUE(groupName.starts_with("manifest_src_file_xml")); + } + } } TEST_F(PrefabBehaviorTests, PrefabBehavior_UpdateManifest_ToggleWorks) diff --git a/Gems/Prefab/PrefabBuilder/PrefabGroup/PrefabGroupBehavior.cpp b/Gems/Prefab/PrefabBuilder/PrefabGroup/PrefabGroupBehavior.cpp index 292d7a2822..6bd8f0d049 100644 --- a/Gems/Prefab/PrefabBuilder/PrefabGroup/PrefabGroupBehavior.cpp +++ b/Gems/Prefab/PrefabBuilder/PrefabGroup/PrefabGroupBehavior.cpp @@ -400,10 +400,10 @@ namespace AZ::SceneAPI::Behaviors // compute the filenames of the scene file AZStd::string relativeSourcePath = scene.GetSourceFilename(); - AZ::StringFunc::Replace(relativeSourcePath, ".", "_"); // the watch folder and forward slash is used to in the asset hint path of the file AZStd::string watchFolder = scene.GetWatchFolder() + "/"; AZ::StringFunc::Replace(relativeSourcePath, watchFolder.c_str(), ""); + AZ::StringFunc::Replace(relativeSourcePath, ".", "_"); AZStd::string filenameOnly{ relativeSourcePath }; AZ::StringFunc::Path::GetFileName(filenameOnly.c_str(), filenameOnly); AZ::StringFunc::Path::ReplaceExtension(filenameOnly, "prefab");