ApplicationTests.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 <AzCore/UnitTest/TestTypes.h>
  9. #include <AzCore/std/smart_ptr/make_shared.h>
  10. #include <Application.h>
  11. #include <ProjectManager_Test_Traits_Platform.h>
  12. #include "MockPythonBindings.h"
  13. namespace O3DE::ProjectManager
  14. {
  15. class ProjectManagerApplicationTests
  16. : public ::UnitTest::LeakDetectionFixture
  17. {
  18. public:
  19. void SetUp() override
  20. {
  21. m_application = AZStd::make_unique<ProjectManager::Application>();
  22. }
  23. void TearDown() override
  24. {
  25. m_application.reset();
  26. }
  27. AZStd::unique_ptr<ProjectManager::Application> m_application;
  28. };
  29. #if AZ_TRAIT_DISABLE_FAILED_PROJECT_MANAGER_TESTS
  30. TEST_F(ProjectManagerApplicationTests, DISABLED_Application_Init_Succeeds)
  31. #else
  32. TEST_F(ProjectManagerApplicationTests, Application_Init_Succeeds)
  33. #endif // !AZ_TRAIT_DISABLE_FAILED_PROJECT_MANAGER_TESTS
  34. {
  35. using ::testing::NiceMock;
  36. using ::testing::Return;
  37. // mock python bindings because those have separate tests and we want
  38. // to avoid modifying the manifest that other tests may be trying to read
  39. auto pythonBindings = AZStd::make_unique<NiceMock<MockPythonBindings>>();
  40. EngineInfo engineInfo;
  41. engineInfo.m_registered = true;
  42. ON_CALL(*pythonBindings, GetEngineInfo()).WillByDefault(Return(AZ::Success(AZStd::move(engineInfo))));
  43. ON_CALL(*pythonBindings, PythonStarted()).WillByDefault(Return(true));
  44. ON_CALL(*pythonBindings, StopPython()).WillByDefault(Return(true));
  45. // gem repos currently pop up a messagebox if no gem repos are found
  46. // so we must return an empty list
  47. ON_CALL(*pythonBindings, GetAllGemRepoInfos()).WillByDefault(Return(AZ::Success(QVector<GemRepoInfo>())));
  48. // we don't want to interact with actual GUI or display it
  49. EXPECT_TRUE(m_application->Init(/*interactive=*/false, AZStd::move(pythonBindings)));
  50. }
  51. }