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