removed reliance on dali-adaptor
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-RenderTaskList.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <iostream>
19
20 #include <stdlib.h>
21 #include <dali/public-api/dali-core.h>
22 #include <dali-test-suite-utils.h>
23
24 using namespace Dali;
25
26 void utc_dali_render_task_list_startup(void)
27 {
28   test_return_value = TET_UNDEF;
29 }
30
31 void utc_dali_render_task_list_cleanup(void)
32 {
33   test_return_value = TET_PASS;
34 }
35
36 int UtcDaliRenderTaskListDefaultConstructor(void)
37 {
38   TestApplication application;
39
40   tet_infoline("Testing RenderTaskList::RenderTaskList()");
41
42   RenderTaskList taskList;
43
44   DALI_TEST_CHECK( ! taskList );
45   END_TEST;
46 }
47
48 int UtcDaliRenderTaskListDownCast(void)
49 {
50   TestApplication application;
51
52   tet_infoline("Testing RenderTaskList::DownCast()");
53
54   BaseHandle base = Stage::GetCurrent().GetRenderTaskList();
55
56   RenderTaskList taskList = RenderTaskList::DownCast( base );
57
58   DALI_TEST_CHECK( taskList );
59
60   // Try calling a method
61   DALI_TEST_CHECK( 1u == taskList.GetTaskCount() );
62   END_TEST;
63 }
64
65 int UtcDaliRenderTaskListCreateTask(void)
66 {
67   TestApplication application;
68
69   tet_infoline("Testing RenderTaskList::CreateTask()");
70
71   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
72   DALI_TEST_CHECK( 1u == taskList.GetTaskCount() );
73
74   taskList.CreateTask();
75   DALI_TEST_CHECK( 2u == taskList.GetTaskCount() );
76   END_TEST;
77 }
78
79 int UtcDaliRenderTaskListRemoveTask(void)
80 {
81   TestApplication application;
82
83   tet_infoline("Testing RenderTaskList::RemoveTask()");
84
85   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
86   DALI_TEST_CHECK( 1u == taskList.GetTaskCount() );
87
88   RenderTask newTask = taskList.CreateTask();
89   DALI_TEST_CHECK( 2u == taskList.GetTaskCount() );
90
91   taskList.RemoveTask( newTask );
92   DALI_TEST_CHECK( 1u == taskList.GetTaskCount() );
93   END_TEST;
94 }
95
96 int UtcDaliRenderTaskListGetTaskCount(void)
97 {
98   TestApplication application;
99
100   tet_infoline("Testing RenderTaskList::GetTaskCount()");
101
102   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
103   DALI_TEST_CHECK( 1u == taskList.GetTaskCount() );
104
105   taskList.RemoveTask( taskList.GetTask(0u) );
106   DALI_TEST_CHECK( 0u == taskList.GetTaskCount() );
107   END_TEST;
108 }
109
110 int UtcDaliRenderTaskListGetTask(void)
111 {
112   TestApplication application;
113
114   tet_infoline("Testing RenderTaskList::GetTask()");
115
116   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
117   RenderTask defaultTask = taskList.GetTask( 0u );
118   DALI_TEST_CHECK( 1u == taskList.GetTaskCount() );
119   DALI_TEST_CHECK( defaultTask );
120   DALI_TEST_CHECK( defaultTask == taskList.GetTask( 0u ) );
121
122   RenderTask newTask = taskList.CreateTask();
123   DALI_TEST_CHECK( 2u == taskList.GetTaskCount() );
124
125   RenderTask temp = taskList.GetTask( 0u );
126   RenderTask temp2 = taskList.GetTask( 1u );
127
128   DALI_TEST_CHECK( newTask );
129   DALI_TEST_CHECK( defaultTask != newTask );
130   DALI_TEST_CHECK( taskList.GetTask( 0u ) == defaultTask );
131   DALI_TEST_CHECK( taskList.GetTask( 1u ) == newTask );
132   DALI_TEST_CHECK( taskList.GetTask( 1u ) != defaultTask );
133
134   taskList.RemoveTask( taskList.GetTask(0u) );
135   DALI_TEST_CHECK( 1u == taskList.GetTaskCount() );
136   DALI_TEST_CHECK( taskList.GetTask( 0u ) != defaultTask  );
137   DALI_TEST_CHECK( taskList.GetTask( 0u ) == newTask );
138   END_TEST;
139 }