56 #include "unity_fixture.h"
59 #include "smPolymorphism.h"
60 #include "Mock_rkhqueue.h"
61 #include "Mockrkhsm.h"
62 #include "Mockrkhtrc.h"
63 #include "Mock_rkhport.h"
69 TEST_GROUP(polymorphism);
76 #if RKH_CFG_SMA_VFUNCT_EN == RKH_ENABLED
81 TEST_ASSERT_EQUAL_PTR(activate, me->vptr->activate);
82 TEST_ASSERT_EQUAL_PTR(task, me->vptr->task);
83 TEST_ASSERT_EQUAL_PTR(postFifo, me->vptr->post_fifo);
84 TEST_ASSERT_EQUAL_PTR(postLifo, me->vptr->post_lifo);
89 void *stkSto, rui32_t stkSize)
123 TEST_SETUP(polymorphism)
125 #if RKH_CFG_SMA_VFUNCT_EN == RKH_ENABLED
132 TEST_TEAR_DOWN(polymorphism)
134 #if RKH_CFG_SMA_VFUNCT_EN == RKH_ENABLED
145 TEST(polymorphism, defaultVirtualFunctions)
147 #if RKH_CFG_SMA_VFUNCT_EN == RKH_ENABLED
151 TEST_ASSERT_EQUAL_PTR(&
rkhSmaVtbl, singleton->vptr);
155 TEST(polymorphism, callVirtualFunction)
157 #if RKH_CFG_SMA_VFUNCT_EN == RKH_ENABLED
160 rkh_queue_init_Ignore();
161 rkh_enter_critical_Expect();
163 rkh_exit_critical_Expect();
164 rkh_sm_init_Ignore();
167 rkh_enter_critical_Expect();
168 rkh_queue_put_fifo_Ignore();
170 rkh_exit_critical_Expect();
172 rkh_enter_critical_Expect();
173 rkh_queue_put_lifo_Ignore();
175 rkh_exit_critical_Expect();
183 TEST(polymorphism, setVirtualTable)
185 #if RKH_CFG_SMA_VFUNCT_EN == RKH_ENABLED
189 testActivate, testTask, testPostFifo, testPostLifo
192 vptr = singleton->vptr = &vtbl;
195 testActivate, testTask, testPostFifo, testPostLifo);
199 TEST(polymorphism, runtimeSingletonAOCtor)
201 #if RKH_CFG_SMA_VFUNCT_EN == RKH_ENABLED
202 rkh_sm_ctor_Expect(&singleton->sm);
205 TEST_ASSERT_EQUAL(8, Singleton_getFoo());
208 TEST_ASSERT_EQUAL(0, Singleton_getFoo());
212 TEST(polymorphism, runtimeMultipleAOCtorWithVtblForObj)
214 #if RKH_CFG_SMA_VFUNCT_EN == RKH_ENABLED
215 rkh_sm_ctor_Ignore();
216 rkh_sm_ctor_Ignore();
218 Multiple_ctor(multA, 2, Multiple_postFifoA);
219 Multiple_ctor(multB, 4, Multiple_postFifoB);
224 TEST_ASSERT_EQUAL(2, Multiple_getFoobar(multA));
225 TEST_ASSERT_EQUAL(4, Multiple_getFoobar(multB));
230 TEST_ASSERT_EQUAL(0, Multiple_getFoobar(multA));
231 TEST_ASSERT_EQUAL(8, Multiple_getFoobar(multB));
235 TEST(polymorphism, runtimeMultipleAOCtorWithVtblForType)
237 #if RKH_CFG_SMA_VFUNCT_EN == RKH_ENABLED
238 Command_ctor(cmdSignal, 128);
239 Command_ctor(cmdRegister, 64);
243 Command_postFifo, Command_postLifo);
247 Command_postFifo, Command_postLifo);
251 TEST(polymorphism, runtimeSubObjectCtorOfSMAAndSM)
253 #if RKH_CFG_SMA_VFUNCT_EN == RKH_ENABLED
254 CallControl_ctorA(16);
256 TEST_ASSERT_EQUAL(16, CallControl_getFoo());
258 CallControl_activate, CallControl_task,
263 TEST(polymorphism, runtimeSubObjectCtorOfSMAAndSMWithDefaultVtbl)
265 #if RKH_CFG_SMA_VFUNCT_EN == RKH_ENABLED
266 CallControl_ctorB(8);
268 TEST_ASSERT_EQUAL(8, CallControl_getFoo());
void rkh_sma_activate(RKH_SMA_T *me, const RKH_EVT_T **qSto, RKH_QUENE_T qSize, void *stkSto, rui32_t stkSize)
Initializes and activates a previously created state machine application (SMA) as known as active obj...
void(* RKHPostFifo)(RKH_SMA_T *me, const RKH_EVT_T *e, const void *const sender)
Describes the SMA (active object in UML).
rui8_t RKH_QUENE_T
This data type defines the maximum number of elements that any queue can contain. ...
Represents events without parameters.
RKH_SMA_T * rkh_sptbl[RKH_CFG_FWK_MAX_SMA]
Priority arranged table of registered SMA.
Interface of unit test with Trazer application.
#define RKH_FALSE
Standard define.
void(* RKHTask)(RKH_SMA_T *me, void *arg)
void rkh_sma_post_lifo(RKH_SMA_T *me, const RKH_EVT_T *e, const void *const sender)
Send an event to a state machine application (SMA) as known as active object through a queue using th...
const RKHSmaVtbl rkhSmaVtbl
Virtual table for the RKH_SMA_T structure.
void(* RKHPostLifo)(RKH_SMA_T *me, const RKH_EVT_T *e, const void *const sender)
void rkh_sma_post_fifo(RKH_SMA_T *me, const RKH_EVT_T *e, const void *const sender)
Send an event to a state machine application (SMA) as known as active object through a queue using th...
#define RKH_TE_SMA_REG
Registers a state machine application (SMA) as known as active object into the framework, which implies to store a pointer to the SMA in the priority table.
#define RKH_TE_SMA_LIFO
Send an event to a state machine application (SMA) as known as active object through a queue using th...
#define RKH_SMA_POST_LIFO(me_, e_, sender_)
Invoke the direct event posting facility rkh_sma_post_lifo(). If RKH_CFG_SMA_VFUNCT_EN is set RKH_ENA...
#define RKH_TE_SMA_FIFO
Send an event to a state machine application (SMA) as known as active object through a queue using th...
#define RKH_TE_SMA_ACT
Initializes and activates a previously created state machine application (SMA) as known as active obj...
#define RKH_SMA_POST_FIFO(me_, e_, sender_)
Invoke the direct event posting facility rkh_sma_post_fifo(). If RKH_CFG_SMA_VFUNCT_EN is set RKH_ENA...
void(* RKHActivate)(RKH_SMA_T *me, const RKH_EVT_T **qSto, RKH_QUENE_T qSize, void *stkSto, rui32_t stkSize)
Specifies the interface of the acive object (SMA state machine applications) manager.
#define RKH_SMA_ACTIVATE(me_, qSto_, qStoSize, stkSto_, stkSize_)
Invoke the active object activation function rkh_sma_activate(). If RKH_CFG_SMA_VFUNCT_EN is set RKH_...