Merge remote-tracking branch 'upstream/development' into nvsickle/GenericDomJson

This commit is contained in:
Nicholas Van Sickle
2021-11-29 09:40:56 -08:00
2916 changed files with 268517 additions and 32443 deletions
+41 -6
View File
@@ -2376,17 +2376,52 @@ namespace UnitTest
static_assert(AZStd::wildcard_match_case(filter1, blahValue));
}
TEST_F(String, StringEraseIf_Succeeds)
TEST_F(String, StringCXX20Erase_Succeeds)
{
AZStd::string eraseIfTest = "ABC CBA";
auto eraseCount = AZStd::erase_if(eraseIfTest, [](AZStd::string::value_type ch)
{
return ch == 'C';
});
auto erasePredicate = [](AZStd::string::value_type ch)
{
return ch == 'C';
};
auto eraseCount = AZStd::erase_if(eraseIfTest, erasePredicate);
EXPECT_EQ(2, eraseCount);
EXPECT_EQ(5, eraseIfTest.size());
EXPECT_STREQ("AB BA", eraseIfTest.c_str());
// Now erase the letter 'A';
eraseCount = AZStd::erase(eraseIfTest, 'A');
EXPECT_EQ(2, eraseCount);
EXPECT_EQ(3, eraseIfTest.size());
EXPECT_EQ("B B", eraseIfTest);
}
TEST_F(String, FixedStringCXX20Erase_Succeeds)
{
// Erase 'l' from the phrase "Hello" World"
constexpr auto eraseTest = [](const char* testString) constexpr
{
AZStd::fixed_string<16> testResult{ testString };
AZStd::erase(testResult, 'l');
return testResult;
}("HelloWorld");
static_assert(eraseTest == "HeoWord");
EXPECT_EQ("HeoWord", eraseTest);
// Use erase_if to erase both 'H' and 'e' from the remaining eraseTest string
constexpr auto eraseIfTest = [](AZStd::string_view testString) constexpr
{
AZStd::fixed_string<16> testResult{ testString };
auto erasePredicate = [](char ch)
{
return ch == 'H' || ch == 'e';
};
AZStd::erase_if(testResult, erasePredicate);
return testResult;
}(eraseTest);
static_assert(eraseIfTest == "oWord");
EXPECT_EQ("oWord", eraseIfTest);
}
template <typename StringType>
@@ -753,7 +753,7 @@ namespace UnitTest
TEST_F(Arrays, FixedVectorCanCopyAndMoveWithDifferentCapacity)
{
constexpr AZStd::fixed_vector<int, 32> sourceVector{ 1,2,3,4,5 };
AZStd::fixed_vector<int, 32> sourceVector{ 1,2,3,4,5 };
AZStd::fixed_vector<int, 8> copyConstructVector{ sourceVector };
EXPECT_EQ(sourceVector, copyConstructVector);
@@ -768,32 +768,63 @@ namespace UnitTest
AZStd::fixed_vector<int, 16> moveAssignVector = AZStd::move(moveConstructVector);
constexpr AZStd::fixed_vector expectedVector{ 1,2,3,4,5,6 };
AZStd::fixed_vector expectedVector{ 1,2,3,4,5,6 };
EXPECT_EQ(expectedVector, moveAssignVector);
}
TEST_F(Arrays, FixedVectorComparisonOperatorsSucceedAsExpected)
{
constexpr AZStd::fixed_vector<int, 32> testVector{ 1,2,3,4,5 };
constexpr AZStd::fixed_vector<int, 32> equalVector{ 1,2,3,4,5 };
constexpr AZStd::fixed_vector<int, 32> notEqualVectorDifferentSize{ 1,2,3,4,5,6 };
constexpr AZStd::fixed_vector<int, 32> lessVector{ 1,2,3,4,4 };
constexpr AZStd::fixed_vector<int, 32> greaterVectorDifferentSize{ 1,2,3,4,5, 1 };
AZStd::fixed_vector<int, 32> testVector{ 1,2,3,4,5 };
AZStd::fixed_vector<int, 32> equalVector{ 1,2,3,4,5 };
AZStd::fixed_vector<int, 32> notEqualVectorDifferentSize{ 1,2,3,4,5,6 };
AZStd::fixed_vector<int, 32> lessVector{ 1,2,3,4,4 };
AZStd::fixed_vector<int, 32> greaterVectorDifferentSize{ 1,2,3,4,5, 1 };
static_assert(testVector == equalVector);
static_assert(testVector != notEqualVectorDifferentSize);
static_assert(testVector != lessVector);
static_assert(lessVector < testVector);
static_assert(lessVector < greaterVectorDifferentSize);
static_assert(lessVector <= lessVector);
static_assert(lessVector <= testVector);
static_assert(lessVector <= greaterVectorDifferentSize);
static_assert(testVector > lessVector);
static_assert(testVector > lessVector);
static_assert(notEqualVectorDifferentSize > testVector);
static_assert(testVector >= testVector);
static_assert(testVector >= lessVector);
static_assert(greaterVectorDifferentSize > lessVector);
EXPECT_EQ(testVector, equalVector);
EXPECT_NE(testVector, notEqualVectorDifferentSize);
EXPECT_NE(testVector, lessVector);
EXPECT_LT(lessVector, testVector);
EXPECT_LT(lessVector, greaterVectorDifferentSize);
EXPECT_LE(lessVector, lessVector);
EXPECT_LE(lessVector, testVector);
EXPECT_LE(lessVector, greaterVectorDifferentSize);
EXPECT_GT(testVector, lessVector);
EXPECT_GT(testVector, lessVector);
EXPECT_GT(notEqualVectorDifferentSize, testVector);
EXPECT_GE(testVector, testVector);
EXPECT_GE(testVector, lessVector);
EXPECT_GT(greaterVectorDifferentSize, lessVector);
}
TEST_F(Arrays, FixedVectorCXX20Erase_Succeeds)
{
// Erase 'l' from the phrase "Hello" World"
auto eraseTest = [](AZStd::initializer_list<char> testInit)
{
AZStd::fixed_vector<char, 16> testResult{ testInit };
AZStd::erase(testResult, 'l');
return testResult;
}({ 'H', 'e', 'l', 'l', 'o', 'W', 'o', 'r', 'l', 'd' });
constexpr AZStd::string_view expectedEraseString = "HeoWord";
AZStd::string_view testEraseString{ eraseTest.begin(), eraseTest.end() };
EXPECT_EQ(expectedEraseString, testEraseString);
// Use erase_if to erase both 'H' and 'e' from the remaining eraseTest string
auto eraseIfTest = [](const AZStd::fixed_vector<char, 16>& testVector)
{
AZStd::fixed_vector<char, 16> testResult{ testVector };
auto erasePredicate = [](char ch)
{
return ch == 'H' || ch == 'e';
};
AZStd::erase_if(testResult, erasePredicate);
return testResult;
}(testEraseString);
constexpr AZStd::string_view expectedEraseIfString = "oWord";
AZStd::string_view testEraseIfString{ eraseIfTest.begin(), eraseIfTest.end() };
EXPECT_EQ(expectedEraseIfString, testEraseIfString);
}
TEST_F(Arrays, VectorSwap)
@@ -608,24 +608,9 @@ namespace UnitTest
AZ::Data::AssetData::AssetStatus expected_base_status = AZ::Data::AssetData::AssetStatus::Ready;
EXPECT_EQ(baseStatus, expected_base_status);
}
struct DebugListener : AZ::Interface<IDebugAssetEvent>::Registrar
{
void AssetStatusUpdate(AZ::Data::AssetId id, AZ::Data::AssetData::AssetStatus status) override
{
AZ::Debug::Trace::Output(
"", AZStd::string::format("Status %s - %d\n", id.ToString<AZStd::string>().c_str(), static_cast<int>(status)).c_str());
}
void ReleaseAsset(AZ::Data::AssetId id) override
{
AZ::Debug::Trace::Output(
"", AZStd::string::format("Release %s\n", id.ToString<AZStd::string>().c_str()).c_str());
}
};
TEST_F(AssetJobsFloodTest, RapidAcquireAndRelease)
{
DebugListener listener;
auto assetUuids = {
MyAsset1Id,
MyAsset2Id,
@@ -652,7 +637,7 @@ namespace UnitTest
threads.emplace_back([this, &threadCount, &cv, assetUuid]() {
bool checkLoaded = true;
for (int i = 0; i < 5000; i++)
for (int i = 0; i < 1000; i++)
{
Asset<AssetWithAssetReference> asset1 =
m_testAssetManager->GetAsset(assetUuid, azrtti_typeid<AssetWithAssetReference>(), AZ::Data::AssetLoadBehavior::PreLoad);
@@ -678,7 +663,7 @@ namespace UnitTest
while (threadCount > 0 && !timedOut)
{
AZStd::unique_lock<AZStd::mutex> lock(mutex);
timedOut = (AZStd::cv_status::timeout == cv.wait_until(lock, AZStd::chrono::system_clock::now() + DefaultTimeoutSeconds * 20000));
timedOut = (AZStd::cv_status::timeout == cv.wait_until(lock, AZStd::chrono::system_clock::now() + DefaultTimeoutSeconds));
}
ASSERT_EQ(threadCount, 0) << "Thread count is non-zero, a thread has likely deadlocked. Test will not shut down cleanly.";
@@ -1190,7 +1175,7 @@ namespace UnitTest
#if AZ_TRAIT_DISABLE_FAILED_ASSET_MANAGER_TESTS
TEST_F(AssetJobsFloodTest, DISABLED_ContainerFilterTest_ContainersWithAndWithoutFiltering_Success)
#else
TEST_F(AssetJobsFloodTest, DISABLED_ContainerFilterTest_ContainersWithAndWithoutFiltering_Success)
TEST_F(AssetJobsFloodTest, ContainerFilterTest_ContainersWithAndWithoutFiltering_Success)
#endif // !AZ_TRAIT_DISABLE_FAILED_ASSET_MANAGER_TESTS
{
m_assetHandlerAndCatalog->AssetCatalogRequestBus::Handler::BusConnect();
@@ -2297,6 +2282,45 @@ namespace UnitTest
AssetManager::Destroy();
}
struct MockAssetContainer : AssetContainer
{
MockAssetContainer(Asset<AssetData> assetData, const AssetLoadParameters& loadParams)
{
// Copying the code in the original constructor, we can't call that constructor because it will not invoke our virtual method
m_rootAsset = AssetInternal::WeakAsset<AssetData>(assetData);
m_containerAssetId = m_rootAsset.GetId();
AddDependentAssets(assetData, loadParams);
}
protected:
AZStd::vector<AZStd::pair<AssetInfo, Asset<AssetData>>> CreateAndQueueDependentAssets(
const AZStd::vector<AssetInfo>& dependencyInfoList, const AssetLoadParameters& loadParamsCopyWithNoLoadingFilter) override
{
auto result = AssetContainer::CreateAndQueueDependentAssets(dependencyInfoList, loadParamsCopyWithNoLoadingFilter);
// Sleep for a long enough time to allow asset loads to complete and start triggering AssetReady events
// This forces the race condition to occur
AZStd::this_thread::sleep_for(AZStd::chrono::milliseconds(500));
return result;
}
};
struct MockAssetManager : AssetManager
{
explicit MockAssetManager(const Descriptor& desc)
: AssetManager(desc)
{
}
protected:
AZStd::shared_ptr<AssetContainer> CreateAssetContainer(Asset<AssetData> asset, const AssetLoadParameters& loadParams) const override
{
return AZStd::shared_ptr<AssetContainer>(aznew MockAssetContainer(asset, loadParams));
}
};
void ParallelDeepAssetReferences()
{
SerializeContext context;
@@ -2304,7 +2328,7 @@ namespace UnitTest
AssetWithAssetReference::Reflect(context);
AssetManager::Descriptor desc;
AssetManager::Create(desc);
AssetManager::SetInstance(aznew MockAssetManager(desc));
auto& db = AssetManager::Instance();
@@ -2327,17 +2351,17 @@ namespace UnitTest
// AssetC is MYASSETC
AssetWithAssetReference c;
c.m_asset = AssetManager::Instance().CreateAsset<AssetWithSerializedData>(AssetId(MyAssetDId)); // point at D
c.m_asset = db.CreateAsset<AssetWithSerializedData>(AssetId(MyAssetDId)); // point at D
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset3.txt", AZ::DataStream::ST_XML, &c, &context));
// AssetB is MYASSETB
AssetWithAssetReference b;
b.m_asset = AssetManager::Instance().CreateAsset<AssetWithAssetReference>(AssetId(MyAssetCId)); // point at C
b.m_asset = db.CreateAsset<AssetWithAssetReference>(AssetId(MyAssetCId)); // point at C
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset2.txt", AZ::DataStream::ST_XML, &b, &context));
// AssetA will be written to disk as MYASSETA
AssetWithAssetReference a;
a.m_asset = AssetManager::Instance().CreateAsset<AssetWithAssetReference>(AssetId(MyAssetBId)); // point at B
a.m_asset = db.CreateAsset<AssetWithAssetReference>(AssetId(MyAssetBId)); // point at B
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset1.txt", AZ::DataStream::ST_XML, &a, &context));
}
@@ -2546,7 +2570,7 @@ namespace UnitTest
TEST_F(AssetJobsMultithreadedTest, DISABLED_ParallelDeepAssetReferences)
#else
// temporarily disabled until sporadic failures can be root caused
TEST_F(AssetJobsMultithreadedTest, DISABLED_ParallelDeepAssetReferences)
TEST_F(AssetJobsMultithreadedTest, ParallelDeepAssetReferences)
#endif // AZ_TRAIT_DISABLE_FAILED_ASSET_MANAGER_TESTS
{
ParallelDeepAssetReferences();
@@ -67,7 +67,10 @@ namespace UnitTest
{
SerializeContextFixture::SetUp();
SuppressTraceOutput(false);
AZ::JobManagerDesc jobDesc;
AZ::JobManagerThreadDesc threadDesc;
for (size_t threadCount = 0; threadCount < GetNumJobManagerThreads(); threadCount++)
{
@@ -111,9 +114,21 @@ namespace UnitTest
delete m_jobContext;
delete m_jobManager;
// Reset back to default suppression settings to avoid affecting other tests
SuppressTraceOutput(true);
SerializeContextFixture::TearDown();
}
void BaseAssetManagerTest::SuppressTraceOutput(bool suppress)
{
UnitTest::TestRunner::Instance().m_suppressAsserts = suppress;
UnitTest::TestRunner::Instance().m_suppressErrors = suppress;
UnitTest::TestRunner::Instance().m_suppressWarnings = suppress;
UnitTest::TestRunner::Instance().m_suppressPrintf = suppress;
UnitTest::TestRunner::Instance().m_suppressOutput = suppress;
}
void BaseAssetManagerTest::WriteAssetToDisk(const AZStd::string& assetName, [[maybe_unused]] const AZStd::string& assetIdGuid)
{
AZStd::string assetFileName = GetTestFolderPath() + assetName;
@@ -63,6 +63,8 @@ namespace UnitTest
void SetUp() override;
void TearDown() override;
static void SuppressTraceOutput(bool suppress);
// Helper methods to create and destroy actual assets on the disk for true end-to-end asset loading.
void WriteAssetToDisk(const AZStd::string& assetName, const AZStd::string& assetIdGuid);
void DeleteAssetFromDisk(const AZStd::string& assetName);
@@ -59,7 +59,6 @@ namespace UnitTest
AZ::SerializeContext* GetSerializeContext() override { return nullptr; }
AZ::BehaviorContext* GetBehaviorContext() override { return m_behaviorContext; }
AZ::JsonRegistrationContext* GetJsonRegistrationContext() override { return nullptr; }
const char* GetAppRoot() const override { return nullptr; }
const char* GetEngineRoot() const override { return nullptr; }
const char* GetExecutableFolder() const override { return nullptr; }
void EnumerateEntities(const EntityCallback& /*callback*/) override {}
+7 -13
View File
@@ -1060,26 +1060,21 @@ namespace UnitTest
/**
* UserSettingsComponent test
*/
class UserSettingsTestApp
: public ComponentApplication
, public UserSettingsFileLocatorBus::Handler
{
public:
void SetExecutableFolder(const char* path)
{
m_exeDirectory = path;
}
class UserSettingsTestApp
: public ComponentApplication
, public UserSettingsFileLocatorBus::Handler
{
public:
AZStd::string ResolveFilePath(u32 providerId) override
{
AZStd::string filePath;
if (providerId == UserSettings::CT_GLOBAL)
{
filePath = (m_exeDirectory / "GlobalUserSettings.xml").String();
filePath = (AZ::IO::Path(GetTestFolderPath()) / "GlobalUserSettings.xml").Native();
}
else if (providerId == UserSettings::CT_LOCAL)
{
filePath = (m_exeDirectory / "LocalUserSettings.xml").String();
filePath = (AZ::IO::Path(GetTestFolderPath()) / "LocalUserSettings.xml").Native();
}
return filePath;
}
@@ -1117,7 +1112,6 @@ namespace UnitTest
ComponentApplication::Descriptor appDesc;
appDesc.m_memoryBlocksByteSize = 10 * 1024 * 1024;
Entity* systemEntity = app.Create(appDesc);
app.SetExecutableFolder(GetTestFolderPath().c_str());
app.UserSettingsFileLocatorBus::Handler::BusConnect();
// Make sure user settings file does not exist at this point
-1
View File
@@ -6,7 +6,6 @@
*
*/
#include <AzCore/Debug/Timer.h>
#include <AzCore/Debug/StackTracer.h>
#include <AzCore/Debug/TraceMessagesDrillerBus.h>
#include <AzCore/Debug/Profiler.h>
@@ -11,7 +11,7 @@
#include <AzCore/EBus/ScheduledEvent.h>
#include <AzCore/Interface/Interface.h>
#include <AzCore/Console/LoggerSystemComponent.h>
#include <AzCore/Time/TimeSystemComponent.h>
#include <AzCore/Time/TimeSystem.h>
#include <AzCore/Name/NameDictionary.h>
#include <AzCore/UnitTest/TestTypes.h>
@@ -26,22 +26,22 @@ namespace UnitTest
SetupAllocator();
AZ::NameDictionary::Create();
m_loggerComponent = new AZ::LoggerSystemComponent;
m_timeComponent = new AZ::TimeSystemComponent;
m_eventSchedulerComponent = new AZ::EventSchedulerSystemComponent;
m_loggerComponent = AZStd::make_unique<AZ::LoggerSystemComponent>();
m_timeSystem = AZStd::make_unique<AZ::TimeSystem>();
m_eventSchedulerComponent = AZStd::make_unique<AZ::EventSchedulerSystemComponent>();
m_testEvent = new AZ::ScheduledEvent([this] { TestBasicEvent(); }, AZ::Name("UnitTestEvent fire once event"));
m_testRequeue = new AZ::ScheduledEvent([this] { TestAutoRequeuedEvent(); }, AZ::Name("UnitTestEvent auto Requeue"));
m_testEvent = AZStd::make_unique<AZ::ScheduledEvent>([this] { TestBasicEvent(); }, AZ::Name("UnitTestEvent fire once event"));
m_testRequeue = AZStd::make_unique<AZ::ScheduledEvent>([this] { TestAutoRequeuedEvent(); }, AZ::Name("UnitTestEvent auto Requeue"));
}
void TearDown() override
{
delete m_testEvent;
delete m_testRequeue;
m_testEvent.reset();
m_testRequeue.reset();
delete m_eventSchedulerComponent;
delete m_timeComponent;
delete m_loggerComponent;
m_eventSchedulerComponent.reset();
m_timeSystem.reset();
m_loggerComponent.reset();
AZ::NameDictionary::Destroy();
TeardownAllocator();
@@ -60,12 +60,12 @@ namespace UnitTest
uint32_t m_basicEventTriggerCount = 0;
uint32_t m_requeuedEventTriggerCount = 0;
AZ::ScheduledEvent* m_testEvent = nullptr;
AZ::ScheduledEvent* m_testRequeue = nullptr;
AZStd::unique_ptr<AZ::ScheduledEvent> m_testEvent;
AZStd::unique_ptr<AZ::ScheduledEvent> m_testRequeue;
AZ::LoggerSystemComponent* m_loggerComponent = nullptr;
AZ::TimeSystemComponent* m_timeComponent = nullptr;
AZ::EventSchedulerSystemComponent* m_eventSchedulerComponent = nullptr;
AZStd::unique_ptr<AZ::LoggerSystemComponent> m_loggerComponent;
AZStd::unique_ptr<AZ::TimeSystem> m_timeSystem;
AZStd::unique_ptr<AZ::EventSchedulerSystemComponent> m_eventSchedulerComponent;
};
TEST_F(ScheduledEventTests, TestFireOnce)
@@ -552,7 +552,6 @@ namespace UnitTest
box.testCaseName = "BoxShaped";
frustums.push_back(box);
// Default values in a CCamera from Cry_Camera.h
FrustumTestCase defaultCameraFrustum;
defaultCameraFrustum.nearTopLeft = AZ::Vector3(-0.204621f, 0.200000f, 0.153465f);
defaultCameraFrustum.nearTopRight = AZ::Vector3(0.204621f, 0.200000f, 0.153465f);
@@ -33,6 +33,15 @@ namespace MathTestData
AZ::Matrix3x3::CreateScale(AZ::Vector3(0.7f, 1.3f, 0.9f))
};
static const AZ::Matrix4x4 Matrix4x4s[] = {
AZ::Matrix4x4::CreateIdentity(),
AZ::Matrix4x4::CreateFromQuaternionAndTranslation(AZ::Quaternion(-0.46f, 0.26f, -0.22f, 0.82f), AZ::Vector3(1.0f, 5.0f, 10.0f)),
AZ::Matrix4x4::CreateFromTransform(AZ::Transform::CreateFromMatrix3x3AndTranslation(
AZ::Matrix3x3::CreateScale(AZ::Vector3(1.0f, 2.0f, 3.0f)), AZ::Vector3(2.0f, 4.0f, 6.0f))),
AZ::Matrix4x4::CreateScale(AZ::Vector3(5.0f, 10.0f, 15.0f)),
AZ::Matrix4x4::CreateRotationZ(AZ::DegToRad(45.0f))
};
using AxisPair = AZStd::pair<AZ::Constants::Axis, AZ::Vector3>;
static const AxisPair Axes[] = {
{ AZ::Constants::Axis::XPositive, AZ::Vector3::CreateAxisX(1.0f) },
@@ -10,6 +10,7 @@
#include <AzCore/Math/Matrix3x4.h>
#include <AzCore/Math/Matrix3x3.h>
#include <AzCore/Math/Quaternion.h>
#include <AzCore/Math/VectorConversions.h>
#include <AZTestShared/Math/MathTestHelpers.h>
#include "MathTestData.h"
@@ -392,6 +393,32 @@ namespace UnitTest
INSTANTIATE_TEST_CASE_P(MATH_Matrix3x4, Matrix3x4CreateFromMatrix3x3Fixture, ::testing::ValuesIn(MathTestData::Matrix3x3s));
using Matrix3x4CreateFromMatrix4x4Fixture = ::testing::TestWithParam<AZ::Matrix4x4>;
TEST_P(Matrix3x4CreateFromMatrix4x4Fixture, UnsafeCreateFromMatrix4x4)
{
const AZ::Matrix4x4 matrix4x4 = GetParam();
const AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::UnsafeCreateFromMatrix4x4(matrix4x4);
EXPECT_THAT(matrix3x4.GetTranslation(), IsClose(matrix4x4.GetTranslation()));
const AZ::Vector3 vector(2.3f, -0.6, 1.8f);
EXPECT_THAT(matrix3x4.TransformVector(vector), IsClose((matrix4x4 * AZ::Vector3ToVector4(vector, 0.0f)).GetAsVector3()));
const AZ::Vector3 point(12.3f, -5.6, 7.3f);
EXPECT_THAT(matrix3x4.TransformPoint(point), IsClose((matrix4x4 * AZ::Vector3ToVector4(point, 1.0f)).GetAsVector3()));
}
INSTANTIATE_TEST_CASE_P(MATH_Matrix3x4, Matrix3x4CreateFromMatrix4x4Fixture, ::testing::ValuesIn(MathTestData::Matrix4x4s));
TEST(MATH_Matrix3x4, TransformPoint)
{
const AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromMatrix3x3AndTranslation(
AZ::Matrix3x3::CreateRotationY(AZ::DegToRad(90.0f)), AZ::Vector3(5.0f, 0.0f, 0.0f));
const AZ::Vector3 result = matrix3x4.TransformPoint(AZ::Vector3(1.0f, 0.0f, 0.0f));
const AZ::Vector3 expected = AZ::Vector3(5.0f, 0.0f, -1.0f);
EXPECT_THAT(result, expected);
}
TEST(MATH_Matrix3x4, CreateScale)
{
const AZ::Vector3 scale(1.7f, 0.3f, 2.4f);
@@ -1240,7 +1240,6 @@ namespace UnitTest
SerializeContext* GetSerializeContext() override { return m_serializeContext.get(); }
BehaviorContext* GetBehaviorContext() override { return nullptr; }
JsonRegistrationContext* GetJsonRegistrationContext() override { return nullptr; }
const char* GetAppRoot() const override { return nullptr; }
const char* GetEngineRoot() const override { return nullptr; }
const char* GetExecutableFolder() const override { return nullptr; }
void EnumerateEntities(const EntityCallback& /*callback*/) override {}
+28 -4
View File
@@ -6,7 +6,7 @@
*
*/
#include <AzCore/Time/TimeSystemComponent.h>
#include <AzCore/Time/TimeSystem.h>
#include <AzCore/UnitTest/TestTypes.h>
namespace UnitTest
@@ -18,16 +18,16 @@ namespace UnitTest
void SetUp() override
{
SetupAllocator();
m_timeComponent = new AZ::TimeSystemComponent;
m_timeSystem = AZStd::make_unique<AZ::TimeSystem>();
}
void TearDown() override
{
delete m_timeComponent;
m_timeSystem.reset();
TeardownAllocator();
}
AZ::TimeSystemComponent* m_timeComponent = nullptr;
AZStd::unique_ptr<AZ::TimeSystem> m_timeSystem;
};
TEST_F(TimeTests, TestConversionUsToMs)
@@ -44,6 +44,30 @@ namespace UnitTest
EXPECT_EQ(timeUs, AZ::TimeUs{ 1000000 });
}
TEST_F(TimeTests, TestConversionTimeMsToSeconds)
{
AZ::TimeMs timeMs = AZ::TimeMs{ 1000 };
float timeSecondsFloat = AZ::TimeMsToSeconds(timeMs);
EXPECT_TRUE(AZ::IsClose(timeSecondsFloat, 1.0f));
double timeSecondsDouble = AZ::TimeMsToSecondsDouble(timeMs);
EXPECT_TRUE(AZ::IsClose(timeSecondsDouble, 1.0));
}
TEST_F(TimeTests, TestConversionSecondsToTimeUs)
{
double seconds = 1.0;
AZ::TimeUs timeUs = AZ::SecondsToTimeUs(seconds);
EXPECT_EQ(timeUs, AZ::TimeUs{ 1000000 });
}
TEST_F(TimeTests, TestConversionSecondsToTimeMs)
{
double seconds = 1.0;
AZ::TimeMs timeMs = AZ::SecondsToTimeMs(seconds);
EXPECT_EQ(timeMs, AZ::TimeMs{ 1000 });
}
TEST_F(TimeTests, TestClocks)
{
AZ::TimeUs timeUs = AZ::GetElapsedTimeUs();