test_CryEditDocPythonBindings.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 "EditorDefs.h"
  9. #include <AzTest/AzTest.h>
  10. #include <Util/EditorUtils.h>
  11. #include <AzCore/base.h>
  12. #include <AzCore/Memory/SystemAllocator.h>
  13. #include <AzCore/Debug/TraceMessageBus.h>
  14. #include <AzCore/UnitTest/TestTypes.h>
  15. #include <AzToolsFramework/API/ToolsApplicationAPI.h>
  16. #include <AzToolsFramework/Application/ToolsApplication.h>
  17. #include <CryEditDoc.h>
  18. #include <AzCore/RTTI/BehaviorContext.h>
  19. #include <AzCore/UserSettings/UserSettingsComponent.h>
  20. namespace CryEditDocPythonBindingsUnitTests
  21. {
  22. class CryEditDocPythonBindingsFixture
  23. : public ::UnitTest::LeakDetectionFixture
  24. {
  25. public:
  26. AzToolsFramework::ToolsApplication m_app;
  27. void SetUp() override
  28. {
  29. AzFramework::Application::Descriptor appDesc;
  30. AZ::ComponentApplication::StartupParameters startupParameters;
  31. startupParameters.m_loadSettingsRegistry = false;
  32. m_app.Start(appDesc, startupParameters);
  33. // Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
  34. // shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash
  35. // in the unit tests.
  36. AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
  37. m_app.RegisterComponentDescriptor(AzToolsFramework::CryEditDocFuncsHandler::CreateDescriptor());
  38. }
  39. void TearDown() override
  40. {
  41. m_app.Stop();
  42. }
  43. };
  44. TEST_F(CryEditDocPythonBindingsFixture, CryEditDocEditorCommands_ApiExists)
  45. {
  46. AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
  47. ASSERT_TRUE(behaviorContext);
  48. EXPECT_TRUE(behaviorContext->m_methods.find("save_level") != behaviorContext->m_methods.end());
  49. }
  50. }