diff --git a/Source/Engine/Level/DirectionalLight.cs b/Source/Engine/Level/DirectionalLight.cs index 201d35dc1..032d0dce6 100644 --- a/Source/Engine/Level/DirectionalLight.cs +++ b/Source/Engine/Level/DirectionalLight.cs @@ -1,3 +1,5 @@ +// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved. + namespace FlaxEngine { public partial class DirectionalLight diff --git a/Source/Engine/Tests/TestDebugCommands.cpp b/Source/Engine/Tests/TestDebugCommands.cpp new file mode 100644 index 000000000..d8b8c2e08 --- /dev/null +++ b/Source/Engine/Tests/TestDebugCommands.cpp @@ -0,0 +1,45 @@ +// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved. + +#include "TestScripting.h" +#include "Engine/Debug/DebugCommands.h" +#include + +namespace +{ + bool PassExec = false; +} + +bool TestDebugCommand1::Var = false; +float TestDebugCommand2::Var = 0.0f; + +TestDebugCommand2::TestDebugCommand2(const SpawnParams& params) + : ScriptingObject(params) +{ +} + +void TestDebugCommand2::Exec() +{ + PassExec = true; +} + +TEST_CASE("DebugCommands") +{ + SECTION("Test Commands") + { + // Test async cache flow + DebugCommands::InitAsync(); + Platform::Sleep(1); + + // Test commands invoking + CHECK(TestDebugCommand1::Var == false); + DebugCommands::Execute(TEXT("TestDebugCommand1.Var true")); + CHECK(TestDebugCommand1::Var == true); + CHECK(TestDebugCommand2::Var == 0.0f); + DebugCommands::Execute(TEXT("TestDebugCommand2.Var 1.5")); + DebugCommands::Execute(TEXT("TestDebugCommand2.Var")); + CHECK(TestDebugCommand2::Var == 1.5f); + CHECK(!PassExec); + DebugCommands::Execute(TEXT("TestDebugCommand2.Exec")); + CHECK(PassExec); + } +} diff --git a/Source/Engine/Tests/TestScripting.h b/Source/Engine/Tests/TestScripting.h index dc05750e1..b86938b85 100644 --- a/Source/Engine/Tests/TestScripting.h +++ b/Source/Engine/Tests/TestScripting.h @@ -177,3 +177,24 @@ public: return str.Length(); } }; + +// Test debug commands via static class. +API_CLASS(Static, Attributes="DebugCommand") class FLAXENGINE_API TestDebugCommand1 +{ + DECLARE_SCRIPTING_TYPE_NO_SPAWN(TestDebugCommand1); + + // Static variable to test. + API_FIELD() static bool Var; +}; + +// Test debug commands inside a class. +API_CLASS() class FLAXENGINE_API TestDebugCommand2 : public ScriptingObject +{ + DECLARE_SCRIPTING_TYPE(TestDebugCommand2); + + // Static variable to test. + API_FIELD(Attributes="DebugCommand") static float Var; + + // Static method to test. + API_FUNCTION(Attributes="DebugCommand") static void Exec(); +};