2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 // http://floralicense.org/license/
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.
22 #include <dali/public-api/dali-core.h>
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>
29 #include <dali-toolkit-test-suite-utils.h>
32 using namespace Dali::Toolkit;
34 static void Startup();
35 static void Cleanup();
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;
52 static bool gObjectCreatedCallBackCalled;
53 static void TestCallback(BaseHandle handle)
55 gObjectCreatedCallBackCalled = true;
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.
63 void Wait(ToolkitTestApplication& application, float durationToPass)
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++)
69 application.SendNotification();
70 application.Render(RENDER_FRAME_INTERVAL);
75 ImageActor CreateSolidColorImageActor( ToolkitTestApplication& application, const Vector4& color, unsigned int width, unsigned int height )
77 BitmapImage imageData = BitmapImage::New( width, height, Pixel::RGBA8888 );
78 ImageActor imageActor = ImageActor::New( imageData );
79 Stage::GetCurrent().Add( imageActor );
82 PixelBuffer* pixbuf = imageData.GetBuffer();
83 unsigned int size = width * height;
85 for( size_t i = 0; i < size; i++ )
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;
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();
103 //Callback class to test whether transition completed signal is emitted when the transition animation is finished
104 class TransitionCompletedCallback : public Dali::ConnectionTracker
107 TransitionCompletedCallback( bool& signalReceived, CubeTransitionEffect& effect, ImageActor& imageActor )
108 : mSignalVerified( signalReceived ),
109 mCurrentEffect( effect ),
110 mActorTransitTo( imageActor )
114 void Callback( CubeTransitionEffect effect, ImageActor imageActor )
116 tet_infoline( "Verifying TransitionCompletedSignal" );
118 if( mCurrentEffect == effect && mActorTransitTo == imageActor )
120 mSignalVerified = true;
126 mSignalVerified = false;
129 bool& mSignalVerified;
130 CubeTransitionEffect& mCurrentEffect;
131 ImageActor& mActorTransitTo;
137 void (*tet_startup)() = Startup;
138 void (*tet_cleanup)() = Cleanup;
142 POSITIVE_TC_IDX = 0x01,
146 #define MAX_NUMBER_OF_TESTS 10000
148 struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
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 );
171 // Called only once before first test is run.
172 static void Startup()
176 // Called only once after last test is run
177 static void Cleanup()
181 static void UtcDaliCubeTransitionWaveEffectNew()
183 ToolkitTestApplication application;
184 tet_infoline(" UtcDaliCubeTransitionWaveEffectNew ");
186 CubeTransitionEffect waveEffect;
188 DALI_TEST_CHECK( !waveEffect );
190 waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
192 DALI_TEST_CHECK( waveEffect );
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 );
200 gObjectCreatedCallBackCalled = false;
201 registry.ObjectCreatedSignal().Connect( &TestCallback );
203 CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
205 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
208 static void UtcDaliCubeTransitionCrossEffectNew()
210 ToolkitTestApplication application;
211 tet_infoline(" UtcDaliCubeTransitionCrossEffectNew ");
213 CubeTransitionEffect crossEffect;
215 DALI_TEST_CHECK( !crossEffect );
217 crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
219 DALI_TEST_CHECK( crossEffect );
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 );
227 gObjectCreatedCallBackCalled = false;
228 registry.ObjectCreatedSignal().Connect( &TestCallback );
230 CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
232 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
235 static void UtcDaliCubeTransitionFoldEffectNew()
237 ToolkitTestApplication application;
238 tet_infoline( " UtcDaliCubeTransitionFoldEffectNew " );
240 CubeTransitionEffect foldEffect;
242 DALI_TEST_CHECK( !foldEffect );
244 foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
246 DALI_TEST_CHECK( foldEffect );
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 );
254 gObjectCreatedCallBackCalled = false;
255 registry.ObjectCreatedSignal().Connect( &TestCallback );
257 CubeTransitionEffect foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
259 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
262 static void UtcDaliCubeTransitionEffectSetGetTransitionDuration()
264 ToolkitTestApplication application;
265 tet_infoline(" UtcDaliCubeTransitionEffectSetGetTransitionDuration ");
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 );
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 );
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 );
280 static void UtcDaliCubeTransitionEffectSetGetCubeDisplacement()
282 ToolkitTestApplication application;
283 tet_infoline(" UtcDaliCubeTransitionEffectSetGetTransitionDuration ");
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 );
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 );
293 //Cube displacement is not used in CubeTransitionFoldEffect
296 //Test common codes in base class
297 static void UtcDaliCubeTransitionEffectGetRoot()
299 ToolkitTestApplication application;
300 tet_infoline(" UtcDaliCubeTransitionEffectGetRoot ");
302 unsigned int totalNum = NUM_ROWS*NUM_COLUMNS;
304 CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
305 Actor rootActor = waveEffect.GetRoot();
307 // check that we have a total of NUM_ROWS*NUM_COLUMNS cubes;
308 DALI_TEST_CHECK( totalNum == rootActor.GetChildCount() );
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() );
316 static void UtcDaliCubeTransitionEffectIsTransiting()
318 ToolkitTestApplication application;
319 tet_infoline(" UtcDaliCubeTransitionEffectIsTransiting ");
321 ImageActor imageActor = CreateSolidColorImageActor(application, Color::BLUE,30,30);
323 CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
324 Actor rootActor = waveEffect.GetRoot();
325 Stage::GetCurrent().Add( rootActor );
327 waveEffect.SetTransitionDuration( TRANSITION_DURATION );
328 waveEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
329 DALI_TEST_CHECK( !waveEffect.IsTransiting() );
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() );
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() );
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() );
354 CubeTransitionEffect foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
355 foldEffect.SetTransitionDuration( TRANSITION_DURATION );
356 DALI_TEST_CHECK( !foldEffect.IsTransiting() );
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() );
369 //Test common codes in base class
370 static void UtcDaliCubeTransitionEffectSetCurrentImage()
372 ToolkitTestApplication application;
373 tet_infoline(" UtcDaliCubeTransitionEffectSetCurrentImage ");
375 ImageActor imageActor = CreateSolidColorImageActor(application, Color::BLUE,40,40) ;
377 CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
378 waveEffect.SetCurrentImage( imageActor );
380 // the current image content is set to the tiles facing the camera
381 ImageActor tile = ImageActor::DownCast( (waveEffect.GetRoot().GetChildAt(0).GetChildAt(0)));
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 );
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 );
395 //Test common codes in base class
396 static void UtcDaliCubeTransitionEffectSetTargetImage()
398 ToolkitTestApplication application;
399 tet_infoline(" UtcDaliCubeTransitionEffectSetTargetImage ");
401 ImageActor imageActor = CreateSolidColorImageActor(application, Color::BLUE,30,30);
403 CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
404 Actor rootActor = waveEffect.GetRoot();
405 Stage::GetCurrent().Add( rootActor );
407 waveEffect.SetCurrentImage( imageActor );
408 waveEffect.SetTargetImage( imageActor );
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)));
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 );
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 );
425 static void UtcDaliCubeTransitionWaveEffectStartTransition()
427 ToolkitTestApplication application;
428 tet_infoline(" UtcDaliCubeTransitionWaveEffectStartTransition ");
430 ImageActor imageActor = CreateSolidColorImageActor(application, Color::BLUE,30,30);
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);
439 waveEffect.SetCurrentImage( imageActor );
441 Vector4 fullBrightness = Vector4(1.f,1.f,1.f,1.f);
442 Vector4 halfBrightness = Vector4(0.5f, 0.5f, 0.5f, 1.f);
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 );
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 );
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 );
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 );
474 static void UtcDaliCubeTransitionCrossEffectStartTransition()
476 ToolkitTestApplication application;
477 tet_infoline(" UtcDaliCubeTransitionCrossEffectStartTransition ");
479 ImageActor imageActor = CreateSolidColorImageActor(application, Color::BLUE,30,30);
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);
490 Vector4 fullBrightness = Vector4(1.f,1.f,1.f,1.f);
491 Vector4 halfBrightness = Vector4(0.5f, 0.5f, 0.5f, 1.f);
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 );
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 );
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 );
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 );
528 static void UtcDaliCubeTransitionFoldEffectStartTransition()
530 ToolkitTestApplication application;
531 tet_infoline(" UtcDaliCubeTransitionFoldEffectStartTransition ");
533 ImageActor imageActor = CreateSolidColorImageActor(application, Color::BLUE,30,30);
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);
543 Vector4 fullBrightness = Vector4(1.f,1.f,1.f,1.f);
544 Vector4 halfBrightness = Vector4(0.5f, 0.5f, 0.5f, 1.f);
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 );
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 );
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 );
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 );
581 static void UtcDaliCubeTransitionEffectSignalTransitionCompleted()
583 ToolkitTestApplication application;
584 tet_infoline(" UtcDaliCubeTransitionEffectSignalTransitionCompleted ");
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);
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 );
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 );
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 );
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 );
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);
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);
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);
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);
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 );
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 );
669 static void UtcDaliCubeTransitionEffectPauseResumeTransition()
671 ToolkitTestApplication application;
672 tet_infoline(" UtcDaliCubeTransitionEffectPauseResumeTransition ");
674 ImageActor firstImageActor = CreateSolidColorImageActor(application, Color::RED,30,30);
675 ImageActor secondImageActor = CreateSolidColorImageActor(application, Color::GREEN,20,20);
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 );
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 );
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 );
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 );
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);
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);
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);
774 static void UtcDaliCubeTransitionWaveEffectStopTransition()
776 ToolkitTestApplication application;
777 tet_infoline(" UtcDaliCubeTransitionWaveEffectStopTransition ");
779 ImageActor firstImageActor = CreateSolidColorImageActor(application, Color::RED,30,30);
780 ImageActor secondImageActor = CreateSolidColorImageActor(application, Color::GREEN,20,20);
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 );
790 Vector4 fullBrightness = Vector4(1.f,1.f,1.f,1.f);
791 Vector4 halfBrightness = Vector4(0.5f, 0.5f, 0.5f, 1.f);
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 );
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 );
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 );
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 );
835 static void UtcDaliCubeTransitionCrossEffectStopTransition()
837 ToolkitTestApplication application;
838 tet_infoline(" UtcDaliCubeTransitionCrossEffectStopTransition ");
840 ImageActor firstImageActor = CreateSolidColorImageActor(application, Color::RED,30,30);
841 ImageActor secondImageActor = CreateSolidColorImageActor(application, Color::GREEN,20,20);
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);
852 Vector4 fullBrightness = Vector4(1.f,1.f,1.f,1.f);
853 Vector4 halfBrightness = Vector4(0.5f, 0.5f, 0.5f, 1.f);
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 );
865 DALI_TEST_CHECK( cube0.GetChildAt(0).GetCurrentColor() == halfBrightness );
866 DALI_TEST_CHECK( cube0.GetChildAt(1).GetCurrentColor() == fullBrightness );
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 );
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 );
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 );
902 static void UtcDaliCubeTransitionFoldEffectStopTransition()
904 ToolkitTestApplication application;
905 tet_infoline(" UtcDaliCubeTransitionFoldEffectStopTransition ");
907 ImageActor firstImageActor = CreateSolidColorImageActor(application, Color::RED,30,30);
908 ImageActor secondImageActor = CreateSolidColorImageActor(application, Color::GREEN,20,20);
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);
918 Vector4 fullBrightness = Vector4(1.f,1.f,1.f,1.f);
919 Vector4 halfBrightness = Vector4(0.5f, 0.5f, 0.5f, 1.f);
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 );
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 );
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 );
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 );