EventManagerTests.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 "SystemComponentFixture.h"
  9. #include <EMotionFX/Source/TwoStringEventData.h>
  10. #include <EMotionFX/Source/MotionEventTrack.h>
  11. #include <AzCore/Serialization/Utils.h>
  12. namespace EMotionFX
  13. {
  14. TEST_F(SystemComponentFixture, DISABLED_EventDataFactoryMakesUniqueData)
  15. {
  16. MotionEventTrack* track = aznew MotionEventTrack();
  17. track->SetName("My name");
  18. {
  19. const auto data = EMotionFX::GetEventManager().FindOrCreateEventData<TwoStringEventData>("My subject", "My parameter");
  20. track->AddEvent(0.5, data);
  21. }
  22. EXPECT_EQ(track->GetEvent(0).GetEventDatas()[0].use_count(), 1);
  23. AZStd::vector<char> charBuffer;
  24. AZ::IO::ByteContainerStream<AZStd::vector<char> > charStream(&charBuffer);
  25. AZ::Utils::SaveObjectToStream(charStream, AZ::ObjectStream::ST_XML, track, GetSerializeContext());
  26. MotionEventTrack* loadedTrack = AZ::Utils::LoadObjectFromBuffer<MotionEventTrack>(&charBuffer[0], charBuffer.size(), GetSerializeContext());
  27. EXPECT_EQ(loadedTrack->GetEvent(0).GetEventDatas()[0], track->GetEvent(0).GetEventDatas()[0]);
  28. EXPECT_EQ(loadedTrack->GetEvent(0).GetEventDatas()[0].use_count(), 2);
  29. delete track;
  30. delete loadedTrack;
  31. }
  32. } // end namespace EMotionFX