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