2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 #include <dali/public-api/dali-core.h>
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>
30 #include <dali-toolkit-test-suite-utils.h>
33 using namespace Dali::Toolkit;
35 static void Startup();
36 static void Cleanup();
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;
53 static bool gObjectCreatedCallBackCalled;
54 static void TestCallback(BaseHandle handle)
56 gObjectCreatedCallBackCalled = true;
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.
64 void Wait(ToolkitTestApplication& application, float durationToPass)
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++)
70 application.SendNotification();
71 application.Render(RENDER_FRAME_INTERVAL);
76 ImageActor CreateSolidColorImageActor( ToolkitTestApplication& application, const Vector4& color, unsigned int width, unsigned int height )
78 BitmapImage imageData = BitmapImage::New( width, height, Pixel::RGBA8888 );
79 ImageActor imageActor = ImageActor::New( imageData );
80 Stage::GetCurrent().Add( imageActor );
83 PixelBuffer* pixbuf = imageData.GetBuffer();
84 unsigned int size = width * height;
86 for( size_t i = 0; i < size; i++ )
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;
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();
104 //Callback class to test whether transition completed signal is emitted when the transition animation is finished
105 class TransitionCompletedCallback : public Dali::ConnectionTracker
108 TransitionCompletedCallback( bool& signalReceived, CubeTransitionEffect& effect, ImageActor& imageActor )
109 : mSignalVerified( signalReceived ),
110 mCurrentEffect( effect ),
111 mActorTransitTo( imageActor )
115 void Callback( CubeTransitionEffect effect, ImageActor imageActor )
117 tet_infoline( "Verifying TransitionCompletedSignal" );
119 if( mCurrentEffect == effect && mActorTransitTo == imageActor )
121 mSignalVerified = true;
127 mSignalVerified = false;
130 bool& mSignalVerified;
131 CubeTransitionEffect& mCurrentEffect;
132 ImageActor& mActorTransitTo;
138 void (*tet_startup)() = Startup;
139 void (*tet_cleanup)() = Cleanup;
143 POSITIVE_TC_IDX = 0x01,
147 #define MAX_NUMBER_OF_TESTS 10000
149 struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
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 );
172 // Called only once before first test is run.
173 static void Startup()
177 // Called only once after last test is run
178 static void Cleanup()
182 static void UtcDaliCubeTransitionWaveEffectNew()
184 ToolkitTestApplication application;
185 tet_infoline(" UtcDaliCubeTransitionWaveEffectNew ");
187 CubeTransitionEffect waveEffect;
189 DALI_TEST_CHECK( !waveEffect );
191 waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
193 DALI_TEST_CHECK( waveEffect );
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 );
201 gObjectCreatedCallBackCalled = false;
202 registry.ObjectCreatedSignal().Connect( &TestCallback );
204 CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
206 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
209 static void UtcDaliCubeTransitionCrossEffectNew()
211 ToolkitTestApplication application;
212 tet_infoline(" UtcDaliCubeTransitionCrossEffectNew ");
214 CubeTransitionEffect crossEffect;
216 DALI_TEST_CHECK( !crossEffect );
218 crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
220 DALI_TEST_CHECK( crossEffect );
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 );
228 gObjectCreatedCallBackCalled = false;
229 registry.ObjectCreatedSignal().Connect( &TestCallback );
231 CubeTransitionEffect crossEffect = CubeTransitionCrossEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
233 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
236 static void UtcDaliCubeTransitionFoldEffectNew()
238 ToolkitTestApplication application;
239 tet_infoline( " UtcDaliCubeTransitionFoldEffectNew " );
241 CubeTransitionEffect foldEffect;
243 DALI_TEST_CHECK( !foldEffect );
245 foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
247 DALI_TEST_CHECK( foldEffect );
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 );
255 gObjectCreatedCallBackCalled = false;
256 registry.ObjectCreatedSignal().Connect( &TestCallback );
258 CubeTransitionEffect foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
260 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
263 static void UtcDaliCubeTransitionEffectSetGetTransitionDuration()
265 ToolkitTestApplication application;
266 tet_infoline(" UtcDaliCubeTransitionEffectSetGetTransitionDuration ");
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 );
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 );
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 );
281 static void UtcDaliCubeTransitionEffectSetGetCubeDisplacement()
283 ToolkitTestApplication application;
284 tet_infoline(" UtcDaliCubeTransitionEffectSetGetTransitionDuration ");
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 );
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 );
294 //Cube displacement is not used in CubeTransitionFoldEffect
297 //Test common codes in base class
298 static void UtcDaliCubeTransitionEffectGetRoot()
300 ToolkitTestApplication application;
301 tet_infoline(" UtcDaliCubeTransitionEffectGetRoot ");
303 unsigned int totalNum = NUM_ROWS*NUM_COLUMNS;
305 CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
306 Actor rootActor = waveEffect.GetRoot();
308 // check that we have a total of NUM_ROWS*NUM_COLUMNS cubes;
309 DALI_TEST_CHECK( totalNum == rootActor.GetChildCount() );
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() );
317 static void UtcDaliCubeTransitionEffectIsTransiting()
319 ToolkitTestApplication application;
320 tet_infoline(" UtcDaliCubeTransitionEffectIsTransiting ");
322 ImageActor imageActor = CreateSolidColorImageActor(application, Color::BLUE,30,30);
324 CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
325 Actor rootActor = waveEffect.GetRoot();
326 Stage::GetCurrent().Add( rootActor );
328 waveEffect.SetTransitionDuration( TRANSITION_DURATION );
329 waveEffect.SetCubeDisplacement( CUBE_DISPLACEMENT );
330 DALI_TEST_CHECK( !waveEffect.IsTransiting() );
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() );
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() );
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() );
355 CubeTransitionEffect foldEffect = CubeTransitionFoldEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
356 foldEffect.SetTransitionDuration( TRANSITION_DURATION );
357 DALI_TEST_CHECK( !foldEffect.IsTransiting() );
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() );
370 //Test common codes in base class
371 static void UtcDaliCubeTransitionEffectSetCurrentImage()
373 ToolkitTestApplication application;
374 tet_infoline(" UtcDaliCubeTransitionEffectSetCurrentImage ");
376 ImageActor imageActor = CreateSolidColorImageActor(application, Color::BLUE,40,40) ;
378 CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
379 waveEffect.SetCurrentImage( imageActor );
381 // the current image content is set to the tiles facing the camera
382 ImageActor tile = ImageActor::DownCast( (waveEffect.GetRoot().GetChildAt(0).GetChildAt(0)));
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 );
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 );
396 //Test common codes in base class
397 static void UtcDaliCubeTransitionEffectSetTargetImage()
399 ToolkitTestApplication application;
400 tet_infoline(" UtcDaliCubeTransitionEffectSetTargetImage ");
402 ImageActor imageActor = CreateSolidColorImageActor(application, Color::BLUE,30,30);
404 CubeTransitionEffect waveEffect = CubeTransitionWaveEffect::New( NUM_ROWS, NUM_COLUMNS, VIEW_AREA_SIZE );
405 Actor rootActor = waveEffect.GetRoot();
406 Stage::GetCurrent().Add( rootActor );
408 waveEffect.SetCurrentImage( imageActor );
409 waveEffect.SetTargetImage( imageActor );
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)));
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 );
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 );
426 static void UtcDaliCubeTransitionWaveEffectStartTransition()
428 ToolkitTestApplication application;
429 tet_infoline(" UtcDaliCubeTransitionWaveEffectStartTransition ");
431 ImageActor imageActor = CreateSolidColorImageActor(application, Color::BLUE,30,30);
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);
440 waveEffect.SetCurrentImage( imageActor );
442 Vector4 fullBrightness = Vector4(1.f,1.f,1.f,1.f);
443 Vector4 halfBrightness = Vector4(0.5f, 0.5f, 0.5f, 1.f);
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 );
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 );
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 );
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 );
475 static void UtcDaliCubeTransitionCrossEffectStartTransition()
477 ToolkitTestApplication application;
478 tet_infoline(" UtcDaliCubeTransitionCrossEffectStartTransition ");
480 ImageActor imageActor = CreateSolidColorImageActor(application, Color::BLUE,30,30);
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);
491 Vector4 fullBrightness = Vector4(1.f,1.f,1.f,1.f);
492 Vector4 halfBrightness = Vector4(0.5f, 0.5f, 0.5f, 1.f);
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 );
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 );
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 );
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 );
529 static void UtcDaliCubeTransitionFoldEffectStartTransition()
531 ToolkitTestApplication application;
532 tet_infoline(" UtcDaliCubeTransitionFoldEffectStartTransition ");
534 ImageActor imageActor = CreateSolidColorImageActor(application, Color::BLUE,30,30);
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);
544 Vector4 fullBrightness = Vector4(1.f,1.f,1.f,1.f);
545 Vector4 halfBrightness = Vector4(0.5f, 0.5f, 0.5f, 1.f);
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 );
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 );
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 );
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 );
582 static void UtcDaliCubeTransitionEffectSignalTransitionCompleted()
584 ToolkitTestApplication application;
585 tet_infoline(" UtcDaliCubeTransitionEffectSignalTransitionCompleted ");
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);
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 );
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 );
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 );
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 );
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);
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);
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);
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);
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 );
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 );
670 static void UtcDaliCubeTransitionEffectPauseResumeTransition()
672 ToolkitTestApplication application;
673 tet_infoline(" UtcDaliCubeTransitionEffectPauseResumeTransition ");
675 ImageActor firstImageActor = CreateSolidColorImageActor(application, Color::RED,30,30);
676 ImageActor secondImageActor = CreateSolidColorImageActor(application, Color::GREEN,20,20);
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 );
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 );
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 );
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 );
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);
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);
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);
775 static void UtcDaliCubeTransitionWaveEffectStopTransition()
777 ToolkitTestApplication application;
778 tet_infoline(" UtcDaliCubeTransitionWaveEffectStopTransition ");
780 ImageActor firstImageActor = CreateSolidColorImageActor(application, Color::RED,30,30);
781 ImageActor secondImageActor = CreateSolidColorImageActor(application, Color::GREEN,20,20);
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 );
791 Vector4 fullBrightness = Vector4(1.f,1.f,1.f,1.f);
792 Vector4 halfBrightness = Vector4(0.5f, 0.5f, 0.5f, 1.f);
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 );
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 );
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 );
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 );
836 static void UtcDaliCubeTransitionCrossEffectStopTransition()
838 ToolkitTestApplication application;
839 tet_infoline(" UtcDaliCubeTransitionCrossEffectStopTransition ");
841 ImageActor firstImageActor = CreateSolidColorImageActor(application, Color::RED,30,30);
842 ImageActor secondImageActor = CreateSolidColorImageActor(application, Color::GREEN,20,20);
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);
853 Vector4 fullBrightness = Vector4(1.f,1.f,1.f,1.f);
854 Vector4 halfBrightness = Vector4(0.5f, 0.5f, 0.5f, 1.f);
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 );
866 DALI_TEST_CHECK( cube0.GetChildAt(0).GetCurrentColor() == halfBrightness );
867 DALI_TEST_CHECK( cube0.GetChildAt(1).GetCurrentColor() == fullBrightness );
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 );
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 );
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 );
903 static void UtcDaliCubeTransitionFoldEffectStopTransition()
905 ToolkitTestApplication application;
906 tet_infoline(" UtcDaliCubeTransitionFoldEffectStopTransition ");
908 ImageActor firstImageActor = CreateSolidColorImageActor(application, Color::RED,30,30);
909 ImageActor secondImageActor = CreateSolidColorImageActor(application, Color::GREEN,20,20);
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);
919 Vector4 fullBrightness = Vector4(1.f,1.f,1.f,1.f);
920 Vector4 halfBrightness = Vector4(0.5f, 0.5f, 0.5f, 1.f);
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 );
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 );
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 );
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 );