diff --git a/Code/Framework/AzFramework/CMakeLists.txt b/Code/Framework/AzFramework/CMakeLists.txt index 1f53472ff8..2cfc5e4b89 100644 --- a/Code/Framework/AzFramework/CMakeLists.txt +++ b/Code/Framework/AzFramework/CMakeLists.txt @@ -52,3 +52,63 @@ ly_add_source_properties( PROPERTY COMPILE_DEFINITIONS VALUES TOUCHBENDING_LAYER_BIT=${LY_TOUCHBENDING_LAYER_BIT} ) + +if(PAL_TRAIT_BUILD_TESTS_SUPPORTED) + + ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Tests/Platform/${PAL_PLATFORM_NAME}) + + ly_add_target( + NAME AzFrameworkTestShared STATIC + NAMESPACE AZ + FILES_CMAKE + Tests/framework_shared_tests_files.cmake + INCLUDE_DIRECTORIES + PUBLIC + Tests + BUILD_DEPENDENCIES + PRIVATE + AZ::AzCore + AZ::AzFramework + ) + + if(PAL_TRAIT_BUILD_HOST_TOOLS) + + ly_add_target( + NAME ProcessLaunchTest EXECUTABLE + NAMESPACE AZ + FILES_CMAKE + Tests/process_launch_test_files.cmake + INCLUDE_DIRECTORIES + PRIVATE + Tests + BUILD_DEPENDENCIES + PRIVATE + AZ::AzCore + AZ::AzFramework + ) + + ly_add_target( + NAME AzFramework.Tests ${PAL_TRAIT_TEST_TARGET_TYPE} + NAMESPACE AZ + FILES_CMAKE + Tests/frameworktests_files.cmake + INCLUDE_DIRECTORIES + PRIVATE + Tests + ${pal_dir} + BUILD_DEPENDENCIES + PRIVATE + AZ::AzFramework + AZ::AzTest + AZ::AzTestShared + AZ::AzFrameworkTestShared + RUNTIME_DEPENDENCIES + AZ::ProcessLaunchTest + ) + ly_add_googletest( + NAME AZ::AzFramework.Tests + ) + + endif() + +endif() \ No newline at end of file diff --git a/Code/Framework/AzFramework/Tests/CMakeLists.txt b/Code/Framework/AzFramework/Tests/CMakeLists.txt deleted file mode 100644 index 6781466413..0000000000 --- a/Code/Framework/AzFramework/Tests/CMakeLists.txt +++ /dev/null @@ -1,64 +0,0 @@ -# -# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution. -# -# SPDX-License-Identifier: Apache-2.0 OR MIT -# -# - -if(PAL_TRAIT_BUILD_TESTS_SUPPORTED) - - ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME}) - - ly_add_target( - NAME AzFrameworkTestShared STATIC - NAMESPACE AZ - FILES_CMAKE - framework_shared_tests_files.cmake - INCLUDE_DIRECTORIES - PUBLIC - . - BUILD_DEPENDENCIES - PRIVATE - AZ::AzCore - AZ::AzFramework - ) - - if(PAL_TRAIT_BUILD_HOST_TOOLS) - ly_add_target( - NAME ProcessLaunchTest EXECUTABLE - NAMESPACE AZ - FILES_CMAKE - process_launch_test_files.cmake - INCLUDE_DIRECTORIES - PRIVATE - . - BUILD_DEPENDENCIES - PRIVATE - AZ::AzCore - AZ::AzFramework - ) - - ly_add_target( - NAME Framework.Tests ${PAL_TRAIT_TEST_TARGET_TYPE} - NAMESPACE AZ - FILES_CMAKE - frameworktests_files.cmake - INCLUDE_DIRECTORIES - PRIVATE - . - ${pal_dir} - BUILD_DEPENDENCIES - PRIVATE - AZ::AzTest - AZ::AzToolsFramework - AZ::AzTestShared - AZ::AzFrameworkTestShared - RUNTIME_DEPENDENCIES - AZ::ProcessLaunchTest - ) - ly_add_googletest( - NAME AZ::Framework.Tests - ) - endif() - -endif() diff --git a/Code/Framework/AzFramework/Tests/GenAppDescriptors.cpp b/Code/Framework/AzFramework/Tests/GenAppDescriptors.cpp index dde3800895..069d3b35f2 100644 --- a/Code/Framework/AzFramework/Tests/GenAppDescriptors.cpp +++ b/Code/Framework/AzFramework/Tests/GenAppDescriptors.cpp @@ -15,16 +15,16 @@ namespace UnitTest { using namespace AZ; - class SetRestoreFileIOBaseRAII + class FileIOBaseRAII { public: - SetRestoreFileIOBaseRAII(AZ::IO::FileIOBase& fileIO) + FileIOBaseRAII(AZ::IO::FileIOBase& fileIO) : m_prevFileIO(AZ::IO::FileIOBase::GetInstance()) { AZ::IO::FileIOBase::SetInstance(&fileIO); } - ~SetRestoreFileIOBaseRAII() + ~FileIOBaseRAII() { AZ::IO::FileIOBase::SetInstance(m_prevFileIO); } @@ -102,7 +102,7 @@ namespace UnitTest TEST_F(GenAppDescriptors, Test) { AZ::IO::LocalFileIO fileIO; - SetRestoreFileIOBaseRAII restoreFileIOScope(fileIO); + FileIOBaseRAII restoreFileIOScope(fileIO); run(); } } diff --git a/Code/Framework/AzFramework/Tests/Scene.cpp b/Code/Framework/AzFramework/Tests/Scene.cpp index 32a0958692..57293c9d77 100644 --- a/Code/Framework/AzFramework/Tests/Scene.cpp +++ b/Code/Framework/AzFramework/Tests/Scene.cpp @@ -9,7 +9,6 @@ AZ_PUSH_DISABLE_WARNING(, "-Wdelete-non-virtual-dtor") -#include #include #include #include diff --git a/Code/Framework/AzFramework/Tests/framework_shared_tests_files.cmake b/Code/Framework/AzFramework/Tests/framework_shared_tests_files.cmake index 72ffdf0043..5ee7ff644b 100644 --- a/Code/Framework/AzFramework/Tests/framework_shared_tests_files.cmake +++ b/Code/Framework/AzFramework/Tests/framework_shared_tests_files.cmake @@ -9,4 +9,5 @@ set(FILES Mocks/MockSpawnableEntitiesInterface.h Utils/Utils.h Utils/Utils.cpp + FrameworkApplicationFixture.h ) diff --git a/Code/Framework/AzFramework/Tests/frameworktests_files.cmake b/Code/Framework/AzFramework/Tests/frameworktests_files.cmake index 398bb8f45b..25c56f5a71 100644 --- a/Code/Framework/AzFramework/Tests/frameworktests_files.cmake +++ b/Code/Framework/AzFramework/Tests/frameworktests_files.cmake @@ -6,44 +6,28 @@ # set(FILES - ../AzCore/Tests/Main.cpp + ../../AzCore/Tests/Main.cpp Spawnable/SpawnableEntitiesManagerTests.cpp ArchiveCompressionTests.cpp ArchiveTests.cpp BehaviorEntityTests.cpp BinToTextEncode.cpp - ComponentAddRemove.cpp - ComponentAdapterTests.cpp CameraInputTests.cpp ClickDetectorTests.cpp CursorStateTests.cpp EntityContext.cpp - EntityTestbed.h - FileFunc.cpp FileIO.cpp FileTagTests.cpp - FrameworkApplicationFixture.h GenAppDescriptors.cpp - GenericComponentWrapperTest.cpp - InstanceDataHierarchy.cpp OctreePerformanceTests.cpp OctreeTests.cpp - Slices.cpp - Script/ScriptComponentTests.cpp - Script/ScriptEntityTests.cpp AssetCatalog.cpp AssetProcessorConnection.cpp NativeWindow.cpp - TransformComponent.cpp - SQLiteConnectionTests.cpp ProcessLaunchParseTests.cpp Application.cpp PlatformHelper.cpp Scene.cpp - EntityOwnershipService/EntityOwnershipServiceTestFixture.h - EntityOwnershipService/EntityOwnershipServiceTestFixture.cpp - EntityOwnershipService/SliceEditorEntityOwnershipTests.cpp - EntityOwnershipService/SliceEntityOwnershipTests.cpp CameraState.cpp InputTests.cpp ) diff --git a/Code/Framework/AzToolsFramework/CMakeLists.txt b/Code/Framework/AzToolsFramework/CMakeLists.txt index b2a9690948..9a54ee5226 100644 --- a/Code/Framework/AzToolsFramework/CMakeLists.txt +++ b/Code/Framework/AzToolsFramework/CMakeLists.txt @@ -76,6 +76,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED) PRIVATE AZ::AzTestShared 3rdParty::Qt::Test + AZ::AzFrameworkTestShared AZ::AzToolsFramework AZ::AzToolsFrameworkTestCommon AZ::AzManipulatorTestFramework.Static diff --git a/Code/Framework/AzToolsFramework/Tests/FileFunc.cpp b/Code/Framework/AzToolsFramework/Tests/FileFunc.cpp index 4edb91164c..420caa0f55 100644 --- a/Code/Framework/AzToolsFramework/Tests/FileFunc.cpp +++ b/Code/Framework/AzToolsFramework/Tests/FileFunc.cpp @@ -5,8 +5,8 @@ * */ -#include "FrameworkApplicationFixture.h" -#include "Utils/Utils.h" +#include +#include #include #include #include diff --git a/Code/Framework/AzToolsFramework/Tests/Slices.cpp b/Code/Framework/AzToolsFramework/Tests/Slices.cpp index ba413eb727..a8c98d2a85 100644 --- a/Code/Framework/AzToolsFramework/Tests/Slices.cpp +++ b/Code/Framework/AzToolsFramework/Tests/Slices.cpp @@ -972,11 +972,11 @@ namespace UnitTest }; - class TestExportEditorComponent + class SliceTestExportEditorComponent : public AzToolsFramework::Components::EditorComponentBase { public: - AZ_COMPONENT(TestExportEditorComponent, "{8FA877A2-38E6-49AD-B31E-71B86DC8BB03}", AzToolsFramework::Components::EditorComponentBase); + AZ_COMPONENT(SliceTestExportEditorComponent, "{8FA877A2-38E6-49AD-B31E-71B86DC8BB03}", AzToolsFramework::Components::EditorComponentBase); enum ExportComponentType { @@ -986,9 +986,9 @@ namespace UnitTest EXPORT_NULL_COMPONENT }; - TestExportEditorComponent() {} + SliceTestExportEditorComponent() {} - TestExportEditorComponent(ExportComponentType exportType, bool exportHandled) : + SliceTestExportEditorComponent(ExportComponentType exportType, bool exportHandled) : m_exportType(exportType), m_exportHandled(exportHandled) {} @@ -1000,15 +1000,15 @@ namespace UnitTest { if (AZ::SerializeContext* serializeContext = azrtti_cast(context)) { - serializeContext->Class() + serializeContext->Class() ; if (AZ::EditContext* editContext = serializeContext->GetEditContext()) { - editContext->Class( + editContext->Class( "Test Export Editor Component", "Validate different options for exporting editor components") ->ClassElement(AZ::Edit::ClassElements::EditorData, "") - ->Attribute(AZ::Edit::Attributes::RuntimeExportCallback, &TestExportEditorComponent::ExportComponent) + ->Attribute(AZ::Edit::Attributes::RuntimeExportCallback, &SliceTestExportEditorComponent::ExportComponent) ; } } @@ -1070,7 +1070,7 @@ namespace UnitTest m_app.RegisterComponentDescriptor(TestExportRuntimeComponent::CreateDescriptor()); m_app.RegisterComponentDescriptor(TestExportOtherRuntimeComponent::CreateDescriptor()); - m_app.RegisterComponentDescriptor(TestExportEditorComponent::CreateDescriptor()); + m_app.RegisterComponentDescriptor(SliceTestExportEditorComponent::CreateDescriptor()); m_editorSliceAsset = Data::AssetManager::Instance().CreateAsset(Data::AssetId(Uuid::CreateRandom())); @@ -1125,11 +1125,11 @@ namespace UnitTest } // create entity containing the EditorOnly component in the editor slice - void CreateTestExportEditorEntity(const char* name, TestExportEditorComponent::ExportComponentType exportType, bool exportHandled) + void CreateTestExportEditorEntity(const char* name, SliceTestExportEditorComponent::ExportComponentType exportType, bool exportHandled) { AZ::Entity* entity = aznew AZ::Entity(name); entity->CreateComponent(); - entity->CreateComponent(exportType, exportHandled); + entity->CreateComponent(exportType, exportHandled); m_editorSliceComponent->AddEntity(entity); } @@ -1314,7 +1314,7 @@ namespace UnitTest TEST_F(SliceCompilerTest, RuntimeExportCallback_EditorComponentExportedSuccessfully) { // Create an editor component that has a RuntimeExportCallback and successfully exports itself - CreateTestExportEditorEntity("EntityWithEditorComponent", TestExportEditorComponent::ExportComponentType::EXPORT_OTHER_RUNTIME_COMPONENT, true); + CreateTestExportEditorEntity("EntityWithEditorComponent", SliceTestExportEditorComponent::ExportComponentType::EXPORT_OTHER_RUNTIME_COMPONENT, true); if (!CompileSlice()) { @@ -1325,7 +1325,7 @@ namespace UnitTest // (A result of Runtime component means BuildGameEntity() ran instead) AZ::Entity* entity = GetCompiledEntity("EntityWithEditorComponent"); EXPECT_TRUE(entity); - EXPECT_FALSE(entity->FindComponent()); + EXPECT_FALSE(entity->FindComponent()); EXPECT_FALSE(entity->FindComponent()); EXPECT_TRUE(entity->FindComponent()); } @@ -1333,7 +1333,7 @@ namespace UnitTest TEST_F(SliceCompilerTest, RuntimeExportCallback_EditorComponentExportSuppressed) { // Create an editor component that has a RuntimeExportCallback and successfully suppresses itself from exporting - CreateTestExportEditorEntity("EntityWithEditorComponent", TestExportEditorComponent::ExportComponentType::EXPORT_NULL_COMPONENT, true); + CreateTestExportEditorEntity("EntityWithEditorComponent", SliceTestExportEditorComponent::ExportComponentType::EXPORT_NULL_COMPONENT, true); if (!CompileSlice()) { @@ -1343,7 +1343,7 @@ namespace UnitTest // Expected result: exported slice does NOT contain either component. AZ::Entity* entity = GetCompiledEntity("EntityWithEditorComponent"); EXPECT_TRUE(entity); - EXPECT_FALSE(entity->FindComponent()); + EXPECT_FALSE(entity->FindComponent()); EXPECT_FALSE(entity->FindComponent()); EXPECT_FALSE(entity->FindComponent()); } @@ -1351,7 +1351,7 @@ namespace UnitTest TEST_F(SliceCompilerTest, RuntimeExportCallback_EditorComponentExportUnhandledFallbackToBuildGameEntity) { // Create an editor component that has a RuntimeExportCallback, returns a pointer to itself, but says it wasn't handled. - CreateTestExportEditorEntity("EntityWithEditorComponent", TestExportEditorComponent::ExportComponentType::EXPORT_EDITOR_COMPONENT, false); + CreateTestExportEditorEntity("EntityWithEditorComponent", SliceTestExportEditorComponent::ExportComponentType::EXPORT_EDITOR_COMPONENT, false); if (!CompileSlice()) { @@ -1362,7 +1362,7 @@ namespace UnitTest // produced a runtime component. AZ::Entity* entity = GetCompiledEntity("EntityWithEditorComponent"); EXPECT_TRUE(entity); - EXPECT_FALSE(entity->FindComponent()); + EXPECT_FALSE(entity->FindComponent()); EXPECT_TRUE(entity->FindComponent()); EXPECT_FALSE(entity->FindComponent()); } @@ -1370,7 +1370,7 @@ namespace UnitTest TEST_F(SliceCompilerTest, RuntimeExportCallback_EditorComponentExportSuppressedAndUnhandledFallbackToBuildGameEntity) { // Create an editor component that has a RuntimeExportCallback and suppresses itself from exporting, but says it wasn't handled - CreateTestExportEditorEntity("EntityWithEditorComponent", TestExportEditorComponent::ExportComponentType::EXPORT_NULL_COMPONENT, false); + CreateTestExportEditorEntity("EntityWithEditorComponent", SliceTestExportEditorComponent::ExportComponentType::EXPORT_NULL_COMPONENT, false); if (!CompileSlice()) { @@ -1381,7 +1381,7 @@ namespace UnitTest // produced a runtime component. AZ::Entity* entity = GetCompiledEntity("EntityWithEditorComponent"); EXPECT_TRUE(entity); - EXPECT_FALSE(entity->FindComponent()); + EXPECT_FALSE(entity->FindComponent()); EXPECT_TRUE(entity->FindComponent()); EXPECT_FALSE(entity->FindComponent()); } @@ -1389,7 +1389,7 @@ namespace UnitTest TEST_F(SliceCompilerTest, RuntimeExportCallback_EditorComponentFailsToExportItself) { // Create an editor component that has a RuntimeExportCallback and suppresses itself from exporting, but says it wasn't handled - CreateTestExportEditorEntity("EntityWithEditorComponent", TestExportEditorComponent::ExportComponentType::EXPORT_EDITOR_COMPONENT, true); + CreateTestExportEditorEntity("EntityWithEditorComponent", SliceTestExportEditorComponent::ExportComponentType::EXPORT_EDITOR_COMPONENT, true); // We expect the slice compilation to fail, since an editor component is being exported as a game component CompileSlice(false); diff --git a/Code/Framework/AzToolsFramework/Tests/aztoolsframeworktests_files.cmake b/Code/Framework/AzToolsFramework/Tests/aztoolsframeworktests_files.cmake index 2e2be6f921..573de25d42 100644 --- a/Code/Framework/AzToolsFramework/Tests/aztoolsframeworktests_files.cmake +++ b/Code/Framework/AzToolsFramework/Tests/aztoolsframeworktests_files.cmake @@ -100,4 +100,19 @@ set(FILES Viewport/ClusterTests.cpp Viewport/ViewportUiWidgetManagerTests.cpp Visibility/EditorVisibilityTests.cpp + ComponentAdapterTests.cpp + ComponentAddRemove.cpp + EntityTestbed.h + GenericComponentWrapperTest.cpp + InstanceDataHierarchy.cpp + Slices.cpp + SQLiteConnectionTests.cpp + TransformComponent.cpp + EntityOwnershipService/EntityOwnershipServiceTestFixture.h + EntityOwnershipService/EntityOwnershipServiceTestFixture.cpp + EntityOwnershipService/SliceEditorEntityOwnershipTests.cpp + EntityOwnershipService/SliceEntityOwnershipTests.cpp + Script/ScriptComponentTests.cpp + Script/ScriptEntityTests.cpp + FileFunc.cpp ) diff --git a/Code/Framework/CMakeLists.txt b/Code/Framework/CMakeLists.txt index e12a8f4cab..880751632c 100644 --- a/Code/Framework/CMakeLists.txt +++ b/Code/Framework/CMakeLists.txt @@ -18,4 +18,3 @@ add_subdirectory(AzNetworking) add_subdirectory(Crcfix) add_subdirectory(GFxFramework) add_subdirectory(GridMate) -add_subdirectory(Tests)