Skip to content
This repository was archived by the owner on Jul 8, 2022. It is now read-only.

Commit 3950063

Browse files
committed
Test for sending attr conf event after dev restart
Add test that verifies if attribute configuration event is sent to all subscribers after device restart (regardless if properties have changed).
1 parent 7115111 commit 3950063

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

cpp_test_suite/new_tests/cxx_dserver_misc.cpp

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ using namespace std;
1414
#undef SUITE_NAME
1515
#define SUITE_NAME DServerMiscTestSuite
1616

17+
template <typename TEvent>
1718
struct EventCallback : public Tango::CallBack
1819
{
1920
EventCallback()
2021
: num_of_all_events(0)
2122
, num_of_error_events(0)
2223
{}
2324

24-
void push_event(Tango::EventData* event)
25+
void push_event(TEvent* event)
2526
{
2627
num_of_all_events++;
2728
if (event->err)
@@ -237,7 +238,7 @@ cout << "str = " << str << endl;
237238
*/
238239
void test_event_subscription_recovery_after_device_restart()
239240
{
240-
EventCallback callback{};
241+
EventCallback<Tango::EventData> callback{};
241242

242243
std::string attribute_name = "event_change_tst";
243244

@@ -263,6 +264,37 @@ cout << "str = " << str << endl;
263264
TS_ASSERT_EQUALS(0, callback.num_of_error_events);
264265
}
265266

267+
/* Tests that attribute configuration change event
268+
* is sent to all subscribers after device restart.
269+
*/
270+
void test_attr_conf_change_event_after_device_restart()
271+
{
272+
EventCallback<Tango::AttrConfEventData> callback{};
273+
274+
const std::string attribute_name = "event_change_tst";
275+
276+
int subscription = 0;
277+
TS_ASSERT_THROWS_NOTHING(subscription = device1->subscribe_event(
278+
attribute_name,
279+
Tango::ATTR_CONF_EVENT,
280+
&callback));
281+
282+
Tango_sleep(1);
283+
TS_ASSERT_EQUALS(1, callback.num_of_all_events);
284+
TS_ASSERT_EQUALS(0, callback.num_of_error_events);
285+
286+
{
287+
Tango::DeviceData input{};
288+
input << device1_name;
289+
TS_ASSERT_THROWS_NOTHING(dserver->command_inout("DevRestart", input));
290+
}
291+
292+
Tango_sleep(1);
293+
TS_ASSERT_EQUALS(2, callback.num_of_all_events);
294+
TS_ASSERT_EQUALS(0, callback.num_of_error_events);
295+
296+
TS_ASSERT_THROWS_NOTHING(device1->unsubscribe_event(subscription));
297+
}
266298
};
267299
#undef cout
268300
#endif // DServerMiscTestSuite_h

0 commit comments

Comments
 (0)