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.
18 #include <dali-test-suite-utils.h>
19 #include <dali/public-api/dali-core.h>
26 void layer_test_startup(void)
28 test_return_value = TET_UNDEF;
31 void layer_test_cleanup(void)
33 test_return_value = TET_PASS;
36 int UtcDaliLayerNew(void)
38 TestApplication application;
39 Layer layer = Layer::New();
41 DALI_TEST_CHECK(layer);
45 int UtcDaliLayerDownCast(void)
47 TestApplication application;
48 tet_infoline("Testing Dali::Layer::DownCast()");
50 Layer actor1 = Layer::New();
51 Actor anActor = Actor::New();
54 Actor child = anActor.GetChildAt(0);
55 Layer layer = DownCast<Layer>(child);
57 DALI_TEST_CHECK(layer);
61 int UtcDaliLayerDownCast2(void)
63 TestApplication application;
64 tet_infoline("Testing Dali::Layer::DownCast()");
66 Actor actor1 = Actor::New();
67 Actor anActor = Actor::New();
70 Actor child = anActor.GetChildAt(0);
71 Layer layer = DownCast<Layer>(child);
72 DALI_TEST_CHECK(!layer);
74 Actor unInitialzedActor;
75 layer = Layer::DownCast(unInitialzedActor);
76 DALI_TEST_CHECK(!layer);
80 int UtcDaliLayerMoveConstructor(void)
82 TestApplication application;
83 Layer layer = Layer::New();
84 DALI_TEST_CHECK(layer);
85 DALI_TEST_EQUALS(1, layer.GetBaseObject().ReferenceCount(), TEST_LOCATION);
86 DALI_TEST_EQUALS(0, layer.GetProperty<int>(Layer::Property::DEPTH), TEST_LOCATION);
88 application.GetScene().Add(layer);
89 DALI_TEST_EQUALS(2, layer.GetBaseObject().ReferenceCount(), TEST_LOCATION);
90 DALI_TEST_EQUALS(1, layer.GetProperty<int>(Layer::Property::DEPTH), TEST_LOCATION);
92 Layer move = std::move(layer);
93 DALI_TEST_CHECK(move);
94 DALI_TEST_EQUALS(2, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
95 DALI_TEST_EQUALS(1, move.GetProperty<int>(Layer::Property::DEPTH), TEST_LOCATION);
96 DALI_TEST_CHECK(!layer);
101 int UtcDaliLayerMoveAssignment(void)
103 TestApplication application;
104 Layer layer = Layer::New();
105 DALI_TEST_CHECK(layer);
106 DALI_TEST_EQUALS(1, layer.GetBaseObject().ReferenceCount(), TEST_LOCATION);
107 DALI_TEST_EQUALS(0, layer.GetProperty<int>(Layer::Property::DEPTH), TEST_LOCATION);
109 application.GetScene().Add(layer);
110 DALI_TEST_EQUALS(2, layer.GetBaseObject().ReferenceCount(), TEST_LOCATION);
111 DALI_TEST_EQUALS(1, layer.GetProperty<int>(Layer::Property::DEPTH), TEST_LOCATION);
114 move = std::move(layer);
115 DALI_TEST_CHECK(move);
116 DALI_TEST_EQUALS(2, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
117 DALI_TEST_EQUALS(1, move.GetProperty<int>(Layer::Property::DEPTH), TEST_LOCATION);
118 DALI_TEST_CHECK(!layer);
123 int UtcDaliLayerGetDepth(void)
125 tet_infoline("Testing Dali::Layer::GetDepth()");
126 TestApplication application;
127 Layer layer1 = Layer::New();
128 Layer layer2 = Layer::New();
130 // layers are not on scene
131 DALI_TEST_EQUALS(layer1.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
132 DALI_TEST_EQUALS(layer2.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
135 Layer root = application.GetScene().GetLayer(0);
136 DALI_TEST_EQUALS(root.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
138 application.GetScene().Add(layer1);
139 application.GetScene().Add(layer2);
141 DALI_TEST_EQUALS(root.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
142 DALI_TEST_EQUALS(layer1.GetProperty<int>(Layer::Property::DEPTH), 1u, TEST_LOCATION);
143 DALI_TEST_EQUALS(layer2.GetProperty<int>(Layer::Property::DEPTH), 2u, TEST_LOCATION);
147 int UtcDaliLayerRaise(void)
149 tet_infoline("Testing Dali::Layer::Raise()");
150 TestApplication application;
151 Layer layer1 = Layer::New();
152 Layer layer2 = Layer::New();
154 application.GetScene().Add(layer1);
155 application.GetScene().Add(layer2);
156 DALI_TEST_EQUALS(layer1.GetProperty<int>(Layer::Property::DEPTH), 1u, TEST_LOCATION);
159 DALI_TEST_EQUALS(layer1.GetProperty<int>(Layer::Property::DEPTH), 2u, TEST_LOCATION);
162 Layer root = application.GetScene().GetLayer(0);
163 DALI_TEST_EQUALS(root.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
165 DALI_TEST_EQUALS(root.GetProperty<int>(Layer::Property::DEPTH), 1u, TEST_LOCATION);
166 DALI_TEST_EQUALS(layer1.GetProperty<int>(Layer::Property::DEPTH), 2u, TEST_LOCATION);
167 DALI_TEST_EQUALS(layer2.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
171 int UtcDaliLayerLower(void)
173 tet_infoline("Testing Dali::Layer::Lower()");
174 TestApplication application;
175 Layer layer1 = Layer::New();
176 Layer layer2 = Layer::New();
178 application.GetScene().Add(layer1);
179 application.GetScene().Add(layer2);
180 DALI_TEST_EQUALS(layer2.GetProperty<int>(Layer::Property::DEPTH), 2u, TEST_LOCATION);
183 DALI_TEST_EQUALS(layer2.GetProperty<int>(Layer::Property::DEPTH), 1u, TEST_LOCATION);
186 Layer root = application.GetScene().GetLayer(0);
188 DALI_TEST_EQUALS(root.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
190 DALI_TEST_EQUALS(root.GetProperty<int>(Layer::Property::DEPTH), 1u, TEST_LOCATION);
191 DALI_TEST_EQUALS(layer2.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
195 int UtcDaliLayerRaiseToTop(void)
197 tet_infoline("Testing Dali::Layer::RaiseToTop()");
198 TestApplication application;
199 Layer layer1 = Layer::New();
200 Layer layer2 = Layer::New();
201 Layer layer3 = Layer::New();
203 application.GetScene().Add(layer1);
204 application.GetScene().Add(layer2);
205 application.GetScene().Add(layer3);
206 Layer root = application.GetScene().GetLayer(0);
208 DALI_TEST_EQUALS(root.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
209 DALI_TEST_EQUALS(layer1.GetProperty<int>(Layer::Property::DEPTH), 1u, TEST_LOCATION);
210 DALI_TEST_EQUALS(layer2.GetProperty<int>(Layer::Property::DEPTH), 2u, TEST_LOCATION);
211 DALI_TEST_EQUALS(layer3.GetProperty<int>(Layer::Property::DEPTH), 3u, TEST_LOCATION);
214 DALI_TEST_EQUALS(layer1.GetProperty<int>(Layer::Property::DEPTH), 3u, TEST_LOCATION);
217 DALI_TEST_EQUALS(root.GetProperty<int>(Layer::Property::DEPTH), 3u, TEST_LOCATION);
221 int UtcDaliLayerLowerToBottom(void)
223 tet_infoline("Testing Dali::Layer::LowerToBottom()");
224 TestApplication application;
225 Layer layer1 = Layer::New();
226 Layer layer2 = Layer::New();
227 Layer layer3 = Layer::New();
229 application.GetScene().Add(layer1);
230 application.GetScene().Add(layer2);
231 application.GetScene().Add(layer3);
233 DALI_TEST_EQUALS(layer1.GetProperty<int>(Layer::Property::DEPTH), 1u, TEST_LOCATION);
234 DALI_TEST_EQUALS(layer2.GetProperty<int>(Layer::Property::DEPTH), 2u, TEST_LOCATION);
235 DALI_TEST_EQUALS(layer3.GetProperty<int>(Layer::Property::DEPTH), 3u, TEST_LOCATION);
237 layer3.LowerToBottom();
238 DALI_TEST_EQUALS(layer3.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
242 int UtcDaliLayerSetClipping(void)
244 tet_infoline("Testing Dali::Layer::SetClipping()");
245 TestApplication application;
247 Layer layer = Layer::New();
248 DALI_TEST_CHECK(!layer.GetProperty<bool>(Layer::Property::CLIPPING_ENABLE));
250 layer.SetProperty(Layer::Property::CLIPPING_ENABLE, true);
251 DALI_TEST_CHECK(layer.GetProperty<bool>(Layer::Property::CLIPPING_ENABLE));
255 int UtcDaliLayerIsClipping(void)
257 tet_infoline("Testing Dali::Layer::IsClipping()");
258 TestApplication application;
260 Layer layer = Layer::New();
261 DALI_TEST_CHECK(!layer.GetProperty<bool>(Layer::Property::CLIPPING_ENABLE));
265 int UtcDaliLayerSetClippingBox(void)
267 tet_infoline("Testing Dali::Layer::SetClippingBox()");
268 TestApplication application;
270 ClippingBox testBox(5, 6, 77, 83);
272 Layer layer = Layer::New();
273 DALI_TEST_CHECK(layer.GetProperty<Rect<int32_t> >(Layer::Property::CLIPPING_BOX) != testBox);
274 layer.SetProperty(Layer::Property::CLIPPING_BOX, testBox);
275 DALI_TEST_CHECK(layer.GetProperty<Rect<int32_t> >(Layer::Property::CLIPPING_BOX) == testBox);
279 int UtcDaliLayerGetClippingBox(void)
281 tet_infoline("Testing Dali::Layer::GetClippingBox()");
282 TestApplication application;
284 Layer layer = Layer::New();
285 DALI_TEST_CHECK(layer.GetProperty<Rect<int32_t> >(Layer::Property::CLIPPING_BOX) == ClippingBox(0, 0, 0, 0));
289 static int gTestSortFunctionCalled;
291 static float TestSortFunction(const Vector3& /*position*/)
293 ++gTestSortFunctionCalled;
297 int UtcDaliLayerSetSortFunction(void)
299 tet_infoline("Testing Dali::Layer::SetSortFunction()");
300 TestApplication application;
302 // create two transparent actors so there is something to sort
303 Actor actor = CreateRenderableActor();
304 Actor actor2 = CreateRenderableActor();
305 actor.SetProperty(Actor::Property::SIZE, Vector2(1, 1));
306 actor.SetProperty(Actor::Property::COLOR, Vector4(1, 1, 1, 0.5f)); // 50% transparent
307 actor2.SetProperty(Actor::Property::SIZE, Vector2(1, 1));
308 actor2.SetProperty(Actor::Property::COLOR, Vector4(1, 1, 1, 0.5f)); // 50% transparent
311 application.GetScene().Add(actor);
312 application.GetScene().Add(actor2);
314 Layer root = application.GetScene().GetLayer(0);
315 gTestSortFunctionCalled = 0;
316 root.SetSortFunction(TestSortFunction);
318 // flush the queue and render once
319 application.SendNotification();
320 application.Render();
322 DALI_TEST_CHECK(gTestSortFunctionCalled > 0);
326 int UtcDaliLayerRaiseAbove(void)
328 tet_infoline("Testing Dali::Layer::RaiseAbove()");
329 TestApplication application;
330 Layer layer = Layer::New();
331 // try to raise above root layer
332 Layer root = application.GetScene().GetLayer(0);
333 layer.RaiseAbove(root);
334 // layer depth is zero as its not on scene
335 DALI_TEST_EQUALS(layer.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
337 application.GetScene().Add(layer);
338 layer.RaiseAbove(root);
339 DALI_TEST_EQUALS(layer.GetProperty<int>(Layer::Property::DEPTH), 1u, TEST_LOCATION);
340 root.RaiseAbove(layer);
341 DALI_TEST_EQUALS(layer.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
342 layer.RaiseAbove(layer);
343 DALI_TEST_EQUALS(layer.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
345 // make another layer on the scene
346 Layer layer2 = Layer::New();
347 application.GetScene().Add(layer2);
348 layer.RaiseAbove(layer2);
349 DALI_TEST_GREATER(layer.GetProperty<int>(Layer::Property::DEPTH), layer2.GetProperty<int>(Layer::Property::DEPTH), TEST_LOCATION);
350 layer2.RaiseAbove(layer);
351 DALI_TEST_GREATER(layer2.GetProperty<int>(Layer::Property::DEPTH), layer.GetProperty<int>(Layer::Property::DEPTH), TEST_LOCATION);
352 root.RaiseAbove(layer2);
353 DALI_TEST_GREATER(root.GetProperty<int>(Layer::Property::DEPTH), layer2.GetProperty<int>(Layer::Property::DEPTH), TEST_LOCATION);
357 int UtcDaliLayerRaiseBelow(void)
359 tet_infoline("Testing Dali::Layer::RaiseBelow()");
360 TestApplication application;
361 Layer layer = Layer::New();
362 // try to lower below root layer
363 Layer root = application.GetScene().GetLayer(0);
364 layer.LowerBelow(root);
365 // layer depth is zero as its not on scene
366 DALI_TEST_EQUALS(layer.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
368 application.GetScene().Add(layer);
369 DALI_TEST_EQUALS(layer.GetProperty<int>(Layer::Property::DEPTH), 1u, TEST_LOCATION);
370 layer.LowerBelow(root);
371 DALI_TEST_EQUALS(layer.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
372 root.LowerBelow(layer);
373 DALI_TEST_EQUALS(layer.GetProperty<int>(Layer::Property::DEPTH), 1u, TEST_LOCATION);
374 layer.LowerBelow(layer);
375 DALI_TEST_EQUALS(layer.GetProperty<int>(Layer::Property::DEPTH), 1u, TEST_LOCATION);
377 // make another layer on the scene
378 Layer layer2 = Layer::New();
379 application.GetScene().Add(layer2);
380 layer.LowerBelow(layer2);
381 DALI_TEST_GREATER(layer2.GetProperty<int>(Layer::Property::DEPTH), layer.GetProperty<int>(Layer::Property::DEPTH), TEST_LOCATION);
382 layer2.LowerBelow(layer);
383 DALI_TEST_GREATER(layer.GetProperty<int>(Layer::Property::DEPTH), layer2.GetProperty<int>(Layer::Property::DEPTH), TEST_LOCATION);
384 root.LowerBelow(layer2);
385 DALI_TEST_GREATER(layer2.GetProperty<int>(Layer::Property::DEPTH), root.GetProperty<int>(Layer::Property::DEPTH), TEST_LOCATION);
389 int UtcDaliLayerMoveAbove(void)
391 tet_infoline("Testing Dali::Layer::MoveAbove()");
392 TestApplication application;
393 Layer layer = Layer::New();
394 // try to raise above root layer
395 Layer root = application.GetScene().GetLayer(0);
396 layer.MoveAbove(root);
397 // layer depth is zero as its not on scene
398 DALI_TEST_EQUALS(layer.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
399 root.MoveAbove(layer);
400 // root depth is zero as layer is not on scene
401 DALI_TEST_EQUALS(layer.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
403 application.GetScene().Add(layer);
404 layer.MoveAbove(root);
405 DALI_TEST_EQUALS(layer.GetProperty<int>(Layer::Property::DEPTH), 1u, TEST_LOCATION);
406 DALI_TEST_EQUALS(root.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
407 root.MoveAbove(layer);
408 DALI_TEST_EQUALS(layer.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
409 DALI_TEST_EQUALS(root.GetProperty<int>(Layer::Property::DEPTH), 1u, TEST_LOCATION);
411 // make another layer on the scene
412 Layer layer2 = Layer::New();
413 application.GetScene().Add(layer2);
414 layer.MoveAbove(layer2);
415 DALI_TEST_EQUALS(layer.GetProperty<int>(Layer::Property::DEPTH), layer2.GetProperty<int>(Layer::Property::DEPTH) + 1u, TEST_LOCATION);
416 layer2.MoveAbove(root);
417 DALI_TEST_EQUALS(layer2.GetProperty<int>(Layer::Property::DEPTH), root.GetProperty<int>(Layer::Property::DEPTH) + 1u, TEST_LOCATION);
418 root.MoveAbove(layer);
419 DALI_TEST_EQUALS(root.GetProperty<int>(Layer::Property::DEPTH), layer.GetProperty<int>(Layer::Property::DEPTH) + 1u, TEST_LOCATION);
421 Layer layer3 = Layer::New();
422 application.GetScene().Add(layer3);
423 DALI_TEST_EQUALS(layer3.GetProperty<int>(Layer::Property::DEPTH), 3u, TEST_LOCATION);
424 root.MoveAbove(layer3);
425 DALI_TEST_EQUALS(root.GetProperty<int>(Layer::Property::DEPTH), 3u, TEST_LOCATION);
426 DALI_TEST_EQUALS(layer3.GetProperty<int>(Layer::Property::DEPTH), 2u, TEST_LOCATION);
427 DALI_TEST_EQUALS(application.GetScene().GetLayer(0).GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
428 layer3.MoveAbove(application.GetScene().GetLayer(0));
429 DALI_TEST_EQUALS(layer3.GetProperty<int>(Layer::Property::DEPTH), 1u, TEST_LOCATION);
433 int UtcDaliLayerMoveBelow(void)
435 tet_infoline("Testing Dali::Layer::MoveBelow()");
436 TestApplication application;
437 Layer layer = Layer::New();
438 // try to raise above root layer
439 Layer root = application.GetScene().GetLayer(0);
440 layer.MoveBelow(root);
441 // layer depth is zero as its not on scene
442 DALI_TEST_EQUALS(layer.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
443 root.MoveBelow(layer);
444 // root depth is zero as layer is not on scene
445 DALI_TEST_EQUALS(layer.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
447 application.GetScene().Add(layer);
448 layer.MoveBelow(root);
449 DALI_TEST_EQUALS(layer.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
450 DALI_TEST_EQUALS(root.GetProperty<int>(Layer::Property::DEPTH), 1u, TEST_LOCATION);
451 root.MoveBelow(layer);
452 DALI_TEST_EQUALS(layer.GetProperty<int>(Layer::Property::DEPTH), 1u, TEST_LOCATION);
453 DALI_TEST_EQUALS(root.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
455 // make another layer on the scene
456 Layer layer2 = Layer::New();
457 application.GetScene().Add(layer2);
458 layer.MoveBelow(layer2);
459 DALI_TEST_EQUALS(layer.GetProperty<int>(Layer::Property::DEPTH), layer2.GetProperty<int>(Layer::Property::DEPTH) - 1u, TEST_LOCATION);
460 layer2.MoveBelow(root);
461 DALI_TEST_EQUALS(layer2.GetProperty<int>(Layer::Property::DEPTH), root.GetProperty<int>(Layer::Property::DEPTH) - 1u, TEST_LOCATION);
462 root.MoveBelow(layer);
463 DALI_TEST_EQUALS(root.GetProperty<int>(Layer::Property::DEPTH), layer.GetProperty<int>(Layer::Property::DEPTH) - 1u, TEST_LOCATION);
465 Layer layer3 = Layer::New();
466 application.GetScene().Add(layer3);
467 DALI_TEST_EQUALS(layer3.GetProperty<int>(Layer::Property::DEPTH), 3u, TEST_LOCATION);
468 root.MoveBelow(layer3);
469 DALI_TEST_EQUALS(root.GetProperty<int>(Layer::Property::DEPTH), 2u, TEST_LOCATION);
470 DALI_TEST_EQUALS(layer3.GetProperty<int>(Layer::Property::DEPTH), 3u, TEST_LOCATION);
474 int UtcDaliLayerDefaultProperties(void)
476 TestApplication application;
477 tet_infoline("Testing Dali::Layer DefaultProperties");
479 Layer actor = Layer::New();
481 std::vector<Property::Index> indices;
482 indices.push_back(Layer::Property::CLIPPING_ENABLE);
483 indices.push_back(Layer::Property::CLIPPING_BOX);
484 indices.push_back(Layer::Property::BEHAVIOR);
485 indices.push_back(Layer::Property::DEPTH);
486 indices.push_back(Layer::Property::DEPTH_TEST);
487 indices.push_back(Layer::Property::CONSUMES_TOUCH);
488 indices.push_back(Layer::Property::CONSUMES_HOVER);
490 DALI_TEST_CHECK(actor.GetPropertyCount() == (Actor::New().GetPropertyCount() + indices.size()));
492 for(std::vector<Property::Index>::iterator iter = indices.begin(); iter != indices.end(); ++iter)
494 DALI_TEST_CHECK(*iter == actor.GetPropertyIndex(actor.GetPropertyName(*iter)));
495 DALI_TEST_CHECK(*iter == Layer::Property::DEPTH ? !actor.IsPropertyWritable(*iter) : actor.IsPropertyWritable(*iter));
496 DALI_TEST_CHECK(!actor.IsPropertyAnimatable(*iter));
497 DALI_TEST_CHECK(actor.GetPropertyType(*iter) == actor.GetPropertyType(*iter)); // just checking call succeeds
500 // set/get one of them
501 actor.SetProperty(Layer::Property::CLIPPING_BOX, ClippingBox(0, 0, 0, 0));
503 ClippingBox testBox(10, 20, 30, 40);
504 DALI_TEST_CHECK(actor.GetProperty<Rect<int32_t> >(Layer::Property::CLIPPING_BOX) != testBox);
506 actor.SetProperty(Layer::Property::CLIPPING_BOX, Property::Value(Rect<int>(testBox)));
508 DALI_TEST_CHECK(Property::RECTANGLE == actor.GetPropertyType(Layer::Property::CLIPPING_BOX));
510 Property::Value v = actor.GetProperty(Layer::Property::CLIPPING_BOX);
511 DALI_TEST_CHECK(v.Get<Rect<int> >() == testBox);
513 v = actor.GetCurrentProperty(Layer::Property::CLIPPING_BOX);
514 DALI_TEST_CHECK(v.Get<Rect<int> >() == testBox);
516 // set the same boundaries, but through a clipping box object
517 actor.SetProperty(Layer::Property::CLIPPING_BOX, testBox);
518 DALI_TEST_CHECK(actor.GetProperty<Rect<int32_t> >(Layer::Property::CLIPPING_BOX) == testBox);
520 actor.SetProperty(Layer::Property::BEHAVIOR, Property::Value(Layer::LAYER_UI));
521 DALI_TEST_CHECK(Property::INTEGER == actor.GetPropertyType(Layer::Property::BEHAVIOR));
523 Property::Value behavior = actor.GetProperty(Layer::Property::BEHAVIOR);
524 DALI_TEST_EQUALS(behavior.Get<Dali::Layer::Behavior>(), Layer::LAYER_UI, TEST_LOCATION);
526 behavior = actor.GetCurrentProperty(Layer::Property::BEHAVIOR);
527 DALI_TEST_EQUALS(behavior.Get<Dali::Layer::Behavior>(), Layer::LAYER_UI, TEST_LOCATION);
532 int UtcDaliLayerSetDepthTestDisabled(void)
534 TestApplication application;
535 tet_infoline("Testing Dali::Layer::SetDepthTestDisabled() ");
537 Layer actor = Layer::New();
538 // Note that Layer::Property::DEPTH_TEST does not depend on layer behavior,
539 // as 2D layers can still have depth tests performed on a per-renderer basis.
541 DALI_TEST_CHECK(!actor.GetProperty<bool>(Layer::Property::DEPTH_TEST));
543 // Check Set / Unset.
544 actor.SetProperty(Layer::Property::DEPTH_TEST, true);
545 DALI_TEST_CHECK(actor.GetProperty<bool>(Layer::Property::DEPTH_TEST));
546 actor.SetProperty(Layer::Property::DEPTH_TEST, false);
547 DALI_TEST_CHECK(!actor.GetProperty<bool>(Layer::Property::DEPTH_TEST));
552 int UtcDaliLayerCreateDestroy(void)
554 tet_infoline("Testing Dali::Layer::CreateDestroy() ");
555 Layer* layer = new Layer;
556 DALI_TEST_CHECK(layer);
561 int UtcDaliLayerPropertyIndices(void)
563 TestApplication application;
564 Actor basicActor = Actor::New();
565 Layer layer = Layer::New();
567 Property::IndexContainer indices;
568 layer.GetPropertyIndices(indices);
569 DALI_TEST_CHECK(indices.Size() > basicActor.GetPropertyCount());
570 DALI_TEST_EQUALS(indices.Size(), layer.GetPropertyCount(), TEST_LOCATION);
574 int UtcDaliLayerTouchConsumed(void)
576 TestApplication application;
577 Layer layer = Layer::New();
579 DALI_TEST_EQUALS(layer.GetProperty<bool>(Layer::Property::CONSUMES_TOUCH), false, TEST_LOCATION);
580 layer.SetProperty(Layer::Property::CONSUMES_TOUCH, true);
581 DALI_TEST_EQUALS(layer.GetProperty<bool>(Layer::Property::CONSUMES_TOUCH), true, TEST_LOCATION);
585 int UtcDaliLayerHoverConsumed(void)
587 TestApplication application;
588 Layer layer = Layer::New();
590 DALI_TEST_EQUALS(layer.GetProperty<bool>(Layer::Property::CONSUMES_HOVER), false, TEST_LOCATION);
591 layer.SetProperty(Layer::Property::CONSUMES_HOVER, true);
592 DALI_TEST_EQUALS(layer.GetProperty<bool>(Layer::Property::CONSUMES_HOVER), true, TEST_LOCATION);
596 int UtcDaliLayerClippingGLCalls(void)
598 TestApplication application;
599 const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
600 Integration::Scene scene(application.GetScene());
602 ClippingBox testBox(5, 6, 77, 83);
603 Layer layer = application.GetScene().GetRootLayer();
604 layer.SetProperty(Layer::Property::CLIPPING_ENABLE, true);
605 layer.SetProperty(Layer::Property::CLIPPING_BOX, testBox);
607 // Add at least one renderable actor so the GL calls are actually made
608 Texture img = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 1, 1);
609 Actor actor = CreateRenderableActor(img);
612 // flush the queue and render once
613 application.SendNotification();
614 application.Render();
616 DALI_TEST_EQUALS(testBox.x, glScissorParams.x, TEST_LOCATION);
617 DALI_TEST_EQUALS(testBox.y, (int)(scene.GetSize().height - glScissorParams.y - testBox.height), TEST_LOCATION); // GL Coordinates are from bottom left
618 DALI_TEST_EQUALS(testBox.width, glScissorParams.width, TEST_LOCATION);
619 DALI_TEST_EQUALS(testBox.height, glScissorParams.height, TEST_LOCATION);
623 int UtcDaliLayerBehaviour(void)
625 TestApplication application;
626 Layer layer = Layer::New();
628 DALI_TEST_EQUALS(layer.GetProperty<Layer::Behavior>(Layer::Property::BEHAVIOR), Dali::Layer::LAYER_UI, TEST_LOCATION);
629 layer.SetProperty(Layer::Property::BEHAVIOR, Dali::Layer::LAYER_3D);
630 DALI_TEST_EQUALS(layer.GetProperty<Layer::Behavior>(Layer::Property::BEHAVIOR), Dali::Layer::LAYER_3D, TEST_LOCATION);
634 Actor CreateActor(bool withAlpha)
636 Texture texture = Texture::New(TextureType::TEXTURE_2D, withAlpha ? Pixel::Format::RGBA8888 : Pixel::Format::RGB888, 1u, 1u);
638 Actor actor = CreateRenderableActor(texture);
639 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
640 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
645 int UtcDaliLayer3DSort(void)
647 tet_infoline("Testing LAYER_3D sort coverage test");
648 TestApplication application;
649 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
650 TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
652 application.GetScene().GetRootLayer().SetProperty(Layer::Property::BEHAVIOR, Layer::LAYER_3D);
655 Actor actor = CreateActor(false);
656 application.GetScene().Add(actor);
658 // Create child actors.
659 Actor child1 = CreateActor(true);
661 Actor child2 = CreateActor(false);
664 enabledDisableTrace.Reset();
665 enabledDisableTrace.Enable(true);
666 application.SendNotification();
667 application.Render();
668 enabledDisableTrace.Enable(false);
670 DALI_TEST_CHECK(enabledDisableTrace.FindMethodAndParams("Enable", "2929")); // 2929 is GL_DEPTH_TEST
675 int UtcDaliLayerLowerBelowNegative(void)
677 TestApplication application;
678 Dali::Layer instance;
682 instance.LowerBelow(arg1);
683 DALI_TEST_CHECK(false); // Should not get here
687 DALI_TEST_CHECK(true); // We expect an assert
692 int UtcDaliLayerRaiseAboveNegative(void)
694 TestApplication application;
695 Dali::Layer instance;
699 instance.RaiseAbove(arg1);
700 DALI_TEST_CHECK(false); // Should not get here
704 DALI_TEST_CHECK(true); // We expect an assert
709 int UtcDaliLayerRaiseToTopNegative(void)
711 TestApplication application;
712 Dali::Layer instance;
715 instance.RaiseToTop();
716 DALI_TEST_CHECK(false); // Should not get here
720 DALI_TEST_CHECK(true); // We expect an assert
725 int UtcDaliLayerLowerToBottomNegative(void)
727 TestApplication application;
728 Dali::Layer instance;
731 instance.LowerToBottom();
732 DALI_TEST_CHECK(false); // Should not get here
736 DALI_TEST_CHECK(true); // We expect an assert
741 int UtcDaliLayerSetSortFunctionNegative(void)
743 TestApplication application;
744 Dali::Layer instance;
747 Layer::SortFunctionType function = nullptr;
748 instance.SetSortFunction(function);
749 DALI_TEST_CHECK(false); // Should not get here
753 DALI_TEST_CHECK(true); // We expect an assert
758 int UtcDaliLayerLowerNegative(void)
760 TestApplication application;
761 Dali::Layer instance;
765 DALI_TEST_CHECK(false); // Should not get here
769 DALI_TEST_CHECK(true); // We expect an assert
774 int UtcDaliLayerRaiseNegative(void)
776 TestApplication application;
777 Dali::Layer instance;
781 DALI_TEST_CHECK(false); // Should not get here
785 DALI_TEST_CHECK(true); // We expect an assert
790 int UtcDaliLayerMoveAboveNegative(void)
792 TestApplication application;
793 Dali::Layer instance;
797 instance.MoveAbove(arg1);
798 DALI_TEST_CHECK(false); // Should not get here
802 DALI_TEST_CHECK(true); // We expect an assert
807 int UtcDaliLayerMoveBelowNegative(void)
809 TestApplication application;
810 Dali::Layer instance;
814 instance.MoveBelow(arg1);
815 DALI_TEST_CHECK(false); // Should not get here
819 DALI_TEST_CHECK(true); // We expect an assert