/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ #include #include #include namespace EMotionFX { struct RegisterHandler : AzToolsFramework::PropertyTypeRegistrationMessages::Bus::Handler { RegisterHandler() { BusConnect(); } ~RegisterHandler() { BusDisconnect(); for(auto* handler : m_handlers) { delete handler; } } void RegisterPropertyType(AzToolsFramework::PropertyHandlerBase* pHandler) override { m_handlers.insert(pHandler); } void UnregisterPropertyType(AzToolsFramework::PropertyHandlerBase* pHandler) override { m_handlers.erase(pHandler); } AzToolsFramework::PropertyHandlerBase* ResolvePropertyHandler(AZ::u32 handlerName, const AZ::Uuid& handlerType) override { return {}; } AZStd::unordered_set m_handlers{}; }; struct MotionSetFixture : SystemComponentFixtureWithCatalog { RegisterHandler m_registerHandler; void TearDown() override { SystemComponentFixtureWithCatalog::TearDown(); m_app.Stop(); } }; struct MockAssetSystemRequests : AzFramework::AssetSystemRequestBus::Handler { MockAssetSystemRequests() { BusConnect(); } ~MockAssetSystemRequests() { BusDisconnect(); } AzFramework::AssetSystem::AssetStatus CompileAssetSync(const AZStd::string& assetPath) override { ++m_compileSyncCount; return AzFramework::AssetSystem::AssetStatus_Queued; } bool EscalateAssetBySearchTerm(AZStd::string_view searchTerm) override { ++m_escalateCount; return true; } MOCK_METHOD1(EscalateAssetByUuid, bool (const AZ::Uuid&)); MOCK_METHOD1(CompileAssetSync_FlushIO, AzFramework::AssetSystem::AssetStatus (const AZStd::string&)); MOCK_METHOD1(CompileAssetSyncById, AzFramework::AssetSystem::AssetStatus (const AZ::Data::AssetId&)); MOCK_METHOD1(CompileAssetSyncById_FlushIO, AzFramework::AssetSystem::AssetStatus (const AZ::Data::AssetId&)); MOCK_METHOD4(ConfigureSocketConnection, bool (const AZStd::string&, const AZStd::string&, const AZStd::string&, const AZStd::string&)); MOCK_METHOD1(Connect, bool (const char*)); MOCK_METHOD2(ConnectWithTimeout, bool (const char*, AZStd::chrono::duration)); MOCK_METHOD0(Disconnect, bool ()); MOCK_METHOD0(GetAssetProcessorPingTimeMilliseconds, float ()); MOCK_METHOD1(GetAssetStatus, AzFramework::AssetSystem::AssetStatus (const AZStd::string&)); MOCK_METHOD1(GetAssetStatus_FlushIO, AzFramework::AssetSystem::AssetStatus (const AZStd::string&)); MOCK_METHOD1(GetAssetStatusById, AzFramework::AssetSystem::AssetStatus (const AZ::Data::AssetId&)); MOCK_METHOD1(GetAssetStatusById_FlushIO, AzFramework::AssetSystem::AssetStatus (const AZ::Data::AssetId&)); MOCK_METHOD3(GetUnresolvedProductReferences, void (AZ::Data::AssetId, AZ::u32&, AZ::u32&)); MOCK_METHOD0(SaveCatalog, bool ()); MOCK_METHOD1(SetAssetProcessorIP, void (const AZStd::string&)); MOCK_METHOD1(SetAssetProcessorPort, void (AZ::u16)); MOCK_METHOD1(SetBranchToken, void (const AZStd::string&)); MOCK_METHOD1(SetProjectName, void (const AZStd::string&)); MOCK_METHOD0(ShowAssetProcessor, void ()); MOCK_METHOD1(ShowInAssetProcessor, void (const AZStd::string&)); int m_compileSyncCount = 0; int m_escalateCount = 0; }; TEST_F(MotionSetFixture, MeshLoadTest) { const AZStd::string fileName = "@assets@/Gems/EMotionFX/Code/Tests/TestAssets/EMotionFXBuilderTestAssets/MotionSetExample.motionset"; MockAssetSystemRequests assetSystem; auto* handler = static_cast(AZ::Data::AssetManager::Instance().GetHandler(azrtti_typeid())); AZ::Data::AssetPtr assetPointer = handler->CreateAsset(AZ::Data::AssetId(AZ::Uuid::CreateRandom(), 0), AZ::Data::AssetType::CreateRandom()); AZ::Data::Asset asset = assetPointer; handler->LoadAssetData(asset, fileName.c_str(), &AZ::Data::AssetFilterNoAssetLoading); handler->OnInitAsset(asset); ASSERT_EQ(assetSystem.m_escalateCount, 2); ASSERT_EQ(assetSystem.m_compileSyncCount, 2); } } // end namespace EMotionFX