DirectRendering:
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-DrawableActor.cpp
1 /*
2  * Copyright (c) 2022 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 <dali-test-suite-utils.h>
19 #include <dali/public-api/actors/drawable-actor.h>
20
21 struct DrawableObject
22 {
23   bool Render(const RenderCallbackInput& inputData)
24   {
25     // Store the size of rendered area
26     size = inputData.size;
27
28     return false;
29   }
30
31   Size size;
32 };
33
34 int UtcDaliDrawableActor1P(void)
35 {
36   tet_infoline("Testing DrawableActor");
37   TestApplication application;
38
39   DrawableObject drawable{};
40
41   auto callback = RenderCallback::New<DrawableObject>(&drawable, &DrawableObject::Render);
42
43   DrawableActor drawableActor = DrawableActor::New(*callback);
44   application.GetScene().Add(drawableActor);
45
46   drawableActor.SetProperty(Actor::Property::SIZE, Vector2(100, 100));
47
48   // flush the queue and render once
49   application.SendNotification();
50   application.Render();
51
52   // Check the size (whether callback has been called)
53   auto size(drawable.size);
54   DALI_TEST_EQUALS(drawable.size, Size(100, 100), TEST_LOCATION);
55
56   END_TEST;
57 }