2 * Copyright (c) 2020 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-test-suite-utils.h>
19 #include <dali/public-api/dali-core.h>
26 void utc_dali_render_task_list_startup(void)
28 test_return_value = TET_UNDEF;
31 void utc_dali_render_task_list_cleanup(void)
33 test_return_value = TET_PASS;
36 int UtcDaliRenderTaskListDefaultConstructor(void)
38 TestApplication application;
40 tet_infoline("Testing RenderTaskList::RenderTaskList()");
42 RenderTaskList taskList;
44 DALI_TEST_CHECK(!taskList);
48 int UtcDaliRenderTaskListCopyConstructor(void)
50 TestApplication application;
52 tet_infoline("Testing RenderTaskList::RenderTaskList(const RenderTaskList& handle)");
54 RenderTaskList taskList1;
56 RenderTaskList taskList2(taskList1);
58 DALI_TEST_CHECK(!taskList2);
62 int UtcDaliRenderTaskListAssignment(void)
64 TestApplication application;
66 tet_infoline("Testing RenderTaskList::RenderTaskList(const RenderTaskList& handle)");
68 RenderTaskList taskList1;
70 RenderTaskList taskList2;
72 taskList1 = taskList2;
74 DALI_TEST_CHECK(!taskList1);
78 int UtcDaliRenderTaskListMoveConstructor(void)
80 TestApplication application;
82 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
83 DALI_TEST_CHECK(taskList);
84 DALI_TEST_EQUALS(2, taskList.GetBaseObject().ReferenceCount(), TEST_LOCATION);
85 DALI_TEST_CHECK(1u == taskList.GetTaskCount());
87 RenderTaskList move = std::move(taskList);
88 DALI_TEST_CHECK(move);
89 DALI_TEST_EQUALS(2, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
90 DALI_TEST_CHECK(1u == move.GetTaskCount());
91 DALI_TEST_CHECK(!taskList);
96 int UtcDaliRenderTaskListMoveAssignment(void)
98 TestApplication application;
100 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
101 DALI_TEST_CHECK(taskList);
102 DALI_TEST_EQUALS(2, taskList.GetBaseObject().ReferenceCount(), TEST_LOCATION);
103 DALI_TEST_CHECK(1u == taskList.GetTaskCount());
106 move = std::move(taskList);
107 DALI_TEST_CHECK(move);
108 DALI_TEST_EQUALS(2, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
109 DALI_TEST_CHECK(1u == move.GetTaskCount());
110 DALI_TEST_CHECK(!taskList);
115 int UtcDaliRenderTaskListDownCast(void)
117 TestApplication application;
119 tet_infoline("Testing RenderTaskList::DownCast()");
121 BaseHandle base = application.GetScene().GetRenderTaskList();
123 RenderTaskList taskList = RenderTaskList::DownCast(base);
125 DALI_TEST_CHECK(taskList);
127 // Try calling a method
128 DALI_TEST_CHECK(1u == taskList.GetTaskCount());
132 int UtcDaliRenderTaskListCreateTask(void)
134 TestApplication application;
136 tet_infoline("Testing RenderTaskList::CreateTask()");
138 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
139 DALI_TEST_CHECK(1u == taskList.GetTaskCount());
141 taskList.CreateTask();
142 DALI_TEST_CHECK(2u == taskList.GetTaskCount());
146 int UtcDaliRenderTaskListRemoveTask(void)
148 TestApplication application;
150 tet_infoline("Testing RenderTaskList::RemoveTask()");
152 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
153 DALI_TEST_CHECK(1u == taskList.GetTaskCount());
155 RenderTask newTask = taskList.CreateTask();
156 DALI_TEST_CHECK(2u == taskList.GetTaskCount());
158 taskList.RemoveTask(newTask);
159 DALI_TEST_CHECK(1u == taskList.GetTaskCount());
163 int UtcDaliRenderTaskListRemoveTaskWithExclusiveActor(void)
165 TestApplication application;
167 tet_infoline("Testing RenderTaskList::RemoveTask() which has an exclusive actor set");
169 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
170 DALI_TEST_CHECK(1u == taskList.GetTaskCount());
172 RenderTask newTask = taskList.CreateTask();
173 DALI_TEST_CHECK(2u == taskList.GetTaskCount());
175 auto actor = CreateRenderableActor();
176 newTask.SetSourceActor(actor);
177 newTask.SetExclusive(true);
178 DALI_TEST_EQUALS(actor, newTask.GetSourceActor(), TEST_LOCATION);
179 DALI_TEST_EQUALS(true, newTask.IsExclusive(), TEST_LOCATION);
180 taskList.RemoveTask(newTask);
182 DALI_TEST_CHECK(1u == taskList.GetTaskCount());
186 int UtcDaliRenderTaskListGetTaskCount(void)
188 TestApplication application;
190 tet_infoline("Testing RenderTaskList::GetTaskCount()");
192 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
193 DALI_TEST_CHECK(1u == taskList.GetTaskCount());
195 taskList.RemoveTask(taskList.GetTask(0u));
196 DALI_TEST_CHECK(0u == taskList.GetTaskCount());
200 int UtcDaliRenderTaskListGetTask(void)
202 TestApplication application;
204 tet_infoline("Testing RenderTaskList::GetTask()");
206 RenderTaskList taskList = application.GetScene().GetRenderTaskList();
207 RenderTask defaultTask = taskList.GetTask(0u);
208 DALI_TEST_CHECK(1u == taskList.GetTaskCount());
209 DALI_TEST_CHECK(defaultTask);
210 DALI_TEST_CHECK(defaultTask == taskList.GetTask(0u));
212 RenderTask newTask = taskList.CreateTask();
213 DALI_TEST_CHECK(2u == taskList.GetTaskCount());
215 RenderTask temp = taskList.GetTask(0u);
216 RenderTask temp2 = taskList.GetTask(1u);
218 DALI_TEST_CHECK(newTask);
219 DALI_TEST_CHECK(defaultTask != newTask);
220 DALI_TEST_CHECK(taskList.GetTask(0u) == defaultTask);
221 DALI_TEST_CHECK(taskList.GetTask(1u) == newTask);
222 DALI_TEST_CHECK(taskList.GetTask(1u) != defaultTask);
224 taskList.RemoveTask(taskList.GetTask(0u));
225 DALI_TEST_CHECK(1u == taskList.GetTaskCount());
226 DALI_TEST_CHECK(taskList.GetTask(0u) != defaultTask);
227 DALI_TEST_CHECK(taskList.GetTask(0u) == newTask);
231 int UtcDaliRenderTaskListCreateTaskNegative(void)
233 TestApplication application;
234 Dali::RenderTaskList instance;
237 instance.CreateTask();
238 DALI_TEST_CHECK(false); // Should not get here
242 DALI_TEST_CHECK(true); // We expect an assert
247 int UtcDaliRenderTaskListRemoveTaskNegative(void)
249 TestApplication application;
250 Dali::RenderTaskList instance;
253 Dali::RenderTask arg1(application.GetScene().GetRenderTaskList().GetTask(0u));
254 instance.RemoveTask(arg1);
255 DALI_TEST_CHECK(false); // Should not get here
259 DALI_TEST_CHECK(true); // We expect an assert
264 int UtcDaliRenderTaskListGetTaskCountNegative(void)
266 TestApplication application;
267 Dali::RenderTaskList instance;
270 instance.GetTaskCount();
271 DALI_TEST_CHECK(false); // Should not get here
275 DALI_TEST_CHECK(true); // We expect an assert
280 int UtcDaliRenderTaskListGetTaskNegative(void)
282 TestApplication application;
283 Dali::RenderTaskList instance;
286 unsigned int arg1(0u);
287 instance.GetTask(arg1);
288 DALI_TEST_CHECK(false); // Should not get here
292 DALI_TEST_CHECK(true); // We expect an assert