Merge "Introduce WindowData" into devel/master
[platform/core/uifw/dali-adaptor.git] / automated-tests / src / dali-adaptor / utc-Dali-WidgetApplication.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-application.h>
21 #include <dali/public-api/adaptor-framework/widget.h>
22
23 using namespace Dali;
24
25 void utc_dali_widget_application_startup(void)
26 {
27   test_return_value = TET_UNDEF;
28 }
29
30 void utc_dali_widget_application_cleanup(void)
31 {
32   test_return_value = TET_PASS;
33 }
34
35 namespace
36 {
37 Widget CreateWidgetFunction(const std::string&)
38 {
39   return Dali::Widget();
40 }
41 } // namespace
42
43 int UtcDaliWidgetApplicationRegisterWidgetCreatingFunctionNegative(void)
44 {
45   Dali::WidgetApplication instance;
46   try
47   {
48     std::string arg1;
49     instance.RegisterWidgetCreatingFunction(arg1, &CreateWidgetFunction);
50     DALI_TEST_CHECK(false); // Should not get here
51   }
52   catch(...)
53   {
54     DALI_TEST_CHECK(true); // We expect an assert
55   }
56   END_TEST;
57 }
58
59 int UtcDaliWidgetApplicationConstructorsPositive(void)
60 {
61   WidgetApplication widget1;
62
63   // copy constructor
64   WidgetApplication widget2 = WidgetApplication(widget1);
65
66   // copy assignment
67   widget1 = widget2;
68
69   // move constructor
70   WidgetApplication widget3 = WidgetApplication(std::move(widget1));
71
72   // move assignemnt
73   widget2 = std::move(widget3);
74
75   DALI_TEST_CHECK(!widget1);
76   DALI_TEST_CHECK(!widget2);
77   DALI_TEST_CHECK(!widget3);
78
79   END_TEST;
80 }
81
82 int UtcDaliWidgetApplicationNewP(void)
83 {
84   WidgetApplication widget1 = WidgetApplication::New(nullptr, nullptr, std::string());
85   DALI_TEST_CHECK(widget1);
86
87   END_TEST;
88 }