fixes and cmake changes to get it to compile

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
monroegm-disable-blank-issue-2
Esteban Papp 5 years ago
parent afd97abdcf
commit c13720e255

@ -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()

@ -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()

@ -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();
}
}

@ -9,7 +9,6 @@
AZ_PUSH_DISABLE_WARNING(, "-Wdelete-non-virtual-dtor")
#include <FrameworkApplicationFixture.h>
#include <AzCore/Component/ComponentApplication.h>
#include <AzCore/Component/Entity.h>
#include <AzCore/Component/Component.h>

@ -9,4 +9,5 @@ set(FILES
Mocks/MockSpawnableEntitiesInterface.h
Utils/Utils.h
Utils/Utils.cpp
FrameworkApplicationFixture.h
)

@ -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
)

@ -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

@ -5,8 +5,8 @@
*
*/
#include "FrameworkApplicationFixture.h"
#include "Utils/Utils.h"
#include <FrameworkApplicationFixture.h>
#include <Utils/Utils.h>
#include <AzCore/IO/Path/Path.h>
#include <AzCore/Outcome/Outcome.h>
#include <AzCore/Serialization/Json/JsonSerialization.h>

@ -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<AZ::SerializeContext*>(context))
{
serializeContext->Class<TestExportEditorComponent, AzToolsFramework::Components::EditorComponentBase>()
serializeContext->Class<SliceTestExportEditorComponent, AzToolsFramework::Components::EditorComponentBase>()
;
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
{
editContext->Class<TestExportEditorComponent>(
editContext->Class<SliceTestExportEditorComponent>(
"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<SliceAsset>(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<AzToolsFramework::Components::TransformComponent>();
entity->CreateComponent<TestExportEditorComponent>(exportType, exportHandled);
entity->CreateComponent<SliceTestExportEditorComponent>(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<TestExportEditorComponent>());
EXPECT_FALSE(entity->FindComponent<SliceTestExportEditorComponent>());
EXPECT_FALSE(entity->FindComponent<TestExportRuntimeComponent>());
EXPECT_TRUE(entity->FindComponent<TestExportOtherRuntimeComponent>());
}
@ -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<TestExportEditorComponent>());
EXPECT_FALSE(entity->FindComponent<SliceTestExportEditorComponent>());
EXPECT_FALSE(entity->FindComponent<TestExportRuntimeComponent>());
EXPECT_FALSE(entity->FindComponent<TestExportOtherRuntimeComponent>());
}
@ -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<TestExportEditorComponent>());
EXPECT_FALSE(entity->FindComponent<SliceTestExportEditorComponent>());
EXPECT_TRUE(entity->FindComponent<TestExportRuntimeComponent>());
EXPECT_FALSE(entity->FindComponent<TestExportOtherRuntimeComponent>());
}
@ -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<TestExportEditorComponent>());
EXPECT_FALSE(entity->FindComponent<SliceTestExportEditorComponent>());
EXPECT_TRUE(entity->FindComponent<TestExportRuntimeComponent>());
EXPECT_FALSE(entity->FindComponent<TestExportOtherRuntimeComponent>());
}
@ -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);

@ -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
)

@ -18,4 +18,3 @@ add_subdirectory(AzNetworking)
add_subdirectory(Crcfix)
add_subdirectory(GFxFramework)
add_subdirectory(GridMate)
add_subdirectory(Tests)

Loading…
Cancel
Save