diff --git a/Code/Editor/Util/UndoUtil.h b/Code/Editor/Util/UndoUtil.h index f352eb317b..e825647f6b 100644 --- a/Code/Editor/Util/UndoUtil.h +++ b/Code/Editor/Util/UndoUtil.h @@ -31,7 +31,7 @@ public: static void Record(IUndoObject* undo); private: - static const uint32 scDescSize = 256; + static const AZ::u32 scDescSize = 256; char m_description[scDescSize]; bool m_bCancelled; bool m_bStartedRecord; diff --git a/Gems/AudioSystem/Code/Tests/AudioSystemEditorTest.cpp b/Gems/AudioSystem/Code/Tests/AudioSystemEditorTest.cpp index a486e24326..0debe128e2 100644 --- a/Gems/AudioSystem/Code/Tests/AudioSystemEditorTest.cpp +++ b/Gems/AudioSystem/Code/Tests/AudioSystemEditorTest.cpp @@ -10,54 +10,45 @@ #include #include +#include + #include #include -#include -#include -#include - using ::testing::NiceMock; using namespace AudioControls; namespace CustomMocks { - class AudioControlsEditorTest_CryPakMock - : public CryPakMock + class AudioControlsEditorTest_FileIOMock + : public AZ::IO::MockFileIOBase { public: - AZ_TEST_CLASS_ALLOCATOR(AudioControlsEditorTest_CryPakMock) + AZ_TEST_CLASS_ALLOCATOR(AudioControlsEditorTest_FileIOMock); - AudioControlsEditorTest_CryPakMock(const char* levelName) - : m_levelName(levelName) - {} - - AZ::IO::ArchiveFileIterator FindFirst([[maybe_unused]] AZStd::string_view dir, AZ::IO::IArchive::EFileSearchType) override + AudioControlsEditorTest_FileIOMock() { - AZ::IO::FileDesc fileDesc; - fileDesc.nSize = sizeof(AZ::IO::FileDesc); - // Add a filename and file description reference to the TestFindData map to make sure the file iterator is valid - m_findData = new TestFindData(); - m_findData->m_fileSet.emplace(AZ::IO::ArchiveFileIterator{ static_cast(m_findData.get()), m_levelName, fileDesc }); - return m_findData->Fetch(); } - AZ::IO::ArchiveFileIterator FindNext(AZ::IO::ArchiveFileIterator iter) override + bool IsDirectory([[maybe_unused]] const char* path) override { - return ++iter; + return false; } - // public: for easy resetting... - AZStd::string m_levelName; - - // Add an inherited FindData class to control the adding of a mapfile which indicates that a FileIterator is valid - struct TestFindData - : AZ::IO::FindData + AZ::IO::Result FindFiles( + [[maybe_unused]] const char* path, + [[maybe_unused]] const char* filter, + AZ::IO::FileIOBase::FindFilesCallbackType callback) override { - using AZ::IO::FindData::m_fileSet; - }; + if (callback) + { + callback(m_levelName.c_str()); + return AZ::IO::ResultCode::Success; + } + return AZ::IO::ResultCode::Error; + } - AZStd::intrusive_ptr m_findData; + AZStd::string m_levelName; }; } // namespace CustomMocks @@ -75,10 +66,6 @@ protected: void SetupEnvironment() override { m_allocatorScope.ActivateAllocators(); - - m_stubEnv.pCryPak = nullptr; - m_stubEnv.pFileIO = nullptr; - gEnv = &m_stubEnv; } void TeardownEnvironment() override @@ -87,30 +74,68 @@ protected: } private: - AZ::AllocatorScope m_allocatorScope; - SSystemGlobalEnvironment m_stubEnv; + AZ::AllocatorScope m_allocatorScope; }; AZ_UNIT_TEST_HOOK(new AudioControlsEditorTestEnvironment); -TEST(AudioControlsEditorTest, AudioControlsLoader_LoadScopes_ScopesAreAdded) +class AudioControlsEditorTest + : public ::testing::Test { - ASSERT_TRUE(gEnv != nullptr); - ASSERT_TRUE(gEnv->pCryPak == nullptr); +public: + void SetUp() override + { + // Store and remove the existing fileIO... + m_prevFileIO = AZ::IO::FileIOBase::GetInstance(); + if (m_prevFileIO) + { + AZ::IO::FileIOBase::SetInstance(nullptr); + } - NiceMock m_cryPakMock("ly_extension.ly"); - gEnv->pCryPak = &m_cryPakMock; + // Replace with a new FileIO Mock... + m_fileIO = AZStd::make_unique(); + AZ::IO::FileIOBase::SetInstance(m_fileIO.get()); + } + void TearDown() override + { + // Destroy our LocalFileIO... + m_fileIO.reset(); + + // Replace the old fileIO (set instance to null first)... + AZ::IO::FileIOBase::SetInstance(nullptr); + if (m_prevFileIO) + { + AZ::IO::FileIOBase::SetInstance(m_prevFileIO); + m_prevFileIO = nullptr; + } + } + +protected: + AZ::IO::FileIOBase* m_prevFileIO = nullptr; + AZStd::unique_ptr m_fileIO; +}; + +TEST_F(AudioControlsEditorTest, AudioControlsLoader_LoadScopes_ScopesAreAdded) +{ CATLControlsModel atlModel; CAudioControlsLoader loader(&atlModel, nullptr, nullptr); + m_fileIO->m_levelName = "ly_extension.ly"; loader.LoadScopes(); EXPECT_TRUE(atlModel.ScopeExists("ly_extension")); - m_cryPakMock.m_levelName = "cry_extension.cry"; + m_fileIO->m_levelName = "cry_extension.cry"; loader.LoadScopes(); EXPECT_TRUE(atlModel.ScopeExists("cry_extension")); + m_fileIO->m_levelName = "prefab_extension.prefab"; + loader.LoadScopes(); + EXPECT_TRUE(atlModel.ScopeExists("prefab_extension")); + + m_fileIO->m_levelName = "spawnable_extension.spawnable"; + loader.LoadScopes(); + EXPECT_FALSE(atlModel.ScopeExists("spawnable_extension")); + atlModel.ClearScopes(); - gEnv->pCryPak = nullptr; }