Merge branch 'devel/graphics' into devel/master
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-AddOn.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/devel-api/common/addon-binder.h>
20
21 #include "dali-test-suite-utils/test-addon-manager.h"
22
23 struct DummyAddOn : public Dali::AddOn::AddOnBinder
24 {
25   DummyAddOn()
26   : Dali::AddOn::AddOnBinder("SampleAddOn")
27   {
28   }
29
30   ~DummyAddOn() override = default;
31
32   ADDON_BIND_FUNCTION(DoSum, int(int, int));
33
34   ADDON_BIND_FUNCTION(StringLen, int());
35 };
36
37 int UtcDaliAddOnBinderP(void)
38 {
39   TestApplication application;
40
41   auto* addOnManager = new Dali::Test::AddOnManager();
42
43   tet_infoline("Testing Dali::AddOn::AddOnBinder");
44
45   DummyAddOn addon;
46
47   // Test whether library handle is non-null
48   DALI_TEST_EQUALS(addon.GetHandle(), (void*)1, TEST_LOCATION);
49
50   // Test whether addon is valid
51   auto isValid = addon.IsValid();
52   DALI_TEST_EQUALS(isValid, true, TEST_LOCATION);
53
54   // Test AddOnInfo
55   const auto& info = addon.GetAddOnInfo();
56   DALI_TEST_EQUALS(info.name, "SampleAddOn", TEST_LOCATION);
57
58   delete addOnManager;
59
60   END_TEST;
61 }
62
63 int UtcDaliAddOnManagerNotSupportedP(void)
64 {
65   TestApplication application;
66
67   tet_infoline("Testing Dali::AddOn::AddOnBinder when AddOnManager not supported");
68
69   // Not supported
70   using VoidPtr = void*;
71   DALI_TEST_EQUALS(VoidPtr(Dali::Integration::AddOnManager::Get()), VoidPtr(nullptr), TEST_LOCATION);
72
73   DummyAddOn addon{};
74
75   // Test whether library handle is non-null
76   DALI_TEST_EQUALS(addon.GetHandle(), (void*)0, TEST_LOCATION);
77
78   // Test whether addon is valid
79   auto isValid = addon.IsValid();
80   DALI_TEST_EQUALS(isValid, false, TEST_LOCATION);
81
82   END_TEST;
83 }