test_MainWindowPythonBindings.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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/UnitTest/TestTypes.h>
  16. #include <AzCore/UserSettings/UserSettingsComponent.h>
  17. #include <AzToolsFramework/Application/ToolsApplication.h>
  18. #include <MainWindow.h>
  19. #include <AzCore/RTTI/BehaviorContext.h>
  20. namespace MainWindowPythonBindingsUnitTests
  21. {
  22. class MainWindowPythonBindingsFixture
  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::MainWindowEditorFuncsHandler::CreateDescriptor());
  38. }
  39. void TearDown() override
  40. {
  41. m_app.Stop();
  42. }
  43. };
  44. TEST_F(MainWindowPythonBindingsFixture, MainWindowEditorCommands_ApiExists)
  45. {
  46. AZ::BehaviorContext* behaviorContext = m_app.GetBehaviorContext();
  47. ASSERT_TRUE(behaviorContext);
  48. EXPECT_TRUE(behaviorContext->m_methods.find("open_pane") != behaviorContext->m_methods.end());
  49. EXPECT_TRUE(behaviorContext->m_methods.find("close_pane") != behaviorContext->m_methods.end());
  50. EXPECT_TRUE(behaviorContext->m_methods.find("is_pane_visible") != behaviorContext->m_methods.end());
  51. EXPECT_TRUE(behaviorContext->m_methods.find("get_pane_class_names") != behaviorContext->m_methods.end());
  52. EXPECT_TRUE(behaviorContext->m_methods.find("exit") != behaviorContext->m_methods.end());
  53. EXPECT_TRUE(behaviorContext->m_methods.find("exit_no_prompt") != behaviorContext->m_methods.end());
  54. }
  55. }