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