AWSGameLiftClientFixture.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. #pragma once
  9. #include <AWSNativeSDKTestManager.h>
  10. #include <AzCore/Jobs/JobManager.h>
  11. #include <AzCore/Jobs/JobManagerBus.h>
  12. #include <AzCore/Jobs/JobContext.h>
  13. #include <AzCore/Memory/PoolAllocator.h>
  14. #include <AzCore/UnitTest/TestTypes.h>
  15. #include <AzTest/Utils.h>
  16. class AWSGameLiftClientFixture
  17. : public UnitTest::LeakDetectionFixture
  18. {
  19. public:
  20. AWSGameLiftClientFixture() {}
  21. virtual ~AWSGameLiftClientFixture() = default;
  22. void SetUp() override
  23. {
  24. AZ::JobManagerDesc jobManagerDesc;
  25. AZ::JobManagerThreadDesc threadDesc;
  26. m_jobManager.reset(aznew AZ::JobManager(jobManagerDesc));
  27. m_jobCancelGroup.reset(aznew AZ::JobCancelGroup());
  28. jobManagerDesc.m_workerThreads.push_back(threadDesc);
  29. jobManagerDesc.m_workerThreads.push_back(threadDesc);
  30. jobManagerDesc.m_workerThreads.push_back(threadDesc);
  31. m_jobContext.reset(aznew AZ::JobContext(*m_jobManager, *m_jobCancelGroup));
  32. AZ::JobContext::SetGlobalContext(m_jobContext.get());
  33. AWSNativeSDKTestLibs::AWSNativeSDKTestManager::Init();
  34. }
  35. void TearDown() override
  36. {
  37. AWSNativeSDKTestLibs::AWSNativeSDKTestManager::Shutdown();
  38. AZ::JobContext::SetGlobalContext(nullptr);
  39. m_jobContext.reset();
  40. m_jobCancelGroup.reset();
  41. m_jobManager.reset();
  42. }
  43. AZStd::unique_ptr<AZ::JobContext> m_jobContext;
  44. AZStd::unique_ptr<AZ::JobCancelGroup> m_jobCancelGroup;
  45. AZStd::unique_ptr<AZ::JobManager> m_jobManager;
  46. };