2 * Copyright (c) 2024 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #define DEBUG_ENABLED 1
20 #include <dali-test-suite-utils.h>
21 #include <dali/internal/update/manager/transform-manager-property.h>
22 #include <dali/internal/update/nodes/node-helper.h>
24 // Internal headers are allowed here
28 #if defined(DEBUG_ENABLED)
29 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Verbose, true, "LOG_UTC_TRANSFORM_MANAGER_PROPERTY");
33 void utc_dali_internal_transform_manager_property_startup()
35 test_return_value = TET_UNDEF;
38 void utc_dali_internal_transform_manager_property_cleanup()
40 test_return_value = TET_PASS;
43 int UtcTransformManagerPropertyGetFloatComponentN(void)
45 TestApplication application;
48 DALI_LOG_TRACE_METHOD(gLogFilter);
52 Dali::Internal::SceneGraph::TransformManagerData txMgrData;
53 Dali::Internal::SceneGraph::TransformManagerPropertyQuaternion<sizeof(txMgrData)> property;
58 // There is no float component getter in derived class, only in base class.
59 s.property.GetFloatComponent(0u);
61 catch(Dali::DaliException& e)
63 DALI_TEST_ASSERT(e, "0 && \"Invalid call\"", TEST_LOCATION);
67 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Test End\n");
72 int UtcTransformManagerPropertyUninitializedMgrData(void)
74 TestApplication application;
78 const Vector3 input{1.0f, 2.0f, 3.0f};
80 Dali::Internal::SceneGraph::TransformManagerData txMgrData;
81 Dali::Internal::SceneGraph::TransformManagerVector3Input<sizeof(txMgrData)> property{Dali::Internal::SceneGraph::TRANSFORM_PROPERTY_POSITION, input};
84 Vector3 output = s.property.GetVector3(0);
86 tet_infoline("Test that if input property's transform manager data is not initialized, that getting a value returns the initial value of the property.");
88 DALI_TEST_EQUALS(s.input, output, 0.001f, TEST_LOCATION);
93 using namespace Dali::Internal::SceneGraph;
94 int UtcDaliInternalTransformPropertyGetValueSize(void)
98 Dali::Internal::PropertyInputImpl* property;
99 Property::Value value;
101 S(Dali::Internal::PropertyInputImpl* p, Property::Value v, size_t s)
108 std::vector<S> properties;
110 properties.emplace_back(new TransformManagerPropertyVector3<TransformManagerProperty::TRANSFORM_PROPERTY_SCALE, 0>(), Vector3(2.3f, 4.5f, 1.9f), sizeof(Vector3));
112 properties.emplace_back(new TransformManagerPropertyQuaternion<0>(), Quaternion(Radian(1.619f), Vector3::ZAXIS), sizeof(Quaternion));
114 properties.emplace_back(new TransformManagerVector3Input<0>(TransformManagerProperty::TRANSFORM_PROPERTY_WORLD_SCALE, Vector3(2.3f, 4.5f, 1.9f)), Vector3(2.3f, 4.5f, 1.9f), sizeof(Vector3));
116 properties.emplace_back(new TransformManagerQuaternionInput<0>(), Quaternion(Radian(1.619f), Vector3::ZAXIS), sizeof(Quaternion));
118 properties.emplace_back(new TransformManagerMatrixInput<0>(), Matrix::IDENTITY, sizeof(Matrix));
120 for(auto& s : properties)
122 DALI_TEST_EQUALS(s.property->GetValueSize(), s.size, TEST_LOCATION);
128 int UtcDaliInternalTransformPropertyGetValueAddress(void)
132 BASE(TransformManagerData, mTransformManagerData);
133 PROPERTY_WRAPPER(mTransformManagerData, TransformManagerPropertyVector3, TRANSFORM_PROPERTY_SCALE, mScale);
134 TEMPLATE_WRAPPER(mScale, TransformManagerPropertyQuaternion, mOrientation);
135 TEMPLATE_WRAPPER(mOrientation, TransformManagerVector3Input, mWorldPosition);
136 TEMPLATE_WRAPPER(mWorldPosition, TransformManagerQuaternionInput, mWorldOrientation);
137 TEMPLATE_WRAPPER(mWorldOrientation, TransformManagerMatrixInput, mWorldMatrix);
140 : mTransformManagerData(),
141 mWorldPosition(TRANSFORM_PROPERTY_WORLD_POSITION, Vector3(1.0f, 1.0f, 1.0f)),
148 TransformManager testManager;
150 node.mTransformManagerData.mManager = &testManager;
151 node.mTransformManagerData.mId = testManager.CreateTransform();
153 const void* addr = node.mScale.GetValueAddress(0);
154 node.mScale.Set(0, Vector3(1.2f, 1.2f, 1.2f));
156 DALI_TEST_EQUALS(*reinterpret_cast<const Vector3*>(addr), Vector3(1.2f, 1.2f, 1.2f), TEST_LOCATION);
158 node.mOrientation.Set(0, Quaternion(Radian(1.619f), Vector3::ZAXIS));
159 addr = node.mOrientation.GetValueAddress(0);
160 DALI_TEST_EQUALS(*reinterpret_cast<const Quaternion*>(addr), Quaternion(Radian(1.619f), Vector3::ZAXIS), TEST_LOCATION);
162 Matrix& m = node.mWorldMatrix.Get(0);
163 m = Matrix::IDENTITY;
165 addr = node.mWorldPosition.GetValueAddress(0);
166 DALI_TEST_EQUALS(*reinterpret_cast<const Vector3*>(addr), Vector3(0.f, 0.f, 0.f), TEST_LOCATION);
168 addr = node.mWorldOrientation.GetValueAddress(0);
169 DALI_TEST_EQUALS(*reinterpret_cast<const Quaternion*>(addr), Quaternion(Radian(0), Vector3::ZAXIS), TEST_LOCATION);
171 addr = node.mWorldMatrix.GetValueAddress(0);
172 DALI_TEST_EQUALS(*reinterpret_cast<const Matrix*>(addr), Matrix::IDENTITY, TEST_LOCATION);