Update unittest code for modes_h
authorJinWang An <jinwang.an@samsung.com>
Tue, 21 Jan 2020 04:29:07 +0000 (13:29 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Thu, 19 Mar 2020 04:30:37 +0000 (13:30 +0900)
unittests/mdsp_test_bt.cpp
unittests/mdsp_test_integration.cpp

index cfa604e..f07937b 100644 (file)
@@ -31,6 +31,7 @@ protected:
        {
                plugin = objectCreate();
                loop = g_main_loop_new(NULL, FALSE);
+               handle = modes_connect();
        }
 
        void TearDown() override
@@ -39,11 +40,13 @@ protected:
                plugin = NULL;
                g_main_loop_unref(loop);
                loop = NULL;
+               modes_disconnect(handle);
+               handle = NULL;
        }
 
        static gboolean apply_mode_idler(gpointer data)
        {
-               result = modes_apply_mode((const char*)data);
+               result = modes_apply_mode(handle, (const char*)data);
 
                g_main_loop_quit(loop);
                return G_SOURCE_REMOVE;
@@ -51,15 +54,16 @@ protected:
 
        static gboolean undo_mode_idler(gpointer data)
        {
-               result = modes_apply_mode((const char*)data);
+               result = modes_apply_mode(handle, (const char*)data);
                EXPECT_EQ(MODES_ERROR_NONE, result);
                sleep(5);
-               result = modes_undo_mode((const char*)data);
+               result = modes_undo_mode(handle, (const char*)data);
 
                g_main_loop_quit(loop);
                return G_SOURCE_REMOVE;
        }
 
+       static modes_h handle;
        static int result;
        static GMainLoop *loop;
        Plugin *plugin;
@@ -67,6 +71,7 @@ protected:
 
 int BtPluginTest::result = 0;
 GMainLoop *BtPluginTest::loop = NULL;
+modes_h BtPluginTest::handle = NULL;
 
 TEST_F(BtPluginTest, undoModebtOff)
 {
index 1a9b6de..566246a 100644 (file)
@@ -22,32 +22,37 @@ protected:
        void SetUp() override
        {
                loop = g_main_loop_new(NULL, FALSE);
+               handle = modes_connect();
        }
 
        void TearDown() override
        {
                g_main_loop_unref(loop);
                loop = NULL;
+               modes_disconnect(handle);
+               handle = NULL;
        }
 
        static gboolean check_mode_idler(gpointer data)
        {
-               modes_undo_mode((const char*)data);
-               result = modes_apply_mode((const char*)data);
+               modes_undo_mode(handle, (const char*)data);
+               result = modes_apply_mode(handle, (const char*)data);
                EXPECT_EQ(MODES_ERROR_NONE, result);
                sleep(2);
-               result = modes_undo_mode((const char*)data);
+               result = modes_undo_mode(handle, (const char*)data);
 
                g_main_loop_quit(loop);
                return G_SOURCE_REMOVE;
        }
 
+       static modes_h handle;
        static int result;
        static GMainLoop *loop;
 };
 
 int IntegrationTest::result = 0;
 GMainLoop *IntegrationTest::loop = NULL;
+modes_h IntegrationTest::handle = NULL;
 
 TEST_F(IntegrationTest, runMode_btAudioConnect)
 {