2 * Copyright (c) 2023 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 #include <dali-toolkit-test-suite-utils.h>
19 #include <dali-toolkit/dali-toolkit.h>
23 #include <dali-scene3d/public-api/model-motion/motion-index/motion-index.h>
24 #include <dali-scene3d/public-api/model-motion/motion-index/motion-transform-index.h>
27 using namespace Dali::Toolkit;
28 using namespace Dali::Scene3D;
30 void model_motion_motion_transform_index_startup(void)
32 test_return_value = TET_UNDEF;
35 void model_motion_motion_transform_index_cleanup(void)
37 test_return_value = TET_PASS;
42 struct PropertyStringIndex
44 const MotionTransformIndex::TransformType type;
46 const char* const name;
47 const Property::Index index;
49 const PropertyStringIndex PROPERTY_TABLE[] =
51 {MotionTransformIndex::TransformType::POSITION, "position", Actor::Property::POSITION},
52 {MotionTransformIndex::TransformType::POSITION_X, "positionX", Actor::Property::POSITION_X},
53 {MotionTransformIndex::TransformType::POSITION_Y, "positionY", Actor::Property::POSITION_Y},
54 {MotionTransformIndex::TransformType::POSITION_Z, "positionZ", Actor::Property::POSITION_Z},
55 {MotionTransformIndex::TransformType::ORIENTATION, "orientation", Actor::Property::ORIENTATION},
56 {MotionTransformIndex::TransformType::SCALE, "scale", Actor::Property::SCALE},
57 {MotionTransformIndex::TransformType::SCALE_X, "scaleX", Actor::Property::SCALE_X},
58 {MotionTransformIndex::TransformType::SCALE_Y, "scaleY", Actor::Property::SCALE_Y},
59 {MotionTransformIndex::TransformType::SCALE_Z, "scaleZ", Actor::Property::SCALE_Z},
63 // Positive test case for a method
64 int UtcDaliMotionTransformIndexNew(void)
66 ToolkitTestApplication application;
67 tet_infoline(" UtcDaliMotionTransformIndexNew");
69 MotionTransformIndex motionTransformIndex = MotionTransformIndex::New();
70 DALI_TEST_CHECK(motionTransformIndex);
71 DALI_TEST_EQUALS(motionTransformIndex.GetModelNodeId().stringKey, "", TEST_LOCATION);
72 DALI_TEST_EQUALS(motionTransformIndex.GetTransformType(), MotionTransformIndex::TransformType::INVALID, TEST_LOCATION);
74 motionTransformIndex = MotionTransformIndex::New("dummy", MotionTransformIndex::TransformType::SCALE);
75 DALI_TEST_CHECK(motionTransformIndex);
76 DALI_TEST_EQUALS(motionTransformIndex.GetModelNodeId().stringKey, "dummy", TEST_LOCATION);
77 DALI_TEST_EQUALS(motionTransformIndex.GetTransformType(), MotionTransformIndex::TransformType::SCALE, TEST_LOCATION);
81 // Positive test case for a method
82 int UtcDaliMotionTransformIndexDownCast(void)
84 ToolkitTestApplication application;
85 tet_infoline(" UtcDaliMotionTransformIndexDownCast");
87 MotionTransformIndex motionTransformIndex = MotionTransformIndex::New();
88 BaseHandle handle(motionTransformIndex);
90 MotionTransformIndex motionTransformIndex2 = MotionTransformIndex::DownCast(handle);
91 DALI_TEST_CHECK(motionTransformIndex);
92 DALI_TEST_CHECK(motionTransformIndex2);
93 DALI_TEST_CHECK(motionTransformIndex2 == motionTransformIndex);
97 int UtcDaliMotionTransformIndexTypeRegistry(void)
99 ToolkitTestApplication application;
101 TypeRegistry typeRegistry = TypeRegistry::Get();
102 DALI_TEST_CHECK(typeRegistry);
104 TypeInfo typeInfo = typeRegistry.GetTypeInfo("MotionTransformIndex");
105 DALI_TEST_CHECK(typeInfo);
107 BaseHandle handle = typeInfo.CreateInstance();
108 DALI_TEST_CHECK(handle);
110 MotionTransformIndex motionTransformIndex = MotionTransformIndex::DownCast(handle);
111 DALI_TEST_CHECK(motionTransformIndex);
116 int UtcDaliMotionTransformIndexCopyAndAssignment(void)
118 ToolkitTestApplication application;
120 MotionTransformIndex motionTransformIndex = MotionTransformIndex::New();
121 DALI_TEST_CHECK(motionTransformIndex);
123 MotionTransformIndex copy(motionTransformIndex);
124 DALI_TEST_CHECK(motionTransformIndex == copy);
126 MotionTransformIndex assign;
127 DALI_TEST_CHECK(!assign);
130 DALI_TEST_CHECK(assign == motionTransformIndex);
135 int UtcDaliMotionTransformIndexMoveConstructor(void)
137 ToolkitTestApplication application;
139 MotionTransformIndex motionTransformIndex = MotionTransformIndex::New();
140 DALI_TEST_EQUALS(1, motionTransformIndex.GetBaseObject().ReferenceCount(), TEST_LOCATION);
142 MotionTransformIndex moved = std::move(motionTransformIndex);
143 DALI_TEST_CHECK(moved);
144 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
145 DALI_TEST_CHECK(!motionTransformIndex);
150 int UtcDaliMotionTransformIndexMoveAssignment(void)
152 ToolkitTestApplication application;
154 MotionTransformIndex motionTransformIndex = MotionTransformIndex::New();
155 DALI_TEST_EQUALS(1, motionTransformIndex.GetBaseObject().ReferenceCount(), TEST_LOCATION);
157 MotionTransformIndex moved;
158 moved = std::move(motionTransformIndex);
159 DALI_TEST_CHECK(moved);
160 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
167 int UtcDaliMotionTransformIndexGetPropertyNameAndIndex(void)
169 auto transfromTypeCount = sizeof(PROPERTY_TABLE) / sizeof(PROPERTY_TABLE[0]);
170 for(auto i = 0u; i < transfromTypeCount; i++)
172 auto type = PROPERTY_TABLE[i].type;
174 std::string expectPropertyName = PROPERTY_TABLE[i].name;
175 Property::Index expectPropertyIndex = PROPERTY_TABLE[i].index;
177 MotionIndex index = MotionTransformIndex::New("", type);
179 DALI_TEST_EQUALS(expectPropertyName, index.GetPropertyName(), TEST_LOCATION);
180 DALI_TEST_EQUALS(expectPropertyIndex, index.GetPropertyIndex(), TEST_LOCATION);
185 int UtcDaliMotionTransformIndexGetPropertyInvalid(void)
187 std::string expectPropertyName = "";
188 Property::Index expectPropertyIndex = Property::INVALID_INDEX;
190 MotionIndex index = MotionTransformIndex::New();
192 // Invalid motion index return empty string, invalid index
193 DALI_TEST_EQUALS(expectPropertyName, index.GetPropertyName(), TEST_LOCATION);
194 DALI_TEST_EQUALS(expectPropertyIndex, index.GetPropertyIndex(), TEST_LOCATION);
199 int UtcDaliMotionTransformIndexSetGetPropertType(void)
201 auto expectType = MotionTransformIndex::TransformType::POSITION;
202 MotionTransformIndex index = MotionTransformIndex::New("", expectType);
204 // Invalid motion index return empty string, invalid index
205 DALI_TEST_EQUALS(expectType, index.GetTransformType(), TEST_LOCATION);
207 expectType = MotionTransformIndex::TransformType::ORIENTATION;
208 index.SetTransformType(expectType);
209 DALI_TEST_EQUALS(expectType, index.GetTransformType(), TEST_LOCATION);