/* * 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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace EMotionFX { class ActorComponentNotificationTestBus : Integration::ActorComponentNotificationBus::Handler { public: ActorComponentNotificationTestBus(AZ::EntityId entityId) { Integration::ActorComponentNotificationBus::Handler::BusConnect(entityId); } ~ActorComponentNotificationTestBus() { Integration::ActorComponentNotificationBus::Handler::BusDisconnect(); } MOCK_METHOD1(OnActorInstanceCreated, void(EMotionFX::ActorInstance*)); MOCK_METHOD1(OnActorInstanceDestroyed, void(EMotionFX::ActorInstance*)); }; TEST_F(EntityComponentFixture, ActorComponentNotificationBusTest) { AZStd::unique_ptr entity = AZStd::make_unique(); AZ::EntityId entityId = AZ::EntityId(740216387); entity->SetId(entityId); ActorComponentNotificationTestBus testBus(entityId); auto transformComponent = entity->CreateComponent(); Integration::ActorComponent* actorComponent = entity->CreateComponent(); entity->Init(); AZ::Data::AssetId actorAssetId("{5060227D-B6F4-422E-BF82-41AAC5F228A5}"); AZStd::unique_ptr actor = ActorFactory::CreateAndInit(); AZ::Data::Asset actorAsset = TestActorAssets::GetAssetFromActor(actorAssetId, AZStd::move(actor)); actorComponent->OnAssetReady(actorAsset); EXPECT_CALL(testBus, OnActorInstanceCreated(testing::_)); entity->Activate(); EXPECT_CALL(testBus, OnActorInstanceDestroyed(testing::_)); entity->Deactivate(); } } // end namespace EMotionFX