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-components/model-primitive.h>
26 using namespace Dali::Toolkit;
28 void model_components_model_primitive_startup(void)
30 test_return_value = TET_UNDEF;
33 void model_components_model_primitive_cleanup(void)
35 test_return_value = TET_PASS;
42 // Positive test case for a method
43 int UtcDaliModelPrimitiveNew(void)
45 ToolkitTestApplication application;
46 tet_infoline(" UtcDaliModelPrimitiveNew");
48 Scene3D::ModelPrimitive modelPrimitive = Scene3D::ModelPrimitive::New();
49 DALI_TEST_CHECK(modelPrimitive);
53 // Positive test case for a method
54 int UtcDaliModelPrimitiveDownCast(void)
56 ToolkitTestApplication application;
57 tet_infoline(" UtcDaliModelPrimitiveDownCast");
59 Scene3D::ModelPrimitive modelPrimitive = Scene3D::ModelPrimitive::New();
60 BaseHandle handle(modelPrimitive);
62 Scene3D::ModelPrimitive modelPrimitive2 = Scene3D::ModelPrimitive::DownCast(handle);
63 DALI_TEST_CHECK(modelPrimitive);
64 DALI_TEST_CHECK(modelPrimitive2);
65 DALI_TEST_CHECK(modelPrimitive2 == modelPrimitive);
69 int UtcDaliModelPrimitiveTypeRegistry(void)
71 ToolkitTestApplication application;
73 TypeRegistry typeRegistry = TypeRegistry::Get();
74 DALI_TEST_CHECK(typeRegistry);
76 TypeInfo typeInfo = typeRegistry.GetTypeInfo("ModelPrimitive");
77 DALI_TEST_CHECK(typeInfo);
79 BaseHandle handle = typeInfo.CreateInstance();
80 DALI_TEST_CHECK(handle);
82 Scene3D::ModelPrimitive modelPrimitive = Scene3D::ModelPrimitive::DownCast(handle);
83 DALI_TEST_CHECK(modelPrimitive);
88 int UtcDaliModelPrimitiveCopyAndAssignment(void)
90 ToolkitTestApplication application;
92 Scene3D::ModelPrimitive modelPrimitive = Scene3D::ModelPrimitive::New();
93 DALI_TEST_CHECK(modelPrimitive);
95 Scene3D::ModelPrimitive copy(modelPrimitive);
96 DALI_TEST_CHECK(modelPrimitive == copy);
98 Scene3D::ModelPrimitive assign;
99 DALI_TEST_CHECK(!assign);
102 DALI_TEST_CHECK(assign == modelPrimitive);
107 int UtcDaliModelPrimitiveMoveConstructor(void)
109 ToolkitTestApplication application;
111 Scene3D::ModelPrimitive modelPrimitive = Scene3D::ModelPrimitive::New();
112 DALI_TEST_EQUALS(1, modelPrimitive.GetBaseObject().ReferenceCount(), TEST_LOCATION);
114 Scene3D::ModelPrimitive moved = std::move(modelPrimitive);
115 DALI_TEST_CHECK(moved);
116 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
117 DALI_TEST_CHECK(!modelPrimitive);
122 int UtcDaliModelPrimitiveMoveAssignment(void)
124 ToolkitTestApplication application;
126 Scene3D::ModelPrimitive modelPrimitive = Scene3D::ModelPrimitive::New();
127 DALI_TEST_EQUALS(1, modelPrimitive.GetBaseObject().ReferenceCount(), TEST_LOCATION);
129 Scene3D::ModelPrimitive moved;
130 moved = std::move(modelPrimitive);
131 DALI_TEST_CHECK(moved);
132 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
138 int UtcDaliModelPrimitiveSetGetGeometry(void)
140 ToolkitTestApplication application;
142 Scene3D::ModelPrimitive modelPrimitive = Scene3D::ModelPrimitive::New();
144 tet_printf("Check primitive don't have renderer initial time\n");
146 DALI_TEST_CHECK(!modelPrimitive.GetGeometry());
148 Dali::Geometry geometry = Dali::Geometry::New();
150 modelPrimitive.SetGeometry(geometry);
151 DALI_TEST_CHECK(geometry == modelPrimitive.GetGeometry());
153 tet_printf("Replace as new Renderer\n");
155 Dali::Geometry geometry2 = Dali::Geometry::New();
157 modelPrimitive.SetGeometry(geometry2);
158 DALI_TEST_CHECK(geometry != modelPrimitive.GetGeometry());
159 DALI_TEST_CHECK(geometry2 == modelPrimitive.GetGeometry());
163 int UtcDaliModelPrimitiveSetGetMaterial(void)
165 ToolkitTestApplication application;
167 Scene3D::ModelPrimitive modelPrimitive = Scene3D::ModelPrimitive::New();
169 tet_printf("Check primitive don't have material initial time\n");
171 DALI_TEST_CHECK(!modelPrimitive.GetMaterial());
173 Dali::Scene3D::Material material = Dali::Scene3D::Material::New();
175 modelPrimitive.SetMaterial(material);
176 DALI_TEST_CHECK(material == modelPrimitive.GetMaterial());
178 tet_printf("Replace as new Material\n");
180 Dali::Scene3D::Material material2 = Dali::Scene3D::Material::New();
182 modelPrimitive.SetMaterial(material2);
183 DALI_TEST_CHECK(material != modelPrimitive.GetMaterial());
184 DALI_TEST_CHECK(material2 == modelPrimitive.GetMaterial());