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/blend-shape-index.h>
24 #include <dali-scene3d/public-api/model-motion/motion-index/motion-index.h>
25 #include <dali-scene3d/public-api/model-motion/motion-index/motion-property-index.h>
26 #include <dali-scene3d/public-api/model-motion/motion-index/motion-transform-index.h>
29 using namespace Dali::Toolkit;
30 using namespace Dali::Scene3D;
32 void model_motion_motion_index_startup(void)
34 test_return_value = TET_UNDEF;
37 void model_motion_motion_index_cleanup(void)
39 test_return_value = TET_PASS;
46 // Positive test case for a method
47 int UtcDaliMotionIndexDownCast(void)
49 ToolkitTestApplication application;
50 tet_infoline(" UtcDaliMotionIndexDownCast");
52 MotionIndex blendShapeIndex = BlendShapeIndex::New();
53 BaseHandle handle(blendShapeIndex);
55 MotionIndex blendShapeIndex2 = MotionIndex::DownCast(handle);
56 DALI_TEST_CHECK(blendShapeIndex);
57 DALI_TEST_CHECK(blendShapeIndex2);
58 DALI_TEST_CHECK(blendShapeIndex2 == blendShapeIndex);
62 int UtcDaliMotionIndexDownCastNotMatchedType(void)
64 ToolkitTestApplication application;
65 tet_infoline(" UtcDaliMotionIndexDownCastNotMatchedType");
68 MotionIndex baseIndex = BlendShapeIndex::New();
69 DALI_TEST_CHECK(baseIndex);
71 BaseHandle handle(baseIndex);
73 MotionIndex motionPropertyIndex = MotionPropertyIndex::DownCast(handle);
74 DALI_TEST_CHECK(!motionPropertyIndex);
76 MotionIndex motionTransformIndex = MotionTransformIndex::DownCast(handle);
77 DALI_TEST_CHECK(!motionTransformIndex);
79 MotionIndex blendShapeIndex = BlendShapeIndex::DownCast(handle);
80 DALI_TEST_CHECK(blendShapeIndex);
81 DALI_TEST_CHECK(blendShapeIndex == baseIndex);
86 int UtcDaliMotionIndexCopyAndAssignment(void)
88 ToolkitTestApplication application;
90 MotionIndex blendShapeIndex = BlendShapeIndex::New();
91 DALI_TEST_CHECK(blendShapeIndex);
93 MotionIndex copy(blendShapeIndex);
94 DALI_TEST_CHECK(blendShapeIndex == copy);
97 DALI_TEST_CHECK(!assign);
100 DALI_TEST_CHECK(assign == blendShapeIndex);
105 int UtcDaliMotionIndexMoveConstructor(void)
107 ToolkitTestApplication application;
109 MotionIndex blendShapeIndex = MotionTransformIndex::New();
110 DALI_TEST_EQUALS(1, blendShapeIndex.GetBaseObject().ReferenceCount(), TEST_LOCATION);
112 MotionIndex moved = std::move(blendShapeIndex);
113 DALI_TEST_CHECK(moved);
114 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
115 DALI_TEST_CHECK(!blendShapeIndex);
120 int UtcDaliMotionIndexMoveAssignment(void)
122 ToolkitTestApplication application;
124 MotionIndex blendShapeIndex = BlendShapeIndex::New();
125 DALI_TEST_EQUALS(1, blendShapeIndex.GetBaseObject().ReferenceCount(), TEST_LOCATION);
128 moved = std::move(blendShapeIndex);
129 DALI_TEST_CHECK(moved);
130 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
137 int UtcDaliMotionIndexSetGetModelNodeId(void)
139 std::string expectModelNodeStringId = "nodeId";
140 MotionIndex index = MotionTransformIndex::New(expectModelNodeStringId, MotionTransformIndex::TransformType::POSITION);
142 auto propertyKey = index.GetModelNodeId();
143 DALI_TEST_CHECK(propertyKey.type == Property::Key::Type::STRING);
144 DALI_TEST_EQUALS(expectModelNodeStringId, propertyKey.stringKey, TEST_LOCATION);
146 expectModelNodeStringId = "anotherId";
147 index.SetModelNodeId(expectModelNodeStringId);
149 propertyKey = index.GetModelNodeId();
150 DALI_TEST_CHECK(propertyKey.type == Property::Key::Type::STRING);
151 DALI_TEST_EQUALS(expectModelNodeStringId, propertyKey.stringKey, TEST_LOCATION);
153 Property::Index expectModelNodeIndexId = 193u;
154 index.SetModelNodeId(expectModelNodeIndexId);
156 propertyKey = index.GetModelNodeId();
157 DALI_TEST_CHECK(propertyKey.type == Property::Key::Type::INDEX);
158 DALI_TEST_EQUALS(expectModelNodeIndexId, propertyKey.indexKey, TEST_LOCATION);