diff --git a/Code/Framework/AzCore/AzCore/UnitTest/Mocks/MockSettingsRegistry.h b/Code/Framework/AzCore/AzCore/UnitTest/Mocks/MockSettingsRegistry.h new file mode 100644 index 0000000000..f4abbd9867 --- /dev/null +++ b/Code/Framework/AzCore/AzCore/UnitTest/Mocks/MockSettingsRegistry.h @@ -0,0 +1,59 @@ +/* +* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +* its licensors. +* +* For complete copyright and license terms please see the LICENSE at the root of this +* distribution (the "License"). All use of this software is governed by the License, +* or, if provided, by the license below or the license accompanying this file. Do not +* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* +*/ +#pragma once + +#include +#include +#include + +namespace AZ +{ + class MockSettingsRegistry; + using NiceSettingsRegistrySimpleMock = ::testing::NiceMock; + + class MockSettingsRegistry + : public AZ::SettingsRegistryInterface + { + public: + MOCK_CONST_METHOD1(GetType, Type(AZStd::string_view)); + MOCK_CONST_METHOD2(Visit, bool(Visitor&, AZStd::string_view)); + MOCK_CONST_METHOD2(Visit, bool(const VisitorCallback&, AZStd::string_view)); + MOCK_METHOD1(RegisterNotifier, NotifyEventHandler(const NotifyCallback&)); + MOCK_METHOD1(RegisterNotifier, NotifyEventHandler(NotifyCallback&&)); + + MOCK_CONST_METHOD2(Get, bool(bool&, AZStd::string_view)); + MOCK_CONST_METHOD2(Get, bool(s64&, AZStd::string_view)); + MOCK_CONST_METHOD2(Get, bool(u64&, AZStd::string_view)); + MOCK_CONST_METHOD2(Get, bool(double&, AZStd::string_view)); + MOCK_CONST_METHOD2(Get, bool(AZStd::string&, AZStd::string_view)); + MOCK_CONST_METHOD2(Get, bool(FixedValueString&, AZStd::string_view)); + MOCK_CONST_METHOD3(GetObject, bool(void*, Uuid, AZStd::string_view)); + + MOCK_METHOD2(Set, bool(AZStd::string_view, bool)); + MOCK_METHOD2(Set, bool(AZStd::string_view, s64)); + MOCK_METHOD2(Set, bool(AZStd::string_view, u64)); + MOCK_METHOD2(Set, bool(AZStd::string_view, double)); + MOCK_METHOD2(Set, bool(AZStd::string_view, AZStd::string_view)); + MOCK_METHOD2(Set, bool(AZStd::string_view, const char*)); + MOCK_METHOD3(SetObject, bool(AZStd::string_view, const void*, Uuid)); + + MOCK_METHOD1(Remove, bool(AZStd::string_view)); + + MOCK_METHOD3(MergeCommandLineArgument, bool(AZStd::string_view, AZStd::string_view, const CommandLineArgumentSettings&)); + MOCK_METHOD2(MergeSettings, bool(AZStd::string_view, Format)); + MOCK_METHOD4(MergeSettingsFile, bool(AZStd::string_view, Format, AZStd::string_view, AZStd::vector*)); + MOCK_METHOD5( + MergeSettingsFolder, + bool(AZStd::string_view, const Specializations&, AZStd::string_view, AZStd::string_view, AZStd::vector*)); + }; +} // namespace AZ + diff --git a/Code/Framework/AzCore/AzCore/azcoretestcommon_files.cmake b/Code/Framework/AzCore/AzCore/azcoretestcommon_files.cmake index 86fb964197..a2ce93f68b 100644 --- a/Code/Framework/AzCore/AzCore/azcoretestcommon_files.cmake +++ b/Code/Framework/AzCore/AzCore/azcoretestcommon_files.cmake @@ -15,4 +15,5 @@ set(FILES UnitTest/UnitTest.h UnitTest/TestTypes.h UnitTest/Mocks/MockFileIOBase.h + UnitTest/Mocks/MockSettingsRegistry.h ) diff --git a/Code/Tools/SceneAPI/SceneCore/DllMain.cpp b/Code/Tools/SceneAPI/SceneCore/DllMain.cpp index 49cea83dff..52976f9e56 100644 --- a/Code/Tools/SceneAPI/SceneCore/DllMain.cpp +++ b/Code/Tools/SceneAPI/SceneCore/DllMain.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -168,6 +169,7 @@ namespace AZ context->Class()->Version(1); context->Class()->Version(1); context->Class()->Version(1); + context->Class()->Version(1); // Register graph data interfaces context->Class()->Version(1); context->Class()->Version(1); diff --git a/Code/Tools/SceneAPI/SceneData/Behaviors/ScriptProcessorRuleBehavior.h b/Code/Tools/SceneAPI/SceneData/Behaviors/ScriptProcessorRuleBehavior.h index 338f8d1896..b9cc17b99a 100644 --- a/Code/Tools/SceneAPI/SceneData/Behaviors/ScriptProcessorRuleBehavior.h +++ b/Code/Tools/SceneAPI/SceneData/Behaviors/ScriptProcessorRuleBehavior.h @@ -12,6 +12,7 @@ #pragma once +#include #include #include #include @@ -27,7 +28,7 @@ namespace AZ { namespace Behaviors { - class ScriptProcessorRuleBehavior + class SCENE_DATA_CLASS ScriptProcessorRuleBehavior : public SceneCore::BehaviorComponent , public Events::AssetImportRequestBus::Handler { @@ -36,12 +37,12 @@ namespace AZ ~ScriptProcessorRuleBehavior() override = default; - void Activate() override; - void Deactivate() override; + SCENE_DATA_API void Activate() override; + SCENE_DATA_API void Deactivate() override; static void Reflect(ReflectContext* context); // AssetImportRequestBus::Handler - Events::ProcessingResult UpdateManifest( + SCENE_DATA_API Events::ProcessingResult UpdateManifest( Containers::Scene& scene, ManifestAction action, RequestingApplication requester) override; diff --git a/Code/Tools/SceneAPI/SceneData/ManifestMetaInfoHandler.cpp b/Code/Tools/SceneAPI/SceneData/ManifestMetaInfoHandler.cpp index b7347c0c91..b01dc80d44 100644 --- a/Code/Tools/SceneAPI/SceneData/ManifestMetaInfoHandler.cpp +++ b/Code/Tools/SceneAPI/SceneData/ManifestMetaInfoHandler.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -55,7 +54,6 @@ namespace AZ { AZ_TraceContext("Object Type", target.RTTI_GetTypeName()); modifiers.push_back(SceneData::CommentRule::TYPEINFO_Uuid()); - modifiers.push_back(SceneData::ScriptProcessorRule::TYPEINFO_Uuid()); if (target.RTTI_IsTypeOf(DataTypes::IMeshGroup::TYPEINFO_Uuid())) { diff --git a/Code/Tools/SceneAPI/SceneData/Tests/SceneManifest/SceneManifestRuleTests.cpp b/Code/Tools/SceneAPI/SceneData/Tests/SceneManifest/SceneManifestRuleTests.cpp index 17a1b0d19a..a5994dd272 100644 --- a/Code/Tools/SceneAPI/SceneData/Tests/SceneManifest/SceneManifestRuleTests.cpp +++ b/Code/Tools/SceneAPI/SceneData/Tests/SceneManifest/SceneManifestRuleTests.cpp @@ -13,19 +13,23 @@ #include #include +#include +#include #include #include +#include +#include #include #include #include -#include #include +#include #include #include +#include #include #include -#include namespace AZ { @@ -94,6 +98,19 @@ namespace AZ m_jsonSystemComponent = AZStd::make_unique(); m_jsonSystemComponent->Reflect(m_jsonRegistrationContext.get()); + + m_data.reset(new DataMembers); + + using FixedValueString = AZ::SettingsRegistryInterface::FixedValueString; + + ON_CALL(m_data->m_settings, Get(::testing::Matcher(::testing::_), testing::_)) + .WillByDefault([](FixedValueString& value, AZStd::string_view) -> bool + { + value = "mock_path"; + return true; + }); + + AZ::SettingsRegistry::Register(&m_data->m_settings); } void TearDown() override @@ -106,9 +123,19 @@ namespace AZ m_jsonRegistrationContext.reset(); m_jsonSystemComponent.reset(); + AZ::SettingsRegistry::Unregister(&m_data->m_settings); + m_data.reset(); + AZ::NameDictionary::Destroy(); UnitTest::AllocatorsFixture::TearDown(); } + + struct DataMembers + { + AZ::NiceSettingsRegistrySimpleMock m_settings; + }; + + AZStd::unique_ptr m_data; }; TEST_F(SceneManifest_JSON, LoadFromString_BlankManifest_HasDefaultParts) @@ -223,5 +250,30 @@ namespace AZ EXPECT_THAT(jsonText.c_str(), ::testing::HasSubstr(R"(3.0)")); EXPECT_THAT(jsonText.c_str(), ::testing::HasSubstr(R"("scale": 10.0)")); } + + TEST_F(SceneManifest_JSON, ScriptProcessorRule_LoadWithEmptyScriptFilename_ReturnsEarly) + { + using namespace SceneAPI::Containers; + using namespace SceneAPI::Events; + + constexpr const char* jsonManifest = { R"JSON( + { + "values": [ + { + "$type": "ScriptProcessorRule", + "scriptFilename": "" + } + ] + })JSON" }; + + auto scene = AZ::SceneAPI::Containers::Scene("mock"); + auto result = scene.GetManifest().LoadFromString(jsonManifest, m_serializeContext.get(), m_jsonRegistrationContext.get()); + EXPECT_TRUE(result.IsSuccess()); + EXPECT_FALSE(scene.GetManifest().IsEmpty()); + + auto scriptProcessorRuleBehavior = AZ::SceneAPI::Behaviors::ScriptProcessorRuleBehavior(); + auto update = scriptProcessorRuleBehavior.UpdateManifest(scene, AssetImportRequest::Update, AssetImportRequest::Generic); + EXPECT_EQ(update, ProcessingResult::Ignored); + } } } diff --git a/cmake/3rdParty.cmake b/cmake/3rdParty.cmake index b6731ae239..d1b1fe7cc6 100644 --- a/cmake/3rdParty.cmake +++ b/cmake/3rdParty.cmake @@ -21,8 +21,6 @@ if(NOT EXISTS ${LY_3RDPARTY_PATH}/3rdParty.txt) message(FATAL_ERROR "3rdParty.txt not found in ${LY_3RDPARTY_PATH}, call cmake defining a valid LY_3RDPARTY_PATH or use cmake-gui to configure it") endif() -include(CMakeParseArguments) - #! ly_add_external_target_path: adds a path to module path so 3rdparty Find files can be added from paths different than cmake/3rdParty # # \arg:PATH path to add diff --git a/cmake/LYWrappers.cmake b/cmake/LYWrappers.cmake index 25465ce69c..bd904adaa3 100644 --- a/cmake/LYWrappers.cmake +++ b/cmake/LYWrappers.cmake @@ -12,7 +12,6 @@ set(LY_UNITY_BUILD OFF CACHE BOOL "UNITY builds") include(CMakeFindDependencyMacro) -include(CMakeParseArguments) include(cmake/LyAutoGen.cmake) ly_get_absolute_pal_filename(pal_dir ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Platform/${PAL_PLATFORM_NAME})