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