Add core test case for getting device type 85/272885/1
authorhyunuk.tak <hyunuk.tak@samsung.com>
Tue, 22 Mar 2022 06:00:23 +0000 (15:00 +0900)
committerhyunuk.tak <hyunuk.tak@samsung.com>
Mon, 28 Mar 2022 01:52:10 +0000 (10:52 +0900)
Change-Id: I79ad30b08e174ed55cc642b50dcfcdfe6be86fb9
Signed-off-by: hyunuk.tak <hyunuk.tak@samsung.com>
tests/unittest/mocks/thread-mock-dummy.cpp
tests/unittest/thread-unittest-core.cpp

index 93d1c0e..717dcb4 100644 (file)
@@ -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,
index 4c438f6..309b13a 100644 (file)
@@ -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