From: hyunuk.tak Date: Tue, 22 Mar 2022 04:54:33 +0000 (+0900) Subject: Add core test case for setting device role changed callback X-Git-Tag: accepted/tizen/unified/20220914.164046~99 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bdde2f8abe34a278089bfc9b7934f697bf42e6d3;p=platform%2Fcore%2Fapi%2Fthread.git Add core test case for setting device role changed callback Change-Id: Ifc14e36f8fdfa3a9102f8c1965c8e993f54cf79d Signed-off-by: hyunuk.tak --- diff --git a/tests/unittest/thread-unittest-core.cpp b/tests/unittest/thread-unittest-core.cpp index 658b9e5..4665dec 100644 --- a/tests/unittest/thread-unittest-core.cpp +++ b/tests/unittest/thread-unittest-core.cpp @@ -24,6 +24,9 @@ public: thread_instance_h instance; thread_device_role_e deviceRole; +public: + static void deviceRoleCb(thread_device_role_e device_role, void *user_data) {}; + protected: void SetUp() override { @@ -152,4 +155,24 @@ TEST_F(ThreadCoreTest, GetDeviceRoleErrorNone) { EXPECT_EQ(THREAD_ERROR_NONE, thread_enable(&instance)); EXPECT_EQ(THREAD_ERROR_NONE, thread_get_device_role(instance, &deviceRole)); +} + +TEST_F(ThreadCoreTest, SetDeviceRoleChangedCbNotInitialized) +{ + EXPECT_EQ(THREAD_ERROR_NONE, thread_deinitialize()); + EXPECT_EQ(THREAD_ERROR_NOT_INITIALIZED, + thread_set_device_role_changed_cb(instance, deviceRoleCb, nullptr)); +} + +TEST_F(ThreadCoreTest, SetDeviceRoleChangedCbInvalidParameter) +{ + EXPECT_EQ(THREAD_ERROR_INVALID_PARAMETER, + thread_set_device_role_changed_cb(instance, deviceRoleCb, nullptr)); +} + +TEST_F(ThreadCoreTest, SetDeviceRoleChangedCbErrorNone) +{ + EXPECT_EQ(THREAD_ERROR_NONE, thread_enable(&instance)); + EXPECT_EQ(THREAD_ERROR_NONE, + thread_set_device_role_changed_cb(instance, deviceRoleCb, nullptr)); } \ No newline at end of file