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);
84 int UtcDaliLayerGetDepth(void)
86 tet_infoline("Testing Dali::Layer::GetDepth()");
87 TestApplication application;
88 Layer layer1 = Layer::New();
89 Layer layer2 = Layer::New();
91 // layers are not on stage
92 DALI_TEST_EQUALS(layer1.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION);
93 DALI_TEST_EQUALS(layer2.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION);
96 Layer root = Stage::GetCurrent().GetLayer( 0 );
97 DALI_TEST_EQUALS(root.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION);
99 Stage::GetCurrent().Add(layer1);
100 Stage::GetCurrent().Add(layer2);
102 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION);
103 DALI_TEST_EQUALS(layer1.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION);
104 DALI_TEST_EQUALS(layer2.GetProperty< int >( Layer::Property::DEPTH ), 2u, TEST_LOCATION);
108 int UtcDaliLayerRaise(void)
110 tet_infoline("Testing Dali::Layer::Raise()");
111 TestApplication application;
112 Layer layer1 = Layer::New();
113 Layer layer2 = Layer::New();
115 Stage::GetCurrent().Add(layer1);
116 Stage::GetCurrent().Add(layer2);
117 DALI_TEST_EQUALS(layer1.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION);
120 DALI_TEST_EQUALS(layer1.GetProperty< int >( Layer::Property::DEPTH ), 2u, TEST_LOCATION);
123 Layer root = Stage::GetCurrent().GetLayer( 0 );
124 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION);
126 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION);
127 DALI_TEST_EQUALS(layer1.GetProperty< int >( Layer::Property::DEPTH ), 2u, TEST_LOCATION);
128 DALI_TEST_EQUALS(layer2.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION);
132 int UtcDaliLayerLower(void)
134 tet_infoline("Testing Dali::Layer::Lower()");
135 TestApplication application;
136 Layer layer1 = Layer::New();
137 Layer layer2 = Layer::New();
139 Stage::GetCurrent().Add(layer1);
140 Stage::GetCurrent().Add(layer2);
141 DALI_TEST_EQUALS(layer2.GetProperty< int >( Layer::Property::DEPTH ), 2u, TEST_LOCATION);
144 DALI_TEST_EQUALS(layer2.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION);
147 Layer root = Stage::GetCurrent().GetLayer( 0 );
149 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION);
151 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION);
152 DALI_TEST_EQUALS(layer2.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION);
156 int UtcDaliLayerRaiseToTop(void)
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();
164 Stage::GetCurrent().Add(layer1);
165 Stage::GetCurrent().Add(layer2);
166 Stage::GetCurrent().Add(layer3);
167 Layer root = Stage::GetCurrent().GetLayer( 0 );
169 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION);
170 DALI_TEST_EQUALS(layer1.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION);
171 DALI_TEST_EQUALS(layer2.GetProperty< int >( Layer::Property::DEPTH ), 2u, TEST_LOCATION);
172 DALI_TEST_EQUALS(layer3.GetProperty< int >( Layer::Property::DEPTH ), 3u, TEST_LOCATION);
175 DALI_TEST_EQUALS(layer1.GetProperty< int >( Layer::Property::DEPTH ), 3u, TEST_LOCATION);
178 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 3u, TEST_LOCATION);
182 int UtcDaliLayerLowerToBottom(void)
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();
190 Stage::GetCurrent().Add(layer1);
191 Stage::GetCurrent().Add(layer2);
192 Stage::GetCurrent().Add(layer3);
194 DALI_TEST_EQUALS(layer1.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION);
195 DALI_TEST_EQUALS(layer2.GetProperty< int >( Layer::Property::DEPTH ), 2u, TEST_LOCATION);
196 DALI_TEST_EQUALS(layer3.GetProperty< int >( Layer::Property::DEPTH ), 3u, TEST_LOCATION);
198 layer3.LowerToBottom();
199 DALI_TEST_EQUALS(layer3.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION);
203 int UtcDaliLayerSetClipping(void)
205 tet_infoline("Testing Dali::Layer::SetClipping()");
206 TestApplication application;
208 Layer layer = Layer::New();
209 DALI_TEST_CHECK( !layer.GetProperty< bool >( Layer::Property::CLIPPING_ENABLE ) );
211 layer.SetProperty( Layer::Property::CLIPPING_ENABLE, true );
212 DALI_TEST_CHECK( layer.GetProperty< bool >( Layer::Property::CLIPPING_ENABLE ) );
216 int UtcDaliLayerIsClipping(void)
218 tet_infoline("Testing Dali::Layer::IsClipping()");
219 TestApplication application;
221 Layer layer = Layer::New();
222 DALI_TEST_CHECK( !layer.GetProperty< bool >( Layer::Property::CLIPPING_ENABLE ) );
226 int UtcDaliLayerSetClippingBox(void)
228 tet_infoline("Testing Dali::Layer::SetClippingBox()");
229 TestApplication application;
231 ClippingBox testBox(5,6, 77,83);
233 Layer layer = Layer::New();
234 DALI_TEST_CHECK(layer.GetProperty< Rect<int32_t> >( Layer::Property::CLIPPING_BOX ) != testBox);
235 layer.SetProperty( Layer::Property::CLIPPING_BOX, testBox );
236 DALI_TEST_CHECK(layer.GetProperty< Rect<int32_t> >( Layer::Property::CLIPPING_BOX ) == testBox);
240 int UtcDaliLayerGetClippingBox(void)
242 tet_infoline("Testing Dali::Layer::GetClippingBox()");
243 TestApplication application;
245 Layer layer = Layer::New();
246 DALI_TEST_CHECK( layer.GetProperty< Rect<int32_t> >( Layer::Property::CLIPPING_BOX ) == ClippingBox(0,0,0,0) );
250 static int gTestSortFunctionCalled;
252 static float TestSortFunction(const Vector3& /*position*/)
254 ++gTestSortFunctionCalled;
258 int UtcDaliLayerSetSortFunction(void)
260 tet_infoline("Testing Dali::Layer::SetSortFunction()");
261 TestApplication application;
263 // create two transparent actors so there is something to sort
264 Actor actor = CreateRenderableActor();
265 Actor actor2 = CreateRenderableActor();
266 actor.SetProperty( Actor::Property::SIZE, Vector2( 1, 1 ) );
267 actor.SetProperty( Actor::Property::COLOR, Vector4(1, 1, 1, 0.5f ) ); // 50% transparent
268 actor2.SetProperty( Actor::Property::SIZE, Vector2( 1, 1 ) );
269 actor2.SetProperty( Actor::Property::COLOR, Vector4(1, 1, 1, 0.5f ) ); // 50% transparent
272 Stage::GetCurrent().Add( actor );
273 Stage::GetCurrent().Add( actor2 );
275 Layer root = Stage::GetCurrent().GetLayer( 0 );
276 gTestSortFunctionCalled = 0;
277 root.SetSortFunction(TestSortFunction);
279 // flush the queue and render once
280 application.SendNotification();
281 application.Render();
283 DALI_TEST_CHECK( gTestSortFunctionCalled > 0 );
288 int UtcDaliLayerRaiseAbove(void)
290 tet_infoline("Testing Dali::Layer::RaiseAbove()");
291 TestApplication application;
292 Layer layer = Layer::New();
293 // try to raise above root layer
294 Layer root = Stage::GetCurrent().GetLayer( 0 );
295 layer.RaiseAbove( root );
296 // layer depth is zero as its not on stage
297 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
299 Stage::GetCurrent().Add( layer );
300 layer.RaiseAbove( root );
301 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION );
302 root.RaiseAbove( layer );
303 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
304 layer.RaiseAbove( layer );
305 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
307 // make another layer on the stage
308 Layer layer2 = Layer::New();
309 Stage::GetCurrent().Add( layer2 );
310 layer.RaiseAbove( layer2 );
311 DALI_TEST_GREATER( layer.GetProperty< int >( Layer::Property::DEPTH ), layer2.GetProperty< int >( Layer::Property::DEPTH ), TEST_LOCATION );
312 layer2.RaiseAbove( layer );
313 DALI_TEST_GREATER( layer2.GetProperty< int >( Layer::Property::DEPTH ), layer.GetProperty< int >( Layer::Property::DEPTH ), TEST_LOCATION );
314 root.RaiseAbove( layer2 );
315 DALI_TEST_GREATER( root.GetProperty< int >( Layer::Property::DEPTH ), layer2.GetProperty< int >( Layer::Property::DEPTH ), TEST_LOCATION );
319 int UtcDaliLayerRaiseBelow(void)
321 tet_infoline("Testing Dali::Layer::RaiseBelow()");
322 TestApplication application;
323 Layer layer = Layer::New();
324 // try to lower below root layer
325 Layer root = Stage::GetCurrent().GetLayer( 0 );
326 layer.LowerBelow( root );
327 // layer depth is zero as its not on stage
328 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
330 Stage::GetCurrent().Add( layer );
331 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION );
332 layer.LowerBelow( root );
333 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
334 root.LowerBelow( layer );
335 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION );
336 layer.LowerBelow( layer );
337 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION );
339 // make another layer on the stage
340 Layer layer2 = Layer::New();
341 Stage::GetCurrent().Add( layer2 );
342 layer.LowerBelow( layer2 );
343 DALI_TEST_GREATER( layer2.GetProperty< int >( Layer::Property::DEPTH ), layer.GetProperty< int >( Layer::Property::DEPTH ), TEST_LOCATION );
344 layer2.LowerBelow( layer );
345 DALI_TEST_GREATER( layer.GetProperty< int >( Layer::Property::DEPTH ), layer2.GetProperty< int >( Layer::Property::DEPTH ), TEST_LOCATION );
346 root.LowerBelow( layer2 );
347 DALI_TEST_GREATER( layer2.GetProperty< int >( Layer::Property::DEPTH ), root.GetProperty< int >( Layer::Property::DEPTH ), TEST_LOCATION );
351 int UtcDaliLayerMoveAbove(void)
353 tet_infoline("Testing Dali::Layer::MoveAbove()");
354 TestApplication application;
355 Layer layer = Layer::New();
356 // try to raise above root layer
357 Layer root = Stage::GetCurrent().GetLayer( 0 );
358 layer.MoveAbove( root );
359 // layer depth is zero as its not on stage
360 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
361 root.MoveAbove( layer );
362 // root depth is zero as layer is not on stage
363 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
365 Stage::GetCurrent().Add( layer );
366 layer.MoveAbove( root );
367 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION );
368 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
369 root.MoveAbove( layer );
370 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
371 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION );
373 // make another layer on the stage
374 Layer layer2 = Layer::New();
375 Stage::GetCurrent().Add( layer2 );
376 layer.MoveAbove( layer2 );
377 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), layer2.GetProperty< int >( Layer::Property::DEPTH ) + 1u, TEST_LOCATION );
378 layer2.MoveAbove( root );
379 DALI_TEST_EQUALS( layer2.GetProperty< int >( Layer::Property::DEPTH ), root.GetProperty< int >( Layer::Property::DEPTH ) + 1u, TEST_LOCATION );
380 root.MoveAbove( layer );
381 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), layer.GetProperty< int >( Layer::Property::DEPTH ) + 1u, TEST_LOCATION );
383 Layer layer3 = Layer::New();
384 Stage::GetCurrent().Add( layer3 );
385 DALI_TEST_EQUALS( layer3.GetProperty< int >( Layer::Property::DEPTH ), 3u, TEST_LOCATION );
386 root.MoveAbove( layer3 );
387 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 3u, TEST_LOCATION );
388 DALI_TEST_EQUALS( layer3.GetProperty< int >( Layer::Property::DEPTH ), 2u, TEST_LOCATION );
389 DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer( 0 ).GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
390 layer3.MoveAbove( Stage::GetCurrent().GetLayer( 0 ) );
391 DALI_TEST_EQUALS( layer3.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION );
395 int UtcDaliLayerMoveBelow(void)
397 tet_infoline("Testing Dali::Layer::MoveBelow()");
398 TestApplication application;
399 Layer layer = Layer::New();
400 // try to raise above root layer
401 Layer root = Stage::GetCurrent().GetLayer( 0 );
402 layer.MoveBelow( root );
403 // layer depth is zero as its not on stage
404 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
405 root.MoveBelow( layer );
406 // root depth is zero as layer is not on stage
407 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
409 Stage::GetCurrent().Add( layer );
410 layer.MoveBelow( root );
411 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
412 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION );
413 root.MoveBelow( layer );
414 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), 1u, TEST_LOCATION );
415 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 0u, TEST_LOCATION );
417 // make another layer on the stage
418 Layer layer2 = Layer::New();
419 Stage::GetCurrent().Add( layer2 );
420 layer.MoveBelow( layer2 );
421 DALI_TEST_EQUALS( layer.GetProperty< int >( Layer::Property::DEPTH ), layer2.GetProperty< int >( Layer::Property::DEPTH ) - 1u, TEST_LOCATION );
422 layer2.MoveBelow( root );
423 DALI_TEST_EQUALS( layer2.GetProperty< int >( Layer::Property::DEPTH ), root.GetProperty< int >( Layer::Property::DEPTH ) - 1u, TEST_LOCATION );
424 root.MoveBelow( layer );
425 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), layer.GetProperty< int >( Layer::Property::DEPTH ) - 1u, TEST_LOCATION );
427 Layer layer3 = Layer::New();
428 Stage::GetCurrent().Add( layer3 );
429 DALI_TEST_EQUALS( layer3.GetProperty< int >( Layer::Property::DEPTH ), 3u, TEST_LOCATION );
430 root.MoveBelow( layer3 );
431 DALI_TEST_EQUALS( root.GetProperty< int >( Layer::Property::DEPTH ), 2u, TEST_LOCATION );
432 DALI_TEST_EQUALS( layer3.GetProperty< int >( Layer::Property::DEPTH ), 3u, TEST_LOCATION );
436 int UtcDaliLayerDefaultProperties(void)
438 TestApplication application;
439 tet_infoline("Testing Dali::Layer DefaultProperties");
441 Layer actor = Layer::New();
443 std::vector<Property::Index> indices;
444 indices.push_back(Layer::Property::CLIPPING_ENABLE);
445 indices.push_back(Layer::Property::CLIPPING_BOX);
446 indices.push_back(Layer::Property::BEHAVIOR);
447 indices.push_back(Layer::Property::DEPTH);
448 indices.push_back(Layer::Property::DEPTH_TEST);
449 indices.push_back(Layer::Property::CONSUMES_TOUCH);
450 indices.push_back(Layer::Property::CONSUMES_HOVER);
452 DALI_TEST_CHECK(actor.GetPropertyCount() == ( Actor::New().GetPropertyCount() + indices.size() ) );
454 for(std::vector<Property::Index>::iterator iter = indices.begin(); iter != indices.end(); ++iter)
456 DALI_TEST_CHECK( *iter == actor.GetPropertyIndex(actor.GetPropertyName(*iter)) );
457 DALI_TEST_CHECK( *iter == Layer::Property::DEPTH ? !actor.IsPropertyWritable(*iter) : actor.IsPropertyWritable(*iter) );
458 DALI_TEST_CHECK( !actor.IsPropertyAnimatable(*iter) );
459 DALI_TEST_CHECK( actor.GetPropertyType(*iter) == actor.GetPropertyType(*iter) ); // just checking call succeeds
462 // set/get one of them
463 actor.SetProperty( Layer::Property::CLIPPING_BOX, ClippingBox( 0, 0, 0, 0 ) );
465 ClippingBox testBox(10,20,30,40);
466 DALI_TEST_CHECK(actor.GetProperty< Rect<int32_t> >( Layer::Property::CLIPPING_BOX ) != testBox);
468 actor.SetProperty(Layer::Property::CLIPPING_BOX, Property::Value(Rect<int>(testBox)));
470 DALI_TEST_CHECK(Property::RECTANGLE == actor.GetPropertyType(Layer::Property::CLIPPING_BOX));
472 Property::Value v = actor.GetProperty(Layer::Property::CLIPPING_BOX);
473 DALI_TEST_CHECK(v.Get<Rect<int> >() == testBox);
475 v = actor.GetCurrentProperty( Layer::Property::CLIPPING_BOX );
476 DALI_TEST_CHECK(v.Get<Rect<int> >() == testBox);
478 // set the same boundaries, but through a clipping box object
479 actor.SetProperty( Layer::Property::CLIPPING_BOX, testBox );
480 DALI_TEST_CHECK( actor.GetProperty< Rect<int32_t> >( Layer::Property::CLIPPING_BOX ) == testBox );
482 actor.SetProperty(Layer::Property::BEHAVIOR, Property::Value(Layer::LAYER_UI));
483 DALI_TEST_CHECK(Property::INTEGER == actor.GetPropertyType(Layer::Property::BEHAVIOR));
485 Property::Value behavior = actor.GetProperty(Layer::Property::BEHAVIOR);
486 DALI_TEST_EQUALS( behavior.Get<Dali::Layer::Behavior>(), Layer::LAYER_UI, TEST_LOCATION );
488 behavior = actor.GetCurrentProperty( Layer::Property::BEHAVIOR );
489 DALI_TEST_EQUALS( behavior.Get<Dali::Layer::Behavior>(), Layer::LAYER_UI, TEST_LOCATION );
494 int UtcDaliLayerSetDepthTestDisabled(void)
496 TestApplication application;
497 tet_infoline("Testing Dali::Layer::SetDepthTestDisabled() ");
499 Layer actor = Layer::New();
500 // Note that Layer::Property::DEPTH_TEST does not depend on layer behavior,
501 // as 2D layers can still have depth tests performed on a per-renderer basis.
503 DALI_TEST_CHECK( !actor.GetProperty< bool >( Layer::Property::DEPTH_TEST ) );
505 // Check Set / Unset.
506 actor.SetProperty(Layer::Property::DEPTH_TEST, true );
507 DALI_TEST_CHECK( actor.GetProperty< bool >( Layer::Property::DEPTH_TEST ) );
508 actor.SetProperty(Layer::Property::DEPTH_TEST, false );
509 DALI_TEST_CHECK( !actor.GetProperty< bool >( Layer::Property::DEPTH_TEST ) );
514 int UtcDaliLayerCreateDestroy(void)
516 tet_infoline("Testing Dali::Layer::CreateDestroy() ");
517 Layer* layer = new Layer;
518 DALI_TEST_CHECK( layer );
523 int UtcDaliLayerPropertyIndices(void)
525 TestApplication application;
526 Actor basicActor = Actor::New();
527 Layer layer = Layer::New();
529 Property::IndexContainer indices;
530 layer.GetPropertyIndices( indices );
531 DALI_TEST_CHECK( indices.Size() > basicActor.GetPropertyCount() );
532 DALI_TEST_EQUALS( indices.Size(), layer.GetPropertyCount(), TEST_LOCATION );
536 int UtcDaliLayerTouchConsumed(void)
538 TestApplication application;
539 Layer layer = Layer::New();
541 DALI_TEST_EQUALS( layer.GetProperty< bool >( Layer::Property::CONSUMES_TOUCH ), false, TEST_LOCATION );
542 layer.SetProperty( Layer::Property::CONSUMES_TOUCH, true );
543 DALI_TEST_EQUALS( layer.GetProperty< bool >( Layer::Property::CONSUMES_TOUCH ), true, TEST_LOCATION );
547 int UtcDaliLayerHoverConsumed(void)
549 TestApplication application;
550 Layer layer = Layer::New();
552 DALI_TEST_EQUALS( layer.GetProperty< bool >( Layer::Property::CONSUMES_HOVER ), false, TEST_LOCATION );
553 layer.SetProperty( Layer::Property::CONSUMES_HOVER, true );
554 DALI_TEST_EQUALS( layer.GetProperty< bool >( Layer::Property::CONSUMES_HOVER ), true, TEST_LOCATION );
558 int UtcDaliLayerClippingGLCalls(void)
560 TestApplication application;
561 const TestGlAbstraction::ScissorParams& glScissorParams( application.GetGlAbstraction().GetScissorParams() );
562 Stage stage( Stage::GetCurrent() );
564 ClippingBox testBox( 5, 6, 77, 83 );
565 Layer layer = Stage::GetCurrent().GetRootLayer();
566 layer.SetProperty( Layer::Property::CLIPPING_ENABLE, true );
567 layer.SetProperty( Layer::Property::CLIPPING_BOX, testBox );
569 // Add at least one renderable actor so the GL calls are actually made
570 Texture img = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1 );
571 Actor actor = CreateRenderableActor( img );
574 // flush the queue and render once
575 application.SendNotification();
576 application.Render();
578 DALI_TEST_EQUALS( testBox.x, glScissorParams.x, TEST_LOCATION );
579 DALI_TEST_EQUALS( testBox.y, (int)(stage.GetSize().height - glScissorParams.y - testBox.height), TEST_LOCATION ); // GL Coordinates are from bottom left
580 DALI_TEST_EQUALS( testBox.width, glScissorParams.width, TEST_LOCATION );
581 DALI_TEST_EQUALS( testBox.height, glScissorParams.height, TEST_LOCATION );
585 int UtcDaliLayerBehaviour(void)
587 TestApplication application;
588 Layer layer = Layer::New();
590 DALI_TEST_EQUALS( layer.GetProperty<Layer::Behavior>( Layer::Property::BEHAVIOR ), Dali::Layer::LAYER_UI, TEST_LOCATION );
591 layer.SetProperty( Layer::Property::BEHAVIOR, Dali::Layer::LAYER_3D );
592 DALI_TEST_EQUALS( layer.GetProperty<Layer::Behavior>( Layer::Property::BEHAVIOR ), Dali::Layer::LAYER_3D, TEST_LOCATION );
596 Actor CreateActor( bool withAlpha )
598 Texture texture = Texture::New(TextureType::TEXTURE_2D, withAlpha ? Pixel::Format::RGBA8888 : Pixel::Format::RGB888, 1u, 1u );
600 Actor actor = CreateRenderableActor( texture );
601 actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
602 actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
607 int UtcDaliLayer3DSort(void)
609 tet_infoline( "Testing LAYER_3D sort coverage test" );
610 TestApplication application;
611 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
612 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
614 Stage::GetCurrent().GetRootLayer().SetProperty( Layer::Property::BEHAVIOR, Layer::LAYER_3D );
617 Actor actor = CreateActor( false );
618 Stage::GetCurrent().Add( actor );
620 // Create child actors.
621 Actor child1 = CreateActor( true );
623 Actor child2 = CreateActor( false );
624 child1.Add( child2 );
626 enabledDisableTrace.Reset();
627 enabledDisableTrace.Enable( true );
628 application.SendNotification();
629 application.Render();
630 enabledDisableTrace.Enable( false );
632 DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "2929" ) ); // 2929 is GL_DEPTH_TEST