From: hyunuk.tak Date: Tue, 22 Mar 2022 06:00:23 +0000 (+0900) Subject: Add core test case for getting device type X-Git-Tag: accepted/tizen/unified/20220914.164046~97 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F85%2F272885%2F1;p=platform%2Fcore%2Fapi%2Fthread.git Add core test case for getting device type Change-Id: I79ad30b08e174ed55cc642b50dcfcdfe6be86fb9 Signed-off-by: hyunuk.tak --- diff --git a/tests/unittest/mocks/thread-mock-dummy.cpp b/tests/unittest/mocks/thread-mock-dummy.cpp index 93d1c0e..717dcb4 100644 --- a/tests/unittest/mocks/thread-mock-dummy.cpp +++ b/tests/unittest/mocks/thread-mock-dummy.cpp @@ -38,11 +38,16 @@ static GVariant *__property_device_role() return g_variant_new("(v)", g_variant_new("s", "child")); } -static GVariant *__property_link_mode() +static GVariant *__property_set_link_mode() { return g_variant_new("(i)", THREAD_ERROR_NONE); } +static GVariant *__property_get_link_mode() +{ + return g_variant_new("(v)", g_variant_new("(bbb)", true, true, true)); +} + struct { const gchar *interface_name; const gchar *signal_name; @@ -97,7 +102,12 @@ struct { { "Set", THREAD_DBUS_PROPERTY_LINK_MODE, - __property_link_mode, + __property_set_link_mode, + }, + { + "Get", + THREAD_DBUS_PROPERTY_LINK_MODE, + __property_get_link_mode, }, { NULL, diff --git a/tests/unittest/thread-unittest-core.cpp b/tests/unittest/thread-unittest-core.cpp index 4c438f6..309b13a 100644 --- a/tests/unittest/thread-unittest-core.cpp +++ b/tests/unittest/thread-unittest-core.cpp @@ -23,6 +23,7 @@ class ThreadCoreTest : public ::testing::Test public: thread_instance_h instance; thread_device_role_e deviceRole; + thread_device_type_e deviceType; public: static void deviceRoleCb(thread_device_role_e device_role, void *user_data) {}; @@ -199,4 +200,21 @@ TEST_F(ThreadCoreTest, SetDeviceTypeErrorNone) thread_set_device_type(instance, THREAD_DEVICE_TYPE_SLEEPY_END_DEVICE)); EXPECT_EQ(THREAD_ERROR_NONE, thread_set_device_type(instance, THREAD_DEVICE_TYPE_ROUTER)); +} + +TEST_F(ThreadCoreTest, GetDeviceTypeNotInitialized) +{ + EXPECT_EQ(THREAD_ERROR_NONE, thread_deinitialize()); + EXPECT_EQ(THREAD_ERROR_NOT_INITIALIZED, thread_get_device_type(instance, &deviceType)); +} + +TEST_F(ThreadCoreTest, GetDeviceTypeInvalidParameter) +{ + EXPECT_EQ(THREAD_ERROR_INVALID_PARAMETER, thread_get_device_type(instance, &deviceType)); +} + +TEST_F(ThreadCoreTest, GetDeviceTypeErrorNone) +{ + EXPECT_EQ(THREAD_ERROR_NONE, thread_enable(&instance)); + EXPECT_EQ(THREAD_ERROR_NONE, thread_get_device_type(instance, &deviceType)); } \ No newline at end of file