test_TerrainLayerPythonBindings.cpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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/PythonTerrainLayerFuncs.h>
  18. #include <AzCore/RTTI/BehaviorContext.h>
  19. namespace TerrainFuncsUnitTests
  20. {
  21. class TerrainLayerPythonBindingsFixture
  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::TerrainLayerPythonFuncsHandler::CreateDescriptor());
  35. }
  36. void TearDown() override
  37. {
  38. m_app.Stop();
  39. }
  40. };
  41. TEST_F(TerrainLayerPythonBindingsFixture, TerrainCommands_ApiExists)
  42. {
  43. AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
  44. ASSERT_TRUE(behaviorContext);
  45. EXPECT_TRUE(behaviorContext->m_methods.find("get_tile_count_x") != behaviorContext->m_methods.end());
  46. EXPECT_TRUE(behaviorContext->m_methods.find("get_tile_count_y") != behaviorContext->m_methods.end());
  47. EXPECT_TRUE(behaviorContext->m_methods.find("get_tile_resolution") != behaviorContext->m_methods.end());
  48. EXPECT_TRUE(behaviorContext->m_methods.find("set_tile_resolution") != behaviorContext->m_methods.end());
  49. EXPECT_TRUE(behaviorContext->m_methods.find("set_tile_count") != behaviorContext->m_methods.end());
  50. EXPECT_TRUE(behaviorContext->m_methods.find("get_color_at") != behaviorContext->m_methods.end());
  51. EXPECT_TRUE(behaviorContext->m_methods.find("import_megaterrain") != behaviorContext->m_methods.end());
  52. EXPECT_TRUE(behaviorContext->m_methods.find("export_megaterrain") != behaviorContext->m_methods.end());
  53. }
  54. }