Merge pull request #6172 from aws-lumberyard-dev/Prism/RefactorProjectSettings
Refactor Project Manager Settingsmonroegm-disable-blank-issue-2
commit
ae3dedfe59
@ -1,59 +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
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ProjectManagerSettings.h>
|
||||
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <AzCore/IO/ByteContainerStream.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
void SaveProjectManagerSettings()
|
||||
{
|
||||
auto settingsRegistry = AZ::SettingsRegistry::Get();
|
||||
AZ::SettingsRegistryMergeUtils::DumperSettings dumperSettings;
|
||||
dumperSettings.m_prettifyOutput = true;
|
||||
dumperSettings.m_jsonPointerPrefix = ProjectManagerKeyPrefix;
|
||||
|
||||
AZStd::string stringBuffer;
|
||||
AZ::IO::ByteContainerStream stringStream(&stringBuffer);
|
||||
if (!AZ::SettingsRegistryMergeUtils::DumpSettingsRegistryToStream(
|
||||
*settingsRegistry, ProjectManagerKeyPrefix, stringStream, dumperSettings))
|
||||
{
|
||||
AZ_Warning("ProjectManager", false, "Could not save Project Manager settings to stream");
|
||||
return;
|
||||
}
|
||||
|
||||
AZ::IO::FixedMaxPath o3deUserPath = AZ::Utils::GetO3deManifestDirectory();
|
||||
o3deUserPath /= AZ::SettingsRegistryInterface::RegistryFolder;
|
||||
o3deUserPath /= "ProjectManager.setreg";
|
||||
|
||||
bool saved = false;
|
||||
constexpr auto configurationMode =
|
||||
AZ::IO::SystemFile::SF_OPEN_CREATE | AZ::IO::SystemFile::SF_OPEN_CREATE_PATH | AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY;
|
||||
|
||||
AZ::IO::SystemFile outputFile;
|
||||
if (outputFile.Open(o3deUserPath.c_str(), configurationMode))
|
||||
{
|
||||
saved = outputFile.Write(stringBuffer.data(), stringBuffer.size()) == stringBuffer.size();
|
||||
}
|
||||
|
||||
AZ_Warning("ProjectManager", saved, "Unable to save Project Manager registry file to path: %s", o3deUserPath.c_str());
|
||||
}
|
||||
|
||||
QString GetProjectBuiltSuccessfullyKey(const QString& projectName)
|
||||
{
|
||||
return QString("%1/Projects/%2/BuiltSuccessfully").arg(ProjectManagerKeyPrefix).arg(projectName);
|
||||
}
|
||||
|
||||
QString GetExternalLinkWarningKey()
|
||||
{
|
||||
return QString("%1/SkipExternalLinkWarning").arg(ProjectManagerKeyPrefix);
|
||||
}
|
||||
}
|
||||
@ -1,22 +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
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <QString>
|
||||
#endif
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
static constexpr char ProjectManagerKeyPrefix[] = "/O3DE/ProjectManager";
|
||||
|
||||
void SaveProjectManagerSettings();
|
||||
QString GetProjectBuiltSuccessfullyKey(const QString& projectName);
|
||||
QString GetExternalLinkWarningKey();
|
||||
}
|
||||
@ -0,0 +1,187 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Settings.h>
|
||||
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <AzCore/IO/ByteContainerStream.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
Settings::Settings(bool saveToDisk)
|
||||
: m_saveToDisk(saveToDisk)
|
||||
{
|
||||
m_settingsRegistry = AZ::SettingsRegistry::Get();
|
||||
|
||||
AZ_Assert(m_settingsRegistry, "Failed to create Settings");
|
||||
}
|
||||
|
||||
void Settings::Save()
|
||||
{
|
||||
AZ::SettingsRegistryMergeUtils::DumperSettings dumperSettings;
|
||||
dumperSettings.m_prettifyOutput = true;
|
||||
dumperSettings.m_jsonPointerPrefix = ProjectManagerKeyPrefix;
|
||||
|
||||
AZStd::string stringBuffer;
|
||||
AZ::IO::ByteContainerStream stringStream(&stringBuffer);
|
||||
if (!AZ::SettingsRegistryMergeUtils::DumpSettingsRegistryToStream(
|
||||
*m_settingsRegistry, ProjectManagerKeyPrefix, stringStream, dumperSettings))
|
||||
{
|
||||
AZ_Warning("ProjectManager", false, "Could not save Project Manager settings to stream");
|
||||
return;
|
||||
}
|
||||
|
||||
AZ::IO::FixedMaxPath o3deUserPath = AZ::Utils::GetO3deManifestDirectory();
|
||||
o3deUserPath /= AZ::SettingsRegistryInterface::RegistryFolder;
|
||||
o3deUserPath /= "ProjectManager.setreg";
|
||||
|
||||
bool saved = false;
|
||||
constexpr auto configurationMode =
|
||||
AZ::IO::SystemFile::SF_OPEN_CREATE | AZ::IO::SystemFile::SF_OPEN_CREATE_PATH | AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY;
|
||||
|
||||
AZ::IO::SystemFile outputFile;
|
||||
if (outputFile.Open(o3deUserPath.c_str(), configurationMode))
|
||||
{
|
||||
saved = outputFile.Write(stringBuffer.data(), stringBuffer.size()) == stringBuffer.size();
|
||||
}
|
||||
|
||||
AZ_Warning("ProjectManager", saved, "Unable to save Project Manager registry file to path: %s", o3deUserPath.c_str());
|
||||
}
|
||||
|
||||
void Settings::OnSettingsChanged()
|
||||
{
|
||||
if (m_saveToDisk)
|
||||
{
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
bool Settings::Get(QString& result, const QString& settingsKey)
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
AZStd::string settingsValue;
|
||||
success = m_settingsRegistry->Get(settingsValue, settingsKey.toStdString().c_str());
|
||||
|
||||
result = settingsValue.c_str();
|
||||
return success;
|
||||
}
|
||||
|
||||
bool Settings::Get(bool& result, const QString& settingsKey)
|
||||
{
|
||||
return m_settingsRegistry->Get(result, settingsKey.toStdString().c_str());
|
||||
}
|
||||
|
||||
bool Settings::Set(const QString& settingsKey, const QString& settingsValue)
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
success = m_settingsRegistry->Set(settingsKey.toStdString().c_str(), settingsValue.toStdString().c_str());
|
||||
OnSettingsChanged();
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool Settings::Set(const QString& settingsKey, bool settingsValue)
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
success = m_settingsRegistry->Set(settingsKey.toStdString().c_str(), settingsValue);
|
||||
OnSettingsChanged();
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool Settings::Remove(const QString& settingsKey)
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
success = m_settingsRegistry->Remove(settingsKey.toStdString().c_str());
|
||||
OnSettingsChanged();
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool Settings::Copy(const QString& settingsKeyOrig, const QString& settingsKeyDest, bool removeOrig)
|
||||
{
|
||||
bool success = false;
|
||||
AZStd::string settingsValue;
|
||||
|
||||
success = m_settingsRegistry->Get(settingsValue, settingsKeyOrig.toStdString().c_str());
|
||||
|
||||
if (success)
|
||||
{
|
||||
success = m_settingsRegistry->Set(settingsKeyDest.toStdString().c_str(), settingsValue);
|
||||
if (success)
|
||||
{
|
||||
if (removeOrig)
|
||||
{
|
||||
success = m_settingsRegistry->Remove(settingsKeyOrig.toStdString().c_str());
|
||||
}
|
||||
OnSettingsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
QString Settings::GetProjectKey(const ProjectInfo& projectInfo)
|
||||
{
|
||||
return QString("%1/Projects/%2/%3").arg(ProjectManagerKeyPrefix, projectInfo.m_id, projectInfo.m_projectName);
|
||||
}
|
||||
|
||||
bool Settings::GetBuiltSuccessfullyPaths(AZStd::set<AZStd::string>& result)
|
||||
{
|
||||
return m_settingsRegistry->GetObject<AZStd::set<AZStd::string>>(result, ProjectsBuiltSuccessfullyKey);
|
||||
}
|
||||
|
||||
bool Settings::GetProjectBuiltSuccessfully(bool& result, const ProjectInfo& projectInfo)
|
||||
{
|
||||
AZStd::set<AZStd::string> builtPathsResult;
|
||||
bool success = GetBuiltSuccessfullyPaths(builtPathsResult);
|
||||
|
||||
// Check if buildPath is listed as successfully built
|
||||
AZStd::string projectPath = projectInfo.m_path.toStdString().c_str();
|
||||
if (builtPathsResult.contains(projectPath))
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
// No project built statuses known
|
||||
else
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool Settings::SetProjectBuiltSuccessfully(const ProjectInfo& projectInfo, bool successfullyBuilt)
|
||||
{
|
||||
AZStd::set<AZStd::string> builtPathsResult;
|
||||
bool success = GetBuiltSuccessfullyPaths(builtPathsResult);
|
||||
|
||||
AZStd::string projectPath = projectInfo.m_path.toStdString().c_str();
|
||||
if (successfullyBuilt)
|
||||
{
|
||||
//Add successfully built path to set
|
||||
builtPathsResult.insert(projectPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Remove unsuccessfully built path from set
|
||||
builtPathsResult.erase(projectPath);
|
||||
}
|
||||
|
||||
success = m_settingsRegistry->SetObject<AZStd::set<AZStd::string>>(ProjectsBuiltSuccessfullyKey, builtPathsResult);
|
||||
OnSettingsChanged();
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
} // namespace O3DE::ProjectManager
|
||||
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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 <SettingsInterface.h>
|
||||
|
||||
#include <AzCore/std/string/string.h>
|
||||
#include <AzCore/std/containers/set.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
class SettingsRegistryInterface;
|
||||
}
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
class Settings
|
||||
: public SettingsInterface::Registrar
|
||||
{
|
||||
public:
|
||||
Settings(bool saveToDisk = true);
|
||||
|
||||
bool Get(QString& result, const QString& settingsKey) override;
|
||||
bool Get(bool& result, const QString& settingsKey) override;
|
||||
bool Set(const QString& settingsKey, const QString& settingsValue) override;
|
||||
bool Set(const QString& settingsKey, bool settingsValue) override;
|
||||
bool Remove(const QString& settingsKey) override;
|
||||
bool Copy(const QString& settingsKeyOrig, const QString& settingsKeyDest, bool removeOrig = false) override;
|
||||
|
||||
QString GetProjectKey(const ProjectInfo& projectInfo) override;
|
||||
|
||||
bool GetProjectBuiltSuccessfully(bool& result, const ProjectInfo& projectInfo) override;
|
||||
bool SetProjectBuiltSuccessfully(const ProjectInfo& projectInfo, bool successfullyBuilt) override;
|
||||
|
||||
private:
|
||||
void Save();
|
||||
void OnSettingsChanged();
|
||||
|
||||
bool GetBuiltSuccessfullyPaths(AZStd::set<AZStd::string>& result);
|
||||
|
||||
bool m_saveToDisk;
|
||||
AZ::SettingsRegistryInterface* m_settingsRegistry = nullptr;
|
||||
};
|
||||
} // namespace O3DE::ProjectManager
|
||||
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* 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 <ProjectInfo.h>
|
||||
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
//! Interface used to interact with the settings functions
|
||||
class ISettings
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(O3DE::ProjectManager::ISettings, "{95D87D95-0E04-462F-8B0B-ED15C0A9F090}");
|
||||
AZ_DISABLE_COPY_MOVE(ISettings);
|
||||
|
||||
static constexpr char ProjectManagerKeyPrefix[] = "/O3DE/ProjectManager";
|
||||
static constexpr char ExternalLinkWarningKey[] = "/O3DE/ProjectManager/SkipExternalLinkWarning";
|
||||
static constexpr char ProjectsBuiltSuccessfullyKey[] = "/O3DE/ProjectManager/SuccessfulBuildPaths";
|
||||
|
||||
ISettings() = default;
|
||||
virtual ~ISettings() = default;
|
||||
|
||||
/**
|
||||
* Get the value for a string settings key
|
||||
* @param result Store string result in this variable
|
||||
* @param settingsKey The key to get the value in
|
||||
* @return true if all calls to settings registry were successful
|
||||
*/
|
||||
virtual bool Get(QString& result, const QString& settingsKey) = 0;
|
||||
/**
|
||||
* Get the value for a bool settings key
|
||||
* @param result Store bool result in this variable
|
||||
* @param settingsKey The key to get the value in
|
||||
* @return true if all calls to settings registry were successful
|
||||
*/
|
||||
virtual bool Get(bool& result, const QString& settingsKey) = 0;
|
||||
|
||||
/**
|
||||
* Set the value for a string settings key
|
||||
* @param settingsKey The key to set the value in
|
||||
* @param settingsValue String value to set key to
|
||||
* @return true if all calls to settings registry were successful
|
||||
*/
|
||||
virtual bool Set(const QString& settingsKey, const QString& settingsValue) = 0;
|
||||
/**
|
||||
* Set the value for a bool settings key
|
||||
* @param settingsKey The key to set the value in
|
||||
* @param settingsValue Bool value to set key to
|
||||
* @return true if all calls to settings registry were successful
|
||||
*/
|
||||
virtual bool Set(const QString& settingsKey, bool settingsValue) = 0;
|
||||
|
||||
/**
|
||||
* Remove settings key
|
||||
* @param settingsKey The key to remove
|
||||
* @return true if all calls to settings registry were successful
|
||||
*/
|
||||
virtual bool Remove(const QString& settingsKey) = 0;
|
||||
|
||||
/**
|
||||
* Copy the string settings value from one key to another
|
||||
* @param settingsKeyOrig The original key to copy from
|
||||
* @param settingsKeyDest The destination key to copy to
|
||||
* @param removeOrig(Optional) Delete the original key if true
|
||||
* @return true if all calls to settings registry were successful
|
||||
*/
|
||||
virtual bool Copy(const QString& settingsKeyOrig, const QString& settingsKeyDest, bool removeOrig = false) = 0;
|
||||
|
||||
/**
|
||||
* Generate prefix for project settings key
|
||||
* @param projectInfo Project for settings key
|
||||
* @return QString Prefix for project specific settings key
|
||||
*/
|
||||
virtual QString GetProjectKey(const ProjectInfo& projectInfo) = 0;
|
||||
|
||||
/**
|
||||
* Get the build status for a project
|
||||
* @param result Store bool build status in this variable
|
||||
* @param projectInfo Project to check built status for
|
||||
* @return true if all calls to settings registry were successful
|
||||
*/
|
||||
virtual bool GetProjectBuiltSuccessfully(bool& result, const ProjectInfo& projectInfo) = 0;
|
||||
/**
|
||||
* Set the build status for a project
|
||||
* @param projectInfo Project to set built status for
|
||||
* @param successfullyBuilt Bool value to set build status to
|
||||
* @return true if all calls to settings registry were successful
|
||||
*/
|
||||
virtual bool SetProjectBuiltSuccessfully(const ProjectInfo& projectInfo, bool successfullyBuilt) = 0;
|
||||
};
|
||||
|
||||
using SettingsInterface = AZ::Interface<ISettings>;
|
||||
} // namespace O3DE::ProjectManager
|
||||
@ -0,0 +1,184 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/Serialization/Json/RegistrationContext.h>
|
||||
#include <AzCore/Settings/SettingsRegistryImpl.h>
|
||||
#include <AzCore/Serialization/Json/JsonSystemComponent.h>
|
||||
#include <AzCore/UnitTest/TestTypes.h>
|
||||
#include <AzTest/Utils.h>
|
||||
|
||||
#include <Settings.h>
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
class SettingsTests
|
||||
: public ::UnitTest::ScopedAllocatorSetupFixture
|
||||
{
|
||||
public:
|
||||
~SettingsTests() override = default;
|
||||
void SetUp() override
|
||||
{
|
||||
UnitTest::ScopedAllocatorSetupFixture::SetUp();
|
||||
|
||||
m_registry = AZStd::make_unique<AZ::SettingsRegistryImpl>();
|
||||
// Store off the old global settings registry to restore after each test
|
||||
m_oldSettingsRegistry = AZ::SettingsRegistry::Get();
|
||||
if (m_oldSettingsRegistry != nullptr)
|
||||
{
|
||||
AZ::SettingsRegistry::Unregister(m_oldSettingsRegistry);
|
||||
}
|
||||
AZ::SettingsRegistry::Register(m_registry.get());
|
||||
|
||||
m_serializeContext = AZStd::make_unique<AZ::SerializeContext>();
|
||||
m_registrationContext = AZStd::make_unique<AZ::JsonRegistrationContext>();
|
||||
|
||||
m_registry->SetContext(m_serializeContext.get());
|
||||
m_registry->SetContext(m_registrationContext.get());
|
||||
|
||||
AZ::JsonSystemComponent::Reflect(m_registrationContext.get());
|
||||
|
||||
m_serializeContext->RegisterGenericType<AZStd::set<AZStd::string>>();
|
||||
|
||||
m_settings = AZStd::make_unique<Settings>(/*saveToDisk*/ false);
|
||||
|
||||
m_projectInfo.m_path = "Z:/ProjectTestPath";
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
m_settings.reset();
|
||||
|
||||
m_registrationContext->EnableRemoveReflection();
|
||||
AZ::JsonSystemComponent::Reflect(m_registrationContext.get());
|
||||
m_registrationContext->DisableRemoveReflection();
|
||||
|
||||
m_registrationContext.reset();
|
||||
m_serializeContext.reset();
|
||||
|
||||
// Restore the old global settings registry
|
||||
AZ::SettingsRegistry::Unregister(m_registry.get());
|
||||
if (m_oldSettingsRegistry != nullptr)
|
||||
{
|
||||
AZ::SettingsRegistry::Register(m_oldSettingsRegistry);
|
||||
m_oldSettingsRegistry = nullptr;
|
||||
}
|
||||
m_registry.reset();
|
||||
|
||||
UnitTest::ScopedAllocatorSetupFixture::TearDown();
|
||||
}
|
||||
|
||||
protected:
|
||||
AZStd::unique_ptr<Settings> m_settings;
|
||||
const QString m_settingsPath = "/Testing/TestKey";
|
||||
const QString m_newSettingsPath = "/Testing/NewTestKey";
|
||||
ProjectInfo m_projectInfo;
|
||||
|
||||
private:
|
||||
AZ::SettingsRegistryInterface* m_oldSettingsRegistry = nullptr;
|
||||
AZStd::unique_ptr<AZ::SettingsRegistryImpl> m_registry;
|
||||
AZStd::unique_ptr<AZ::SerializeContext> m_serializeContext;
|
||||
AZStd::unique_ptr<AZ::JsonRegistrationContext> m_registrationContext;
|
||||
};
|
||||
|
||||
TEST_F(SettingsTests, Settings_GetUnsetPathBool_ReturnsFalse)
|
||||
{
|
||||
bool settingsResult = false;
|
||||
EXPECT_FALSE(m_settings->Get(settingsResult, m_settingsPath));
|
||||
EXPECT_FALSE(settingsResult);
|
||||
}
|
||||
|
||||
TEST_F(SettingsTests, Settings_SetAndGetValueBool_Success)
|
||||
{
|
||||
bool settingsResult = false;
|
||||
EXPECT_FALSE(m_settings->Get(settingsResult, m_settingsPath));
|
||||
|
||||
EXPECT_TRUE(m_settings->Set(m_settingsPath, true));
|
||||
|
||||
settingsResult = false;
|
||||
EXPECT_TRUE(m_settings->Get(settingsResult, m_settingsPath));
|
||||
EXPECT_TRUE(settingsResult);
|
||||
}
|
||||
|
||||
TEST_F(SettingsTests, Settings_GetUnsetPathString_ReturnsFalse)
|
||||
{
|
||||
QString settingsResult;
|
||||
EXPECT_FALSE(m_settings->Get(settingsResult, m_settingsPath));
|
||||
EXPECT_TRUE(settingsResult.isEmpty());
|
||||
}
|
||||
|
||||
TEST_F(SettingsTests, Settings_SetAndGetValueString_Success)
|
||||
{
|
||||
QString settingsResult;
|
||||
EXPECT_FALSE(m_settings->Get(settingsResult, m_settingsPath));
|
||||
|
||||
QString settingsValue = "TestValue";
|
||||
|
||||
EXPECT_TRUE(m_settings->Set(m_settingsPath, settingsValue));
|
||||
|
||||
EXPECT_TRUE(m_settings->Get(settingsResult, m_settingsPath));
|
||||
EXPECT_TRUE(settingsResult == settingsValue);
|
||||
}
|
||||
|
||||
TEST_F(SettingsTests, Settings_CopyStringRemoveOriginal_SuccessAndRemovesOriginal)
|
||||
{
|
||||
QString settingsResult;
|
||||
EXPECT_FALSE(m_settings->Get(settingsResult, m_newSettingsPath));
|
||||
|
||||
QString settingsValue = "TestValue";
|
||||
|
||||
EXPECT_TRUE(m_settings->Set(m_settingsPath, settingsValue));
|
||||
|
||||
EXPECT_TRUE(m_settings->Copy(m_settingsPath, m_newSettingsPath, /*removeOrig*/ true));
|
||||
|
||||
// Check that old path value is removed
|
||||
EXPECT_FALSE(m_settings->Get(settingsResult, m_settingsPath));
|
||||
|
||||
EXPECT_TRUE(m_settings->Get(settingsResult, m_newSettingsPath));
|
||||
EXPECT_TRUE(settingsResult == settingsValue);
|
||||
}
|
||||
|
||||
TEST_F(SettingsTests, Settings_RemoveProjectManagerKey_RemovesKey)
|
||||
{
|
||||
QString settingsResult;
|
||||
EXPECT_FALSE(m_settings->Get(settingsResult, m_settingsPath));
|
||||
|
||||
QString settingsValue = "TestValue";
|
||||
|
||||
EXPECT_TRUE(m_settings->Set(m_settingsPath, settingsValue));
|
||||
EXPECT_TRUE(m_settings->Get(settingsResult, m_settingsPath));
|
||||
|
||||
EXPECT_TRUE(m_settings->Remove(m_settingsPath));
|
||||
EXPECT_FALSE(m_settings->Get(settingsResult, m_settingsPath));
|
||||
}
|
||||
|
||||
TEST_F(SettingsTests, Settings_GetUnsetBuildPath_ReturnsFalse)
|
||||
{
|
||||
bool buildResult = true;
|
||||
EXPECT_FALSE(m_settings->GetProjectBuiltSuccessfully(buildResult, m_projectInfo));
|
||||
EXPECT_FALSE(buildResult);
|
||||
}
|
||||
|
||||
TEST_F(SettingsTests, Settings_SetProjectBuiltSuccessfully_ReturnsTrue)
|
||||
{
|
||||
EXPECT_TRUE(m_settings->SetProjectBuiltSuccessfully(m_projectInfo, true));
|
||||
|
||||
bool buildResult = false;
|
||||
EXPECT_TRUE(m_settings->GetProjectBuiltSuccessfully(buildResult, m_projectInfo));
|
||||
EXPECT_TRUE(buildResult);
|
||||
}
|
||||
|
||||
TEST_F(SettingsTests, Settings_SetProjectBuiltUnsuccessfully_ReturnsFalse)
|
||||
{
|
||||
EXPECT_TRUE(m_settings->SetProjectBuiltSuccessfully(m_projectInfo, false));
|
||||
|
||||
bool buildResult = false;
|
||||
EXPECT_TRUE(m_settings->GetProjectBuiltSuccessfully(buildResult, m_projectInfo));
|
||||
EXPECT_FALSE(buildResult);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue