f648cb1fd8
* Update the FileIOAlias naming to make the cache, project root and engine root paths more clear The alias of `@root@`, `@assets@`, and `@projectplatformcache@` has been collapsed to `@projectproductassets@` The alias of `@devroot@` and `@engroot@` has been collapsed to `@engroot@` The alias of `@devassets@` and `@projectroot@` has been collapsed to `@projectroot@` Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated use of devassets and devroot properties in python Those properties now use projectroot and engroot Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updating the alias @engroot@ alias path comment in each platform specific LocalFileIO_*.cpp file Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Removed hardcoded size of 9 for the product asset alias. The ResolvePath function now just appends the @projectproductassets@ alias with the input path Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Remove duplicate @projectproductassets@ check in ProcessFileTreeRequest Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Fix for typos in Hydra python test Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated LocalFileIO::Copy call on Windows to use the Unicode aware CopyFileW API Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated the AWSMetreicsGemAllocatorFixture to properly suppress asset cache write errors for Test file creation. Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Removed unneeded call to set the @projectproductasstes@ alias at the bottom of the AssetSeedManagerTest SetUp Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Added a deprecated alias map to the FileIO System When a deprecated alias is accessed, the FileIO System logs an AZ_Error and indicates the alias that should be used Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated python test scripts to use the projectroot binding Retrieving the AutomatedTesting project path based on "<devroot>/AutomatedTesting" has been removed. Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated references to devroot and devgame within the codebase The GetAbsoluteDevGameFolderPath functions has been replaced with direct call to AZ::Utils::GetProjectPath The GetAbsoluteDevRootFolderPath functions has been replaced with direct calls to AZ::Utils::GetEnginePath Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated <engroot>/AutomatedTesting references to projectroot Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Replaced references that assumes the project path is <engroot>/AutomatedTesting with <projectroot> in the AutomatedTesting python test Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Correct casing in emfxworkspace file Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Removed newly added AppendPathParts function Removed the Path constructors which accepts a PathIterable instance The PathIterable isn't safe to return to a user of the Path class as it might be referencing temporary paths supplied via PathView arguments Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Fixed unused parameter warning Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Undid change to the LexicallyProximate function to set the path result to the base path. It needs to return the *this path if the pathResult is empty Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Moved the LocalFileIO ConvertToAbsolutePath implementations to AZ::Utils Fixed the ConvertToAbsolutePath implementation for Unix platforms to use a buffer that is size PATH_MAX(4096 on all our supported Unix platforms). Because the buffer before was AZ::IO::MaxPathLength which as a size of 1024, this was resulting in the Unix `realpath` function smashing the stack when it converts a path to an absolute path that is longer than 1024 characters Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated the EditorCore.Tests to attach the AZ Environment to the EditorCore shared library that is statically loaded on launch. Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Fixed for DeprecatedAlaisesKeyVisitor Visit function causing the non string_view overloads being hidden causing a hidden base class function warning Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Changed the AWSMetricsGemMock to use a temporary for writing test assets Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated the LocalFileIO::ResolvePath function to use HasRootPath to determine if a path starts with a root path such as "D:", "D:/" or "/" IsAbsolute was not the corect check as the path of "D:" is a relative path. To be absolute according to the Windows the path must have a root directory. i.e "D:/" or "D:\" Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Removed absolute path comment from LocalFile_UnixLike.cpp and LocalFile_Android.cpp FindFiles implementations Updated the ConvertToAlias to supply an AZ::IO::FixedMaxPath Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Replaced usage of the @projectproductassets@ alias with @engroot@ when referring to the LmbrCentral source folder in the CopyDependencyBuilderTest and the SeedBuilderTests Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated the ScriptCanvas Upgrade Tool to output backed up files to the Project User Path instead of the engine root Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Fixed whitespacing issues in Application.cpp Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Remove unnecessary creation of a FixedMaxPath in the UpgradeTool.cpp Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Modified testSeedFolder variable in the SeedBuilderTests to use the @engroot@ alias instead of @projectproductassets@/.. alias when referring to the LmbrCentral Gem source path Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated references to the Project Asset Cache in the PythonTests. Those tests no longer use the logic `azlmbr.paths.projectroot / "Cache" / "pc"` to retrieve a path to the cache root but instead the `azlmbr.paths.projectproductassets` constant Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Fixed the FileIO Deprecated Alias test on Windows Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Removing @projectsourceassets@ alias, as it is only used once. Updated the PhysX EditorSystemComponent.cpp to query the ProjectPath form the SettingsRegistry. Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Replaced @projectproductassets@ alias with @products@ Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Rollback changes to the PhysX EditorSystemComponent.cpp The changes to use the ProjectPath from the SettingsRegistry has been implemented in PR #4497 Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
169 lines
10 KiB
C++
169 lines
10 KiB
C++
/*
|
|
* 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
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AzCore/std/functional.h>
|
|
#include <AzCore/UnitTest/Mocks/MockFileIOBase.h>
|
|
|
|
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
|
|
#include <AzToolsFramework/Entity/SliceEditorEntityOwnershipServiceBus.h>
|
|
#include <AzToolsFramework/ToolsComponents/EditorComponentBase.h>
|
|
#include <AzToolsFramework/UnitTest/AzToolsFrameworkTestHelpers.h>
|
|
|
|
namespace UnitTest
|
|
{
|
|
class SliceStabilityTest
|
|
: public ToolsApplicationFixture,
|
|
public AzToolsFramework::AssetSystemRequestBus::Handler,
|
|
public AzToolsFramework::EditorRequestBus::Handler,
|
|
public AzToolsFramework::SliceEditorEntityOwnershipServiceNotificationBus::Handler
|
|
{
|
|
public:
|
|
//! Creates an entity within the EditorEntityContext and supplies it required components
|
|
//! @param entityName The name the created entity will use
|
|
//! @param entityList The created entity will be placed at the back of the provided entityList
|
|
//! @param parentId The EntityId to be assigned as the parent of the created entity.
|
|
//! Defaults to an invalid id
|
|
//! @return The EntityId of the created Entity, or an invalid id if operation failed
|
|
AZ::EntityId CreateEditorEntity(const char* entityName, AzToolsFramework::EntityIdList& entityList, const AZ::EntityId& parentId = AZ::EntityId());
|
|
|
|
//! Creates a new slice asset out of the provided entityList and generates the first slice instance using the provided entityList
|
|
//! @param sliceAssetName Name of the newly created slice Asset
|
|
//! @param entityList Created slice will be comprised of the entity hierarchy found in entityList
|
|
//! entities need to exist within the EditorEntityContext and those same entities will be promoted into the first slice instance of the created slice
|
|
//! @param sliceAddress The SliceInstanceAddress of the first slice instance generated out of the entities found in entityList
|
|
//! @return The AssetId of the newly created slice, or an invalid id if operation failed
|
|
AZ::Data::AssetId CreateSlice(AZStd::string sliceAssetName, AzToolsFramework::EntityIdList entityList, AZ::SliceComponent::SliceInstanceAddress& sliceAddress);
|
|
|
|
//! Pushes a set of entities to an existing slice asset generated via CreateSlice
|
|
//! @param sliceInstanceAddress An instance of the slice being pushed to
|
|
//! Note: The act of pushing to a slice destroys and remakes all existing instances sliceInstanceAddress will be updated to represent the remade slice instance.
|
|
//! Any copies of sliceInstanceAddress from before this operation are invalid.
|
|
//! @param entitiesToPush A list of entities to push to the slice.
|
|
//! If an entity in the list is already in the slice instance then it will be pushed as an updated entity
|
|
//! If an entity in the list is not in the slice instance then it will be pushed as an added entity
|
|
//! @return true if the push succeeded, or false if the operation failed
|
|
bool PushEntitiesToSlice(AZ::SliceComponent::SliceInstanceAddress& sliceInstanceAddress, const AzToolsFramework::EntityIdList& entitiesToPush);
|
|
|
|
//! Instantiates a slice into the EditorEntityContext using an existing slice Asset created via CreateSlice
|
|
//! @param sliceAssetId The asset id of the slice being instantiated
|
|
//! @param entityList All newly instantiated entities will be added to the back of entityList
|
|
//! @param parent The EntityId to be assigned as the parent of the slice instance entities.
|
|
//! Defaults to an invalid id
|
|
//! @return The SliceInstanceAddress of the new slice instance, or an invalid address if operation failed
|
|
AZ::SliceComponent::SliceInstanceAddress InstantiateEditorSlice(AZ::Data::AssetId sliceAssetId, AzToolsFramework::EntityIdList& entityList, const AZ::EntityId& parent = AZ::EntityId());
|
|
|
|
//! Performs a reparent of entity to newParent. Handles any slice hierarchy manipulation needed
|
|
//! @param entity The entity being reparented
|
|
//! @param newParent The new parent in the reparent operation
|
|
void ReparentEntity(AZ::EntityId& entity, const AZ::EntityId& newParent);
|
|
|
|
//! Helper that searches for an entityId within a list of entities
|
|
//! @param entityId The EntityId being searched for
|
|
//! @param entityList the list to search in
|
|
//! @return The Entity* whose EntityId matches entityId and is found in entityList.
|
|
//! Returns nullptr if not found
|
|
static AZ::Entity* FindEntityInList(const AZ::EntityId& entityId, const AZ::SliceComponent::EntityList& entityList);
|
|
|
|
//! Helper that searches for an entity within the EditorEntityContext
|
|
//! @param entityId The entityId being searched for
|
|
//! @return The Entity* whose id matches entityId and is found in the EditorEntityContext
|
|
//! Returns nullptr if not found
|
|
static AZ::Entity* FindEntityInEditor(const AZ::EntityId& entityId);
|
|
|
|
class SliceOperationValidator
|
|
{
|
|
public:
|
|
SliceOperationValidator();
|
|
~SliceOperationValidator();
|
|
void SetSerializeContext(AZ::SerializeContext* serializeContext);
|
|
|
|
//! Clones the provided entities out of the EditorEntityContext and caches them for Compare operations
|
|
//! @param entitiesToCapture List of EntityIDs that is used to search the EditorEntityContext and clone the respective Entity* into a cache for Compare operations
|
|
//! @return Returns whether the capture was successful
|
|
//! Can fail if there is already a cached capture or the entities could not be found in the EditorEntityContext
|
|
bool Capture(const AzToolsFramework::EntityIdList& entitiesToCapture);
|
|
|
|
//! Does a DataPatch compare of the reflected fields of a captured EntityList and the Instantiated entities found in instanceToCompare
|
|
//! @param instanceToCompare A SliceInstanceAddress whose InstantiatedContainer will be diffed against a previously captured EntityList using DataPatch
|
|
bool Compare(const AZ::SliceComponent::SliceInstanceAddress& instanceToCompare);
|
|
|
|
//! Resets the current capture so a new one can be made
|
|
void Reset();
|
|
private:
|
|
|
|
bool SortCapture(const AzToolsFramework::EntityList& orderToMatch);
|
|
|
|
AZ::SerializeContext* m_serializeContext;
|
|
AZ::SliceComponent::EntityList m_entityStateCapture;
|
|
};
|
|
|
|
class EntityReferenceComponent
|
|
: public AzToolsFramework::Components::EditorComponentBase
|
|
{
|
|
public:
|
|
AZ_EDITOR_COMPONENT(EntityReferenceComponent, "{3628F6A3-DFAD-4C1E-B9DE-EFBB1B6915C3}");
|
|
|
|
void Init() override {}
|
|
void Activate() override {}
|
|
void Deactivate() override {}
|
|
|
|
static void Reflect(AZ::ReflectContext* reflection);
|
|
|
|
AZ::EntityId m_entityReference;
|
|
};
|
|
SliceOperationValidator m_validator;
|
|
|
|
private:
|
|
|
|
void SetUpEditorFixtureImpl() override;
|
|
void TearDownEditorFixtureImpl() override;
|
|
|
|
/*
|
|
* SliceEditorEntityOwnershipServiceNotificationBus
|
|
*/
|
|
void OnSliceInstantiated(const AZ::Data::AssetId& sliceAssetId, AZ::SliceComponent::SliceInstanceAddress& sliceAddress, const AzFramework::SliceInstantiationTicket& ticket) override;
|
|
void OnSliceInstantiationFailed(const AZ::Data::AssetId& sliceAssetId, const AzFramework::SliceInstantiationTicket& ticket) override;
|
|
|
|
/*
|
|
* EditorRequestBus
|
|
*/
|
|
void CreateEditorRepresentation(AZ::Entity* entity) override;
|
|
void BrowseForAssets(AzToolsFramework::AssetBrowser::AssetSelectionModel& selection) override { AZ_UNUSED(selection); }
|
|
int GetIconTextureIdFromEntityIconPath(const AZStd::string& entityIconPath) override { AZ_UNUSED(entityIconPath); return 0; }
|
|
bool DisplayHelpersVisible() override { return false; }
|
|
|
|
/*
|
|
* AssetSystemRequestBus
|
|
*/
|
|
bool GetRelativeProductPathFromFullSourceOrProductPath([[maybe_unused]] const AZStd::string& fullPath, [[maybe_unused]] AZStd::string& relativeProductPath) override { return false; }
|
|
bool GenerateRelativeSourcePath(
|
|
[[maybe_unused]] const AZStd::string& sourcePath, [[maybe_unused]] AZStd::string& relativePath,
|
|
[[maybe_unused]] AZStd::string& watchFolder) override { return false; }
|
|
bool GetFullSourcePathFromRelativeProductPath([[maybe_unused]] const AZStd::string& relPath, [[maybe_unused]] AZStd::string& fullSourcePath) override { return false; }
|
|
bool GetAssetInfoById([[maybe_unused]] const AZ::Data::AssetId& assetId, [[maybe_unused]] const AZ::Data::AssetType& assetType, [[maybe_unused]] const AZStd::string& platformName, [[maybe_unused]] AZ::Data::AssetInfo& assetInfo, [[maybe_unused]] AZStd::string& rootFilePath) override { return false; }
|
|
bool GetSourceInfoBySourcePath(const char* sourcePath, AZ::Data::AssetInfo& assetInfo, AZStd::string& watchFolder) override;
|
|
bool GetSourceInfoBySourceUUID([[maybe_unused]] const AZ::Uuid& sourceUuid, [[maybe_unused]] AZ::Data::AssetInfo& assetInfo, [[maybe_unused]] AZStd::string& watchFolder) override { return false; }
|
|
bool GetScanFolders([[maybe_unused]] AZStd::vector<AZStd::string>& scanFolders) override { return false; }
|
|
bool GetAssetSafeFolders([[maybe_unused]] AZStd::vector<AZStd::string>& assetSafeFolders) override { return false; }
|
|
bool IsAssetPlatformEnabled([[maybe_unused]] const char* platform) override { return false; }
|
|
int GetPendingAssetsForPlatform([[maybe_unused]] const char* platform) override { return -1; }
|
|
bool GetAssetsProducedBySourceUUID([[maybe_unused]] const AZ::Uuid& sourceUuid, [[maybe_unused]] AZStd::vector<AZ::Data::AssetInfo>& productsAssetInfo) override { return false; }
|
|
|
|
AZStd::unique_ptr<testing::NiceMock<AZ::IO::MockFileIOBase>> m_fileIOMock;
|
|
AZ::IO::FileIOBase* m_priorFileIO = nullptr;
|
|
|
|
AZStd::unordered_map<AZ::Data::AssetId, AZStd::vector<AZ::SliceComponent::SliceInstanceAddress>> m_createdSlices;
|
|
AZ::Data::AssetId m_newSliceId;
|
|
AzFramework::SliceInstantiationTicket m_ticket;
|
|
|
|
static constexpr const char* m_relativeSourceAssetRoot = "Test/";
|
|
};
|
|
}
|