60 #include "rkhfwk_pubsubSpy.h"
61 #include "Mock_rkhfwk_rdygrp.h"
62 #include "Mock_rkhsma.h"
63 #include "Mock_rkhassert.h"
64 #include "Mock_rkhport.h"
65 #include "Mock_rkhfwk_dynevt.h"
70 typedef struct PubArg PubArg;
79 int GlobalExpectCount;
80 int GlobalVerifyOrder;
81 char *GlobalOrderError;
94 MockAssertCallback(
const char*
const file,
int line,
int cmock_num_calls)
103 Mock_rkhfwk_rdygrp_Init();
105 Mock_rkhassert_Init();
112 Mock_rkhfwk_rdygrp_Verify();
113 Mock_rkhsma_Verify();
114 Mock_rkhassert_Verify();
115 Mock_rkhport_Verify();
116 Mock_rkhfwk_rdygrp_Destroy();
117 Mock_rkhsma_Destroy();
118 Mock_rkhassert_Destroy();
119 Mock_rkhport_Destroy();
129 test_AfterInitAllChannelsAreAvailable(
void)
135 rkh_rdygrp_init_Expect(0);
136 rkh_rdygrp_init_IgnoreArg_me();
143 test_SubscribeOneActiveObject(
void)
145 rkh_rdygrp_init_Ignore();
146 rkh_enter_critical_Expect();
148 rkh_rdygrp_setReady_IgnoreArg_me();
149 rkh_exit_critical_Expect();
156 test_UnsubscribeOneActiveObject(
void)
158 rkh_rdygrp_init_Ignore();
159 rkh_enter_critical_Expect();
161 rkh_rdygrp_setUnready_IgnoreArg_me();
162 rkh_exit_critical_Expect();
169 test_UnsubscribeAllActiveObjects(
void)
173 rkh_rdygrp_init_Ignore();
178 rkh_enter_critical_Expect();
180 rkh_exit_critical_Expect();
181 rkh_rdygrp_setReady_IgnoreArg_me();
185 rkh_enter_critical_Expect();
189 rkh_rdygrp_setUnready_IgnoreArg_me();
191 rkh_exit_critical_Expect();
197 test_PublishOneActiveObject(
void)
203 rkh_rdygrp_init_Ignore();
204 rkh_enter_critical_Expect();
205 rkh_rdygrp_traverse_ExpectAndReturn(0, 0, 0, 1);
206 rkh_exit_critical_Expect();
207 rkh_fwk_gc_Expect(&evt, &me);
208 rkh_rdygrp_traverse_IgnoreArg_me();
209 rkh_rdygrp_traverse_IgnoreArg_rdyCb();
210 rkh_rdygrp_traverse_IgnoreArg_rdyCbArg();
214 TEST_ASSERT_EQUAL(1, nRdyAo);
218 test_InvokePublishCallbackOnPublish(
void)
226 publishArg.event = &event;
227 publishArg.sender = aoSender;
228 rkh_sma_post_fifo_Expect(ao, &event, aoSender);
230 publish((RdyCbArg *)&publishArg);
234 test_IgnoreSelfPublishing(
void)
241 publishArg.event = &event;
242 publishArg.sender = ao;
244 publish((RdyCbArg *)&publishArg);
248 test_Fails_SubscribeWithWrongArgs(
void)
252 rkh_assert_Expect(
"rkhfwk_pubsub", 0);
253 rkh_assert_IgnoreArg_file();
254 rkh_assert_IgnoreArg_line();
255 rkh_assert_StubWithCallback(MockAssertCallback);
258 rkh_assert_Expect(
"rkhfwk_pubsub", 0);
259 rkh_assert_IgnoreArg_line();
260 rkh_assert_StubWithCallback(MockAssertCallback);
265 test_Fails_UnsubscribeWithWrongArgs(
void)
269 rkh_assert_Expect(
"rkhfwk_pubsub", 0);
270 rkh_assert_IgnoreArg_file();
271 rkh_assert_IgnoreArg_line();
272 rkh_assert_StubWithCallback(MockAssertCallback);
275 rkh_assert_Expect(
"rkhfwk_pubsub", 0);
276 rkh_assert_IgnoreArg_line();
277 rkh_assert_StubWithCallback(MockAssertCallback);
#define RKH_CFG_FWK_MAX_SMA
Specify the maximum number of state machine applications (SMA) to be used by the application (can be ...
#define RKH_CFG_FWK_MAX_SUBS_CHANNELS
Specify the maximum number of channels (topics) to which an active object wants to subscribe (can be ...
RKH_SMA_T * rkh_sptbl[RKH_CFG_FWK_MAX_SMA]
Priority arranged table of registered SMA.
Specifies the publish-subscribe interface.
rui8_t rkh_pubsub_publish(rui8_t channel, RKH_EVT_T *event, const void *const sender)
void rkh_pubsub_subscribe(rui8_t channel, const RKH_SMA_T *ao)
Adds an active object to the notification list of an event channel. Each subscription registers a cli...
void rkh_pubsub_unsubscribeAll(const RKH_SMA_T *ao)
Unsubscribes an active object from all topics.
void rkh_pubsub_unsubscribe(rui8_t channel, const RKH_SMA_T *ao)
Unsubscribes an active object from topic.
void rkh_pubsub_init(void)
Encapsulates the initialization of publish-subscribe module.
#define RKH_SMA_DEF_PTR(me_)
Declare a opaque pointer pointing to an previously created active object.
#define RKH_GET_PRIO(_ao)
Retrieves the priority number of an registered active object (SMA).
#define RKH_SMA_CREATE(type, name, prio, ppty, initialState, initialAction, initialEvt)
Declare and allocate a SMA (active object) derived from RKH_SMA_T. Also, initializes and assigns a st...
Represents events without parameters.
Describes the SMA (active object in UML).