Dali 3D User Interface Engine
utc-Dali-BloomView.cpp
Go to the documentation of this file.
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 #include <stdlib.h>
23 
24 
25 using namespace Dali;
26 using namespace Dali::Toolkit;
27 
28 
30 {
32 }
33 
35 {
37 }
38 
39 // Negative test case for a method
41 {
42  ToolkitTestApplication application;
43  tet_infoline(" UtcDaliBloomViewUninitialized");
44 
45  Toolkit::BloomView view;
46 
47  try
48  {
49  // New() must be called to create a BloomView or it wont be valid.
50  Actor a = Actor::New();
51  view.Add( a );
52  DALI_TEST_CHECK( false );
53  }
54  catch (Dali::DaliException& e)
55  {
56  // Tests that a negative test of an assertion succeeds
58  DALI_TEST_CHECK(!view);
59  }
60  END_TEST;
61 }
62 
63 // Positive test case for a method
65 {
66  ToolkitTestApplication application;
67  tet_infoline(" UtcDaliBloomViewNew");
68 
70  DALI_TEST_CHECK( view );
71 
72  Toolkit::BloomView view2 = Toolkit::BloomView::New(10, 1.0f, Pixel::RGB888, 0.5f, 0.5f);
73  DALI_TEST_CHECK( view2 );
74  END_TEST;
75 }
76 
77 // Positive test case for a method
79 {
80  ToolkitTestApplication application;
81  tet_infoline(" UtcDaliBloomViewDownCast");
82 
84  BaseHandle handle(view);
85 
87  DALI_TEST_CHECK( view );
88  DALI_TEST_CHECK( bloomView );
89  DALI_TEST_CHECK( bloomView == view );
90  END_TEST;
91 }
92 
93 
94 // Positive test case for a method
96 {
97  ToolkitTestApplication application;
98  tet_infoline(" UtcDaliBloomViewPropertyNames");
99 
101  DALI_TEST_CHECK( view );
102 
103  // Check the names, this names are used in the shader code,
104  // if they change in the shader code, then it has to be updated here.
106  DALI_TEST_EQUALS( view.GetBlurStrengthPropertyIndex(), view.GetPropertyIndex("BlurStrengthProperty"), TEST_LOCATION );
111  END_TEST;
112 }
113 
114 // Positive test case for a method
116 {
117  ToolkitTestApplication application;
118  tet_infoline(" UtcDaliBloomViewAddRemove");
119 
121  DALI_TEST_CHECK( view );
122 
123  Actor actor = Actor::New();
124  DALI_TEST_CHECK( !actor.OnStage() );
125 
126 
128  view.SetSize(Stage::GetCurrent().GetSize());
129  view.Add(actor);
130  Stage::GetCurrent().Add(view);
131 
132  DALI_TEST_CHECK( actor.OnStage() );
133 
134  view.Remove(actor);
135 
136  DALI_TEST_CHECK( !actor.OnStage() );
137  END_TEST;
138 }
139 
140 // Positive test case for a method
142 {
143  ToolkitTestApplication application;
144  tet_infoline(" UtcDaliBloomActivateDeactivate");
145 
147  DALI_TEST_CHECK( view );
148 
150  DALI_TEST_CHECK( 1u == taskList.GetTaskCount() );
151 
153  view.SetSize(Stage::GetCurrent().GetSize());
154  view.Add(Actor::New());
155  Stage::GetCurrent().Add(view);
156  view.Activate();
157 
159  DALI_TEST_CHECK( 1u != taskList2.GetTaskCount() );
160 
161  view.Deactivate();
162 
164  DALI_TEST_CHECK( 1u == taskList3.GetTaskCount() );
165  END_TEST;
166 }
167 
169 {
170  ToolkitTestApplication application;
171 
173  DALI_TEST_CHECK( view );
174 
175  BloomView copy( view );
176  DALI_TEST_CHECK( view == copy );
177 
178  BloomView assign;
179  DALI_TEST_CHECK( ! assign );
180 
181  assign = copy;
182  DALI_TEST_CHECK( assign == view );
183 
184  END_TEST;
185 }
186 
188 {
189  ToolkitTestApplication application;
190 
191  TypeRegistry typeRegistry = TypeRegistry::Get();
192  DALI_TEST_CHECK( typeRegistry );
193 
194  TypeInfo typeInfo = typeRegistry.GetTypeInfo( "BloomView" );
195  DALI_TEST_CHECK( typeInfo );
196 
197  BaseHandle handle = typeInfo.CreateInstance();
198  DALI_TEST_CHECK( handle );
199 
200  BloomView view = BloomView::DownCast( handle );
201  DALI_TEST_CHECK( view );
202 
203  END_TEST;
204 }
205 
207 {
208  ToolkitTestApplication application;
209 
211 
212  Stage::GetCurrent().Add( view );
213 
214  application.SendNotification();
215  application.Render();
216 
217  Vector3 size( 200.0f, 300.0f, 0.0f );
218  view.SetSize( size );
219 
220  application.SendNotification();
221  application.Render();
222 
224 
225  END_TEST;
226 }
Dali Docs Home
Read more about Dali