Remove deprecated APIs in Tizen 3.0
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Layer.cpp
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <iostream>
19
20 #include <stdlib.h>
21
22 #include <dali/public-api/dali-core.h>
23
24 #include <dali-test-suite-utils.h>
25
26 using namespace Dali;
27
28 void layer_test_startup(void)
29 {
30   test_return_value = TET_UNDEF;
31 }
32
33 void layer_test_cleanup(void)
34 {
35   test_return_value = TET_PASS;
36 }
37
38
39 int UtcDaliLayerNew(void)
40 {
41   TestApplication application;
42   Layer layer = Layer::New();
43
44   DALI_TEST_CHECK(layer);
45   END_TEST;
46 }
47
48 int UtcDaliLayerDownCast(void)
49 {
50   TestApplication application;
51   tet_infoline("Testing Dali::Layer::DownCast()");
52
53   Layer actor1 = Layer::New();
54   Actor anActor = Actor::New();
55   anActor.Add(actor1);
56
57   Actor child = anActor.GetChildAt(0);
58   Layer layer = DownCast< Layer >(child);
59
60   DALI_TEST_CHECK(layer);
61   END_TEST;
62 }
63
64 int UtcDaliLayerDownCast2(void)
65 {
66   TestApplication application;
67   tet_infoline("Testing Dali::Layer::DownCast()");
68
69   Actor actor1 = Actor::New();
70   Actor anActor = Actor::New();
71   anActor.Add(actor1);
72
73   Actor child = anActor.GetChildAt(0);
74   Layer layer = DownCast< Layer >(child);
75   DALI_TEST_CHECK(!layer);
76
77   Actor unInitialzedActor;
78   layer = Layer::DownCast( unInitialzedActor );
79   DALI_TEST_CHECK(!layer);
80   END_TEST;
81 }
82
83
84 int UtcDaliLayerGetDepth(void)
85 {
86   tet_infoline("Testing Dali::Layer::GetDepth()");
87   TestApplication application;
88   Layer layer1 = Layer::New();
89   Layer layer2 = Layer::New();
90
91   // layers are not on stage
92   DALI_TEST_EQUALS(layer1.GetDepth(), 0u, TEST_LOCATION);
93   DALI_TEST_EQUALS(layer2.GetDepth(), 0u, TEST_LOCATION);
94
95   // root depth is 0
96   Layer root = Stage::GetCurrent().GetLayer( 0 );
97   DALI_TEST_EQUALS(root.GetDepth(), 0u, TEST_LOCATION);
98
99   Stage::GetCurrent().Add(layer1);
100   Stage::GetCurrent().Add(layer2);
101
102   DALI_TEST_EQUALS(  root.GetDepth(), 0u, TEST_LOCATION);
103   DALI_TEST_EQUALS(layer1.GetDepth(), 1u, TEST_LOCATION);
104   DALI_TEST_EQUALS(layer2.GetDepth(), 2u, TEST_LOCATION);
105   END_TEST;
106 }
107
108 int UtcDaliLayerRaise(void)
109 {
110   tet_infoline("Testing Dali::Layer::Raise()");
111   TestApplication application;
112   Layer layer1 = Layer::New();
113   Layer layer2 = Layer::New();
114
115   Stage::GetCurrent().Add(layer1);
116   Stage::GetCurrent().Add(layer2);
117   DALI_TEST_EQUALS(layer1.GetDepth(), 1u, TEST_LOCATION);
118
119   layer1.Raise();
120   DALI_TEST_EQUALS(layer1.GetDepth(), 2u, TEST_LOCATION);
121
122   // get root
123   Layer root = Stage::GetCurrent().GetLayer( 0 );
124   DALI_TEST_EQUALS(  root.GetDepth(), 0u, TEST_LOCATION);
125   root.Raise();
126   DALI_TEST_EQUALS(  root.GetDepth(), 1u, TEST_LOCATION);
127   DALI_TEST_EQUALS(layer1.GetDepth(), 2u, TEST_LOCATION);
128   DALI_TEST_EQUALS(layer2.GetDepth(), 0u, TEST_LOCATION);
129   END_TEST;
130 }
131
132 int UtcDaliLayerLower(void)
133 {
134   tet_infoline("Testing Dali::Layer::Lower()");
135   TestApplication application;
136   Layer layer1 = Layer::New();
137   Layer layer2 = Layer::New();
138
139   Stage::GetCurrent().Add(layer1);
140   Stage::GetCurrent().Add(layer2);
141   DALI_TEST_EQUALS(layer2.GetDepth(), 2u, TEST_LOCATION);
142
143   layer2.Lower();
144   DALI_TEST_EQUALS(layer2.GetDepth(), 1u, TEST_LOCATION);
145
146   // get root
147   Layer root = Stage::GetCurrent().GetLayer( 0 );
148   root.Lower();
149   DALI_TEST_EQUALS(  root.GetDepth(), 0u, TEST_LOCATION);
150   layer2.Lower();
151   DALI_TEST_EQUALS(  root.GetDepth(), 1u, TEST_LOCATION);
152   DALI_TEST_EQUALS(layer2.GetDepth(), 0u, TEST_LOCATION);
153   END_TEST;
154 }
155
156 int UtcDaliLayerRaiseToTop(void)
157 {
158   tet_infoline("Testing Dali::Layer::RaiseToTop()");
159   TestApplication application;
160   Layer layer1 = Layer::New();
161   Layer layer2 = Layer::New();
162   Layer layer3 = Layer::New();
163
164   Stage::GetCurrent().Add(layer1);
165   Stage::GetCurrent().Add(layer2);
166   Stage::GetCurrent().Add(layer3);
167   Layer root = Stage::GetCurrent().GetLayer( 0 );
168
169   DALI_TEST_EQUALS(  root.GetDepth(), 0u, TEST_LOCATION);
170   DALI_TEST_EQUALS(layer1.GetDepth(), 1u, TEST_LOCATION);
171   DALI_TEST_EQUALS(layer2.GetDepth(), 2u, TEST_LOCATION);
172   DALI_TEST_EQUALS(layer3.GetDepth(), 3u, TEST_LOCATION);
173
174   layer1.RaiseToTop();
175   DALI_TEST_EQUALS(layer1.GetDepth(), 3u, TEST_LOCATION);
176
177   root.RaiseToTop();
178   DALI_TEST_EQUALS(  root.GetDepth(), 3u, TEST_LOCATION);
179   END_TEST;
180 }
181
182 int UtcDaliLayerLowerToBottom(void)
183 {
184   tet_infoline("Testing Dali::Layer::LowerToBottom()");
185   TestApplication application;
186   Layer layer1 = Layer::New();
187   Layer layer2 = Layer::New();
188   Layer layer3 = Layer::New();
189
190   Stage::GetCurrent().Add(layer1);
191   Stage::GetCurrent().Add(layer2);
192   Stage::GetCurrent().Add(layer3);
193
194   DALI_TEST_EQUALS(layer1.GetDepth(), 1u, TEST_LOCATION);
195   DALI_TEST_EQUALS(layer2.GetDepth(), 2u, TEST_LOCATION);
196   DALI_TEST_EQUALS(layer3.GetDepth(), 3u, TEST_LOCATION);
197
198   layer3.LowerToBottom();
199   DALI_TEST_EQUALS(layer3.GetDepth(), 0u, TEST_LOCATION);
200   END_TEST;
201 }
202
203 int UtcDaliLayerSetClipping(void)
204 {
205   tet_infoline("Testing Dali::Layer::SetClipping()");
206   TestApplication application;
207
208   Layer layer = Layer::New();
209   DALI_TEST_CHECK(!layer.IsClipping());
210
211   layer.SetClipping(true);
212   DALI_TEST_CHECK(layer.IsClipping());
213   END_TEST;
214 }
215
216 int UtcDaliLayerIsClipping(void)
217 {
218   tet_infoline("Testing Dali::Layer::IsClipping()");
219   TestApplication application;
220
221   Layer layer = Layer::New();
222   DALI_TEST_CHECK(!layer.IsClipping());
223   END_TEST;
224 }
225
226 int UtcDaliLayerSetClippingBox(void)
227 {
228   tet_infoline("Testing Dali::Layer::SetClippingBox()");
229   TestApplication application;
230
231   ClippingBox testBox(5,6, 77,83);
232
233   Layer layer = Layer::New();
234   DALI_TEST_CHECK(layer.GetClippingBox() != testBox);
235
236   layer.SetClippingBox(5,6, 77,83);
237   DALI_TEST_CHECK(layer.GetClippingBox() == testBox);
238   END_TEST;
239 }
240
241 int UtcDaliLayerGetClippingBox(void)
242 {
243   tet_infoline("Testing Dali::Layer::GetClippingBox()");
244   TestApplication application;
245
246   Layer layer = Layer::New();
247   DALI_TEST_CHECK(layer.GetClippingBox() == ClippingBox(0,0,0,0));
248   END_TEST;
249 }
250
251 static int gTestSortFunctionCalled;
252
253 static float TestSortFunction(const Vector3& /*position*/)
254 {
255   ++gTestSortFunctionCalled;
256   return 0.0f;
257 }
258
259 int UtcDaliLayerSetSortFunction(void)
260 {
261   tet_infoline("Testing Dali::Layer::SetSortFunction()");
262   TestApplication application;
263   BufferImage img = BufferImage::New( 1,1 );
264   // create two transparent actors so there is something to sort
265   Actor actor = CreateRenderableActor( img );
266   Actor actor2 = CreateRenderableActor( img );
267   actor.SetSize(1,1);
268   actor.SetColor( Vector4(1, 1, 1, 0.5f ) ); // 50% transparent
269   actor2.SetSize(1,1);
270   actor2.SetColor( Vector4(1, 1, 1, 0.5f ) ); // 50% transparent
271
272   // add to stage
273   Stage::GetCurrent().Add( actor );
274   Stage::GetCurrent().Add( actor2 );
275
276   Layer root = Stage::GetCurrent().GetLayer( 0 );
277   gTestSortFunctionCalled = 0;
278   root.SetSortFunction(TestSortFunction);
279
280   // flush the queue and render once
281   application.SendNotification();
282   application.Render();
283
284   DALI_TEST_CHECK( gTestSortFunctionCalled > 0 );
285   END_TEST;
286 }
287
288
289 int UtcDaliLayerRaiseAbove(void)
290 {
291   tet_infoline("Testing Dali::Layer::RaiseAbove()");
292   TestApplication application;
293   Layer layer = Layer::New();
294   // try to raise above root layer
295   Layer root = Stage::GetCurrent().GetLayer( 0 );
296   layer.RaiseAbove( root );
297   // layer depth is zero as its not on stage
298   DALI_TEST_EQUALS( layer.GetDepth(), 0u, TEST_LOCATION );
299   // add to stage
300   Stage::GetCurrent().Add( layer );
301   layer.RaiseAbove( root );
302   DALI_TEST_EQUALS( layer.GetDepth(), 1u, TEST_LOCATION );
303   root.RaiseAbove( layer );
304   DALI_TEST_EQUALS( layer.GetDepth(), 0u, TEST_LOCATION );
305   layer.RaiseAbove( layer );
306   DALI_TEST_EQUALS( layer.GetDepth(), 0u, TEST_LOCATION );
307
308   // make another layer on the stage
309   Layer layer2 = Layer::New();
310   Stage::GetCurrent().Add( layer2 );
311   layer.RaiseAbove( layer2 );
312   DALI_TEST_GREATER( layer.GetDepth(), layer2.GetDepth(), TEST_LOCATION );
313   layer2.RaiseAbove( layer );
314   DALI_TEST_GREATER( layer2.GetDepth(), layer.GetDepth(), TEST_LOCATION );
315   root.RaiseAbove( layer2 );
316   DALI_TEST_GREATER( root.GetDepth(), layer2.GetDepth(), TEST_LOCATION );
317   END_TEST;
318 }
319
320 int UtcDaliLayerRaiseBelow(void)
321 {
322   tet_infoline("Testing Dali::Layer::RaiseBelow()");
323   TestApplication application;
324   Layer layer = Layer::New();
325   // try to lower below root layer
326   Layer root = Stage::GetCurrent().GetLayer( 0 );
327   layer.LowerBelow( root );
328   // layer depth is zero as its not on stage
329   DALI_TEST_EQUALS( layer.GetDepth(), 0u, TEST_LOCATION );
330   // add to stage
331   Stage::GetCurrent().Add( layer );
332   DALI_TEST_EQUALS( layer.GetDepth(), 1u, TEST_LOCATION );
333   layer.LowerBelow( root );
334   DALI_TEST_EQUALS( layer.GetDepth(), 0u, TEST_LOCATION );
335   root.LowerBelow( layer );
336   DALI_TEST_EQUALS( layer.GetDepth(), 1u, TEST_LOCATION );
337   layer.LowerBelow( layer );
338   DALI_TEST_EQUALS( layer.GetDepth(), 1u, TEST_LOCATION );
339
340   // make another layer on the stage
341   Layer layer2 = Layer::New();
342   Stage::GetCurrent().Add( layer2 );
343   layer.LowerBelow( layer2 );
344   DALI_TEST_GREATER( layer2.GetDepth(), layer.GetDepth(), TEST_LOCATION );
345   layer2.LowerBelow( layer );
346   DALI_TEST_GREATER( layer.GetDepth(), layer2.GetDepth(), TEST_LOCATION );
347   root.LowerBelow( layer2 );
348   DALI_TEST_GREATER( layer2.GetDepth(), root.GetDepth(), TEST_LOCATION );
349   END_TEST;
350 }
351
352 int UtcDaliLayerMoveAbove(void)
353 {
354   tet_infoline("Testing Dali::Layer::MoveAbove()");
355   TestApplication application;
356   Layer layer = Layer::New();
357   // try to raise above root layer
358   Layer root = Stage::GetCurrent().GetLayer( 0 );
359   layer.MoveAbove( root );
360   // layer depth is zero as its not on stage
361   DALI_TEST_EQUALS( layer.GetDepth(), 0u, TEST_LOCATION );
362   root.MoveAbove( layer );
363   // root depth is zero as layer is not on stage
364   DALI_TEST_EQUALS( layer.GetDepth(), 0u, TEST_LOCATION );
365   // add to stage
366   Stage::GetCurrent().Add( layer );
367   layer.MoveAbove( root );
368   DALI_TEST_EQUALS( layer.GetDepth(), 1u, TEST_LOCATION );
369   DALI_TEST_EQUALS( root.GetDepth(), 0u, TEST_LOCATION );
370   root.MoveAbove( layer );
371   DALI_TEST_EQUALS( layer.GetDepth(), 0u, TEST_LOCATION );
372   DALI_TEST_EQUALS( root.GetDepth(), 1u, TEST_LOCATION );
373
374   // make another layer on the stage
375   Layer layer2 = Layer::New();
376   Stage::GetCurrent().Add( layer2 );
377   layer.MoveAbove( layer2 );
378   DALI_TEST_EQUALS( layer.GetDepth(), layer2.GetDepth() + 1u, TEST_LOCATION );
379   layer2.MoveAbove( root );
380   DALI_TEST_EQUALS( layer2.GetDepth(), root.GetDepth() + 1u, TEST_LOCATION );
381   root.MoveAbove( layer );
382   DALI_TEST_EQUALS( root.GetDepth(), layer.GetDepth() + 1u, TEST_LOCATION );
383
384   Layer layer3 = Layer::New();
385   Stage::GetCurrent().Add( layer3 );
386   DALI_TEST_EQUALS( layer3.GetDepth(), 3u, TEST_LOCATION );
387   root.MoveAbove( layer3 );
388   DALI_TEST_EQUALS( root.GetDepth(), 3u, TEST_LOCATION );
389   DALI_TEST_EQUALS( layer3.GetDepth(), 2u, TEST_LOCATION );
390   DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer( 0 ).GetDepth(), 0u, TEST_LOCATION );
391   layer3.MoveAbove( Stage::GetCurrent().GetLayer( 0 ) );
392   DALI_TEST_EQUALS( layer3.GetDepth(), 1u, TEST_LOCATION );
393   END_TEST;
394 }
395
396 int UtcDaliLayerMoveBelow(void)
397 {
398   tet_infoline("Testing Dali::Layer::MoveBelow()");
399   TestApplication application;
400   Layer layer = Layer::New();
401   // try to raise above root layer
402   Layer root = Stage::GetCurrent().GetLayer( 0 );
403   layer.MoveBelow( root );
404   // layer depth is zero as its not on stage
405   DALI_TEST_EQUALS( layer.GetDepth(), 0u, TEST_LOCATION );
406   root.MoveBelow( layer );
407   // root depth is zero as layer is not on stage
408   DALI_TEST_EQUALS( layer.GetDepth(), 0u, TEST_LOCATION );
409   // add to stage
410   Stage::GetCurrent().Add( layer );
411   layer.MoveBelow( root );
412   DALI_TEST_EQUALS( layer.GetDepth(), 0u, TEST_LOCATION );
413   DALI_TEST_EQUALS( root.GetDepth(), 1u, TEST_LOCATION );
414   root.MoveBelow( layer );
415   DALI_TEST_EQUALS( layer.GetDepth(), 1u, TEST_LOCATION );
416   DALI_TEST_EQUALS( root.GetDepth(), 0u, TEST_LOCATION );
417
418   // make another layer on the stage
419   Layer layer2 = Layer::New();
420   Stage::GetCurrent().Add( layer2 );
421   layer.MoveBelow( layer2 );
422   DALI_TEST_EQUALS( layer.GetDepth(), layer2.GetDepth() - 1u, TEST_LOCATION );
423   layer2.MoveBelow( root );
424   DALI_TEST_EQUALS( layer2.GetDepth(), root.GetDepth() - 1u, TEST_LOCATION );
425   root.MoveBelow( layer );
426   DALI_TEST_EQUALS( root.GetDepth(), layer.GetDepth() - 1u, TEST_LOCATION );
427
428   Layer layer3 = Layer::New();
429   Stage::GetCurrent().Add( layer3 );
430   DALI_TEST_EQUALS( layer3.GetDepth(), 3u, TEST_LOCATION );
431   root.MoveBelow( layer3 );
432   DALI_TEST_EQUALS( root.GetDepth(), 2u, TEST_LOCATION );
433   DALI_TEST_EQUALS( layer3.GetDepth(), 3u, TEST_LOCATION );
434   END_TEST;
435 }
436
437 int UtcDaliLayerDefaultProperties(void)
438 {
439   TestApplication application;
440   tet_infoline("Testing Dali::Layer DefaultProperties");
441
442   Layer actor = Layer::New();
443
444   std::vector<Property::Index> indices;
445   indices.push_back(Layer::Property::CLIPPING_ENABLE);
446   indices.push_back(Layer::Property::CLIPPING_BOX);
447   indices.push_back(Layer::Property::BEHAVIOR);
448
449   DALI_TEST_CHECK(actor.GetPropertyCount() == ( Actor::New().GetPropertyCount() + indices.size() ) );
450
451   for(std::vector<Property::Index>::iterator iter = indices.begin(); iter != indices.end(); ++iter)
452   {
453     DALI_TEST_CHECK( *iter == actor.GetPropertyIndex(actor.GetPropertyName(*iter)) );
454     DALI_TEST_CHECK( actor.IsPropertyWritable(*iter) );
455     DALI_TEST_CHECK( !actor.IsPropertyAnimatable(*iter) );
456     DALI_TEST_CHECK( actor.GetPropertyType(*iter) == actor.GetPropertyType(*iter) );  // just checking call succeeds
457   }
458
459   // set/get one of them
460   actor.SetClippingBox(0,0,0,0);
461
462   ClippingBox testBox(10,20,30,40);
463   DALI_TEST_CHECK(actor.GetClippingBox() != testBox);
464
465   actor.SetProperty(Layer::Property::CLIPPING_BOX, Property::Value(Rect<int>(testBox)));
466
467   DALI_TEST_CHECK(Property::RECTANGLE == actor.GetPropertyType(Layer::Property::CLIPPING_BOX));
468
469   Property::Value v = actor.GetProperty(Layer::Property::CLIPPING_BOX);
470   DALI_TEST_CHECK(v.Get<Rect<int> >() == testBox);
471
472   v = actor.GetCurrentProperty( Layer::Property::CLIPPING_BOX );
473   DALI_TEST_CHECK(v.Get<Rect<int> >() == testBox);
474
475   // set the same boundaries, but through a clipping box object
476   actor.SetClippingBox( testBox );
477   DALI_TEST_CHECK( actor.GetClippingBox() == testBox );
478
479   actor.SetProperty(Layer::Property::BEHAVIOR, Property::Value(Layer::LAYER_UI));
480   DALI_TEST_CHECK(Property::STRING == actor.GetPropertyType(Layer::Property::BEHAVIOR));
481
482   Property::Value behavior = actor.GetProperty(Layer::Property::BEHAVIOR);
483   DALI_TEST_EQUALS(behavior.Get<std::string>().c_str(), "LAYER_UI", TEST_LOCATION );
484
485   behavior = actor.GetCurrentProperty( Layer::Property::BEHAVIOR );
486   DALI_TEST_EQUALS(behavior.Get<std::string>().c_str(), "LAYER_UI", TEST_LOCATION );
487
488   END_TEST;
489 }
490
491 int UtcDaliLayerSetDepthTestDisabled(void)
492 {
493   TestApplication application;
494   tet_infoline("Testing Dali::Layer::SetDepthTestDisabled() ");
495
496   Layer actor = Layer::New();
497   // Note that IsDepthTestDisabled does not depend on layer behavior,
498   // as 2D layers can still have depth tests performed on a per-renderer basis.
499   // Check default.
500   DALI_TEST_CHECK( actor.IsDepthTestDisabled() );
501
502   // Check Set / Unset.
503   actor.SetDepthTestDisabled( false );
504   DALI_TEST_CHECK( !actor.IsDepthTestDisabled() );
505   actor.SetDepthTestDisabled( true );
506   DALI_TEST_CHECK( actor.IsDepthTestDisabled() );
507
508   END_TEST;
509 }
510
511 int UtcDaliLayerCreateDestroy(void)
512 {
513   tet_infoline("Testing Dali::Layer::CreateDestroy() ");
514   Layer* layer = new Layer;
515   DALI_TEST_CHECK( layer );
516   delete layer;
517   END_TEST;
518 }
519
520 int UtcDaliLayerPropertyIndices(void)
521 {
522   TestApplication application;
523   Actor basicActor = Actor::New();
524   Layer layer = Layer::New();
525
526   Property::IndexContainer indices;
527   layer.GetPropertyIndices( indices );
528   DALI_TEST_CHECK( indices.Size() > basicActor.GetPropertyCount() );
529   DALI_TEST_EQUALS( indices.Size(), layer.GetPropertyCount(), TEST_LOCATION );
530   END_TEST;
531 }
532
533 int UtcDaliLayerTouchConsumed(void)
534 {
535   TestApplication application;
536   Layer layer = Layer::New();
537
538   DALI_TEST_EQUALS( layer.IsTouchConsumed(), false, TEST_LOCATION );
539   layer.SetTouchConsumed( true );
540   DALI_TEST_EQUALS( layer.IsTouchConsumed(), true, TEST_LOCATION );
541   END_TEST;
542 }
543
544 int UtcDaliLayerHoverConsumed(void)
545 {
546   TestApplication application;
547   Layer layer = Layer::New();
548
549   DALI_TEST_EQUALS( layer.IsHoverConsumed(), false, TEST_LOCATION );
550   layer.SetHoverConsumed( true );
551   DALI_TEST_EQUALS( layer.IsHoverConsumed(), true, TEST_LOCATION );
552   END_TEST;
553 }
554
555 int UtcDaliLayerClippingGLCalls(void)
556 {
557   TestApplication application;
558   const TestGlAbstraction::ScissorParams& glScissorParams( application.GetGlAbstraction().GetScissorParams() );
559   Stage stage( Stage::GetCurrent() );
560
561   ClippingBox testBox( 5, 6, 77, 83 );
562   Layer layer = Stage::GetCurrent().GetRootLayer();
563   layer.SetClipping( true );
564   layer.SetClippingBox( testBox );
565
566   // Add at least one renderable actor so the GL calls are actually made
567   BufferImage img = BufferImage::New( 1,1 );
568   Actor actor = CreateRenderableActor( img );
569   stage.Add( actor );
570
571   // flush the queue and render once
572   application.SendNotification();
573   application.Render();
574
575   DALI_TEST_EQUALS( testBox.x, glScissorParams.x, TEST_LOCATION );
576   DALI_TEST_EQUALS( testBox.y, (int)(stage.GetSize().height - glScissorParams.y - testBox.height), TEST_LOCATION ); // GL Coordinates are from bottom left
577   DALI_TEST_EQUALS( testBox.width, glScissorParams.width, TEST_LOCATION );
578   DALI_TEST_EQUALS( testBox.height, glScissorParams.height, TEST_LOCATION );
579   END_TEST;
580 }
581
582 int UtcDaliLayerBehaviour(void)
583 {
584   TestApplication application;
585   Layer layer = Layer::New();
586
587   DALI_TEST_EQUALS( layer.GetBehavior(), Dali::Layer::LAYER_UI, TEST_LOCATION );
588   layer.SetBehavior( Dali::Layer::LAYER_3D );
589   DALI_TEST_EQUALS( layer.GetBehavior(), Dali::Layer::LAYER_3D, TEST_LOCATION );
590   END_TEST;
591 }
592
593 Actor CreateActor( bool withAlpha )
594 {
595   Dali::BufferImage bufferImage;
596
597   if( withAlpha )
598   {
599     bufferImage = Dali::BufferImage::WHITE();
600   }
601   else
602   {
603     bufferImage = BufferImage::New( 1u, 1u, Pixel::RGB888 );
604     PixelBuffer* pBuffer = bufferImage.GetBuffer();
605     if( pBuffer )
606     {
607       pBuffer[0] = pBuffer[1] = pBuffer[2] = 0xFF;
608     }
609   }
610
611   Actor actor = CreateRenderableActor( bufferImage );
612   actor.SetParentOrigin( ParentOrigin::CENTER );
613   actor.SetAnchorPoint( AnchorPoint::CENTER );
614
615   return actor;
616 }
617
618 int UtcDaliLayer3DSort(void)
619 {
620   tet_infoline( "Testing LAYER_3D sort coverage test" );
621   TestApplication application;
622   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
623   TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
624
625   Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_3D );
626
627   // Create an actor.
628   Actor actor = CreateActor( false );
629   Stage::GetCurrent().Add( actor );
630
631   // Create child actors.
632   Actor child1 = CreateActor( true );
633   actor.Add( child1 );
634   Actor child2 = CreateActor( false );
635   child1.Add( child2 );
636
637   enabledDisableTrace.Reset();
638   enabledDisableTrace.Enable( true );
639   application.SendNotification();
640   application.Render();
641   enabledDisableTrace.Enable( false );
642
643   DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2929" ) );  // 2929 is GL_DEPTH_TEST
644
645   END_TEST;
646 }