Enable assert always in Dali::Vector
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / test-sample-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/addons/addon-base.h>
20
21 #include <cstring>
22
23 static const std::string DUMMY_ADDON_NAME = "SampleAddOn";
24
25 int StringLen(const char* str)
26 {
27   return strlen(str);
28 }
29
30 int DoSum(int a, int b)
31 {
32   return a + b;
33 }
34
35 class TestDummyAddOn : public Dali::AddOns::AddOnBase
36 {
37 public:
38   void GetAddOnInfo(Dali::AddOnInfo& info) override
39   {
40     info.type    = Dali::AddOnType::GENERIC;
41     info.name    = "SampleAddOn";
42     info.version = Dali::DALI_ADDON_VERSION(1, 0, 0);
43     info.next    = nullptr;
44     tet_printf("SampleAddOn: GetAddOnInfo() : name = %s\n", info.name.c_str());
45   }
46
47   /**
48    * Dispatch table for global functions
49    * @return
50    */
51   Dali::AddOns::DispatchTable* GetGlobalDispatchTable() override
52   {
53     static Dali::AddOns::DispatchTable dispatchTable{};
54     if(dispatchTable.Empty())
55     {
56       dispatchTable["DoSum"]     = DoSum;
57       dispatchTable["StringLen"] = StringLen;
58     }
59     return &dispatchTable;
60   }
61
62   /**
63    * Lifecycle
64    */
65
66   void OnStart() override
67   {
68   }
69
70   void OnStop() override
71   {
72   }
73
74   void OnPause() override
75   {
76   }
77
78   void OnResume() override
79   {
80   }
81
82   /**
83    * Dispatch table for instance functions
84    * @return
85    */
86   Dali::AddOns::DispatchTable* GetInstanceDispatchTable() override
87   {
88     return nullptr;
89   }
90 };
91
92 REGISTER_ADDON_CLASS(TestDummyAddOn);