test_TerrainPythonBindings.cpp 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 <Terrain/PythonTerrainFuncs.h>
  18. #include <AzCore/RTTI/BehaviorContext.h>
  19. namespace TerrainFuncsUnitTests
  20. {
  21. class TerrainPythonBindingsFixture
  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::TerrainPythonFuncsHandler::CreateDescriptor());
  35. }
  36. void TearDown() override
  37. {
  38. m_app.Stop();
  39. }
  40. };
  41. TEST_F(TerrainPythonBindingsFixture, TerrainCommands_ApiExists)
  42. {
  43. AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
  44. ASSERT_TRUE(behaviorContext);
  45. EXPECT_TRUE(behaviorContext->m_methods.find("get_max_height") != behaviorContext->m_methods.end());
  46. EXPECT_TRUE(behaviorContext->m_methods.find("set_max_height") != behaviorContext->m_methods.end());
  47. EXPECT_TRUE(behaviorContext->m_methods.find("import_heightmap") != behaviorContext->m_methods.end());
  48. EXPECT_TRUE(behaviorContext->m_methods.find("export_heightmap") != behaviorContext->m_methods.end());
  49. EXPECT_TRUE(behaviorContext->m_methods.find("get_elevation") != behaviorContext->m_methods.end());
  50. EXPECT_TRUE(behaviorContext->m_methods.find("get_heightmap_elevation") != behaviorContext->m_methods.end());
  51. EXPECT_TRUE(behaviorContext->m_methods.find("set_elevation") != behaviorContext->m_methods.end());
  52. EXPECT_TRUE(behaviorContext->m_methods.find("flatten") != behaviorContext->m_methods.end());
  53. EXPECT_TRUE(behaviorContext->m_methods.find("reduce_range") != behaviorContext->m_methods.end());
  54. EXPECT_TRUE(behaviorContext->m_methods.find("smooth") != behaviorContext->m_methods.end());
  55. EXPECT_TRUE(behaviorContext->m_methods.find("slope_smooth") != behaviorContext->m_methods.end());
  56. EXPECT_TRUE(behaviorContext->m_methods.find("erase") != behaviorContext->m_methods.end());
  57. EXPECT_TRUE(behaviorContext->m_methods.find("resize") != behaviorContext->m_methods.end());
  58. EXPECT_TRUE(behaviorContext->m_methods.find("make_isle") != behaviorContext->m_methods.end());
  59. EXPECT_TRUE(behaviorContext->m_methods.find("normalize") != behaviorContext->m_methods.end());
  60. EXPECT_TRUE(behaviorContext->m_methods.find("invert") != behaviorContext->m_methods.end());
  61. EXPECT_TRUE(behaviorContext->m_methods.find("fetch") != behaviorContext->m_methods.end());
  62. EXPECT_TRUE(behaviorContext->m_methods.find("hold") != behaviorContext->m_methods.end());
  63. }
  64. }