Refactoring ImageVisualShaderFactory::GetShader
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-CubeTransitionEffect.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 #include <stdlib.h>
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <dali-toolkit/dali-toolkit.h>
22 #include <dali-toolkit/devel-api/transition-effects/cube-transition-effect.h>
23 #include <dali-toolkit/devel-api/transition-effects/cube-transition-cross-effect.h>
24 #include <dali-toolkit/devel-api/transition-effects/cube-transition-fold-effect.h>
25 #include <dali-toolkit/devel-api/transition-effects/cube-transition-wave-effect.h>
26 #include <dali/devel-api/adaptor-framework/image-loading.h>
27 #include <dali/devel-api/adaptor-framework/pixel-buffer.h>
28
29
30 using namespace Dali;
31 using namespace Dali::Toolkit;
32
33
34 namespace
35 {
36 const unsigned int NUM_ROWS = 16;
37 const unsigned int NUM_COLUMNS = 10;
38 const Vector2 VIEW_AREA_SIZE( 480.0f, 800.0f );
39 const float TRANSITION_DURATION = 0.5f;
40 const float CUBE_DISPLACEMENT = 55.f;
41 const Vector2 PAN_POSITION1( VIEW_AREA_SIZE.x * 0.75f, VIEW_AREA_SIZE.y * 0.25f );
42 const Vector2 PAN_DISPLACEMENT1( -5.f, 5.f );
43 const Vector2 PAN_POSITION2( VIEW_AREA_SIZE.x * 0.25f, VIEW_AREA_SIZE.y * 0.75f );
44 const Vector2 PAN_DISPLACEMENT2( 5.f, 5.f );
45 const Vector4 FULL_BRIGHTNESS(1.f,1.f,1.f,1.f);
46 const Vector4 HALF_BRIGHTNESS(0.5f, 0.5f, 0.5f, 1.f);
47 const int RENDER_FRAME_INTERVAL = 16;
48 static const float FLT_EPISILON = 0.0001f;
49 static const float EPISILON = 0.05f;
50 const float TRANSITION_BEFORE_END_DURATION = TRANSITION_DURATION - 0.05f;
51
52 static bool gObjectCreatedCallBackCalled;
53 static void TestCallback(BaseHandle handle)
54 {
55   gObjectCreatedCallBackCalled = true;
56 }
57
58 /**
59  * Simulate time passed by, waiting for certain process to finish
60  * @param[in] application Test application instance
61  * @param[in] durationToPass Time to pass in milliseconds.
62  */
63 void Wait(ToolkitTestApplication& application, float durationToPass)
64 {
65   int duration = static_cast<int>(durationToPass*1000.f);
66   // wait 2 more frames to compensate the two frames used by the image waiting for the loading succeeded signal
67   for(int i = 0; i <=  duration/RENDER_FRAME_INTERVAL+2 ; i++)
68   {
69     application.SendNotification();
70     application.Render(RENDER_FRAME_INTERVAL);
71   }
72 }
73
74
75
76 //Callback class to test whether transition completed signal is emitted when the transition animation is finished
77 class TransitionCompletedCallback : public Dali::ConnectionTracker
78 {
79 public:
80   TransitionCompletedCallback( bool& signalReceived, CubeTransitionEffect& effect, Texture& image )
81   : mSignalVerified( signalReceived ),
82     mCurrentEffect( effect ),
83     mActorTransitTo( image )
84   {
85   }
86
87   void Callback( CubeTransitionEffect effect, Texture image )
88   {
89     tet_infoline( "Verifying TransitionCompletedSignal" );
90
91     if( mCurrentEffect == effect && mActorTransitTo == image )
92     {
93       mSignalVerified = true;
94     }
95   }
96
97   void Reset()
98   {
99     mSignalVerified = false;
100   }
101
102   bool&                  mSignalVerified;
103   CubeTransitionEffect&  mCurrentEffect;
104   Texture&               mActorTransitTo;
105 };
106
107 } // namespace
108
109
110
111 void cube_transition_effect_startup(void)
112 {
113   test_return_value = TET_UNDEF;
114 }
115
116 void cube_transition_effect_cleanup(void)
117 {
118   test_return_value = TET_PASS;
119 }
120
121 int UtcDaliCubeTransitionWaveEffectNew(void)
122 {
123   ToolkitTestApplication application;
124   tet_infoline(" UtcDaliCubeTransitionWaveEffectNew ");
125
126   CubeTransitionEffect waveEffect;
127
128   DALI_TEST_CHECK( !waveEffect );
129
130   waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS );
131   waveEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
132
133   DALI_TEST_CHECK( waveEffect );
134
135   waveEffect.Reset();
136
137   //Additional check to ensure object is created by checking if it's registered
138   ObjectRegistry registry = application.GetCore().GetObjectRegistry();
139   DALI_TEST_CHECK( registry );
140
141   gObjectCreatedCallBackCalled = false;
142   registry.ObjectCreatedSignal().Connect( &TestCallback );
143   {
144     CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS );
145     waveEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
146   }
147   DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
148   END_TEST;
149 }
150
151 int UtcDaliCubeTransitionCrossEffectNew(void)
152 {
153   ToolkitTestApplication application;
154   tet_infoline(" UtcDaliCubeTransitionCrossEffectNew ");
155
156   CubeTransitionEffect crossEffect;
157
158   DALI_TEST_CHECK( !crossEffect );
159
160   crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS );
161   crossEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
162
163   DALI_TEST_CHECK( crossEffect );
164
165   crossEffect.Reset();
166
167   //Additional check to ensure object is created by checking if it's registered
168   ObjectRegistry registry = application.GetCore().GetObjectRegistry();
169   DALI_TEST_CHECK( registry );
170
171   gObjectCreatedCallBackCalled = false;
172   registry.ObjectCreatedSignal().Connect( &TestCallback );
173   {
174     CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS );
175     crossEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
176   }
177   DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
178   END_TEST;
179 }
180
181 int UtcDaliCubeTransitionFoldEffectNew(void)
182 {
183   ToolkitTestApplication application;
184   tet_infoline( " UtcDaliCubeTransitionFoldEffectNew " );
185
186   CubeTransitionEffect foldEffect;
187
188   DALI_TEST_CHECK( !foldEffect );
189
190   foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS );
191   foldEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
192
193   DALI_TEST_CHECK( foldEffect );
194
195   foldEffect.Reset();
196
197   //Additional check to ensure object is created by checking if it is registered
198   ObjectRegistry registry = application.GetCore().GetObjectRegistry();
199   DALI_TEST_CHECK( registry );
200
201   gObjectCreatedCallBackCalled = false;
202   registry.ObjectCreatedSignal().Connect( &TestCallback );
203   {
204     CubeTransitionEffect foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS );
205     foldEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
206   }
207   DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
208   END_TEST;
209 }
210
211 int UtcDaliCubeTransitionEffectSetGetTransitionDuration(void)
212 {
213   ToolkitTestApplication application;
214   tet_infoline(" UtcDaliCubeTransitionEffectSetGetTransitionDuration ");
215
216   CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS );
217   waveEffect.SetTransitionDuration( TRANSITION_DURATION );
218   waveEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
219   DALI_TEST_EQUALS( TRANSITION_DURATION, waveEffect.GetTransitionDuration(), TEST_LOCATION );
220
221   CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS );
222   crossEffect.SetTransitionDuration( TRANSITION_DURATION );
223   crossEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
224   DALI_TEST_EQUALS( TRANSITION_DURATION, crossEffect.GetTransitionDuration(), TEST_LOCATION );
225
226   CubeTransitionEffect foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS );
227   foldEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
228   foldEffect.SetTransitionDuration( TRANSITION_DURATION );
229   DALI_TEST_EQUALS( TRANSITION_DURATION, foldEffect.GetTransitionDuration(), TEST_LOCATION );
230   END_TEST;
231 }
232
233 int UtcDaliCubeTransitionEffectSetGetCubeDisplacement(void)
234 {
235   ToolkitTestApplication application;
236   tet_infoline(" UtcDaliCubeTransitionEffectSetGetTransitionDuration ");
237
238   CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS);
239   waveEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
240   waveEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
241   DALI_TEST_EQUALS( CUBE_DISPLACEMENT, waveEffect.GetCubeDisplacement(), TEST_LOCATION );
242
243   CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS );
244   crossEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
245   crossEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
246   DALI_TEST_EQUALS( CUBE_DISPLACEMENT, crossEffect.GetCubeDisplacement(), TEST_LOCATION );
247
248   //Cube displacement is not used in CubeTransitionFoldEffect
249   END_TEST;
250 }
251
252 //Test common codes in base class
253 int UtcDaliCubeTransitionEffectGetRoot(void)
254 {
255   ToolkitTestApplication application;
256   tet_infoline(" UtcDaliCubeTransitionEffectGetRoot ");
257
258   unsigned int totalNum = NUM_ROWS*NUM_COLUMNS;
259
260   Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 40, 40 );
261
262   CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS );
263   waveEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
264   application.GetScene().Add( waveEffect );
265   waveEffect.SetCurrentTexture( texture );
266   waveEffect.SetTargetTexture( texture );
267
268   application.SendNotification();
269   application.Render();
270
271   waveEffect.StartTransition();
272
273   Wait( application, TRANSITION_DURATION * 0.5f );
274
275   // check that we have a total of NUM_ROWS*NUM_COLUMNS cubes;
276   Actor boxesRoot = waveEffect.GetChildAt(0);
277   DALI_TEST_CHECK( totalNum == boxesRoot.GetChildCount() );
278
279   // check that every cube has two children
280   DALI_TEST_CHECK( 2 == boxesRoot.GetChildAt(0).GetChildCount() );
281   DALI_TEST_CHECK( 2 == boxesRoot.GetChildAt(totalNum/2).GetChildCount() );
282   DALI_TEST_CHECK( 2 == boxesRoot.GetChildAt(totalNum-1).GetChildCount() );
283   END_TEST;
284 }
285
286 int UtcDaliCubeTransitionEffectIsTransitioning(void)
287 {
288   ToolkitTestApplication application;
289   tet_infoline(" UtcDaliCubeTransitionEffectIsTransiting ");
290
291   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
292   Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 40, 40 );
293
294   CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS );
295   waveEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
296   application.GetScene().Add( waveEffect );
297
298   waveEffect.SetTransitionDuration( TRANSITION_DURATION );
299   waveEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
300   DALI_TEST_CHECK( !waveEffect.IsTransitioning() );
301
302   waveEffect.SetCurrentTexture( texture );
303   waveEffect.SetTargetTexture( texture );
304   //transition is started
305   waveEffect.StartTransition();
306   DALI_TEST_CHECK( waveEffect.IsTransitioning() );
307   //transition is finished
308   Wait( application, TRANSITION_DURATION );
309   DALI_TEST_CHECK( !waveEffect.IsTransitioning() );
310
311   CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS );
312   crossEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
313   application.GetScene().Add( crossEffect );
314
315   crossEffect.SetTransitionDuration( TRANSITION_DURATION );
316   crossEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
317   DALI_TEST_CHECK( !crossEffect.IsTransitioning() );
318
319   crossEffect.SetCurrentTexture( texture );
320   crossEffect.SetTargetTexture( texture );
321   //transition is started
322   crossEffect.StartTransition(false);
323   DALI_TEST_CHECK( crossEffect.IsTransitioning() );
324   //transition is finished
325   Wait( application, TRANSITION_DURATION );
326   DALI_TEST_CHECK( !crossEffect.IsTransitioning() );
327
328   CubeTransitionEffect foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS );
329   foldEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
330   application.GetScene().Add( foldEffect );
331
332   foldEffect.SetTransitionDuration( TRANSITION_DURATION );
333   DALI_TEST_CHECK( !foldEffect.IsTransitioning() );
334
335   foldEffect.SetCurrentTexture( texture );
336   foldEffect.SetTargetTexture( texture );
337   //transition is started
338   foldEffect.StartTransition(true);
339   DALI_TEST_CHECK(foldEffect.IsTransitioning() );
340   //transition is finished
341   Wait( application, TRANSITION_DURATION );
342   DALI_TEST_CHECK( !foldEffect.IsTransitioning() );
343
344   END_TEST;
345 }
346
347 //Test common codes in base class
348 int UtcDaliCubeTransitionEffectSetCurrentTexture(void)
349 {
350   ToolkitTestApplication application;
351   tet_infoline(" UtcDaliCubeTransitionEffectSetCurrentTexture ");
352
353   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
354   Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 40, 40 );
355
356   CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS );
357   waveEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
358   waveEffect.SetCurrentTexture( texture );
359
360   application.GetScene().Add( waveEffect );
361
362   application.SendNotification();
363   application.Render();
364
365   waveEffect.StartTransition();
366
367   // the current image content is set to the tiles facing the camera
368   Actor currentTile = waveEffect.GetChildAt(0).GetChildAt(0).GetChildAt(0);
369   Actor targetTile = waveEffect.GetChildAt(0).GetChildAt(0).GetChildAt(1);
370
371   //check the pixel area set to the cube
372   Vector4 pixelAreaDef( 0.f, 0.f, 1.f / NUM_COLUMNS, 1.f / NUM_ROWS);
373
374   Property::Index textureRectIndex = currentTile.GetPropertyIndex( "uTextureRect" );
375   DALI_TEST_CHECK( textureRectIndex != Property::INVALID_INDEX );
376   Property::Value textureRectValue = currentTile.GetProperty( textureRectIndex );
377   DALI_TEST_CHECK( textureRectValue.GetType() == Property::VECTOR4 );
378   Vector4 pixelArea;
379   DALI_TEST_CHECK( textureRectValue.Get( pixelArea ) );
380
381   DALI_TEST_EQUALS( pixelAreaDef, pixelArea, FLT_EPISILON, TEST_LOCATION );
382
383   END_TEST;
384 }
385
386 //Test common codes in base class
387 int UtcDaliCubeTransitionEffectSetTargetTexture(void)
388 {
389   ToolkitTestApplication application;
390   tet_infoline(" UtcDaliCubeTransitionEffectSetTargetTexture ");
391
392   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
393   Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 40, 40 );
394   CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS );
395   waveEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
396   application.GetScene().Add( waveEffect );
397
398   waveEffect.SetCurrentTexture( texture );
399   waveEffect.SetTargetTexture( texture );
400
401   application.GetScene().Add( waveEffect );
402
403   application.SendNotification();
404   application.Render();
405
406   waveEffect.StartTransition();
407
408   // the target image content is set to the tiles currently invisible to the camera
409   Actor tile = waveEffect.GetChildAt(0).GetChildAt(0).GetChildAt(1);
410
411   //check the pixel area set to the cube
412   Vector4 pixelAreaDef( 0.f, 0.f, 1.f / NUM_COLUMNS, 1.f / NUM_ROWS);
413
414   Property::Index textureRectIndex = tile.GetPropertyIndex( "uTextureRect" );
415   DALI_TEST_CHECK( textureRectIndex != -1 );
416   Property::Value textureRectValue = tile.GetProperty( textureRectIndex );
417   DALI_TEST_CHECK( textureRectValue.GetType() == Property::VECTOR4 );
418   Vector4 pixelArea;
419   DALI_TEST_CHECK( textureRectValue.Get( pixelArea ) );
420
421   DALI_TEST_EQUALS( pixelAreaDef, pixelArea, FLT_EPISILON, TEST_LOCATION );
422
423   END_TEST;
424 }
425
426 int UtcDaliCubeTransitionWaveEffectStartTransition(void)
427 {
428   ToolkitTestApplication application;
429   tet_infoline(" UtcDaliCubeTransitionWaveEffectStartTransition ");
430
431   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
432
433   Devel::PixelBuffer pixelBuffer = LoadImageFromFile(TEST_RESOURCE_DIR "/gallery-small-1.jpg");
434   PixelData pixelData = Devel::PixelBuffer::Convert( pixelBuffer );
435   Texture texture = Texture::New( TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), pixelData.GetWidth(), pixelData.GetHeight() );
436   texture.Upload( pixelData );
437
438   CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS );
439   waveEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
440   waveEffect.SetTransitionDuration( TRANSITION_DURATION );
441   waveEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
442   waveEffect.SetCurrentTexture( texture );
443
444   application.GetScene().Add( waveEffect );
445
446   application.SendNotification();
447   application.Render();
448
449   waveEffect.StartTransition( true );
450
451   Actor cube = waveEffect.GetChildAt(0).GetChildAt(0);
452
453   //check the cube rotation value and color values just before the end of different transitions
454   waveEffect.SetTargetTexture( texture );
455   Wait( application, TRANSITION_BEFORE_END_DURATION );
456   DALI_TEST_EQUALS( cube.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( -Dali::ANGLE_90,  Vector3::YAXIS), EPISILON, TEST_LOCATION  );
457   DALI_TEST_EQUALS( cube.GetChildAt(0).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), HALF_BRIGHTNESS, EPISILON, TEST_LOCATION );
458   DALI_TEST_EQUALS( cube.GetChildAt(1).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), FULL_BRIGHTNESS, EPISILON, TEST_LOCATION );
459
460   waveEffect.SetTargetTexture( texture );
461   waveEffect.StartTransition(PAN_POSITION1, PAN_DISPLACEMENT1);
462   Wait( application, TRANSITION_BEFORE_END_DURATION );
463   DALI_TEST_EQUALS( cube.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( -Dali::ANGLE_90,  Vector3::YAXIS), EPISILON, TEST_LOCATION  );
464   DALI_TEST_EQUALS( cube.GetChildAt(0).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), HALF_BRIGHTNESS, EPISILON, TEST_LOCATION );
465   DALI_TEST_EQUALS( cube.GetChildAt(1).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), FULL_BRIGHTNESS, EPISILON, TEST_LOCATION );
466
467   waveEffect.SetTargetTexture( texture );
468   waveEffect.StartTransition(false);
469   Wait( application, TRANSITION_BEFORE_END_DURATION );
470   DALI_TEST_EQUALS( cube.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_90,  Vector3::YAXIS), EPISILON, TEST_LOCATION  );
471   DALI_TEST_EQUALS( cube.GetChildAt(0).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), HALF_BRIGHTNESS, EPISILON, TEST_LOCATION );
472   DALI_TEST_EQUALS( cube.GetChildAt(1).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), FULL_BRIGHTNESS, EPISILON, TEST_LOCATION );
473
474   waveEffect.SetTargetTexture( texture );
475   waveEffect.StartTransition(PAN_POSITION2, PAN_DISPLACEMENT2);
476   Wait( application, TRANSITION_BEFORE_END_DURATION );
477   DALI_TEST_EQUALS( cube.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_90,  Vector3::YAXIS), EPISILON, TEST_LOCATION  );
478   DALI_TEST_EQUALS( cube.GetChildAt(0).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), HALF_BRIGHTNESS, EPISILON, TEST_LOCATION );
479   DALI_TEST_EQUALS( cube.GetChildAt(1).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), FULL_BRIGHTNESS, EPISILON, TEST_LOCATION );
480   END_TEST;
481 }
482
483 int UtcDaliCubeTransitionCrossEffectStartTransition(void)
484 {
485   ToolkitTestApplication application;
486   tet_infoline(" UtcDaliCubeTransitionCrossEffectStartTransition ");
487
488   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
489
490   Devel::PixelBuffer pixelBuffer = LoadImageFromFile(TEST_RESOURCE_DIR "/gallery-small-1.jpg");
491   PixelData pixelData = Devel::PixelBuffer::Convert( pixelBuffer );
492   Texture texture = Texture::New( TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), pixelData.GetWidth(), pixelData.GetHeight() );
493   texture.Upload( pixelData );
494
495   CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS );
496   crossEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
497   crossEffect.SetTransitionDuration( TRANSITION_DURATION );
498   crossEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
499   crossEffect.SetCurrentTexture( texture );
500   crossEffect.SetTargetTexture( texture );
501
502   application.GetScene().Add( crossEffect );
503
504   application.SendNotification();
505   application.Render();
506
507   crossEffect.StartTransition(true);
508
509   Actor cube0 = crossEffect.GetChildAt(0).GetChildAt(0);
510   Actor cube1 = crossEffect.GetChildAt(0).GetChildAt(1);
511
512   //check the cube rotation value and color values just before the end of different transitions
513   Wait( application, TRANSITION_BEFORE_END_DURATION );
514   DALI_TEST_EQUALS( cube1.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( -Dali::ANGLE_90,  Vector3::YAXIS), EPISILON, TEST_LOCATION );
515   DALI_TEST_EQUALS( cube0.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_90,  Vector3::XAXIS), EPISILON, TEST_LOCATION );
516   DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), HALF_BRIGHTNESS, EPISILON, TEST_LOCATION );
517   DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), FULL_BRIGHTNESS, EPISILON, TEST_LOCATION );
518
519
520   crossEffect.SetTargetTexture( texture );
521   crossEffect.StartTransition(PAN_POSITION1, PAN_DISPLACEMENT1);
522   Wait( application, TRANSITION_BEFORE_END_DURATION );
523   DALI_TEST_EQUALS( cube1.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( -Dali::ANGLE_90,  Vector3::YAXIS), EPISILON, TEST_LOCATION );
524   DALI_TEST_EQUALS( cube0.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_90,  Vector3::XAXIS), EPISILON, TEST_LOCATION );
525   DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), HALF_BRIGHTNESS, EPISILON, TEST_LOCATION );
526   DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), FULL_BRIGHTNESS, EPISILON, TEST_LOCATION );
527
528
529   crossEffect.SetTargetTexture( texture );
530   crossEffect.StartTransition(false);
531   Wait( application, TRANSITION_BEFORE_END_DURATION );
532   DALI_TEST_EQUALS( cube1.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_90,  Vector3::YAXIS), EPISILON, TEST_LOCATION  );
533   DALI_TEST_EQUALS( cube0.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( -Dali::ANGLE_90,  Vector3::XAXIS), EPISILON, TEST_LOCATION  );
534   DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), HALF_BRIGHTNESS, EPISILON, TEST_LOCATION );
535   DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), FULL_BRIGHTNESS, EPISILON, TEST_LOCATION );
536
537   crossEffect.SetTargetTexture( texture );
538   crossEffect.StartTransition(PAN_POSITION2, PAN_DISPLACEMENT2);
539   Wait( application, TRANSITION_BEFORE_END_DURATION );
540   DALI_TEST_EQUALS( cube1.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_90,  Vector3::YAXIS), EPISILON, TEST_LOCATION );
541   DALI_TEST_EQUALS( cube0.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( -Dali::ANGLE_90,  Vector3::XAXIS), EPISILON, TEST_LOCATION );
542   DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), HALF_BRIGHTNESS, EPISILON, TEST_LOCATION );
543   DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), FULL_BRIGHTNESS, EPISILON, TEST_LOCATION );
544   END_TEST;
545 }
546
547 int UtcDaliCubeTransitionFoldEffectStartTransition(void)
548 {
549   ToolkitTestApplication application;
550   tet_infoline(" UtcDaliCubeTransitionFoldEffectStartTransition ");
551
552   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
553   Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 40, 40 );
554   CubeTransitionEffect foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS );
555   foldEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
556   foldEffect.SetTransitionDuration( TRANSITION_DURATION );
557   foldEffect.SetCurrentTexture( texture );
558   foldEffect.SetTargetTexture( texture );
559
560   application.GetScene().Add( foldEffect );
561
562   application.SendNotification();
563   application.Render();
564
565   foldEffect.StartTransition(true);
566
567   Actor cube0 = foldEffect.GetChildAt(0).GetChildAt(0);
568   Actor cube1 = foldEffect.GetChildAt(0).GetChildAt(1);
569
570   //check the cube rotation value and color values just before the end of different transitions
571   Wait( application, TRANSITION_BEFORE_END_DURATION );
572   DALI_TEST_EQUALS( cube1.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( -Dali::ANGLE_90,  Vector3::YAXIS), EPISILON, TEST_LOCATION  );
573   DALI_TEST_EQUALS( cube0.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_90,  Vector3::YAXIS), EPISILON, TEST_LOCATION  );
574   DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), HALF_BRIGHTNESS, EPISILON, TEST_LOCATION );
575   DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), FULL_BRIGHTNESS, EPISILON, TEST_LOCATION );
576
577   foldEffect.SetTargetTexture( texture );
578   foldEffect.StartTransition(PAN_POSITION1, PAN_DISPLACEMENT1);
579   Wait( application, TRANSITION_BEFORE_END_DURATION );
580   DALI_TEST_EQUALS( cube1.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( -Dali::ANGLE_90,  Vector3::YAXIS), EPISILON, TEST_LOCATION  );
581   DALI_TEST_EQUALS( cube0.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_90,  Vector3::YAXIS), EPISILON, TEST_LOCATION  );
582   DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), HALF_BRIGHTNESS, EPISILON, TEST_LOCATION );
583   DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), FULL_BRIGHTNESS, EPISILON, TEST_LOCATION );
584
585
586   foldEffect.SetTargetTexture( texture );
587   foldEffect.StartTransition(false);
588   Wait( application, TRANSITION_BEFORE_END_DURATION );
589   DALI_TEST_EQUALS( cube1.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_90,  Vector3::YAXIS), EPISILON, TEST_LOCATION  );
590   DALI_TEST_EQUALS( cube0.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( -Dali::ANGLE_90,  Vector3::YAXIS), EPISILON, TEST_LOCATION  );
591   DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), HALF_BRIGHTNESS, EPISILON, TEST_LOCATION );
592   DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ),FULL_BRIGHTNESS, EPISILON, TEST_LOCATION );
593
594   foldEffect.SetTargetTexture( texture );
595   foldEffect.StartTransition(PAN_POSITION2, PAN_DISPLACEMENT2);
596   Wait( application, TRANSITION_BEFORE_END_DURATION );
597   DALI_TEST_EQUALS( cube1.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_90,  Vector3::YAXIS), EPISILON, TEST_LOCATION  );
598   DALI_TEST_EQUALS( cube0.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( -Dali::ANGLE_90,  Vector3::YAXIS), EPISILON, TEST_LOCATION  );
599   DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), HALF_BRIGHTNESS, EPISILON, TEST_LOCATION );
600   DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), FULL_BRIGHTNESS, EPISILON, TEST_LOCATION );
601   END_TEST;
602 }
603
604 int UtcDaliCubeTransitionEffectSignalTransitionCompleted(void)
605 {
606   ToolkitTestApplication application;
607   tet_infoline(" UtcDaliCubeTransitionEffectSignalTransitionCompleted ");
608
609   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
610   Texture firstTexture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 30, 30 );
611   Texture secondTexture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 20, 20 );
612   Texture thirdTexture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 40, 40 );
613
614   CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS );
615   waveEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
616   waveEffect.SetTransitionDuration( TRANSITION_DURATION );
617   waveEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
618   application.GetScene().Add( waveEffect );
619
620   CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS );
621   crossEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
622   crossEffect.SetTransitionDuration( TRANSITION_DURATION );
623   crossEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
624   application.GetScene().Add( crossEffect );
625
626   CubeTransitionEffect foldEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS );
627   foldEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
628   foldEffect.SetTransitionDuration( TRANSITION_DURATION );
629   application.GetScene().Add( foldEffect );
630
631   bool signalVerified = false;
632   CubeTransitionEffect currentEffect;
633   Texture actorTransitTo;
634   TransitionCompletedCallback callback(signalVerified, currentEffect, actorTransitTo);
635   waveEffect.TransitionCompletedSignal().Connect( &callback, &TransitionCompletedCallback::Callback );
636   crossEffect.TransitionCompletedSignal().Connect( &callback, &TransitionCompletedCallback::Callback );
637   foldEffect.TransitionCompletedSignal().Connect( &callback, &TransitionCompletedCallback::Callback );
638
639   //check that the wave effect is used to transit to secondTexture
640   currentEffect = waveEffect;
641   actorTransitTo = secondTexture;
642   waveEffect.SetCurrentTexture( firstTexture );
643   waveEffect.SetTargetTexture( secondTexture );
644   waveEffect.StartTransition(PAN_POSITION1, PAN_DISPLACEMENT1);
645   Wait( application, TRANSITION_DURATION );
646   DALI_TEST_CHECK(callback.mSignalVerified);
647   callback.Reset();
648
649   //check that the wave effect is used to transit to thirdTexture
650   actorTransitTo = thirdTexture;
651   waveEffect.SetTargetTexture( thirdTexture );
652   waveEffect.StartTransition(PAN_POSITION2, PAN_DISPLACEMENT2);
653   Wait( application, TRANSITION_DURATION );
654   DALI_TEST_CHECK(callback.mSignalVerified);
655   callback.Reset();
656
657   //check that the cross effect is used to transit to secondTexture
658   currentEffect = crossEffect;
659   actorTransitTo = secondTexture;
660   crossEffect.SetCurrentTexture( thirdTexture );
661   crossEffect.SetTargetTexture( secondTexture );
662   crossEffect.StartTransition(true);
663   Wait( application, TRANSITION_DURATION );
664   DALI_TEST_CHECK(callback.mSignalVerified);
665   callback.Reset();
666
667   //check that the cross effect is used to transit to firstTexture
668   actorTransitTo = firstTexture;
669   crossEffect.SetTargetTexture( firstTexture );
670   crossEffect.StartTransition(false);
671   Wait( application, TRANSITION_DURATION );
672   DALI_TEST_CHECK(callback.mSignalVerified);
673   callback.Reset();
674
675   //check that the fold effect is used to transit to secondTexture
676   currentEffect = foldEffect;
677   actorTransitTo = secondTexture;
678   foldEffect.SetCurrentTexture( firstTexture );
679   foldEffect.SetTargetTexture( secondTexture );
680   foldEffect.StartTransition();
681   Wait( application, TRANSITION_DURATION );
682   DALI_TEST_CHECK( callback.mSignalVerified );
683   callback.Reset();
684
685   //check that the fold effect is used to transit to thirdTexture
686   actorTransitTo = thirdTexture;
687   foldEffect.SetTargetTexture( thirdTexture );
688   foldEffect.StartTransition( false );
689   Wait( application, TRANSITION_DURATION );
690   DALI_TEST_CHECK( callback.mSignalVerified );
691   END_TEST;
692 }
693
694 int UtcDaliCubeTransitionEffectPauseResumeTransition(void)
695 {
696   ToolkitTestApplication application;
697   tet_infoline(" UtcDaliCubeTransitionEffectPauseResumeTransition ");
698
699   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
700   Texture firstTexture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 30, 30 );
701   Texture secondTexture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 20, 20 );
702
703   CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS );
704   waveEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
705   waveEffect.SetTransitionDuration( TRANSITION_DURATION );
706   waveEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
707   application.GetScene().Add( waveEffect );
708
709   CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS );
710   crossEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
711   crossEffect.SetTransitionDuration( TRANSITION_DURATION );
712   crossEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
713   application.GetScene().Add( crossEffect );
714
715   CubeTransitionEffect foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS );
716   foldEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
717   foldEffect.SetTransitionDuration( TRANSITION_DURATION );
718   application.GetScene().Add( foldEffect );
719
720   bool signalVerified = false;
721   CubeTransitionEffect currentEffect;
722   Texture actorTransitTo;
723   TransitionCompletedCallback callback(signalVerified, currentEffect, actorTransitTo);
724   waveEffect.TransitionCompletedSignal().Connect( &callback, &TransitionCompletedCallback::Callback );
725   crossEffect.TransitionCompletedSignal().Connect( &callback, &TransitionCompletedCallback::Callback );
726   foldEffect.TransitionCompletedSignal().Connect( &callback, &TransitionCompletedCallback::Callback );
727
728   currentEffect = waveEffect;
729   actorTransitTo = secondTexture;
730   waveEffect.SetCurrentTexture( firstTexture );
731   waveEffect.SetTargetTexture( secondTexture );
732   // start transition; transit for 0.5*duration; pause for 0.5*duration;
733   // resume for 0.25*duration; pause for 0.25*duration; resume for another 0.25*duration;
734   // only until now the transition finished signal can be received
735   waveEffect.StartTransition(PAN_POSITION1, PAN_DISPLACEMENT1);
736   Wait( application, TRANSITION_DURATION*0.5f );
737   DALI_TEST_CHECK(!callback.mSignalVerified);
738   waveEffect.PauseTransition();
739   Wait( application, TRANSITION_DURATION*0.5f );
740   DALI_TEST_CHECK(!callback.mSignalVerified);
741   waveEffect.ResumeTransition();
742   Wait( application, TRANSITION_DURATION*0.25f );
743   DALI_TEST_CHECK(!callback.mSignalVerified);
744   waveEffect.PauseTransition();
745   Wait( application, TRANSITION_DURATION*0.25f );
746   DALI_TEST_CHECK(!callback.mSignalVerified);
747   waveEffect.ResumeTransition();
748   Wait( application, TRANSITION_DURATION*0.25f );
749   DALI_TEST_CHECK(callback.mSignalVerified);
750   callback.Reset();
751
752   currentEffect = crossEffect;
753   actorTransitTo = firstTexture;
754   crossEffect.SetCurrentTexture( secondTexture );
755   crossEffect.SetTargetTexture( firstTexture );
756   // start transition; transit for 0.25*duration; pause for 0.2*duration;
757   // resume for 0.5*duration; pause for 0.2*duration; resume for another 0.25*duration;
758   // only until now the transition finished signal can be received
759   crossEffect.StartTransition(false);
760   Wait( application, TRANSITION_DURATION*0.25f );
761   DALI_TEST_CHECK(!callback.mSignalVerified);
762   crossEffect.PauseTransition();
763   Wait( application, TRANSITION_DURATION*0.2f );
764   DALI_TEST_CHECK(!callback.mSignalVerified);
765   crossEffect.ResumeTransition();
766   Wait( application, TRANSITION_DURATION*0.5f );
767   DALI_TEST_CHECK(!callback.mSignalVerified);
768   crossEffect.PauseTransition();
769   Wait( application, TRANSITION_DURATION*0.2f );
770   DALI_TEST_CHECK(!callback.mSignalVerified);
771   crossEffect.ResumeTransition();
772   Wait( application, TRANSITION_DURATION*0.25f );
773   DALI_TEST_CHECK(callback.mSignalVerified);
774   callback.Reset();
775
776   currentEffect = foldEffect;
777   actorTransitTo = secondTexture;
778   foldEffect.SetCurrentTexture( firstTexture );
779   foldEffect.SetTargetTexture( secondTexture );
780   // start transition; transit for 0.5*duration; pause for 0.5*duration;
781   // resume for 0.25*duration; pause for 0.25*duration; resume for another 0.25*duration;
782   // only until now the transition finished signal can be received
783   foldEffect.StartTransition(PAN_POSITION1, PAN_DISPLACEMENT1);
784   Wait( application, TRANSITION_DURATION*0.5f );
785   DALI_TEST_CHECK(!callback.mSignalVerified);
786   foldEffect.PauseTransition();
787   Wait( application, TRANSITION_DURATION*0.5f );
788   DALI_TEST_CHECK(!callback.mSignalVerified);
789   foldEffect.ResumeTransition();
790   Wait( application, TRANSITION_DURATION*0.25f );
791   DALI_TEST_CHECK(!callback.mSignalVerified);
792   foldEffect.PauseTransition();
793   Wait( application, TRANSITION_DURATION*0.25f );
794   DALI_TEST_CHECK(!callback.mSignalVerified);
795   foldEffect.ResumeTransition();
796   Wait( application, TRANSITION_DURATION*0.25f );
797   DALI_TEST_CHECK(callback.mSignalVerified);
798   END_TEST;
799 }
800
801 int UtcDaliCubeTransitionWaveEffectStopTransition(void)
802 {
803   ToolkitTestApplication application;
804   tet_infoline(" UtcDaliCubeTransitionWaveEffectStopTransition ");
805
806   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
807   Texture firstTexture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 30, 30 );
808   Texture secondTexture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 20, 20 );
809
810   CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS );
811   waveEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
812   waveEffect.SetTransitionDuration( TRANSITION_DURATION );
813   waveEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
814   waveEffect.SetCurrentTexture( firstTexture );
815   waveEffect.SetTargetTexture( secondTexture );
816
817   application.GetScene().Add( waveEffect );
818
819   application.SendNotification();
820   application.Render();
821
822   waveEffect.StartTransition(true);
823
824   Actor cube = waveEffect.GetChildAt(0).GetChildAt(0);
825
826   //check the cube rotation value and color values reset after stopping different transitions in the middle
827   Wait( application, TRANSITION_DURATION*0.2f );
828   waveEffect.StopTransition();
829   application.SendNotification();
830   application.Render(RENDER_FRAME_INTERVAL);
831   DALI_TEST_EQUALS( cube.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0,  Vector3::ZERO), FLT_EPISILON, TEST_LOCATION  );
832   DALI_TEST_EQUALS( cube.GetChildAt(0).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), FULL_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
833   DALI_TEST_EQUALS( cube.GetChildAt(1).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), HALF_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
834
835   waveEffect.SetTargetTexture( firstTexture );
836   waveEffect.StartTransition(PAN_POSITION1, PAN_DISPLACEMENT1);
837   Wait( application, TRANSITION_DURATION*0.4f );
838   waveEffect.StopTransition();
839   application.SendNotification();
840   application.Render(RENDER_FRAME_INTERVAL);
841   DALI_TEST_EQUALS( cube.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0,  Vector3::ZERO), FLT_EPISILON, TEST_LOCATION  );
842   DALI_TEST_EQUALS( cube.GetChildAt(0).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), FULL_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
843   DALI_TEST_EQUALS( cube.GetChildAt(1).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), HALF_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
844
845   waveEffect.SetTargetTexture( secondTexture );
846   waveEffect.StartTransition(false);
847   Wait( application, TRANSITION_DURATION*0.6f );
848   waveEffect.StopTransition();
849   application.SendNotification();
850   application.Render(RENDER_FRAME_INTERVAL);
851   DALI_TEST_EQUALS( cube.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0,  Vector3::ZERO), FLT_EPISILON, TEST_LOCATION  );
852   DALI_TEST_EQUALS( cube.GetChildAt(0).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), FULL_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
853   DALI_TEST_EQUALS( cube.GetChildAt(1).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), HALF_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
854
855   waveEffect.SetTargetTexture( firstTexture );
856   waveEffect.StartTransition(PAN_POSITION2, PAN_DISPLACEMENT2);
857   Wait( application, TRANSITION_DURATION*0.8f );
858   waveEffect.StopTransition();
859   application.SendNotification();
860   application.Render(RENDER_FRAME_INTERVAL);
861   DALI_TEST_EQUALS( cube.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0,  Vector3::ZERO), FLT_EPISILON, TEST_LOCATION  );
862   DALI_TEST_EQUALS( cube.GetChildAt(0).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), FULL_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
863   DALI_TEST_EQUALS( cube.GetChildAt(1).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), HALF_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
864   END_TEST;
865 }
866
867 int UtcDaliCubeTransitionCrossEffectStopTransition(void)
868 {
869   ToolkitTestApplication application;
870   tet_infoline(" UtcDaliCubeTransitionCrossEffectStopTransition ");
871
872   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
873   Texture firstTexture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 30, 30 );
874   Texture secondTexture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 20, 20 );
875
876   CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS );
877   crossEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
878   crossEffect.SetTransitionDuration( TRANSITION_DURATION );
879   crossEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
880   crossEffect.SetCurrentTexture( firstTexture );
881   crossEffect.SetTargetTexture( secondTexture );
882
883   application.GetScene().Add( crossEffect );
884
885   application.SendNotification();
886   application.Render();
887
888   crossEffect.StartTransition(true);
889
890   Actor cube0 = crossEffect.GetChildAt(0).GetChildAt(0);
891   Actor cube1 = crossEffect.GetChildAt(0).GetChildAt(1);
892
893   //check the cube rotation values and color values reset after stop the different transitions in the middle
894   Wait( application, TRANSITION_DURATION*0.2f );
895   crossEffect.StopTransition();
896   application.SendNotification();
897   application.Render(RENDER_FRAME_INTERVAL);
898   DALI_TEST_EQUALS( cube0.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0,  Vector3::ZERO), FLT_EPISILON, TEST_LOCATION  );
899   DALI_TEST_EQUALS( cube1.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0,  Vector3::ZERO), FLT_EPISILON, TEST_LOCATION  );
900   DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), FULL_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
901   DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), HALF_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
902
903   crossEffect.SetTargetTexture( firstTexture );
904   crossEffect.StartTransition(PAN_POSITION1, PAN_DISPLACEMENT1);
905   Wait( application, TRANSITION_DURATION*0.4f );
906   crossEffect.StopTransition();
907   application.SendNotification();
908   application.Render(RENDER_FRAME_INTERVAL);
909   DALI_TEST_EQUALS( cube0.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0,  Vector3::ZERO), FLT_EPISILON, TEST_LOCATION  );
910   DALI_TEST_EQUALS( cube1.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0,  Vector3::ZERO), FLT_EPISILON, TEST_LOCATION  );
911   DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), FULL_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
912   DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), HALF_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
913
914   crossEffect.SetTargetTexture( secondTexture );
915   crossEffect.StartTransition(false);
916   Wait( application, TRANSITION_DURATION*0.6f );
917   crossEffect.StopTransition();
918   application.SendNotification();
919   application.Render(RENDER_FRAME_INTERVAL);
920   DALI_TEST_EQUALS( cube0.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0,  Vector3::ZERO), FLT_EPISILON, TEST_LOCATION  );
921   DALI_TEST_EQUALS( cube1.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0,  Vector3::ZERO), FLT_EPISILON, TEST_LOCATION  );
922   DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), FULL_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
923   DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), HALF_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
924
925   crossEffect.SetTargetTexture( firstTexture );
926   crossEffect.StartTransition(PAN_POSITION2, PAN_DISPLACEMENT2);
927   Wait( application, TRANSITION_DURATION*0.8f );
928   crossEffect.StopTransition();
929   application.SendNotification();
930   application.Render(RENDER_FRAME_INTERVAL);
931   DALI_TEST_EQUALS( cube1.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0,  Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION  );
932   DALI_TEST_EQUALS( cube0.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0,  Vector3::XAXIS), FLT_EPISILON, TEST_LOCATION  );
933   DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), FULL_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
934   DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), HALF_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
935   END_TEST;
936 }
937
938 int UtcDaliCubeTransitionFoldEffectStopTransition(void)
939 {
940   ToolkitTestApplication application;
941   tet_infoline(" UtcDaliCubeTransitionFoldEffectStopTransition ");
942
943   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
944   Texture firstTexture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 30, 30 );
945   Texture secondTexture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 20, 20 );
946
947   CubeTransitionEffect foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS );
948   foldEffect.SetProperty( Actor::Property::SIZE, Vector2( VIEW_AREA_SIZE ) );
949   foldEffect.SetTransitionDuration( TRANSITION_DURATION );
950   foldEffect.SetCurrentTexture( firstTexture );
951   foldEffect.SetTargetTexture( secondTexture );
952
953   application.GetScene().Add( foldEffect );
954
955   application.SendNotification();
956   application.Render();
957
958   foldEffect.StartTransition(true);
959
960   Actor cube0 = foldEffect.GetChildAt(0).GetChildAt(0);
961   Actor cube1 = foldEffect.GetChildAt(0).GetChildAt(1);
962
963   //check the cube rotation values and color values after stop the different transitions in the middle
964   Wait( application, TRANSITION_DURATION*0.2f );
965   foldEffect.StopTransition();
966   application.SendNotification();
967   application.Render(RENDER_FRAME_INTERVAL);
968
969   DALI_TEST_EQUALS( cube1.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0,  Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION  );
970   DALI_TEST_EQUALS( cube0.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0,  Vector3::XAXIS), FLT_EPISILON, TEST_LOCATION  );
971   DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), FULL_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
972   DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), HALF_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
973
974   foldEffect.SetTargetTexture( firstTexture );
975   foldEffect.StartTransition(PAN_POSITION1, PAN_DISPLACEMENT1);
976   Wait( application, TRANSITION_DURATION*0.4f );
977   foldEffect.StopTransition();
978   application.SendNotification();
979   application.Render(RENDER_FRAME_INTERVAL);
980   DALI_TEST_EQUALS( cube1.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0,  Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION  );
981   DALI_TEST_EQUALS( cube0.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0,  Vector3::XAXIS), FLT_EPISILON, TEST_LOCATION  );
982   DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), FULL_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
983   DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), HALF_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
984
985   foldEffect.SetTargetTexture( secondTexture );
986   foldEffect.StartTransition(false);
987   Wait( application, TRANSITION_DURATION*0.6f );
988   foldEffect.StopTransition();
989   application.SendNotification();
990   application.Render(RENDER_FRAME_INTERVAL);
991   DALI_TEST_EQUALS( cube1.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0,  Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION  );
992   DALI_TEST_EQUALS( cube0.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0,  Vector3::XAXIS), FLT_EPISILON, TEST_LOCATION  );
993   DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), FULL_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
994   DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), HALF_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
995
996   foldEffect.SetTargetTexture( firstTexture );
997   foldEffect.StartTransition(PAN_POSITION2, PAN_DISPLACEMENT2);
998   Wait( application, TRANSITION_DURATION*0.8f );
999   foldEffect.StopTransition();
1000   application.SendNotification();
1001   application.Render(RENDER_FRAME_INTERVAL);
1002   DALI_TEST_EQUALS( cube1.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0,  Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION  );
1003   DALI_TEST_EQUALS( cube0.GetCurrentProperty< Quaternion >( Actor::Property::ORIENTATION ), Quaternion( Dali::ANGLE_0,  Vector3::YAXIS), FLT_EPISILON, TEST_LOCATION  );
1004   DALI_TEST_EQUALS( cube0.GetChildAt(0).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), FULL_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
1005   DALI_TEST_EQUALS( cube0.GetChildAt(1).GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), HALF_BRIGHTNESS, FLT_EPISILON, TEST_LOCATION );
1006   END_TEST;
1007 }