Merge branch 'development' into cmake/SPEC-2513_w4018
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> # Conflicts: # Gems/EMotionFX/Code/EMotionFX/Source/Actor.cpp
This commit is contained in:
@@ -44,6 +44,22 @@ namespace AZ
|
||||
return &out;
|
||||
}
|
||||
|
||||
void SetPerspectiveMatrixFOV(Matrix4x4& out, float fovY, float aspectRatio)
|
||||
{
|
||||
float sinFov, cosFov;
|
||||
SinCos(0.5f * fovY, sinFov, cosFov);
|
||||
float yScale = cosFov / sinFov; //cot(fovY/2)
|
||||
float xScale = yScale / aspectRatio;
|
||||
|
||||
out.SetElement(0, 0, xScale);
|
||||
out.SetElement(1, 1, yScale);
|
||||
}
|
||||
|
||||
float GetPerspectiveMatrixFOV(const Matrix4x4& m)
|
||||
{
|
||||
return 2.0 * AZStd::atan(1.0f / m.GetElement(1, 1));
|
||||
}
|
||||
|
||||
Matrix4x4* MakeFrustumMatrixRH(Matrix4x4& out, float left, float right, float bottom, float top, float nearDist, float farDist, bool reverseDepth)
|
||||
{
|
||||
AZ_Assert(right > left, "right should be greater than left");
|
||||
|
||||
@@ -64,4 +64,8 @@ namespace AZ
|
||||
//! Transforms a position by a matrix. This function can be used with any generic cases which include projection matrices.
|
||||
Vector3 MatrixTransformPosition(const Matrix4x4& matrix, const Vector3& inPosition);
|
||||
|
||||
|
||||
void SetPerspectiveMatrixFOV(Matrix4x4& out, float fovY, float aspectRatio);
|
||||
float GetPerspectiveMatrixFOV(const Matrix4x4& m);
|
||||
|
||||
} // namespace AZ
|
||||
|
||||
@@ -27,11 +27,10 @@ namespace AZ
|
||||
struct AllocationInfo
|
||||
{
|
||||
size_t m_byteSize{};
|
||||
unsigned int m_alignment{};
|
||||
const char* m_name{};
|
||||
|
||||
const char* m_fileName{};
|
||||
int m_lineNum{};
|
||||
unsigned int m_alignment{};
|
||||
void* m_namesBlock{}; ///< Memory block if m_name and m_fileName have been allocated specifically for this allocation record
|
||||
size_t m_namesBlockSize{};
|
||||
|
||||
@@ -41,7 +40,7 @@ namespace AZ
|
||||
};
|
||||
|
||||
// We use OSAllocator which uses system calls to allocate memory, they are not recorded or tracked!
|
||||
typedef AZStd::unordered_map<void*, AllocationInfo, AZStd::hash<void*>, AZStd::equal_to<void*>, OSStdAllocator> AllocationRecordsType;
|
||||
using AllocationRecordsType = AZStd::unordered_map<void*, AllocationInfo, AZStd::hash<void*>, AZStd::equal_to<void*>, OSStdAllocator>;
|
||||
|
||||
/**
|
||||
* Records enumeration callback
|
||||
@@ -50,7 +49,7 @@ namespace AZ
|
||||
* \param unsigned char number of stack records/levels, if AllocationInfo::m_stackFrames != NULL.
|
||||
* \returns true if you want to continue traverse of the records and false if you want to stop.
|
||||
*/
|
||||
typedef AZStd::function<bool (void*, const AllocationInfo&, unsigned char)> AllocationInfoCBType;
|
||||
using AllocationInfoCBType = AZStd::function<bool (void*, const AllocationInfo&, unsigned char)>;
|
||||
/**
|
||||
* Example of records enumeration callback.
|
||||
*/
|
||||
|
||||
@@ -31,7 +31,6 @@ namespace AZ
|
||||
ScriptPropertyGenericClassArray::Reflect(reflection);
|
||||
|
||||
ScriptPropertyAsset::Reflect(reflection);
|
||||
ScriptPropertyEntityRef::Reflect(reflection);
|
||||
}
|
||||
|
||||
template<class Iterator>
|
||||
@@ -1358,53 +1357,4 @@ namespace AZ
|
||||
m_value = assetProperty->m_value;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
// ScriptPropertyEntityRef
|
||||
////////////////////////////
|
||||
void ScriptPropertyEntityRef::Reflect(AZ::ReflectContext* reflection)
|
||||
{
|
||||
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(reflection);
|
||||
|
||||
if (serializeContext)
|
||||
{
|
||||
serializeContext->Class<AZ::ScriptPropertyEntityRef, AZ::ScriptProperty>()->
|
||||
Version(1)->
|
||||
Field("value", &AZ::ScriptPropertyEntityRef::m_value);
|
||||
}
|
||||
}
|
||||
|
||||
const AZ::Uuid& ScriptPropertyEntityRef::GetDataTypeUuid() const
|
||||
{
|
||||
return AZ::SerializeTypeInfo<AZ::EntityId>::GetUuid();
|
||||
}
|
||||
|
||||
bool ScriptPropertyEntityRef::DoesTypeMatch(AZ::ScriptDataContext& context, int valueIndex) const
|
||||
{
|
||||
return context.IsRegisteredClass(valueIndex);
|
||||
}
|
||||
|
||||
AZ::ScriptPropertyEntityRef* ScriptPropertyEntityRef::Clone(const char* name) const
|
||||
{
|
||||
AZ::ScriptPropertyEntityRef* clonedValue = aznew AZ::ScriptPropertyEntityRef(name ? name : m_name.c_str());
|
||||
clonedValue->m_value = m_value;
|
||||
return clonedValue;
|
||||
}
|
||||
|
||||
bool ScriptPropertyEntityRef::Write(AZ::ScriptContext& context)
|
||||
{
|
||||
AZ::ScriptValue<AZ::EntityId>::StackPush(context.NativeContext(), m_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ScriptPropertyEntityRef::CloneDataFrom(const AZ::ScriptProperty* scriptProperty)
|
||||
{
|
||||
const AZ::ScriptPropertyEntityRef* entityProperty = azrtti_cast<const AZ::ScriptPropertyEntityRef*>(scriptProperty);
|
||||
|
||||
AZ_Error("ScriptPropertyEntityRef", entityProperty, "Invalid call to CloneData. Types must match before clone attempt is made.\n");
|
||||
if (entityProperty)
|
||||
{
|
||||
m_value = entityProperty->m_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,34 +488,6 @@ namespace AZ
|
||||
protected:
|
||||
void CloneDataFrom(const AZ::ScriptProperty* scriptProperty) override;
|
||||
};
|
||||
|
||||
class ScriptPropertyEntityRef
|
||||
: public ScriptProperty
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(ScriptPropertyEntityRef, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(AZ::ScriptPropertyEntityRef, "{68EDE6C3-0A89-4C50-A86E-06C058C9F862}", ScriptProperty);
|
||||
|
||||
static void Reflect(AZ::ReflectContext* reflection);
|
||||
|
||||
ScriptPropertyEntityRef() {}
|
||||
ScriptPropertyEntityRef(const char* name)
|
||||
: ScriptProperty(name) {}
|
||||
virtual ~ScriptPropertyEntityRef() = default;
|
||||
const void* GetDataAddress() const override { return &m_value; }
|
||||
const AZ::Uuid& GetDataTypeUuid() const override;
|
||||
|
||||
bool DoesTypeMatch(AZ::ScriptDataContext& context, int valueIndex) const override;
|
||||
|
||||
ScriptPropertyEntityRef* Clone(const char* name = nullptr) const override;
|
||||
|
||||
bool Write(AZ::ScriptContext& context) override;
|
||||
|
||||
AZ::EntityId m_value;
|
||||
|
||||
protected:
|
||||
void CloneDataFrom(const AZ::ScriptProperty* scriptProperty) override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* 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/Script/ScriptPropertySerializer.h>
|
||||
#include <AzCore/Serialization/DynamicSerializableField.h>
|
||||
#include <AzCore/Serialization/Json/JsonSerialization.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
AZ_CLASS_ALLOCATOR_IMPL(ScriptPropertySerializer, SystemAllocator, 0);
|
||||
|
||||
JsonSerializationResult::Result ScriptPropertySerializer::Load
|
||||
( void* outputValue
|
||||
, [[maybe_unused]] const Uuid& outputValueTypeId
|
||||
, const rapidjson::Value& inputValue
|
||||
, JsonDeserializerContext& context)
|
||||
{
|
||||
namespace JSR = JsonSerializationResult;
|
||||
|
||||
AZ_Assert(outputValueTypeId == azrtti_typeid<DynamicSerializableField>(), "ScriptPropertySerializer Load against output typeID that was not DynamicSerializableField");
|
||||
AZ_Assert(outputValue, "ScriptPropertySerializer Load against null output");
|
||||
|
||||
auto outputVariable = reinterpret_cast<DynamicSerializableField*>(outputValue);
|
||||
JsonSerializationResult::ResultCode result(JSR::Tasks::ReadField);
|
||||
AZ::Uuid typeId = AZ::Uuid::CreateNull();
|
||||
|
||||
auto typeIdMember = inputValue.FindMember(JsonSerialization::TypeIdFieldIdentifier);
|
||||
if (typeIdMember == inputValue.MemberEnd())
|
||||
{
|
||||
return context.Report(JSR::Tasks::ReadField, JSR::Outcomes::Missing, AZStd::string::format("ScriptPropertySerializer::Load failed to load the %s member", JsonSerialization::TypeIdFieldIdentifier));
|
||||
}
|
||||
|
||||
result.Combine(LoadTypeId(typeId, typeIdMember->value, context));
|
||||
if (typeId.IsNull())
|
||||
{
|
||||
return context.Report(JSR::Tasks::ReadField, JSR::Outcomes::Catastrophic, "ScriptPropertySerializer::Load failed to load the AZ TypeId of the value");
|
||||
}
|
||||
|
||||
AZStd::any storage = context.GetSerializeContext()->CreateAny(typeId);
|
||||
if (storage.empty() || storage.type() != typeId)
|
||||
{
|
||||
return context.Report(result, "ScriptPropertySerializer::Load failed to load a value matched the reported AZ TypeId. The C++ declaration may have been deleted or changed.");
|
||||
}
|
||||
|
||||
DynamicSerializableField storageField;
|
||||
storageField.m_data = AZStd::any_cast<void>(&storage);
|
||||
storageField.m_typeId = typeId;
|
||||
outputVariable->CopyDataFrom(storageField, context.GetSerializeContext());
|
||||
|
||||
result.Combine(ContinueLoadingFromJsonObjectField(outputVariable->m_data, typeId, inputValue, "value", context));
|
||||
return context.Report(result, result.GetProcessing() != JSR::Processing::Halted
|
||||
? "ScriptPropertySerializer Load finished loading DynamicSerializableField"
|
||||
: "ScriptPropertySerializer Load failed to load DynamicSerializableField");
|
||||
}
|
||||
|
||||
JsonSerializationResult::Result ScriptPropertySerializer::Store
|
||||
( rapidjson::Value& outputValue
|
||||
, const void* inputValue
|
||||
, const void* defaultValue
|
||||
, [[maybe_unused]] const Uuid& valueTypeId
|
||||
, JsonSerializerContext& context)
|
||||
{
|
||||
namespace JSR = JsonSerializationResult;
|
||||
|
||||
AZ_Assert(valueTypeId == azrtti_typeid<DynamicSerializableField>(), "DynamicSerializableField Store against value typeID that was not DynamicSerializableField");
|
||||
AZ_Assert(inputValue, "DynamicSerializableField Store against null inputValue pointer ");
|
||||
|
||||
auto inputScriptDataPtr = reinterpret_cast<const DynamicSerializableField*>(inputValue);
|
||||
auto inputFieldPtr = inputScriptDataPtr->m_data;
|
||||
auto defaultScriptDataPtr = reinterpret_cast<const DynamicSerializableField*>(defaultValue);
|
||||
auto defaultFieldPtr = defaultScriptDataPtr ? &defaultScriptDataPtr->m_data : nullptr;
|
||||
|
||||
if (defaultScriptDataPtr && inputScriptDataPtr->IsEqualTo(*defaultScriptDataPtr, context.GetSerializeContext()))
|
||||
{
|
||||
return context.Report(JSR::Tasks::WriteValue, JSR::Outcomes::DefaultsUsed, "ScriptPropertySerializer Store used defaults for DynamicSerializableField");
|
||||
}
|
||||
|
||||
JSR::ResultCode result(JSR::Tasks::WriteValue);
|
||||
outputValue.SetObject();
|
||||
|
||||
{
|
||||
rapidjson::Value typeValue;
|
||||
result.Combine(StoreTypeId(typeValue, inputScriptDataPtr->m_typeId, context));
|
||||
outputValue.AddMember(rapidjson::StringRef(JsonSerialization::TypeIdFieldIdentifier), AZStd::move(typeValue), context.GetJsonAllocator());
|
||||
}
|
||||
|
||||
result.Combine(ContinueStoringToJsonObjectField(outputValue, "value", inputFieldPtr, defaultFieldPtr, inputScriptDataPtr->m_typeId, context));
|
||||
|
||||
return context.Report(result, result.GetProcessing() != JSR::Processing::Halted
|
||||
? "ScriptPropertySerializer Store finished saving DynamicSerializableField"
|
||||
: "ScriptPropertySerializer Store failed to save DynamicSerializableField");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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/Memory/Memory.h>
|
||||
#include <AzCore/Serialization/Json/BaseJsonSerializer.h>
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
class ScriptPropertySerializer
|
||||
: public BaseJsonSerializer
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(ScriptPropertySerializer, "{C7BECA49-84EF-45E6-A89D-052D61766197}", BaseJsonSerializer);
|
||||
AZ_CLASS_ALLOCATOR_DECL;
|
||||
|
||||
private:
|
||||
JsonSerializationResult::Result Load
|
||||
( void* outputValue
|
||||
, const Uuid& outputValueTypeId
|
||||
, const rapidjson::Value& inputValue
|
||||
, JsonDeserializerContext& context) override;
|
||||
|
||||
JsonSerializationResult::Result Store
|
||||
( rapidjson::Value& outputValue
|
||||
, const void* inputValue
|
||||
, const void* defaultValue
|
||||
, const Uuid& valueTypeId, JsonSerializerContext& context) override;
|
||||
};
|
||||
}
|
||||
@@ -8,10 +8,8 @@
|
||||
|
||||
#if !defined(AZCORE_EXCLUDE_LUA)
|
||||
|
||||
#include <AzCore/Script/ScriptSystemComponent.h>
|
||||
|
||||
#include <AzCore/Asset/AssetManagerBus.h>
|
||||
#include <AzCore/Asset/AssetManager.h>
|
||||
#include <AzCore/Asset/AssetManagerBus.h>
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
#include <AzCore/Component/ComponentApplication.h>
|
||||
#include <AzCore/Component/Entity.h>
|
||||
@@ -21,13 +19,16 @@
|
||||
#include <AzCore/Math/MathReflection.h>
|
||||
#include <AzCore/PlatformId/PlatformId.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/Script/ScriptAsset.h>
|
||||
#include <AzCore/Script/ScriptContextDebug.h>
|
||||
#include <AzCore/Script/ScriptDebug.h>
|
||||
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
#include <AzCore/Script/ScriptPropertySerializer.h>
|
||||
#include <AzCore/Script/ScriptSystemComponent.h>
|
||||
#include <AzCore/Script/lua/lua.h>
|
||||
#include <AzCore/Serialization/DynamicSerializableField.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/Serialization/Json/RegistrationContext.h>
|
||||
#include <AzCore/std/string/conversions.h>
|
||||
|
||||
using namespace AZ;
|
||||
|
||||
@@ -921,6 +922,12 @@ void ScriptSystemComponent::Reflect(ReflectContext* reflection)
|
||||
}
|
||||
}
|
||||
|
||||
if (AZ::JsonRegistrationContext* jsonContext = azrtti_cast<AZ::JsonRegistrationContext*>(reflection))
|
||||
{
|
||||
jsonContext->Serializer<AZ::ScriptPropertySerializer>()
|
||||
->HandlesType<DynamicSerializableField>();
|
||||
}
|
||||
|
||||
if (BehaviorContext* behaviorContext = azrtti_cast<BehaviorContext*>(reflection))
|
||||
{
|
||||
// reflect default entity
|
||||
|
||||
@@ -98,14 +98,14 @@ namespace AZ
|
||||
return nullptr;
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
void DynamicSerializableField::CopyDataFrom(const DynamicSerializableField& other)
|
||||
void DynamicSerializableField::CopyDataFrom(const DynamicSerializableField& other, SerializeContext* useContext)
|
||||
{
|
||||
DestroyData();
|
||||
m_typeId = other.m_typeId;
|
||||
m_data = other.CloneData();
|
||||
m_data = other.CloneData(useContext);
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
bool DynamicSerializableField::IsEqualTo(const DynamicSerializableField& other, SerializeContext* useContext)
|
||||
bool DynamicSerializableField::IsEqualTo(const DynamicSerializableField& other, SerializeContext* useContext) const
|
||||
{
|
||||
if (other.m_typeId != m_typeId)
|
||||
{
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#define AZCORE_DYNAMIC_SERIALIZABLE_FIELD_H
|
||||
|
||||
#include <AzCore/RTTI/TypeInfo.h>
|
||||
#include <AzCore/Memory/Memory.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -24,6 +26,7 @@ namespace AZ
|
||||
{
|
||||
public:
|
||||
AZ_TYPE_INFO(DynamicSerializableField, "{D761E0C2-A098-497C-B8EB-EA62F5ED896B}")
|
||||
AZ_CLASS_ALLOCATOR(DynamicSerializableField, AZ::SystemAllocator, 0);
|
||||
|
||||
DynamicSerializableField();
|
||||
DynamicSerializableField(const DynamicSerializableField& serializableField);
|
||||
@@ -33,8 +36,8 @@ namespace AZ
|
||||
void DestroyData(SerializeContext* useContext = nullptr);
|
||||
void* CloneData(SerializeContext* useContext = nullptr) const;
|
||||
|
||||
void CopyDataFrom(const DynamicSerializableField& other);
|
||||
bool IsEqualTo(const DynamicSerializableField& other, SerializeContext* useContext = nullptr);
|
||||
void CopyDataFrom(const DynamicSerializableField& other, SerializeContext* useContext = nullptr);
|
||||
bool IsEqualTo(const DynamicSerializableField& other, SerializeContext* useContext = nullptr) const;
|
||||
|
||||
template<class T>
|
||||
void Set(T* object)
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace AZ::SettingsRegistryMergeUtils
|
||||
inline static constexpr char FilePathsRootKey[] = "/Amazon/AzCore/Runtime/FilePaths";
|
||||
inline static constexpr char FilePathKey_BinaryFolder[] = "/Amazon/AzCore/Runtime/FilePaths/BinaryFolder";
|
||||
inline static constexpr char FilePathKey_EngineRootFolder[] = "/Amazon/AzCore/Runtime/FilePaths/EngineRootFolder";
|
||||
inline static constexpr char FilePathKey_InstalledBinaryFolder[] = "/Amazon/AzCore/Runtime/FilePaths/InstalledBinariesFolder";
|
||||
|
||||
//! Stores the absolute path to root of a project's cache. No asset platform in this path, this is where the asset database file lives.
|
||||
//! i.e. <ProjectPath>/Cache
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <AzCore/Outcome/Outcome.h>
|
||||
#include <AzCore/Slice/SliceAsset.h>
|
||||
#include <AzCore/Serialization/DataPatch.h>
|
||||
#include <AzCore/Serialization/DynamicSerializableField.h>
|
||||
#include <AzCore/Serialization/IdUtils.h>
|
||||
|
||||
namespace AZ
|
||||
|
||||
@@ -462,6 +462,8 @@ set(FILES
|
||||
Script/ScriptTimePoint.h
|
||||
Script/ScriptProperty.h
|
||||
Script/ScriptProperty.cpp
|
||||
Script/ScriptPropertySerializer.h
|
||||
Script/ScriptPropertySerializer.cpp
|
||||
Script/ScriptPropertyTable.h
|
||||
Script/ScriptPropertyTable.cpp
|
||||
Script/ScriptPropertyWatcherBus.h
|
||||
|
||||
@@ -21,7 +21,18 @@ namespace AZStd
|
||||
{
|
||||
// alias std::pointer_traits into the AZStd::namespace
|
||||
using std::pointer_traits;
|
||||
|
||||
//! Bring the names of uninitialized_default_construct and
|
||||
//! uninitialized_default_construct_n into the AZStd namespace
|
||||
using std::uninitialized_default_construct;
|
||||
using std::uninitialized_default_construct_n;
|
||||
|
||||
//! uninitialized_value_construct and uninitialized_value_construct_n
|
||||
//! are now brought into scope of the AZStd namespace
|
||||
using std::uninitialized_value_construct;
|
||||
using std::uninitialized_value_construct_n;
|
||||
}
|
||||
|
||||
namespace AZStd::Internal
|
||||
{
|
||||
template <typename T, typename = void>
|
||||
@@ -223,107 +234,6 @@ namespace AZStd
|
||||
}
|
||||
}
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
//! C++20 implementation of uninitialized_default_construct
|
||||
//! Initializes objects by default-initialization via placement new
|
||||
//! Ex. `new(declval<void*>()) T` - Notice no parenthesis after T
|
||||
//! This performs default initialization instead of value initialization
|
||||
//! Default initialization performs the following actions
|
||||
//! # If T is a class type it considers constructors which can be invoked
|
||||
//! with an empty argument list. The selected constructor is invoked
|
||||
//! to provide the initial value of the object
|
||||
//! # If T is an array type, then default initialization is performed
|
||||
//! on each array element
|
||||
//! # Otherwise nothing is done and objects with automatic storage duration(i.e scope)
|
||||
//! are initialized with indeterminate values
|
||||
//! For example given the following struct
|
||||
//! struct Foo
|
||||
//! {
|
||||
//! int mint;
|
||||
//! double bubble;
|
||||
//! };
|
||||
//! Invoking uninitialized_default_construct(FooPtr, FooPtr + 1)
|
||||
//! Will default initialize the FooPtr object (Foo has an implicitly-defined default constructor)
|
||||
//! The values of mint and bubble are indeterminate
|
||||
template <typename ForwardIt>
|
||||
constexpr auto uninitialized_default_construct(ForwardIt first, ForwardIt last)
|
||||
-> enable_if_t<Internal::is_forward_iterator_v<ForwardIt>, void>
|
||||
{
|
||||
for (; first != last; ++first)
|
||||
{
|
||||
return ::new (AZStd::addressof(*first)) typename AZStd::iterator_traits<ForwardIt>::value_type;
|
||||
}
|
||||
}
|
||||
// C++20 implementation of uninitialized_default_construct_n
|
||||
// Constructs "n" objects starting at first via default-initialization
|
||||
template <typename ForwardIt, typename Size>
|
||||
constexpr auto uninitialized_default_construct_n(ForwardIt first, Size numElements)
|
||||
-> enable_if_t<Internal::is_forward_iterator_v<ForwardIt>, ForwardIt>
|
||||
{
|
||||
for (; numElements > 0; ++first, --numElements)
|
||||
{
|
||||
return ::new (AZStd::addressof(*first)) typename AZStd::iterator_traits<ForwardIt>::value_type;
|
||||
}
|
||||
|
||||
return first;
|
||||
}
|
||||
}
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
//! C++20 implementation of uninitialized_value_construct
|
||||
//! Initializes objects by value-initialization via placement new
|
||||
//! Ex. `new(declval<void*>()) T()` - Notice parenthesis are here after T
|
||||
//! value-initialization of an object performs different rules depending
|
||||
//! on the type of T
|
||||
//! Value initialization performs the following actions
|
||||
//! # If T is a class type with no default constructor or with a user-provided
|
||||
//! constructor or a deleted default constructor, then default-initialization
|
||||
//! is performed
|
||||
//! # If T is a class type with a default constructor that is neither
|
||||
//! user-provided nor deleted(i.e a class with an implicitly-defined or defaulted
|
||||
//! default constructor), then the object is zero-initialized and then it is
|
||||
//! default-initialized if it has a non-trivial default constructor
|
||||
//! # If T is an array type, then value initialization is performed
|
||||
//! on each array element
|
||||
//! # Otherwise the object is zero-initialized
|
||||
//! (i.e sets arithmetic and enum objects to 0, bool objects to false, pointers to nullptr)
|
||||
//! For example given the following struct
|
||||
//! struct Foo
|
||||
//! {
|
||||
//! int mint;
|
||||
//! double bubble;
|
||||
//! };
|
||||
//! Invoking uninitialized_default_construct(FooPtr, FooPtr + 1)
|
||||
//! Will value-initialize the FooPtr object.
|
||||
//! The Foo has an implicitly-defined default constructor.
|
||||
//! For aggregates such as int and double this will perform zero-initialization
|
||||
//! which will set their values to 0
|
||||
//! Therefore The values of mint will be 0 and and bubble 0.0
|
||||
template <typename ForwardIt>
|
||||
constexpr auto uninitialized_value_construct(ForwardIt first, ForwardIt last)
|
||||
-> enable_if_t<Internal::is_forward_iterator_v<ForwardIt>, void>
|
||||
{
|
||||
for (; first != last; ++first)
|
||||
{
|
||||
return ::new (AZStd::addressof(*first)) typename AZStd::iterator_traits<ForwardIt>::value_type();
|
||||
}
|
||||
}
|
||||
// C++20 implementation of uninitialized_default_construct_n
|
||||
// Constructs "n" objects starting at the first via by value-initialization
|
||||
template <typename ForwardIt, typename Size>
|
||||
constexpr auto uninitialized_value_construct_n(ForwardIt first, Size numElements)
|
||||
-> enable_if_t<Internal::is_forward_iterator_v<ForwardIt>, ForwardIt>
|
||||
{
|
||||
for (; numElements > 0; ++first, --numElements)
|
||||
{
|
||||
return ::new (AZStd::addressof(*first)) typename AZStd::iterator_traits<ForwardIt>::value_type();
|
||||
}
|
||||
|
||||
return first;
|
||||
}
|
||||
}
|
||||
|
||||
namespace AZStd::Internal
|
||||
{
|
||||
|
||||
@@ -25,29 +25,7 @@ namespace AZStd
|
||||
AZStd::sys_time_t GetTimeNowTicks()
|
||||
{
|
||||
AZStd::sys_time_t timeNow;
|
||||
struct timespec ts;
|
||||
clock_serv_t cclock;
|
||||
mach_timespec_t mts;
|
||||
kern_return_t ret = host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
|
||||
if (ret == KERN_SUCCESS)
|
||||
{
|
||||
ret = clock_get_time(cclock, &mts);
|
||||
if (ret == KERN_SUCCESS)
|
||||
{
|
||||
ts.tv_sec = mts.tv_sec;
|
||||
ts.tv_nsec = mts.tv_nsec;
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Assert(false, "clock_get_time error: %d\n", ret);
|
||||
}
|
||||
mach_port_deallocate(mach_task_self(), cclock);
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Assert(false, "clock_get_time error: %d\n", ret);
|
||||
}
|
||||
timeNow = ts.tv_sec * GetTimeTicksPerSecond() + ts.tv_nsec;
|
||||
timeNow = clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
|
||||
return timeNow;
|
||||
}
|
||||
|
||||
@@ -62,29 +40,7 @@ namespace AZStd
|
||||
AZStd::sys_time_t GetTimeNowSecond()
|
||||
{
|
||||
AZStd::sys_time_t timeNowSecond;
|
||||
struct timespec ts;
|
||||
clock_serv_t cclock;
|
||||
mach_timespec_t mts;
|
||||
kern_return_t ret = host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
|
||||
if (ret == KERN_SUCCESS)
|
||||
{
|
||||
ret = clock_get_time(cclock, &mts);
|
||||
if (ret == KERN_SUCCESS)
|
||||
{
|
||||
ts.tv_sec = mts.tv_sec;
|
||||
ts.tv_nsec = mts.tv_nsec;
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Assert(false, "clock_get_time error: %d\n", ret);
|
||||
}
|
||||
mach_port_deallocate(mach_task_self(), cclock);
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Assert(false, "clock_get_time error: %d\n", ret);
|
||||
}
|
||||
timeNowSecond = ts.tv_sec;
|
||||
timeNowSecond = GetTimeNowTicks()/GetTimeTicksPerSecond();
|
||||
return timeNowSecond;
|
||||
}
|
||||
|
||||
|
||||
@@ -134,4 +134,48 @@ namespace UnitTest
|
||||
EXPECT_FLOAT_EQ(4.0f, resultAddress->m_floatValue);
|
||||
AZStd::destroy_at(resultAddress);
|
||||
}
|
||||
|
||||
TEST(CreateDestroy, UninitializedDefaultConstruct_IsAbleToConstructMultipleElements_Succeeds)
|
||||
{
|
||||
struct RefWrapper
|
||||
{
|
||||
RefWrapper()
|
||||
{}
|
||||
int m_intValue{ 2 };
|
||||
};
|
||||
constexpr size_t ArraySize = 2;
|
||||
AZStd::aligned_storage_for_t<RefWrapper> testArray[ArraySize];
|
||||
RefWrapper(&uninitializedAddress)[2] = reinterpret_cast<RefWrapper(&)[2]>(testArray);
|
||||
AZStd::uninitialized_default_construct(AZStd::begin(uninitializedAddress), AZStd::end(uninitializedAddress));
|
||||
|
||||
|
||||
EXPECT_EQ(2, uninitializedAddress[0].m_intValue);
|
||||
EXPECT_EQ(2, uninitializedAddress[1].m_intValue);
|
||||
// Reset uninitializedAddress to Debug pattern
|
||||
memset(uninitializedAddress, 0xCD, ArraySize * sizeof(RefWrapper));
|
||||
AZStd::uninitialized_default_construct_n(AZStd::data(uninitializedAddress), AZStd::size(uninitializedAddress));
|
||||
EXPECT_EQ(2, uninitializedAddress[0].m_intValue);
|
||||
EXPECT_EQ(2, uninitializedAddress[1].m_intValue);
|
||||
}
|
||||
|
||||
TEST(CreateDestroy, UninitializedValueConstruct_IsAbleToConstructMultipleElements_Succeeds)
|
||||
{
|
||||
struct RefWrapper
|
||||
{
|
||||
int m_intValue;
|
||||
};
|
||||
constexpr size_t ArraySize = 2;
|
||||
AZStd::aligned_storage_for_t<RefWrapper> testArray[ArraySize];
|
||||
RefWrapper(&uninitializedAddress)[2] = reinterpret_cast<RefWrapper(&)[2]>(testArray);
|
||||
AZStd::uninitialized_value_construct(AZStd::begin(uninitializedAddress), AZStd::end(uninitializedAddress));
|
||||
|
||||
|
||||
EXPECT_EQ(0, uninitializedAddress[0].m_intValue);
|
||||
EXPECT_EQ(0, uninitializedAddress[1].m_intValue);
|
||||
// Reset uninitializedAddress to Debug pattern
|
||||
memset(uninitializedAddress, 0xCD, ArraySize * sizeof(RefWrapper));
|
||||
AZStd::uninitialized_value_construct_n(AZStd::data(uninitializedAddress), AZStd::size(uninitializedAddress));
|
||||
EXPECT_EQ(0, uninitializedAddress[0].m_intValue);
|
||||
EXPECT_EQ(0, uninitializedAddress[1].m_intValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +114,9 @@ namespace Camera
|
||||
//! Makes the camera the active view
|
||||
virtual void MakeActiveView() = 0;
|
||||
|
||||
//! Check if this camera is the active render camera
|
||||
virtual bool IsActiveView() = 0;
|
||||
|
||||
//! Get the camera frustum's aggregate configuration
|
||||
virtual Configuration GetCameraConfiguration()
|
||||
{
|
||||
|
||||
+15
-23
@@ -24,7 +24,9 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/resource.h> // for iopolicy
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
extern char **environ;
|
||||
|
||||
namespace AzFramework
|
||||
{
|
||||
@@ -45,7 +47,7 @@ namespace AzFramework
|
||||
// result == 0 means child PID is still running, nothing to check
|
||||
if (result == -1)
|
||||
{
|
||||
AZ_TracePrintf("ProcessWatcher", "IsChildProcessDone could not determine child process status (waitpid errno %d). assuming process either failed to launch or terminated unexpectedly\n", errno);
|
||||
AZ_TracePrintf("ProcessWatcher", "IsChildProcessDone could not determine child process status (waitpid errno %d(%s)). assuming process either failed to launch or terminated unexpectedly\n", errno, strerror(errno));
|
||||
exitCode = 0;
|
||||
}
|
||||
else if (result == childProcessId)
|
||||
@@ -274,28 +276,27 @@ namespace AzFramework
|
||||
azstrcat(commandAndArgs[i], token.size(), token.c_str());
|
||||
}
|
||||
commandAndArgs[commandTokens.size()] = nullptr;
|
||||
|
||||
char** environmentVariables = nullptr;
|
||||
int numEnvironmentVars = 0;
|
||||
|
||||
constexpr int MaxEnvVariables = 128;
|
||||
using EnvironmentVariableContainer = AZStd::fixed_vector<char*, MaxEnvVariables>;
|
||||
EnvironmentVariableContainer environmentVariables;
|
||||
for (char **env = ::environ; *env; env++)
|
||||
{
|
||||
environmentVariables.push_back(*env);
|
||||
}
|
||||
if (processLaunchInfo.m_environmentVariables)
|
||||
{
|
||||
const int numEnvironmentVars = processLaunchInfo.m_environmentVariables->size();
|
||||
// Adding one more as exec expects the array to have a nullptr as the last element
|
||||
environmentVariables = new char*[numEnvironmentVars + 1];
|
||||
for (int i = 0; i < numEnvironmentVars; i++)
|
||||
for (AZStd::string& processLaunchEnv : *processLaunchInfo.m_environmentVariables)
|
||||
{
|
||||
const AZStd::string& envVarString = processLaunchInfo.m_environmentVariables->at(i);
|
||||
environmentVariables[i] = new char[envVarString.size() + 1];
|
||||
environmentVariables[i][0] = '\0';
|
||||
azstrcat(environmentVariables[i], envVarString.size(), envVarString.c_str());
|
||||
environmentVariables.push_back(processLaunchEnv.data());
|
||||
}
|
||||
environmentVariables[numEnvironmentVars] = NULL;
|
||||
}
|
||||
environmentVariables.push_back(nullptr);
|
||||
|
||||
pid_t child_pid = fork();
|
||||
if (IsIdChildProcess(child_pid))
|
||||
{
|
||||
ExecuteCommandAsChild(commandAndArgs, environmentVariables, processLaunchInfo, processData.m_startupInfo);
|
||||
ExecuteCommandAsChild(commandAndArgs, environmentVariables.data(), processLaunchInfo, processData.m_startupInfo);
|
||||
}
|
||||
|
||||
processData.m_childProcessId = child_pid;
|
||||
@@ -303,15 +304,6 @@ namespace AzFramework
|
||||
// Close these handles as they are only to be used by the child process
|
||||
processData.m_startupInfo.CloseAllHandles();
|
||||
|
||||
if (processLaunchInfo.m_environmentVariables)
|
||||
{
|
||||
for (int i = 0; i < numEnvironmentVars; i++)
|
||||
{
|
||||
delete [] environmentVariables[i];
|
||||
}
|
||||
delete [] environmentVariables;
|
||||
}
|
||||
|
||||
for (int i = 0; i < commandTokens.size(); i++)
|
||||
{
|
||||
delete [] commandAndArgs[i];
|
||||
|
||||
+18
-4
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <../Common/WinAPI/AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard_WinAPI.h>
|
||||
#include <AzFramework/Input/Buses/Notifications/RawInputNotificationBus_Platform.h>
|
||||
#include <AzCore/Module/Environment.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
namespace
|
||||
@@ -29,7 +30,7 @@ namespace AzFramework
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//! Count of the number instances of this class that have been created
|
||||
static int s_instanceCount;
|
||||
static AZ::EnvironmentVariable<int> s_instanceCount;
|
||||
|
||||
public:
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -106,7 +107,7 @@ namespace AzFramework
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
int InputDeviceKeyboardWindows::s_instanceCount = 0;
|
||||
AZ::EnvironmentVariable<int> InputDeviceKeyboardWindows::s_instanceCount = nullptr;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
InputDeviceKeyboardWindows::InputDeviceKeyboardWindows(InputDeviceKeyboard& inputDevice)
|
||||
@@ -116,8 +117,10 @@ namespace AzFramework
|
||||
, m_hasFocus(false)
|
||||
, m_hasTextEntryStarted(false)
|
||||
{
|
||||
if (s_instanceCount++ == 0)
|
||||
if (!s_instanceCount)
|
||||
{
|
||||
s_instanceCount = AZ::Environment::CreateVariable<int>("InputDeviceKeyboardInstanceCount", 1);
|
||||
|
||||
// Register for raw keyboard input
|
||||
RAWINPUTDEVICE rawInputDevice;
|
||||
rawInputDevice.usUsagePage = RAW_INPUT_KEYBOARD_USAGE_PAGE;
|
||||
@@ -128,6 +131,10 @@ namespace AzFramework
|
||||
AZ_Assert(result, "Failed to register raw input device: keyboard");
|
||||
AZ_UNUSED(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
s_instanceCount.Set(s_instanceCount.Get() + 1);
|
||||
}
|
||||
|
||||
RawInputNotificationBusWindows::Handler::BusConnect();
|
||||
}
|
||||
@@ -137,7 +144,8 @@ namespace AzFramework
|
||||
{
|
||||
RawInputNotificationBusWindows::Handler::BusDisconnect();
|
||||
|
||||
if (--s_instanceCount == 0)
|
||||
int instanceCount = s_instanceCount.Get();
|
||||
if (--instanceCount == 0)
|
||||
{
|
||||
// Deregister from raw keyboard input
|
||||
RAWINPUTDEVICE rawInputDevice;
|
||||
@@ -148,7 +156,13 @@ namespace AzFramework
|
||||
const BOOL result = RegisterRawInputDevices(&rawInputDevice, 1, sizeof(rawInputDevice));
|
||||
AZ_Assert(result, "Failed to deregister raw input device: keyboard");
|
||||
AZ_UNUSED(result);
|
||||
|
||||
s_instanceCount.Reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
s_instanceCount.Set(instanceCount);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
+21
-7
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
#include <AzCore/Module/Environment.h>
|
||||
#include <AzFramework/Input/Devices/Mouse/InputDeviceMouse.h>
|
||||
#include <AzFramework/Input/Buses/Notifications/RawInputNotificationBus_Platform.h>
|
||||
#include <AzFramework/Input/Buses/Requests/InputSystemCursorRequestBus.h>
|
||||
@@ -43,7 +44,7 @@ namespace AzFramework
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//! Count of the number instances of this class that have been created
|
||||
static int s_instanceCount;
|
||||
static AZ::EnvironmentVariable<int> s_instanceCount;
|
||||
|
||||
public:
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -125,7 +126,7 @@ namespace AzFramework
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
int InputDeviceMouseWindows::s_instanceCount = 0;
|
||||
AZ::EnvironmentVariable<int> InputDeviceMouseWindows::s_instanceCount = nullptr;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
InputDeviceMouseWindows::InputDeviceMouseWindows(InputDeviceMouse& inputDevice)
|
||||
@@ -137,18 +138,24 @@ namespace AzFramework
|
||||
{
|
||||
memset(&m_lastClientRect, 0, sizeof(m_lastClientRect));
|
||||
|
||||
if (s_instanceCount++ == 0)
|
||||
if (!s_instanceCount)
|
||||
{
|
||||
s_instanceCount = AZ::Environment::CreateVariable<int>("InputDeviceMouseInstanceCount", 1);
|
||||
|
||||
// Register for raw mouse input
|
||||
RAWINPUTDEVICE rawInputDevice;
|
||||
rawInputDevice.usUsagePage = RAW_INPUT_MOUSE_USAGE_PAGE;
|
||||
rawInputDevice.usUsage = RAW_INPUT_MOUSE_USAGE;
|
||||
rawInputDevice.dwFlags = 0;
|
||||
rawInputDevice.hwndTarget = 0;
|
||||
rawInputDevice.usUsage = RAW_INPUT_MOUSE_USAGE;
|
||||
rawInputDevice.dwFlags = 0;
|
||||
rawInputDevice.hwndTarget = 0;
|
||||
const BOOL result = RegisterRawInputDevices(&rawInputDevice, 1, sizeof(rawInputDevice));
|
||||
AZ_Assert(result, "Failed to register raw input device: mouse");
|
||||
AZ_UNUSED(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
s_instanceCount.Set(s_instanceCount.Get() + 1);
|
||||
}
|
||||
|
||||
RawInputNotificationBusWindows::Handler::BusConnect();
|
||||
}
|
||||
@@ -161,7 +168,8 @@ namespace AzFramework
|
||||
// Cleanup system cursor visibility and constraint
|
||||
SetSystemCursorState(SystemCursorState::Unknown);
|
||||
|
||||
if (--s_instanceCount == 0)
|
||||
int instanceCount = s_instanceCount.Get();
|
||||
if (--instanceCount == 0)
|
||||
{
|
||||
// Deregister from raw mouse input
|
||||
RAWINPUTDEVICE rawInputDevice;
|
||||
@@ -172,6 +180,12 @@ namespace AzFramework
|
||||
const BOOL result = RegisterRawInputDevices(&rawInputDevice, 1, sizeof(rawInputDevice));
|
||||
AZ_Assert(result, "Failed to deregister raw input device: mouse");
|
||||
AZ_UNUSED(result);
|
||||
|
||||
s_instanceCount.Reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
s_instanceCount.Set(instanceCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@ namespace AzQtComponents
|
||||
QApplication::setApplicationName("O3DE Tools Application");
|
||||
|
||||
AzQtComponents::PrepareQtPaths();
|
||||
|
||||
QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates));
|
||||
}
|
||||
|
||||
void AzQtApplication::InitializeDpiScaling()
|
||||
|
||||
@@ -134,8 +134,6 @@ int main(int argc, char **argv)
|
||||
QApplication::setOrganizationDomain("o3de.org");
|
||||
QApplication::setApplicationName("O3DEWidgetGallery");
|
||||
|
||||
QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates));
|
||||
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||
|
||||
+52
-12
@@ -13,54 +13,94 @@
|
||||
|
||||
TEST(AzQtComponents, FloatToString_Truncate2Decimals)
|
||||
{
|
||||
QLocale testLocal(QLocale::English, QLocale::UnitedStates);
|
||||
QLocale testLocale(QLocale::English, QLocale::UnitedStates);
|
||||
|
||||
const bool showThousandsSeparator = false;
|
||||
const int numDecimalPlaces = 2;
|
||||
EXPECT_EQ(AzQtComponents::toString(0.1234, numDecimalPlaces, testLocal, showThousandsSeparator), "0.12");
|
||||
EXPECT_EQ(AzQtComponents::toString(0.1234, numDecimalPlaces, testLocale, showThousandsSeparator), "0.12");
|
||||
}
|
||||
|
||||
TEST(AzQtComponents, FloatToString_AllZerosButOne)
|
||||
{
|
||||
QLocale testLocal(QLocale::English, QLocale::UnitedStates);
|
||||
QLocale testLocale(QLocale::English, QLocale::UnitedStates);
|
||||
|
||||
const bool showThousandsSeparator = false;
|
||||
int numDecimalPlaces = 2;
|
||||
EXPECT_EQ(AzQtComponents::toString(1.0000, numDecimalPlaces, testLocal, showThousandsSeparator), "1.0");
|
||||
EXPECT_EQ(AzQtComponents::toString(1.0000, numDecimalPlaces, testLocale, showThousandsSeparator), "1.0");
|
||||
}
|
||||
|
||||
TEST(AzQtComponents, FloatToString_TruncateAllZerosButOne)
|
||||
{
|
||||
QLocale testLocal(QLocale::English, QLocale::UnitedStates);
|
||||
QLocale testLocale(QLocale::English, QLocale::UnitedStates);
|
||||
|
||||
const bool showThousandsSeparator = false;
|
||||
int numDecimalPlaces = 2;
|
||||
EXPECT_EQ(AzQtComponents::toString(1.0001, numDecimalPlaces, testLocal, showThousandsSeparator), "1.0");
|
||||
EXPECT_EQ(AzQtComponents::toString(1.0001, numDecimalPlaces, testLocale, showThousandsSeparator), "1.0");
|
||||
}
|
||||
|
||||
TEST(AzQtComponents, FloatToString_TruncateNotRound)
|
||||
{
|
||||
QLocale testLocal(QLocale::English, QLocale::UnitedStates);
|
||||
QLocale testLocale(QLocale::English, QLocale::UnitedStates);
|
||||
|
||||
const bool showThousandsSeparator = false;
|
||||
int numDecimalPlaces = 3;
|
||||
EXPECT_EQ(AzQtComponents::toString(0.1236, numDecimalPlaces, testLocal, showThousandsSeparator), "0.123");
|
||||
EXPECT_EQ(AzQtComponents::toString(0.1236, numDecimalPlaces, testLocale, showThousandsSeparator), "0.123");
|
||||
}
|
||||
|
||||
TEST(AzQtComponents, FloatToString_TruncateShowThousandsSeparatorTruncateNoRound)
|
||||
{
|
||||
QLocale testLocal(QLocale::English, QLocale::UnitedStates);
|
||||
QLocale testLocale(QLocale::English, QLocale::UnitedStates);
|
||||
|
||||
const bool showThousandsSeparator = true;
|
||||
int numDecimalPlaces = 3;
|
||||
EXPECT_EQ(AzQtComponents::toString(1000.1236, numDecimalPlaces, testLocal, showThousandsSeparator), "1,000.123");
|
||||
EXPECT_EQ(AzQtComponents::toString(1000.1236, numDecimalPlaces, testLocale, showThousandsSeparator), "1,000.123");
|
||||
}
|
||||
|
||||
TEST(AzQtComponents, FloatToString_TruncateShowThousandsSeparatorOnlyOneDecimal)
|
||||
{
|
||||
QLocale testLocal(QLocale::English, QLocale::UnitedStates);
|
||||
QLocale testLocale(QLocale::English, QLocale::UnitedStates);
|
||||
|
||||
const bool showThousandsSeparator = true;
|
||||
int numDecimalPlaces = 2;
|
||||
EXPECT_EQ(AzQtComponents::toString(1000.000, numDecimalPlaces, testLocal, showThousandsSeparator), "1,000.0");
|
||||
EXPECT_EQ(AzQtComponents::toString(1000.000, numDecimalPlaces, testLocale, showThousandsSeparator), "1,000.0");
|
||||
}
|
||||
|
||||
TEST(AzQtComponents, FloatToString_Truncate2DecimalsWithLocale)
|
||||
{
|
||||
QLocale testLocale{ QLocale() };
|
||||
|
||||
const bool showThousandsSeparator = false;
|
||||
const int numDecimalPlaces = 2;
|
||||
QString testString = "0" + QString(testLocale.decimalPoint()) + "12";
|
||||
EXPECT_EQ(testString, AzQtComponents::toString(0.1234, numDecimalPlaces, testLocale, showThousandsSeparator));
|
||||
}
|
||||
|
||||
TEST(AzQtComponents, FloatToString_AllZerosButOneWithLocale)
|
||||
{
|
||||
QLocale testLocale{ QLocale() };
|
||||
|
||||
const bool showThousandsSeparator = false;
|
||||
const int numDecimalPlaces = 2;
|
||||
QString testString = "1" + QString(testLocale.decimalPoint()) + "0";
|
||||
EXPECT_EQ(testString, AzQtComponents::toString(1.0000, numDecimalPlaces, testLocale, showThousandsSeparator));
|
||||
}
|
||||
|
||||
TEST(AzQtComponents, FloatToString_TruncateShowThousandsSeparatorTruncateNoRoundWithLocale)
|
||||
{
|
||||
QLocale testLocale{ QLocale() };
|
||||
|
||||
const bool showThousandsSeparator = true;
|
||||
const int numDecimalPlaces = 3;
|
||||
QString testString = "1" + QString(testLocale.groupSeparator()) + "000" + QString(testLocale.decimalPoint()) + "123";
|
||||
EXPECT_EQ(testString, AzQtComponents::toString(1000.1236, numDecimalPlaces, testLocale, showThousandsSeparator));
|
||||
}
|
||||
|
||||
TEST(AzQtComponents, FloatToString_TruncateShowThousandsSeparatorOnlyOneDecimalWithLocale)
|
||||
{
|
||||
QLocale testLocale{ QLocale() };
|
||||
|
||||
const bool showThousandsSeparator = true;
|
||||
int numDecimalPlaces = 2;
|
||||
QString testString = "1" + QString(testLocale.groupSeparator()) + "000" + QString(testLocale.decimalPoint()) + "0";
|
||||
EXPECT_EQ(testString, AzQtComponents::toString(1000.000, numDecimalPlaces, testLocale, showThousandsSeparator));
|
||||
}
|
||||
|
||||
+2
-1
@@ -186,6 +186,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
invalidateFilter();
|
||||
|
||||
Q_EMIT filterChanged();
|
||||
}
|
||||
|
||||
@@ -205,6 +206,6 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
} // namespace AssetBrowser
|
||||
} // namespace AzToolsFramework// namespace AssetBrowser
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
#include "AssetBrowser/moc_AssetBrowserFilterModel.cpp"
|
||||
|
||||
@@ -134,7 +134,8 @@ namespace AzToolsFramework
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//If the column of the parent is one of those we don't want any more rows as children
|
||||
if (parent.isValid())
|
||||
{
|
||||
if ((parent.column() != aznumeric_cast<int>(AssetBrowserEntry::Column::DisplayName)) &&
|
||||
|
||||
+32
-14
@@ -90,24 +90,38 @@ namespace AzToolsFramework
|
||||
const QAbstractItemModel* model, const QModelIndex& parent /*= QModelIndex()*/, int row /*= 0*/)
|
||||
{
|
||||
int rows = model ? model->rowCount(parent) : 0;
|
||||
for (int i = 0; i < rows; ++i)
|
||||
|
||||
if (parent == QModelIndex())
|
||||
{
|
||||
QModelIndex index = model->index(i, 0, parent);
|
||||
AssetBrowserEntry* entry = GetAssetEntry(m_filterModel->mapToSource(index));
|
||||
//We only wanna see the source assets.
|
||||
if (entry->GetEntryType() == AssetBrowserEntry::AssetEntryType::Source)
|
||||
{
|
||||
beginInsertRows(parent, row, row);
|
||||
m_indexMap[row] = index;
|
||||
endInsertRows();
|
||||
m_displayedItemsCounter = 0;
|
||||
}
|
||||
|
||||
Q_EMIT dataChanged(index, index);
|
||||
++row;
|
||||
for (int currentRow = 0; currentRow < rows; ++currentRow)
|
||||
{
|
||||
if (m_displayedItemsCounter < m_numberOfItemsDisplayed)
|
||||
{
|
||||
QModelIndex index = model->index(currentRow, 0, parent);
|
||||
AssetBrowserEntry* entry = GetAssetEntry(m_filterModel->mapToSource(index));
|
||||
// We only want to see the source assets.
|
||||
if (entry->GetEntryType() == AssetBrowserEntry::AssetEntryType::Source)
|
||||
{
|
||||
beginInsertRows(parent, row, row);
|
||||
m_indexMap[row] = index;
|
||||
endInsertRows();
|
||||
|
||||
Q_EMIT dataChanged(index, index);
|
||||
++row;
|
||||
++m_displayedItemsCounter;
|
||||
}
|
||||
|
||||
if (model->hasChildren(index))
|
||||
{
|
||||
row = BuildTableModelMap(model, index, row);
|
||||
}
|
||||
}
|
||||
|
||||
if (model->hasChildren(index))
|
||||
else
|
||||
{
|
||||
row = BuildTableModelMap(model, index, row);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return row;
|
||||
@@ -135,6 +149,10 @@ namespace AzToolsFramework
|
||||
m_indexMap.clear();
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
AzToolsFramework::EditorSettingsAPIBus::BroadcastResult(
|
||||
m_numberOfItemsDisplayed, &AzToolsFramework::EditorSettingsAPIBus::Handler::GetMaxNumberOfItemsShownInSearchView);
|
||||
|
||||
BuildTableModelMap(sourceModel());
|
||||
emit layoutChanged();
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QPointer>
|
||||
#endif
|
||||
#include <Editor/EditorSettingsAPIBus.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
@@ -50,6 +51,8 @@ namespace AzToolsFramework
|
||||
int BuildTableModelMap(const QAbstractItemModel* model, const QModelIndex& parent = QModelIndex(), int row = 0);
|
||||
|
||||
private:
|
||||
int m_numberOfItemsDisplayed = 50;
|
||||
int m_displayedItemsCounter = 0;
|
||||
QPointer<AssetBrowserFilterModel> m_filterModel;
|
||||
QMap<int, QModelIndex> m_indexMap;
|
||||
};
|
||||
|
||||
+1
-11
@@ -6,18 +6,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <API/EditorAssetSystemAPI.h>
|
||||
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserBus.h>
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h>
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserModel.h>
|
||||
#include <AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntryCache.h>
|
||||
#include <AzToolsFramework/AssetBrowser/Entries/ProductAssetBrowserEntry.h>
|
||||
#include <AzToolsFramework/AssetBrowser/Entries/SourceAssetBrowserEntry.h>
|
||||
#include <AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h>
|
||||
#include <AzToolsFramework/AssetBrowser/Views/EntryDelegate.h>
|
||||
|
||||
@@ -28,9 +20,7 @@ AZ_PUSH_DISABLE_WARNING(
|
||||
#include <QCoreApplication>
|
||||
#include <QHeaderView>
|
||||
#include <QMenu>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QPen>
|
||||
|
||||
#include <QTimer>
|
||||
AZ_POP_DISABLE_WARNING
|
||||
namespace AzToolsFramework
|
||||
|
||||
-2
@@ -9,7 +9,6 @@
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzCore/Asset/AssetCommon.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserBus.h>
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h>
|
||||
@@ -55,7 +54,6 @@ namespace AzToolsFramework
|
||||
void OnAssetBrowserComponentReady() override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
Q_SIGNALS:
|
||||
void selectionChangedSignal(const QItemSelection& selected, const QItemSelection& deselected);
|
||||
void ClearStringFilter();
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace AzToolsFramework
|
||||
virtual SettingOutcome GetValue(const AZStd::string_view path) = 0;
|
||||
virtual SettingOutcome SetValue(const AZStd::string_view path, const AZStd::any& value) = 0;
|
||||
virtual ConsoleColorTheme GetConsoleColorTheme() const = 0;
|
||||
virtual int GetMaxNumberOfItemsShownInSearchView() const = 0;
|
||||
};
|
||||
|
||||
using EditorSettingsAPIBus = AZ::EBus<EditorSettingsAPIRequests>;
|
||||
|
||||
-10
@@ -1107,17 +1107,7 @@ namespace AzToolsFramework
|
||||
ElementAttribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)->
|
||||
Attribute(AZ::Edit::Attributes::NameLabelOverride, &AZ::ScriptProperty::m_name);
|
||||
|
||||
ec->Class<AZ::ScriptPropertyAsset>("Script Property Asset(asset)", "A script asset property")->
|
||||
ClassElement(AZ::Edit::ClassElements::EditorData, "ScriptPropertyEditorAsset's class attributes.")->
|
||||
Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)->
|
||||
DataElement("Asset", &AZ::ScriptPropertyAsset::m_value, "m_value", "An object")->
|
||||
Attribute(AZ::Edit::Attributes::NameLabelOverride, &AZ::ScriptProperty::m_name);
|
||||
|
||||
ec->Class<AZ::ScriptPropertyEntityRef>("Script Property Entity(EntityRef)", "A script entity reference property")->
|
||||
ClassElement(AZ::Edit::ClassElements::EditorData, "ScriptPropertyEditorEntityRef's class attributes.")->
|
||||
Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)->
|
||||
DataElement("EntityRef", &AZ::ScriptPropertyEntityRef::m_value, "m_entity", "An entity reference")->
|
||||
Attribute(AZ::Edit::Attributes::NameLabelOverride, &AZ::ScriptProperty::m_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+29
@@ -65,6 +65,35 @@ namespace UnitTest
|
||||
}
|
||||
}
|
||||
|
||||
bool FocusInteractionWidget::event(QEvent* event)
|
||||
{
|
||||
using AzToolsFramework::EditorInteractionSystemViewportSelectionRequestBus;
|
||||
|
||||
auto eventType = event->type();
|
||||
|
||||
switch (eventType)
|
||||
{
|
||||
case QEvent::MouseButtonPress:
|
||||
EditorInteractionSystemViewportSelectionRequestBus::Event(
|
||||
AzToolsFramework::GetEntityContextId(), &EditorInteractionSystemViewportSelectionRequestBus::Events::SetDefaultHandler);
|
||||
return true;
|
||||
case QEvent::FocusIn:
|
||||
case QEvent::FocusOut:
|
||||
{
|
||||
bool handled = false;
|
||||
AzToolsFramework::ViewportInteraction::MouseInteraction mouseInteraction;
|
||||
EditorInteractionSystemViewportSelectionRequestBus::EventResult(
|
||||
handled, AzToolsFramework::GetEntityContextId(),
|
||||
&EditorInteractionSystemViewportSelectionRequestBus::Events::InternalHandleMouseViewportInteraction,
|
||||
AzToolsFramework::ViewportInteraction::MouseInteractionEvent(
|
||||
mouseInteraction, AzToolsFramework::ViewportInteraction::MouseEvent::Down));
|
||||
return handled;
|
||||
}
|
||||
}
|
||||
|
||||
return QWidget::event(event);
|
||||
}
|
||||
|
||||
void TestEditorActions::Connect()
|
||||
{
|
||||
using AzToolsFramework::GetEntityContextId;
|
||||
|
||||
+15
-11
@@ -8,6 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzCore/Asset/AssetCommon.h>
|
||||
#include <AzCore/Component/ComponentApplicationBus.h>
|
||||
#include <AzCore/Slice/SliceAsset.h>
|
||||
@@ -31,6 +32,7 @@
|
||||
#include <AzToolsFramework/ViewportSelection/EditorInteractionSystemViewportSelectionRequestBus.h>
|
||||
#include <AzToolsFramework/SourceControl/PerforceConnection.h>
|
||||
#include <AzToolsFramework/UnitTest/ToolsTestApplication.h>
|
||||
#endif // !defined(Q_MOC_RUN)
|
||||
|
||||
#include <ostream>
|
||||
|
||||
@@ -40,7 +42,7 @@ AZ_POP_DISABLE_WARNING
|
||||
|
||||
#define AUTO_RESULT_IF_SETTING_TRUE(_settingName, _result) \
|
||||
{ \
|
||||
bool settingValue = true; \
|
||||
bool settingValue = true; \
|
||||
if (auto* registry = AZ::SettingsRegistry::Get()) \
|
||||
{ \
|
||||
registry->Get(settingValue, _settingName); \
|
||||
@@ -51,23 +53,16 @@ AZ_POP_DISABLE_WARNING
|
||||
EXPECT_TRUE(_result); \
|
||||
return; \
|
||||
} \
|
||||
}
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
class Entity;
|
||||
class EntityId;
|
||||
|
||||
} // namespace AZ
|
||||
}
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
constexpr AZStd::string_view prefabSystemSetting = "/Amazon/Preferences/EnablePrefabSystem";
|
||||
|
||||
/// Test widget to store QActions generated by EditorTransformComponentSelection.
|
||||
class TestWidget
|
||||
: public QWidget
|
||||
class TestWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TestWidget()
|
||||
: QWidget()
|
||||
@@ -79,6 +74,15 @@ namespace UnitTest
|
||||
bool eventFilter(QObject* watched, QEvent* event) override;
|
||||
};
|
||||
|
||||
/// Widget used to trigger a viewport interaction event while a focus change is happening.
|
||||
class FocusInteractionWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FocusInteractionWidget(QWidget* parent = nullptr) : QWidget(parent) {}
|
||||
bool event(QEvent* event) override;
|
||||
};
|
||||
|
||||
/// Stores actions registered for either normal mode (regular viewport) editing and
|
||||
/// component mode editing.
|
||||
class TestEditorActions
|
||||
|
||||
@@ -50,6 +50,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
|
||||
ly_add_target(
|
||||
NAME AzToolsFrameworkTestCommon STATIC
|
||||
NAMESPACE AZ
|
||||
AUTOMOC
|
||||
FILES_CMAKE
|
||||
AzToolsFramework/aztoolsframeworktestcommon_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
@@ -68,6 +69,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
|
||||
ly_add_target(
|
||||
NAME AzToolsFramework.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
|
||||
NAMESPACE AZ
|
||||
AUTOMOC
|
||||
FILES_CMAKE
|
||||
Tests/aztoolsframeworktests_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
|
||||
@@ -31,8 +31,10 @@
|
||||
#include <AzToolsFramework/Viewport/ActionBus.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorDefaultSelection.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorInteractionSystemViewportSelectionRequestBus.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorPickEntitySelection.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorVisibleEntityDataCache.h>
|
||||
#include <AzToolsFramework/ViewportUi/ViewportUiManager.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -188,6 +190,47 @@ namespace UnitTest
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// EditorTransformComponentSelection Tests
|
||||
|
||||
TEST_F(EditorTransformComponentSelectionFixture, Focus_is_not_changed_while_switching_viewport_interaction_request_instance)
|
||||
{
|
||||
// setup a dummy widget and make it the active window to ensure focus in/out events are fired
|
||||
auto dummyWidget = AZStd::make_unique<QWidget>();
|
||||
QApplication::setActiveWindow(dummyWidget.get());
|
||||
|
||||
// note: it is important to make sure the focus widget is parented to the dummy widget to have focus in/out events fire
|
||||
auto focusWidget = AZStd::make_unique<UnitTest::FocusInteractionWidget>(dummyWidget.get());
|
||||
|
||||
const auto previousFocusWidget = QApplication::focusWidget();
|
||||
|
||||
// Given
|
||||
// setup viewport ui system
|
||||
AzToolsFramework::ViewportUi::ViewportUiManager viewportUiManager;
|
||||
viewportUiManager.ConnectViewportUiBus(AzToolsFramework::ViewportUi::DefaultViewportId);
|
||||
viewportUiManager.InitializeViewportUi(&m_editorActions.m_defaultWidget, focusWidget.get());
|
||||
|
||||
// begin EditorPickEntitySelection
|
||||
using AzToolsFramework::EditorInteractionSystemViewportSelectionRequestBus;
|
||||
EditorInteractionSystemViewportSelectionRequestBus::Event(
|
||||
AzToolsFramework::GetEntityContextId(), &EditorInteractionSystemViewportSelectionRequestBus::Events::SetHandler,
|
||||
[](const AzToolsFramework::EditorVisibleEntityDataCache* entityDataCache)
|
||||
{
|
||||
return AZStd::make_unique<AzToolsFramework::EditorPickEntitySelection>(entityDataCache);
|
||||
});
|
||||
|
||||
// When
|
||||
// a mouse event is sent to the focus widget (set to be the render overlay in the viewport ui system)
|
||||
QTest::mouseClick(focusWidget.get(), Qt::MouseButton::LeftButton);
|
||||
|
||||
// Then
|
||||
// focus should not change
|
||||
EXPECT_FALSE(focusWidget->hasFocus());
|
||||
EXPECT_EQ(previousFocusWidget, QApplication::focusWidget());
|
||||
|
||||
// clean up
|
||||
viewportUiManager.DisconnectViewportUiBus();
|
||||
focusWidget.reset();
|
||||
dummyWidget.reset();
|
||||
}
|
||||
|
||||
TEST_F(EditorTransformComponentSelectionFixture, ManipulatorOrientationIsResetWhenEntityOrientationIsReset)
|
||||
{
|
||||
using AzToolsFramework::EditorTransformComponentSelectionRequestBus;
|
||||
|
||||
@@ -245,12 +245,15 @@ namespace UnitTest
|
||||
{
|
||||
using testing::StrEq;
|
||||
|
||||
QLocale testLocale{ QLocale() };
|
||||
QString testString = "10" + QString(testLocale.decimalPoint()) + "0";
|
||||
|
||||
m_doubleSpinBox->setSuffix("m");
|
||||
m_doubleSpinBox->setValue(10.0);
|
||||
|
||||
// test internal logic (textFromValue() calls private StringValue())
|
||||
QString value = m_doubleSpinBox->textFromValue(10.0);
|
||||
EXPECT_THAT(value.toUtf8().constData(), StrEq("10.0"));
|
||||
EXPECT_THAT(value.toUtf8().constData(), testString);
|
||||
|
||||
m_doubleSpinBox->setFocus();
|
||||
EXPECT_THAT(m_doubleSpinBox->suffix().toUtf8().constData(), StrEq(""));
|
||||
@@ -293,31 +296,44 @@ namespace UnitTest
|
||||
|
||||
TEST_F(SpinBoxFixture, SpinBoxCheckHighValueTruncatesCorrectly)
|
||||
{
|
||||
QString value = setupTruncationTest("0.9999999");
|
||||
QLocale testLocale{ QLocale() };
|
||||
QString testString = "0" + QString(testLocale.decimalPoint()) + "9999999";
|
||||
QString value = setupTruncationTest(testString);
|
||||
|
||||
EXPECT_TRUE(value == "0.999");
|
||||
testString = "0" + QString(testLocale.decimalPoint()) + "999";
|
||||
EXPECT_TRUE(value == testString);
|
||||
}
|
||||
|
||||
TEST_F(SpinBoxFixture, SpinBoxCheckLowValueTruncatesCorrectly)
|
||||
{
|
||||
QString value = setupTruncationTest("0.0000001");
|
||||
QLocale testLocale{ QLocale() };
|
||||
QString testString = "0" + QString(testLocale.decimalPoint()) + "0000001";
|
||||
QString value = setupTruncationTest(testString);
|
||||
|
||||
EXPECT_TRUE(value == "0.0");
|
||||
testString = "0" + QString(testLocale.decimalPoint()) + "0";
|
||||
EXPECT_TRUE(value == testString);
|
||||
}
|
||||
|
||||
TEST_F(SpinBoxFixture, SpinBoxCheckBugValuesTruncatesCorrectly)
|
||||
{
|
||||
QString value = setupTruncationTest("0.12395");
|
||||
QLocale testLocale{ QLocale() };
|
||||
QString testString = "0" + QString(testLocale.decimalPoint()) + "12395";
|
||||
QString value = setupTruncationTest(testString);
|
||||
|
||||
EXPECT_TRUE(value == "0.123");
|
||||
testString = "0" + QString(testLocale.decimalPoint()) + "123";
|
||||
EXPECT_TRUE(value == testString);
|
||||
|
||||
value = setupTruncationTest("0.94496");
|
||||
testString = "0" + QString(testLocale.decimalPoint()) + "94496";
|
||||
value = setupTruncationTest(testString);
|
||||
|
||||
EXPECT_TRUE(value == "0.944");
|
||||
testString = "0" + QString(testLocale.decimalPoint()) + "944";
|
||||
EXPECT_TRUE(value == testString);
|
||||
|
||||
value = setupTruncationTest("0.0009999");
|
||||
testString = "0" + QString(testLocale.decimalPoint()) + "0009999";
|
||||
value = setupTruncationTest(testString);
|
||||
|
||||
EXPECT_TRUE(value == "0.0");
|
||||
testString = "0" + QString(testLocale.decimalPoint()) + "0";
|
||||
EXPECT_TRUE(value == testString);
|
||||
}
|
||||
|
||||
} // namespace UnitTest
|
||||
|
||||
Reference in New Issue
Block a user