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-property-index.h>
27 using namespace Dali::Toolkit;
28 using namespace Dali::Scene3D;
30 void model_motion_motion_property_index_startup(void)
32 test_return_value = TET_UNDEF;
35 void model_motion_motion_property_index_cleanup(void)
37 test_return_value = TET_PASS;
44 // Positive test case for a method
45 int UtcDaliMotionPropertyIndexNew(void)
47 ToolkitTestApplication application;
48 tet_infoline(" UtcDaliMotionPropertyIndexNew");
50 MotionPropertyIndex motionPropertyIndex = MotionPropertyIndex::New();
51 DALI_TEST_CHECK(motionPropertyIndex);
52 DALI_TEST_EQUALS(motionPropertyIndex.GetModelNodeId().stringKey, "", TEST_LOCATION);
53 DALI_TEST_EQUALS(motionPropertyIndex.GetPropertyId().indexKey, Property::INVALID_INDEX, TEST_LOCATION);
55 motionPropertyIndex = MotionPropertyIndex::New("dummy", 3u);
56 DALI_TEST_CHECK(motionPropertyIndex);
57 DALI_TEST_EQUALS(motionPropertyIndex.GetModelNodeId().stringKey, "dummy", TEST_LOCATION);
58 DALI_TEST_EQUALS(motionPropertyIndex.GetPropertyId().indexKey, 3u, TEST_LOCATION);
62 // Positive test case for a method
63 int UtcDaliMotionPropertyIndexDownCast(void)
65 ToolkitTestApplication application;
66 tet_infoline(" UtcDaliMotionPropertyIndexDownCast");
68 MotionPropertyIndex motionPropertyIndex = MotionPropertyIndex::New();
69 BaseHandle handle(motionPropertyIndex);
71 MotionPropertyIndex motionPropertyIndex2 = MotionPropertyIndex::DownCast(handle);
72 DALI_TEST_CHECK(motionPropertyIndex);
73 DALI_TEST_CHECK(motionPropertyIndex2);
74 DALI_TEST_CHECK(motionPropertyIndex2 == motionPropertyIndex);
78 int UtcDaliMotionPropertyIndexTypeRegistry(void)
80 ToolkitTestApplication application;
82 TypeRegistry typeRegistry = TypeRegistry::Get();
83 DALI_TEST_CHECK(typeRegistry);
85 TypeInfo typeInfo = typeRegistry.GetTypeInfo("MotionPropertyIndex");
86 DALI_TEST_CHECK(typeInfo);
88 BaseHandle handle = typeInfo.CreateInstance();
89 DALI_TEST_CHECK(handle);
91 MotionPropertyIndex motionPropertyIndex = MotionPropertyIndex::DownCast(handle);
92 DALI_TEST_CHECK(motionPropertyIndex);
97 int UtcDaliMotionPropertyIndexCopyAndAssignment(void)
99 ToolkitTestApplication application;
101 MotionPropertyIndex motionPropertyIndex = MotionPropertyIndex::New();
102 DALI_TEST_CHECK(motionPropertyIndex);
104 MotionPropertyIndex copy(motionPropertyIndex);
105 DALI_TEST_CHECK(motionPropertyIndex == copy);
107 MotionPropertyIndex assign;
108 DALI_TEST_CHECK(!assign);
111 DALI_TEST_CHECK(assign == motionPropertyIndex);
116 int UtcDaliMotionPropertyIndexMoveConstructor(void)
118 ToolkitTestApplication application;
120 MotionPropertyIndex motionPropertyIndex = MotionPropertyIndex::New();
121 DALI_TEST_EQUALS(1, motionPropertyIndex.GetBaseObject().ReferenceCount(), TEST_LOCATION);
123 MotionPropertyIndex moved = std::move(motionPropertyIndex);
124 DALI_TEST_CHECK(moved);
125 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
126 DALI_TEST_CHECK(!motionPropertyIndex);
131 int UtcDaliMotionPropertyIndexMoveAssignment(void)
133 ToolkitTestApplication application;
135 MotionPropertyIndex motionPropertyIndex = MotionPropertyIndex::New();
136 DALI_TEST_EQUALS(1, motionPropertyIndex.GetBaseObject().ReferenceCount(), TEST_LOCATION);
138 MotionPropertyIndex moved;
139 moved = std::move(motionPropertyIndex);
140 DALI_TEST_CHECK(moved);
141 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
148 int UtcDaliMotionPropertyIndexGetPropertyName(void)
150 std::string expectPropertyName = "";
151 Property::Index expectPropertyIndex = Property::INVALID_INDEX;
153 MotionIndex index = MotionPropertyIndex::New();
155 // Invalid motion index return empty string, invalid index
156 DALI_TEST_EQUALS(expectPropertyName, index.GetPropertyName(), TEST_LOCATION);
157 DALI_TEST_EQUALS(expectPropertyIndex, index.GetPropertyIndex(), TEST_LOCATION);
159 expectPropertyIndex = 0u;
160 index = MotionPropertyIndex::New("", expectPropertyIndex);
161 DALI_TEST_EQUALS(expectPropertyIndex, index.GetPropertyIndex(), TEST_LOCATION);
163 expectPropertyIndex = 45u;
164 index = MotionPropertyIndex::New("", expectPropertyIndex);
165 DALI_TEST_EQUALS(expectPropertyIndex, index.GetPropertyIndex(), TEST_LOCATION);
167 expectPropertyName = "name";
168 index = MotionPropertyIndex::New("", expectPropertyName);
169 DALI_TEST_EQUALS(expectPropertyName, index.GetPropertyName(), TEST_LOCATION);
174 int UtcDaliMotionPropertyIndexSetGetPropertyId(void)
176 Property::Index expectPropertyIndex = 0u;
178 MotionPropertyIndex index = MotionPropertyIndex::New("", expectPropertyIndex);
180 // Invalid motion index return empty string, invalid index
181 DALI_TEST_CHECK(index.GetPropertyId().type == Property::Key::Type::INDEX);
182 DALI_TEST_EQUALS(expectPropertyIndex, index.GetPropertyId().indexKey, TEST_LOCATION);
184 std::string expectPropertyName = "hello";
185 index.SetPropertyId(expectPropertyName);
186 DALI_TEST_CHECK(index.GetPropertyId().type == Property::Key::Type::STRING);
187 DALI_TEST_EQUALS(expectPropertyName, index.GetPropertyId().stringKey, TEST_LOCATION);
189 expectPropertyIndex = 100u;
190 index.SetPropertyId(expectPropertyIndex);
191 DALI_TEST_CHECK(index.GetPropertyId().type == Property::Key::Type::INDEX);
192 DALI_TEST_EQUALS(expectPropertyIndex, index.GetPropertyId().indexKey, TEST_LOCATION);