ScriptEntityTests.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 <AzCore/Asset/AssetManagerComponent.h>
  9. #include <AzCore/RTTI/BehaviorContext.h>
  10. #include <AzCore/Script/ScriptAsset.h>
  11. #include <AzCore/Script/ScriptSystemComponent.h>
  12. #include <AzCore/Script/ScriptContext.h>
  13. #include <AzCore/UnitTest/TestTypes.h>
  14. #include <AzToolsFramework/ToolsComponents/ScriptEditorComponent.h>
  15. #include "EntityTestbed.h"
  16. namespace UnitTest
  17. {
  18. using namespace AZ;
  19. using namespace AzFramework;
  20. class EntityScriptTest
  21. : public EntityTestbed
  22. {
  23. public:
  24. ScriptContext* m_scriptContext;
  25. ~EntityScriptTest() override
  26. {
  27. }
  28. void OnDestroy() override
  29. {
  30. delete m_scriptContext;
  31. m_scriptContext = nullptr;
  32. }
  33. void run()
  34. {
  35. int argc = 0;
  36. char* argv = nullptr;
  37. Run(argc, &argv);
  38. }
  39. void OnReflect(AZ::SerializeContext& context, AZ::Entity& systemEntity) override
  40. {
  41. (void)context;
  42. (void)systemEntity;
  43. }
  44. void OnSetup() override
  45. {
  46. m_scriptContext = aznew AZ::ScriptContext();
  47. auto* catalogBus = AZ::Data::AssetCatalogRequestBus::FindFirstHandler();
  48. if (catalogBus)
  49. {
  50. // Register asset types the asset DB should query our catalog for.
  51. catalogBus->AddAssetType(AZ::AzTypeInfo<AZ::ScriptAsset>::Uuid());
  52. // Build the catalog (scan).
  53. catalogBus->AddExtension(".lua");
  54. }
  55. }
  56. void OnEntityAdded(AZ::Entity& entity) override
  57. {
  58. // Add your components.
  59. entity.CreateComponent<AzToolsFramework::Components::ScriptEditorComponent>();
  60. entity.Activate();
  61. }
  62. };
  63. TEST_F(EntityScriptTest, DISABLED_Test)
  64. {
  65. run();
  66. }
  67. } // namespace UnitTest