TestsMain.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 <AzTest/AzTest.h>
  9. #include <AzCore/Module/DynamicModuleHandle.h>
  10. class SceneDataTestEnvironment
  11. : public AZ::Test::ITestEnvironment
  12. {
  13. public:
  14. virtual ~SceneDataTestEnvironment()
  15. {}
  16. protected:
  17. void SetupEnvironment() override
  18. {
  19. sceneCoreModule = AZ::DynamicModuleHandle::Create("SceneCore");
  20. AZ_Assert(sceneCoreModule, "SceneData unit tests failed to create SceneCore module.");
  21. [[maybe_unused]] bool loaded = sceneCoreModule->Load();
  22. AZ_Assert(loaded, "SceneData unit tests failed to load SceneCore module.");
  23. auto init = sceneCoreModule->GetFunction<AZ::InitializeDynamicModuleFunction>(AZ::InitializeDynamicModuleFunctionName);
  24. AZ_Assert(init, "SceneData unit tests failed to find the initialization function the SceneCore module.");
  25. (*init)();
  26. }
  27. void TeardownEnvironment() override
  28. {
  29. auto uninit = sceneCoreModule->GetFunction<AZ::UninitializeDynamicModuleFunction>(AZ::UninitializeDynamicModuleFunctionName);
  30. AZ_Assert(uninit, "SceneData unit tests failed to find the uninitialization function the SceneCore module.");
  31. (*uninit)();
  32. sceneCoreModule.reset();
  33. }
  34. private:
  35. AZStd::unique_ptr<AZ::DynamicModuleHandle> sceneCoreModule;
  36. };
  37. AZ_UNIT_TEST_HOOK(new SceneDataTestEnvironment);