test_TerrainModifyPythonBindings.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 <AzToolsFramework/API/ToolsApplicationAPI.h>
  15. #include <AzCore/UserSettings/UserSettingsComponent.h>
  16. #include <AzToolsFramework/Application/ToolsApplication.h>
  17. #include <TerrainModifyTool.h>
  18. #include <AzCore/RTTI/BehaviorContext.h>
  19. namespace TerrainModifyPythonBindingsUnitTests
  20. {
  21. class TerrainModifyPythonBindingsFixture
  22. : public UnitTest::LeakDetectionFixture
  23. {
  24. public:
  25. AzToolsFramework::ToolsApplication m_app;
  26. void SetUp() override
  27. {
  28. AzFramework::Application::Descriptor appDesc;
  29. m_app.Start(appDesc);
  30. // Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
  31. // shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash
  32. // in the unit tests.
  33. AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
  34. m_app.RegisterComponentDescriptor(AzToolsFramework::TerrainModifyPythonFuncsHandler::CreateDescriptor());
  35. }
  36. void TearDown() override
  37. {
  38. m_app.Stop();
  39. }
  40. };
  41. TEST_F(TerrainModifyPythonBindingsFixture, TerrainModifyEditorCommands_ApiExists)
  42. {
  43. AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
  44. ASSERT_TRUE(behaviorContext);
  45. EXPECT_TRUE(behaviorContext->m_methods.find("set_tool_flatten") != behaviorContext->m_methods.end());
  46. EXPECT_TRUE(behaviorContext->m_methods.find("set_tool_smooth") != behaviorContext->m_methods.end());
  47. EXPECT_TRUE(behaviorContext->m_methods.find("set_tool_riselower") != behaviorContext->m_methods.end());
  48. }
  49. }