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