Dali 3D User Interface Engine
utc-Dali-GaussianBlurView.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>
22 
23 using namespace Dali;
24 using namespace Dali::Toolkit;
25 
26 namespace
27 {
28 const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
29 } // namespace
30 
32 {
34 }
35 
37 {
39 }
40 
42 {
43 public:
45  : mBlurView( blurView )
46  {
47  mFinished = false;
48  }
49 
50  void Connect()
51  {
52  mBlurView.FinishedSignal().Connect( this, &TestCallback::OnFinished );
53  }
54 
55  void OnFinished( Dali::Toolkit::GaussianBlurView source )
56  {
57  mFinished = true;
58  }
59 
60  bool mFinished;
62 };
63 
64 // Negative test case for a method
66 {
67  ToolkitTestApplication application;
68  tet_infoline("UtcDaliGaussianBlurViewUninitialized");
69 
71 
72  try
73  {
74  // New() must be called to create a GaussianBlurView or it wont be valid.
75  Actor a = Actor::New();
76  view.Add( a );
77  DALI_TEST_CHECK( false );
78  }
79  catch (Dali::DaliException& e)
80  {
81  // Tests that a negative test of an assertion succeeds
83  DALI_TEST_CHECK(!view);
84  }
85  END_TEST;
86 }
87 
88 // Positive test case for a method
90 {
91  ToolkitTestApplication application;
92  tet_infoline("UtcDaliGaussianBlurViewNew");
93 
95  DALI_TEST_CHECK( view );
96 
97  Toolkit::GaussianBlurView view2 = Toolkit::GaussianBlurView::New(5, 1.5f, Pixel::RGB888, 0.5f, 0.5f, false);
98  DALI_TEST_CHECK( view2 );
99  END_TEST;
100 }
101 
102 // Positive test case for a method
104 {
105  ToolkitTestApplication application;
106  tet_infoline("UtcDaliGaussianBlurViewDownCast");
107 
109  BaseHandle handle(view);
110 
112  DALI_TEST_CHECK( view );
113  DALI_TEST_CHECK( gaussianBlurView );
114  DALI_TEST_CHECK( gaussianBlurView == view );
115  END_TEST;
116 }
117 
118 
119 // Positive test case for a method
121 {
122  ToolkitTestApplication application;
123  tet_infoline("UtcDaliGaussianBlurViewPropertyNames");
124 
126  DALI_TEST_CHECK( view );
127 
128  // Check the names, this names are used in the shader code,
129  // if they change in the shader code, then it has to be updated here.
130  DALI_TEST_EQUALS( view.GetBlurStrengthPropertyIndex(), view.GetPropertyIndex("GaussianBlurStrengthPropertyName"), TEST_LOCATION );
131  END_TEST;
132 }
133 
134 // Positive test case for a method
136 {
137  ToolkitTestApplication application;
138  tet_infoline("UtcDaliGaussianBlurViewAddRemove");
139 
141  DALI_TEST_CHECK( view );
142 
143  Actor actor = Actor::New();
144  DALI_TEST_CHECK( !actor.OnStage() );
145 
146 
148  view.SetSize(Stage::GetCurrent().GetSize());
149  view.Add(actor);
150  Stage::GetCurrent().Add(view);
151 
152  DALI_TEST_CHECK( actor.OnStage() );
153 
154  view.Remove(actor);
155 
156  DALI_TEST_CHECK( !actor.OnStage() );
157  END_TEST;
158 }
159 
160 // Positive test case for a method
162 {
163  ToolkitTestApplication application;
164  tet_infoline("UtcDaliGaussianBlurActivateDeactivate");
165 
167  DALI_TEST_CHECK( view );
168 
170  DALI_TEST_CHECK( 1u == taskList.GetTaskCount() );
171 
173  view.SetSize(Stage::GetCurrent().GetSize());
174  view.Add(Actor::New());
175  Stage::GetCurrent().Add(view);
176  view.Activate();
177 
179  DALI_TEST_CHECK( 1u != taskList2.GetTaskCount() );
180 
181  view.Deactivate();
182 
184  DALI_TEST_CHECK( 1u == taskList3.GetTaskCount() );
185  END_TEST;
186 }
187 
188 // Positive test case for a method
190 {
191  ToolkitTestApplication application;
192  tet_infoline("UtcDaliGaussianBlurViewSetGetBackgroundColor");
193 
195  DALI_TEST_CHECK( view );
196 
198  Vector4 color = view.GetBackgroundColor();
199  DALI_TEST_CHECK( color == Dali::Color::RED );
200  END_TEST;
201 }
202 
203 // Positive test case for a method
205 {
206  ToolkitTestApplication application;
207  tet_infoline("UtcDaliGaussianBlurViewSetGetRenderTarget");
208 
210  DALI_TEST_CHECK( view );
211 
213  view.SetSize(Stage::GetCurrent().GetSize());
214  view.Add(Actor::New());
215  Stage::GetCurrent().Add(view);
216  view.Activate();
217 
218  FrameBufferImage renderTarget = FrameBufferImage::New( 480.0f, 800.0f, Pixel::RGB888 );
220  DALI_TEST_CHECK( view.GetBlurredRenderTarget() == renderTarget );
221  END_TEST;
222 }
223 
225 {
226  ToolkitTestApplication application;
227  tet_infoline("UtcDaliGaussianBlurActivateOnce");
228 
230  DALI_TEST_CHECK( view );
231 
233  DALI_TEST_CHECK( 1u == taskList.GetTaskCount() );
234 
236  view.SetSize(Stage::GetCurrent().GetSize());
237  view.Add(Actor::New());
238  Stage::GetCurrent().Add(view);
239  view.ActivateOnce();
240 
242  DALI_TEST_CHECK( 1u != taskList2.GetTaskCount() );
243  application.Render();
244 
245  END_TEST;
246 }
247 
249 {
250  ToolkitTestApplication application;
251  tet_infoline("UtcDaliGaussianBlurViewSetGetRenderTarget");
252 
254  DALI_TEST_CHECK( view );
255 
257  view.SetSize(Stage::GetCurrent().GetSize());
258  view.Add(Actor::New());
259  Stage::GetCurrent().Add(view);
260  view.Activate();
261 
262  TestCallback callback( view );
263  DALI_TEST_CHECK( callback.mFinished == false );
264 
265  callback.Connect();
266 
267  view.Deactivate();
268  application.SendNotification();
269 
270  // FinishedSignal is only for ActivateOnce()
271  DALI_TEST_CHECK( callback.mFinished == false );
272 
273  END_TEST;
274 }
Dali Docs Home
Read more about Dali