{LYN-2185} Helios - Added GraphObjectProxy::GetMethodList() function (#392)
* {LYN-2185} Helios - Added GraphObjectProxy::GetMethodList() function
* Updated the EditorPythonConsoleInterface to get Python type name info
* Added PythonBehaviorInfo to the GraphObjectProxy object to reflect abstract calls that can be invoked
* removed SCENE_DATA_API from Reflect() function
Jira: https://jira.agscollab.com/browse/LYN-2185
Tests: Added tests GraphObjectProxy_GetClassInfo_Loads & GraphObjectProxy_GetClassInfo_CorrectFormats to regress test
* fix compile error
* etchPythonTypeName() returns AZStd::string
* put None into a const char
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include <AzCore/Component/ComponentApplication.h>
|
||||
#include <AzCore/Serialization/Json/RegistrationContext.h>
|
||||
#include <AzCore/Serialization/Json/JsonSystemComponent.h>
|
||||
#include <AzToolsFramework/API/EditorPythonConsoleBus.h>
|
||||
|
||||
#include <SceneAPI/SceneCore/Containers/Scene.h>
|
||||
#include <SceneAPI/SceneCore/Containers/SceneGraph.h>
|
||||
@@ -378,6 +379,25 @@ namespace AZ
|
||||
MOCK_CONST_METHOD1(QueryApplicationType, void(AZ::ApplicationTypeQuery&));
|
||||
};
|
||||
|
||||
class MockEditorPythonConsoleInterface final
|
||||
: public AzToolsFramework::EditorPythonConsoleInterface
|
||||
{
|
||||
public:
|
||||
MockEditorPythonConsoleInterface()
|
||||
{
|
||||
AZ::Interface<AzToolsFramework::EditorPythonConsoleInterface>::Register(this);
|
||||
}
|
||||
|
||||
~MockEditorPythonConsoleInterface()
|
||||
{
|
||||
AZ::Interface<AzToolsFramework::EditorPythonConsoleInterface>::Unregister(this);
|
||||
}
|
||||
|
||||
MOCK_CONST_METHOD1(GetModuleList, void(AZStd::vector<AZStd::string_view>&));
|
||||
MOCK_CONST_METHOD1(GetGlobalFunctionList, void(GlobalFunctionCollection&));
|
||||
MOCK_METHOD1(FetchPythonTypeName, AZStd::string(const AZ::BehaviorParameter&));
|
||||
};
|
||||
|
||||
//
|
||||
// SceneGraphBehaviorScriptTest
|
||||
//
|
||||
@@ -386,6 +406,7 @@ namespace AZ
|
||||
{
|
||||
public:
|
||||
AZStd::unique_ptr<MockSceneComponentApplication> m_componentApplication;
|
||||
AZStd::unique_ptr<MockEditorPythonConsoleInterface> m_editorPythonConsoleInterface;
|
||||
AZStd::unique_ptr<AZ::ScriptContext> m_scriptContext;
|
||||
AZStd::unique_ptr<AZ::BehaviorContext> m_behaviorContext;
|
||||
AZStd::unique_ptr<AZ::SerializeContext> m_serializeContext;
|
||||
@@ -454,6 +475,15 @@ namespace AZ
|
||||
{
|
||||
return this->m_serializeContext.get();
|
||||
}));
|
||||
|
||||
m_editorPythonConsoleInterface = AZStd::make_unique<MockEditorPythonConsoleInterface>();
|
||||
}
|
||||
|
||||
void SetupEditorPythonConsoleInterface()
|
||||
{
|
||||
EXPECT_CALL(*m_editorPythonConsoleInterface, FetchPythonTypeName(::testing::_))
|
||||
.Times(4)
|
||||
.WillRepeatedly(::testing::Invoke([](const AZ::BehaviorParameter&) {return "int"; }));
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
@@ -562,6 +592,38 @@ namespace AZ
|
||||
ExpectExecute("TestExpectEquals(value, 17)");
|
||||
}
|
||||
|
||||
TEST_F(SceneGraphBehaviorScriptTest, GraphObjectProxy_GetClassInfo_Loads)
|
||||
{
|
||||
SetupEditorPythonConsoleInterface();
|
||||
|
||||
ExpectExecute("builder = MockBuilder()");
|
||||
ExpectExecute("builder:BuildSceneGraph()");
|
||||
ExpectExecute("scene = builder:GetScene()");
|
||||
ExpectExecute("nodeG = scene.graph:FindWithPath('A.C.E.G')");
|
||||
ExpectExecute("proxy = scene.graph:GetNodeContent(nodeG)");
|
||||
ExpectExecute("TestExpectTrue(proxy:CastWithTypeName('MockIGraphObject'))");
|
||||
ExpectExecute("info = proxy:GetClassInfo()");
|
||||
ExpectExecute("TestExpectTrue(info ~= nil)");
|
||||
}
|
||||
|
||||
TEST_F(SceneGraphBehaviorScriptTest, GraphObjectProxy_GetClassInfo_CorrectFormats)
|
||||
{
|
||||
SetupEditorPythonConsoleInterface();
|
||||
|
||||
ExpectExecute("builder = MockBuilder()");
|
||||
ExpectExecute("builder:BuildSceneGraph()");
|
||||
ExpectExecute("scene = builder:GetScene()");
|
||||
ExpectExecute("nodeG = scene.graph:FindWithPath('A.C.E.G')");
|
||||
ExpectExecute("proxy = scene.graph:GetNodeContent(nodeG)");
|
||||
ExpectExecute("TestExpectTrue(proxy:CastWithTypeName('MockIGraphObject'))");
|
||||
ExpectExecute("info = proxy:GetClassInfo()");
|
||||
ExpectExecute("TestExpectTrue(info.className == 'MockIGraphObject')");
|
||||
ExpectExecute("TestExpectTrue(info.classUuid == '{66A082CC-851D-4E1F-ABBD-45B58A216CFA}')");
|
||||
ExpectExecute("TestExpectTrue(info.methodList[1] == 'def GetId(self) -> int')");
|
||||
ExpectExecute("TestExpectTrue(info.methodList[2] == 'def SetId(self, arg1: int) -> None')");
|
||||
ExpectExecute("TestExpectTrue(info.methodList[3] == 'def AddAndSet(self, arg1: int, arg2: int) -> None')");
|
||||
}
|
||||
|
||||
//
|
||||
// SceneManifestBehaviorScriptTest is meant to test the script abilities of the SceneManifest
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user