2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali/public-api/dali-core.h>
24 #include <dali-test-suite-utils.h>
28 void layer_test_startup(void)
30 test_return_value = TET_UNDEF;
33 void layer_test_cleanup(void)
35 test_return_value = TET_PASS;
39 int UtcDaliLayerNew(void)
41 TestApplication application;
42 Layer layer = Layer::New();
44 DALI_TEST_CHECK(layer);
48 int UtcDaliLayerDownCast(void)
50 TestApplication application;
51 tet_infoline("Testing Dali::Layer::DownCast()");
53 Layer actor1 = Layer::New();
54 Actor anActor = Actor::New();
57 Actor child = anActor.GetChildAt(0);
58 Layer layer = DownCast< Layer >(child);
60 DALI_TEST_CHECK(layer);
64 int UtcDaliLayerDownCast2(void)
66 TestApplication application;
67 tet_infoline("Testing Dali::Layer::DownCast()");
69 Actor actor1 = Actor::New();
70 Actor anActor = Actor::New();
73 Actor child = anActor.GetChildAt(0);
74 Layer layer = DownCast< Layer >(child);
75 DALI_TEST_CHECK(!layer);
77 Actor unInitialzedActor;
78 layer = Layer::DownCast( unInitialzedActor );
79 DALI_TEST_CHECK(!layer);
83 int UtcDaliLayerMoveConstructor(void)
85 TestApplication application;
86 Layer layer = Layer::New();
87 DALI_TEST_CHECK( layer );
88 DALI_TEST_EQUALS( 1, layer.GetBaseObject().ReferenceCount(), TEST_LOCATION );
89 DALI_TEST_EQUALS( 0, layer.GetProperty< int >( Layer::Property::DEPTH ), TEST_LOCATION );
91 application.GetScene().Add( layer );
92 DALI_TEST_EQUALS( 2, layer.GetBaseObject().ReferenceCount(), TEST_LOCATION );
93 DALI_TEST_EQUALS( 1, layer.GetProperty< int >( Layer::Property::DEPTH ), TEST_LOCATION );
95 Layer move = std::move( layer );
96 DALI_TEST_CHECK( move );
97 DALI_TEST_EQUALS( 2, move.GetBaseObject().ReferenceCount(), TEST_LOCATION );
98 DALI_TEST_EQUALS( 1, move.GetProperty< int >( Layer::Property::DEPTH ), TEST_LOCATION );
99 DALI_TEST_CHECK( !layer );
104 int UtcDaliLayerMoveAssignment(void)
106 TestApplication application;
107 Layer layer = Layer::New();
108 DALI_TEST_CHECK( layer );
109 DALI_TEST_EQUALS( 1, layer.GetBaseObject().ReferenceCount(), TEST_LOCATION );
110 DALI_TEST_EQUALS( 0, layer.GetProperty< int >( Layer::Property::DEPTH ), TEST_LOCATION );
112 application.GetScene().Add( layer );
113 DALI_TEST_EQUALS( 2, layer.GetBaseObject().ReferenceCount(), TEST_LOCATION );
114 DALI_TEST_EQUALS( 1, layer.GetProperty< int >( Layer::Property::DEPTH ), TEST_LOCATION );
117 move = std::move( layer );
118 DALI_TEST_CHECK( move );
119 DALI_TEST_EQUALS( 2, move.GetBaseObject().ReferenceCount(), TEST_LOCATION );
120 DALI_TEST_EQUALS( 1, move.GetProperty< int >( Layer::Property::DEPTH ), TEST_LOCATION );
121 DALI_TEST_CHECK( !layer );
126 int UtcDaliLayerGetDepth(void)
128 tet_infoline("Testing Dali::Layer::GetDepth()");
129 TestApplication application;
130 Layer layer1 = Layer::New();
131 Layer layer2 = Layer::New();
133 // layers are not on scene
134 DALI_TEST_EQUALS(layer1.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION);
135 DALI_TEST_EQUALS(layer2.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION);
138 Layer root = application.GetScene().GetLayer( 0 );
139 DALI_TEST_EQUALS(root.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION);
141 application.GetScene().Add(layer1);
142 application.GetScene().Add(layer2);
144 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION);
145 DALI_TEST_EQUALS(layer1.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION);
146 DALI_TEST_EQUALS(layer2.GetProperty< int >( Layer::Property::DEPTH ), 2u, TEST_LOCATION);
150 int UtcDaliLayerRaise(void)
152 tet_infoline("Testing Dali::Layer::Raise()");
153 TestApplication application;
154 Layer layer1 = Layer::New();
155 Layer layer2 = Layer::New();
157 application.GetScene().Add(layer1);
158 application.GetScene().Add(layer2);
159 DALI_TEST_EQUALS(layer1.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION);
162 DALI_TEST_EQUALS(layer1.GetProperty< int >( Layer::Property::DEPTH ), 2u, TEST_LOCATION);
165 Layer root = application.GetScene().GetLayer( 0 );
166 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION);
168 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION);
169 DALI_TEST_EQUALS(layer1.GetProperty< int >( Layer::Property::DEPTH ), 2u, TEST_LOCATION);
170 DALI_TEST_EQUALS(layer2.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION);
174 int UtcDaliLayerLower(void)
176 tet_infoline("Testing Dali::Layer::Lower()");
177 TestApplication application;
178 Layer layer1 = Layer::New();
179 Layer layer2 = Layer::New();
181 application.GetScene().Add(layer1);
182 application.GetScene().Add(layer2);
183 DALI_TEST_EQUALS(layer2.GetProperty< int >( Layer::Property::DEPTH ), 2u, TEST_LOCATION);
186 DALI_TEST_EQUALS(layer2.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION);
189 Layer root = application.GetScene().GetLayer( 0 );
191 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION);
193 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION);
194 DALI_TEST_EQUALS(layer2.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION);
198 int UtcDaliLayerRaiseToTop(void)
200 tet_infoline("Testing Dali::Layer::RaiseToTop()");
201 TestApplication application;
202 Layer layer1 = Layer::New();
203 Layer layer2 = Layer::New();
204 Layer layer3 = Layer::New();
206 application.GetScene().Add(layer1);
207 application.GetScene().Add(layer2);
208 application.GetScene().Add(layer3);
209 Layer root = application.GetScene().GetLayer( 0 );
211 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION);
212 DALI_TEST_EQUALS(layer1.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION);
213 DALI_TEST_EQUALS(layer2.GetProperty< int >( Layer::Property::DEPTH ), 2u, TEST_LOCATION);
214 DALI_TEST_EQUALS(layer3.GetProperty< int >( Layer::Property::DEPTH ), 3u, TEST_LOCATION);
217 DALI_TEST_EQUALS(layer1.GetProperty< int >( Layer::Property::DEPTH ), 3u, TEST_LOCATION);
220 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 3u, TEST_LOCATION);
224 int UtcDaliLayerLowerToBottom(void)
226 tet_infoline("Testing Dali::Layer::LowerToBottom()");
227 TestApplication application;
228 Layer layer1 = Layer::New();
229 Layer layer2 = Layer::New();
230 Layer layer3 = Layer::New();
232 application.GetScene().Add(layer1);
233 application.GetScene().Add(layer2);
234 application.GetScene().Add(layer3);
236 DALI_TEST_EQUALS(layer1.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION);
237 DALI_TEST_EQUALS(layer2.GetProperty< int >( Layer::Property::DEPTH ), 2u, TEST_LOCATION);
238 DALI_TEST_EQUALS(layer3.GetProperty< int >( Layer::Property::DEPTH ), 3u, TEST_LOCATION);
240 layer3.LowerToBottom();
241 DALI_TEST_EQUALS(layer3.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION);
245 int UtcDaliLayerSetClipping(void)
247 tet_infoline("Testing Dali::Layer::SetClipping()");
248 TestApplication application;
250 Layer layer = Layer::New();
251 DALI_TEST_CHECK( !layer.GetProperty< bool >( Layer::Property::CLIPPING_ENABLE ) );
253 layer.SetProperty( Layer::Property::CLIPPING_ENABLE, true );
254 DALI_TEST_CHECK( layer.GetProperty< bool >( Layer::Property::CLIPPING_ENABLE ) );
258 int UtcDaliLayerIsClipping(void)
260 tet_infoline("Testing Dali::Layer::IsClipping()");
261 TestApplication application;
263 Layer layer = Layer::New();
264 DALI_TEST_CHECK( !layer.GetProperty< bool >( Layer::Property::CLIPPING_ENABLE ) );
268 int UtcDaliLayerSetClippingBox(void)
270 tet_infoline("Testing Dali::Layer::SetClippingBox()");
271 TestApplication application;
273 ClippingBox testBox(5,6, 77,83);
275 Layer layer = Layer::New();
276 DALI_TEST_CHECK(layer.GetProperty< Rect<int32_t> >( Layer::Property::CLIPPING_BOX ) != testBox);
277 layer.SetProperty( Layer::Property::CLIPPING_BOX, testBox );
278 DALI_TEST_CHECK(layer.GetProperty< Rect<int32_t> >( Layer::Property::CLIPPING_BOX ) == testBox);
282 int UtcDaliLayerGetClippingBox(void)
284 tet_infoline("Testing Dali::Layer::GetClippingBox()");
285 TestApplication application;
287 Layer layer = Layer::New();
288 DALI_TEST_CHECK( layer.GetProperty< Rect<int32_t> >( Layer::Property::CLIPPING_BOX ) == ClippingBox(0,0,0,0) );
292 static int gTestSortFunctionCalled;
294 static float TestSortFunction(const Vector3& /*position*/)
296 ++gTestSortFunctionCalled;
300 int UtcDaliLayerSetSortFunction(void)
302 tet_infoline("Testing Dali::Layer::SetSortFunction()");
303 TestApplication application;
305 // create two transparent actors so there is something to sort
306 Actor actor = CreateRenderableActor();
307 Actor actor2 = CreateRenderableActor();
308 actor.SetProperty( Actor::Property::SIZE, Vector2( 1, 1 ) );
309 actor.SetProperty( Actor::Property::COLOR, Vector4(1, 1, 1, 0.5f ) ); // 50% transparent
310 actor2.SetProperty( Actor::Property::SIZE, Vector2( 1, 1 ) );
311 actor2.SetProperty( Actor::Property::COLOR, Vector4(1, 1, 1, 0.5f ) ); // 50% transparent
314 application.GetScene().Add( actor );
315 application.GetScene().Add( actor2 );
317 Layer root = application.GetScene().GetLayer( 0 );
318 gTestSortFunctionCalled = 0;
319 root.SetSortFunction(TestSortFunction);
321 // flush the queue and render once
322 application.SendNotification();
323 application.Render();
325 DALI_TEST_CHECK( gTestSortFunctionCalled > 0 );
330 int UtcDaliLayerRaiseAbove(void)
332 tet_infoline("Testing Dali::Layer::RaiseAbove()");
333 TestApplication application;
334 Layer layer = Layer::New();
335 // try to raise above root layer
336 Layer root = application.GetScene().GetLayer( 0 );
337 layer.RaiseAbove( root );
338 // layer depth is zero as its not on scene
339 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
341 application.GetScene().Add( layer );
342 layer.RaiseAbove( root );
343 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION );
344 root.RaiseAbove( layer );
345 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
346 layer.RaiseAbove( layer );
347 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
349 // make another layer on the scene
350 Layer layer2 = Layer::New();
351 application.GetScene().Add( layer2 );
352 layer.RaiseAbove( layer2 );
353 DALI_TEST_GREATER( layer.GetProperty< int >( Layer::Property::DEPTH ), layer2.GetProperty< int >( Layer::Property::DEPTH ), TEST_LOCATION );
354 layer2.RaiseAbove( layer );
355 DALI_TEST_GREATER( layer2.GetProperty< int >( Layer::Property::DEPTH ), layer.GetProperty< int >( Layer::Property::DEPTH ), TEST_LOCATION );
356 root.RaiseAbove( layer2 );
357 DALI_TEST_GREATER( root.GetProperty< int >( Layer::Property::DEPTH ), layer2.GetProperty< int >( Layer::Property::DEPTH ), TEST_LOCATION );
361 int UtcDaliLayerRaiseBelow(void)
363 tet_infoline("Testing Dali::Layer::RaiseBelow()");
364 TestApplication application;
365 Layer layer = Layer::New();
366 // try to lower below root layer
367 Layer root = application.GetScene().GetLayer( 0 );
368 layer.LowerBelow( root );
369 // layer depth is zero as its not on scene
370 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
372 application.GetScene().Add( layer );
373 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION );
374 layer.LowerBelow( root );
375 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
376 root.LowerBelow( layer );
377 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION );
378 layer.LowerBelow( layer );
379 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION );
381 // make another layer on the scene
382 Layer layer2 = Layer::New();
383 application.GetScene().Add( layer2 );
384 layer.LowerBelow( layer2 );
385 DALI_TEST_GREATER( layer2.GetProperty< int >( Layer::Property::DEPTH ), layer.GetProperty< int >( Layer::Property::DEPTH ), TEST_LOCATION );
386 layer2.LowerBelow( layer );
387 DALI_TEST_GREATER( layer.GetProperty< int >( Layer::Property::DEPTH ), layer2.GetProperty< int >( Layer::Property::DEPTH ), TEST_LOCATION );
388 root.LowerBelow( layer2 );
389 DALI_TEST_GREATER( layer2.GetProperty< int >( Layer::Property::DEPTH ), root.GetProperty< int >( Layer::Property::DEPTH ), TEST_LOCATION );
393 int UtcDaliLayerMoveAbove(void)
395 tet_infoline("Testing Dali::Layer::MoveAbove()");
396 TestApplication application;
397 Layer layer = Layer::New();
398 // try to raise above root layer
399 Layer root = application.GetScene().GetLayer( 0 );
400 layer.MoveAbove( root );
401 // layer depth is zero as its not on scene
402 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
403 root.MoveAbove( layer );
404 // root depth is zero as layer is not on scene
405 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
407 application.GetScene().Add( layer );
408 layer.MoveAbove( root );
409 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION );
410 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
411 root.MoveAbove( layer );
412 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
413 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION );
415 // make another layer on the scene
416 Layer layer2 = Layer::New();
417 application.GetScene().Add( layer2 );
418 layer.MoveAbove( layer2 );
419 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), layer2.GetProperty< int >( Layer::Property::DEPTH ) + 1u, TEST_LOCATION );
420 layer2.MoveAbove( root );
421 DALI_TEST_EQUALS( layer2.GetProperty< int >( Layer::Property::DEPTH ), root.GetProperty< int >( Layer::Property::DEPTH ) + 1u, TEST_LOCATION );
422 root.MoveAbove( layer );
423 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), layer.GetProperty< int >( Layer::Property::DEPTH ) + 1u, TEST_LOCATION );
425 Layer layer3 = Layer::New();
426 application.GetScene().Add( layer3 );
427 DALI_TEST_EQUALS( layer3.GetProperty< int >( Layer::Property::DEPTH ), 3u, TEST_LOCATION );
428 root.MoveAbove( layer3 );
429 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 3u, TEST_LOCATION );
430 DALI_TEST_EQUALS( layer3.GetProperty< int >( Layer::Property::DEPTH ), 2u, TEST_LOCATION );
431 DALI_TEST_EQUALS( application.GetScene().GetLayer( 0 ).GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
432 layer3.MoveAbove( application.GetScene().GetLayer( 0 ) );
433 DALI_TEST_EQUALS( layer3.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION );
437 int UtcDaliLayerMoveBelow(void)
439 tet_infoline("Testing Dali::Layer::MoveBelow()");
440 TestApplication application;
441 Layer layer = Layer::New();
442 // try to raise above root layer
443 Layer root = application.GetScene().GetLayer( 0 );
444 layer.MoveBelow( root );
445 // layer depth is zero as its not on scene
446 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
447 root.MoveBelow( layer );
448 // root depth is zero as layer is not on scene
449 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
451 application.GetScene().Add( layer );
452 layer.MoveBelow( root );
453 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
454 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION );
455 root.MoveBelow( layer );
456 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION );
457 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
459 // make another layer on the scene
460 Layer layer2 = Layer::New();
461 application.GetScene().Add( layer2 );
462 layer.MoveBelow( layer2 );
463 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), layer2.GetProperty< int >( Layer::Property::DEPTH ) - 1u, TEST_LOCATION );
464 layer2.MoveBelow( root );
465 DALI_TEST_EQUALS( layer2.GetProperty< int >( Layer::Property::DEPTH ), root.GetProperty< int >( Layer::Property::DEPTH ) - 1u, TEST_LOCATION );
466 root.MoveBelow( layer );
467 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), layer.GetProperty< int >( Layer::Property::DEPTH ) - 1u, TEST_LOCATION );
469 Layer layer3 = Layer::New();
470 application.GetScene().Add( layer3 );
471 DALI_TEST_EQUALS( layer3.GetProperty< int >( Layer::Property::DEPTH ), 3u, TEST_LOCATION );
472 root.MoveBelow( layer3 );
473 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 2u, TEST_LOCATION );
474 DALI_TEST_EQUALS( layer3.GetProperty< int >( Layer::Property::DEPTH ), 3u, TEST_LOCATION );
478 int UtcDaliLayerDefaultProperties(void)
480 TestApplication application;
481 tet_infoline("Testing Dali::Layer DefaultProperties");
483 Layer actor = Layer::New();
485 std::vector<Property::Index> indices;
486 indices.push_back(Layer::Property::CLIPPING_ENABLE);
487 indices.push_back(Layer::Property::CLIPPING_BOX);
488 indices.push_back(Layer::Property::BEHAVIOR);
489 indices.push_back(Layer::Property::DEPTH);
490 indices.push_back(Layer::Property::DEPTH_TEST);
491 indices.push_back(Layer::Property::CONSUMES_TOUCH);
492 indices.push_back(Layer::Property::CONSUMES_HOVER);
494 DALI_TEST_CHECK(actor.GetPropertyCount() == ( Actor::New().GetPropertyCount() + indices.size() ) );
496 for(std::vector<Property::Index>::iterator iter = indices.begin(); iter != indices.end(); ++iter)
498 DALI_TEST_CHECK( *iter == actor.GetPropertyIndex(actor.GetPropertyName(*iter)) );
499 DALI_TEST_CHECK( *iter == Layer::Property::DEPTH ? !actor.IsPropertyWritable(*iter) : actor.IsPropertyWritable(*iter) );
500 DALI_TEST_CHECK( !actor.IsPropertyAnimatable(*iter) );
501 DALI_TEST_CHECK( actor.GetPropertyType(*iter) == actor.GetPropertyType(*iter) ); // just checking call succeeds
504 // set/get one of them
505 actor.SetProperty( Layer::Property::CLIPPING_BOX, ClippingBox( 0, 0, 0, 0 ) );
507 ClippingBox testBox(10,20,30,40);
508 DALI_TEST_CHECK(actor.GetProperty< Rect<int32_t> >( Layer::Property::CLIPPING_BOX ) != testBox);
510 actor.SetProperty(Layer::Property::CLIPPING_BOX, Property::Value(Rect<int>(testBox)));
512 DALI_TEST_CHECK(Property::RECTANGLE == actor.GetPropertyType(Layer::Property::CLIPPING_BOX));
514 Property::Value v = actor.GetProperty(Layer::Property::CLIPPING_BOX);
515 DALI_TEST_CHECK(v.Get<Rect<int> >() == testBox);
517 v = actor.GetCurrentProperty( Layer::Property::CLIPPING_BOX );
518 DALI_TEST_CHECK(v.Get<Rect<int> >() == testBox);
520 // set the same boundaries, but through a clipping box object
521 actor.SetProperty( Layer::Property::CLIPPING_BOX, testBox );
522 DALI_TEST_CHECK( actor.GetProperty< Rect<int32_t> >( Layer::Property::CLIPPING_BOX ) == testBox );
524 actor.SetProperty(Layer::Property::BEHAVIOR, Property::Value(Layer::LAYER_UI));
525 DALI_TEST_CHECK(Property::INTEGER == actor.GetPropertyType(Layer::Property::BEHAVIOR));
527 Property::Value behavior = actor.GetProperty(Layer::Property::BEHAVIOR);
528 DALI_TEST_EQUALS( behavior.Get<Dali::Layer::Behavior>(), Layer::LAYER_UI, TEST_LOCATION );
530 behavior = actor.GetCurrentProperty( Layer::Property::BEHAVIOR );
531 DALI_TEST_EQUALS( behavior.Get<Dali::Layer::Behavior>(), Layer::LAYER_UI, TEST_LOCATION );
536 int UtcDaliLayerSetDepthTestDisabled(void)
538 TestApplication application;
539 tet_infoline("Testing Dali::Layer::SetDepthTestDisabled() ");
541 Layer actor = Layer::New();
542 // Note that Layer::Property::DEPTH_TEST does not depend on layer behavior,
543 // as 2D layers can still have depth tests performed on a per-renderer basis.
545 DALI_TEST_CHECK( !actor.GetProperty< bool >( Layer::Property::DEPTH_TEST ) );
547 // Check Set / Unset.
548 actor.SetProperty(Layer::Property::DEPTH_TEST, true );
549 DALI_TEST_CHECK( actor.GetProperty< bool >( Layer::Property::DEPTH_TEST ) );
550 actor.SetProperty(Layer::Property::DEPTH_TEST, false );
551 DALI_TEST_CHECK( !actor.GetProperty< bool >( Layer::Property::DEPTH_TEST ) );
556 int UtcDaliLayerCreateDestroy(void)
558 tet_infoline("Testing Dali::Layer::CreateDestroy() ");
559 Layer* layer = new Layer;
560 DALI_TEST_CHECK( layer );
565 int UtcDaliLayerPropertyIndices(void)
567 TestApplication application;
568 Actor basicActor = Actor::New();
569 Layer layer = Layer::New();
571 Property::IndexContainer indices;
572 layer.GetPropertyIndices( indices );
573 DALI_TEST_CHECK( indices.Size() > basicActor.GetPropertyCount() );
574 DALI_TEST_EQUALS( indices.Size(), layer.GetPropertyCount(), TEST_LOCATION );
578 int UtcDaliLayerTouchConsumed(void)
580 TestApplication application;
581 Layer layer = Layer::New();
583 DALI_TEST_EQUALS( layer.GetProperty< bool >( Layer::Property::CONSUMES_TOUCH ), false, TEST_LOCATION );
584 layer.SetProperty( Layer::Property::CONSUMES_TOUCH, true );
585 DALI_TEST_EQUALS( layer.GetProperty< bool >( Layer::Property::CONSUMES_TOUCH ), true, TEST_LOCATION );
589 int UtcDaliLayerHoverConsumed(void)
591 TestApplication application;
592 Layer layer = Layer::New();
594 DALI_TEST_EQUALS( layer.GetProperty< bool >( Layer::Property::CONSUMES_HOVER ), false, TEST_LOCATION );
595 layer.SetProperty( Layer::Property::CONSUMES_HOVER, true );
596 DALI_TEST_EQUALS( layer.GetProperty< bool >( Layer::Property::CONSUMES_HOVER ), true, TEST_LOCATION );
600 int UtcDaliLayerClippingGLCalls(void)
602 TestApplication application;
603 const TestGlAbstraction::ScissorParams& glScissorParams( application.GetGlAbstraction().GetScissorParams() );
604 Integration::Scene scene( application.GetScene() );
606 ClippingBox testBox( 5, 6, 77, 83 );
607 Layer layer = application.GetScene().GetRootLayer();
608 layer.SetProperty( Layer::Property::CLIPPING_ENABLE, true );
609 layer.SetProperty( Layer::Property::CLIPPING_BOX, testBox );
611 // Add at least one renderable actor so the GL calls are actually made
612 Texture img = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1 );
613 Actor actor = CreateRenderableActor( img );
616 // flush the queue and render once
617 application.SendNotification();
618 application.Render();
620 DALI_TEST_EQUALS( testBox.x, glScissorParams.x, TEST_LOCATION );
621 DALI_TEST_EQUALS( testBox.y, (int)(scene.GetSize().height - glScissorParams.y - testBox.height), TEST_LOCATION ); // GL Coordinates are from bottom left
622 DALI_TEST_EQUALS( testBox.width, glScissorParams.width, TEST_LOCATION );
623 DALI_TEST_EQUALS( testBox.height, glScissorParams.height, TEST_LOCATION );
627 int UtcDaliLayerBehaviour(void)
629 TestApplication application;
630 Layer layer = Layer::New();
632 DALI_TEST_EQUALS( layer.GetProperty<Layer::Behavior>( Layer::Property::BEHAVIOR ), Dali::Layer::LAYER_UI, TEST_LOCATION );
633 layer.SetProperty( Layer::Property::BEHAVIOR, Dali::Layer::LAYER_3D );
634 DALI_TEST_EQUALS( layer.GetProperty<Layer::Behavior>( Layer::Property::BEHAVIOR ), Dali::Layer::LAYER_3D, TEST_LOCATION );
638 Actor CreateActor( bool withAlpha )
640 Texture texture = Texture::New(TextureType::TEXTURE_2D, withAlpha ? Pixel::Format::RGBA8888 : Pixel::Format::RGB888, 1u, 1u );
642 Actor actor = CreateRenderableActor( texture );
643 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
644 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
649 int UtcDaliLayer3DSort(void)
651 tet_infoline( "Testing LAYER_3D sort coverage test" );
652 TestApplication application;
653 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
654 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
656 application.GetScene().GetRootLayer().SetProperty( Layer::Property::BEHAVIOR, Layer::LAYER_3D );
659 Actor actor = CreateActor( false );
660 application.GetScene().Add( actor );
662 // Create child actors.
663 Actor child1 = CreateActor( true );
665 Actor child2 = CreateActor( false );
666 child1.Add( child2 );
668 enabledDisableTrace.Reset();
669 enabledDisableTrace.Enable( true );
670 application.SendNotification();
671 application.Render();
672 enabledDisableTrace.Enable( false );
674 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2929" ) ); // 2929 is GL_DEPTH_TEST