Add FrontBufferRendering property in WindowData
[platform/core/uifw/dali-adaptor.git] / automated-tests / src / dali-adaptor / utc-Dali-Widget.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/dali.h>
20 #include <dali/public-api/adaptor-framework/widget-impl.h>
21 #include <dali/public-api/adaptor-framework/widget.h>
22
23 using namespace Dali;
24
25 void utc_dali_widget_startup(void)
26 {
27   test_return_value = TET_UNDEF;
28 }
29
30 void utc_dali_widget_cleanup(void)
31 {
32   test_return_value = TET_PASS;
33 }
34
35 int UtcDaliWidgetConstructorsP(void)
36 {
37   Widget widget1 = Widget::New();
38   DALI_TEST_CHECK(widget1);
39
40   // copy constructor
41   Widget widget2 = Widget(widget1);
42   DALI_TEST_CHECK(widget1 == widget2);
43
44   // copy assignment
45   widget1.Reset();
46   DALI_TEST_CHECK(!widget1);
47   DALI_TEST_CHECK(widget1 != widget2);
48   widget1 = widget2;
49   DALI_TEST_CHECK(widget1 == widget2);
50
51   // move constructor
52   Widget widget3 = Widget(std::move(widget1));
53   DALI_TEST_CHECK(widget3);
54
55   // move assignemnt
56   widget2.Reset();
57   DALI_TEST_CHECK(!widget2);
58   widget2 = std::move(widget3);
59   DALI_TEST_CHECK(widget2);
60
61   Widget widget4;
62   DALI_TEST_CHECK(!widget4);
63   widget4 = Widget::New();
64   DALI_TEST_CHECK(widget4);
65
66   END_TEST;
67 }
68
69 int UtcDaliWidgetImplOnMethodsP(void)
70 {
71   /// No real test in this function, purely for function and line coverage
72
73   Widget widget = Widget::New();
74   DALI_TEST_CHECK(widget);
75   Internal::Adaptor::Widget& widgetImpl = Internal::Adaptor::GetImplementation(widget);
76
77   try
78   {
79     widgetImpl.OnCreate(std::string(), Dali::Window());
80     widgetImpl.OnTerminate(std::string(), Dali::Widget::Termination::PERMANENT);
81     widgetImpl.OnPause();
82     widgetImpl.OnResume();
83     widgetImpl.OnResize(Dali::Window());
84     widgetImpl.OnUpdate(std::string(), 1);
85     DALI_TEST_CHECK(true);
86   }
87   catch(...)
88   {
89     DALI_TEST_CHECK(false); // Should not come here
90   }
91
92   END_TEST;
93 }
94
95 int UtcDaliWidgetImplSetContentInfoP(void)
96 {
97   Widget                     widget     = Widget::New();
98   Internal::Adaptor::Widget& widgetImpl = Internal::Adaptor::GetImplementation(widget);
99
100   try
101   {
102     widgetImpl.SetContentInfo(std::string());
103     DALI_TEST_CHECK(true);
104   }
105   catch(...)
106   {
107     DALI_TEST_CHECK(false); // Should not come here
108   }
109
110   END_TEST;
111 }
112
113 int UtcDaliWidgetImplKeyEventUsingP(void)
114 {
115   Widget                     widget     = Widget::New();
116   Internal::Adaptor::Widget& widgetImpl = Internal::Adaptor::GetImplementation(widget);
117
118   DALI_TEST_CHECK(!widgetImpl.IsKeyEventUsing());
119   widgetImpl.SetUsingKeyEvent(true);
120   DALI_TEST_CHECK(!widgetImpl.IsKeyEventUsing()); // Still false as Impl is not set WidgetImpl
121
122   END_TEST;
123 }
124
125 int UtcDaliWidgetImplSetInformationP(void)
126 {
127   Widget                     widget     = Widget::New();
128   Internal::Adaptor::Widget& widgetImpl = Internal::Adaptor::GetImplementation(widget);
129
130   try
131   {
132     widgetImpl.SetInformation(Dali::Window(), std::string());
133     DALI_TEST_CHECK(true);
134   }
135   catch(...)
136   {
137     DALI_TEST_CHECK(false); // Should not come here
138   }
139
140   END_TEST;
141 }
142
143 int UtcDaliWidgetImplGetWindowP(void)
144 {
145   const Widget                     widget     = Widget::New();
146   const Internal::Adaptor::Widget& widgetImpl = Internal::Adaptor::GetImplementation(widget);
147
148   DALI_TEST_CHECK(!widgetImpl.GetWindow());
149
150   END_TEST;
151 }
152
153 int UtcDaliWidgetImplGetWidgetIdP(void)
154 {
155   const Widget                     widget     = Widget::New();
156   const Internal::Adaptor::Widget& widgetImpl = Internal::Adaptor::GetImplementation(widget);
157
158   DALI_TEST_CHECK(widgetImpl.GetWidgetId().empty());
159
160   END_TEST;
161 }