Formatting automated-tests
[platform/core/uifw/dali-core.git] / automated-tests / src / dali-internal / utc-Dali-Internal-Core.cpp
1 /*
2  * Copyright (c) 2020 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/dali-core.h>
20 #include <stdlib.h>
21
22 #include <iostream>
23
24 // Internal headers are allowed here
25
26 using namespace Dali;
27
28 void utc_dali_internal_core_startup()
29 {
30   test_return_value = TET_UNDEF;
31 }
32
33 void utc_dali_internal_core_cleanup()
34 {
35   test_return_value = TET_PASS;
36 }
37
38 namespace
39 {
40 class RelayoutSignalHandler : public Dali::ConnectionTracker
41 {
42 public:
43   RelayoutSignalHandler(TestApplication& application)
44   : mApplication(application),
45     mSignalCalled(false)
46   {
47   }
48
49   // callback to be connected to RelayoutSignal
50   void RelayoutCallback(Actor actor)
51   {
52     tet_infoline("RelayoutCallback is called");
53
54     mSignalCalled = true;
55
56     mApplication.SendNotification();
57   }
58
59   TestApplication& mApplication;
60   bool             mSignalCalled;
61 };
62
63 } // anonymous namespace
64
65 int UtcDaliCoreProcessEvents(void)
66 {
67   TestApplication application;
68   tet_infoline("Testing Dali::Integration::Core::ProcessEvents");
69
70   Vector3 size(100.0f, 100.0f, 0.0f);
71   Vector3 position(100.0f, 100.0f, 0.0f);
72
73   Actor actor = Actor::New();
74   actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
75   actor.SetProperty(Actor::Property::SIZE, size);
76   actor.SetProperty(Actor::Property::POSITION, position);
77   application.GetScene().Add(actor);
78
79   RelayoutSignalHandler relayoutSignal(application);
80   actor.OnRelayoutSignal().Connect(&relayoutSignal, &RelayoutSignalHandler::RelayoutCallback);
81
82   application.SendNotification();
83
84   DALI_TEST_EQUALS(relayoutSignal.mSignalCalled, true, TEST_LOCATION);
85
86   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE).Get<Vector3>(), size, TEST_LOCATION);
87   DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::POSITION).Get<Vector3>(), position, TEST_LOCATION);
88
89   END_TEST;
90 }