mmifw-ipc : create mmifw-ipc api tc 38/264138/1
authorulgal-park <ulgal.park@samsung.com>
Mon, 13 Sep 2021 05:36:21 +0000 (14:36 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Mon, 13 Sep 2021 12:15:07 +0000 (21:15 +0900)
Change-Id: I43849d32288f8d61845f8bb482cf7bdee6a191e8

tests/meson.build
tests/mmifw-ipc-test.cpp [new file with mode: 0644]

index 4a7ce23..7f6c4cf 100644 (file)
@@ -1,6 +1,7 @@
 mmifw_tests_srcs = [
        'mmifw-tests.cpp',
-       'mmifw-main-test.cpp'
+       'mmifw-main-test.cpp',
+       'mmifw-ipc-test.cpp'
        ]
 
 gmock_dep = dependency('gmock', method : 'pkg-config')
diff --git a/tests/mmifw-ipc-test.cpp b/tests/mmifw-ipc-test.cpp
new file mode 100644 (file)
index 0000000..ad62f15
--- /dev/null
@@ -0,0 +1,168 @@
+/*
+* Copyright © 2021 Samsung Electronics co., Ltd. All Rights Reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#include "mmifw.h"
+#include "mmifw-tests.h"
+#include "mmifw-ipc.h"
+
+#include <Ecore.h>
+#include <rpc-port-internal.h>
+
+class MMIFWIpcTest : public ::testing::Test
+{
+public:
+       void SetUp(void) override
+       {
+       }
+
+       void TearDown(void) override
+       {
+       }
+};
+
+TEST_F(MMIFWIpcTest, MMIFWIpcInitSuccess)
+{
+       int res = mmi_init();
+       const char *app_id = "org.tizen.mmi-system-ux-test";
+       int ipc_init_res = mmi_ipc_init(app_id);
+       
+       EXPECT_EQ(ipc_init_res, 0);
+
+       if(ipc_init_res == 0)
+       {
+               mmi_ipc_shutdown();
+
+               if(rpc_port_deregister_proc_info() == RPC_PORT_ERROR_NONE)
+               {
+                       PRINT("Remove AUL Proxy Success\n");
+               }
+               else
+               {
+                       PRINT("Remove AUL Proxy Fail(RPC_PORT_ERROR_IO_ERROR)");
+               }
+       }
+
+       if(res)
+               mmi_shutdown();
+}
+
+TEST_F(MMIFWIpcTest, MMIFWIpcInitFail)
+{
+       int res = mmi_init();
+       const char *app_id = NULL;
+       int ipc_init_res = mmi_ipc_init(app_id);
+
+       EXPECT_NE(ipc_init_res, 0);
+
+       if(ipc_init_res == 0)
+       {
+               mmi_ipc_shutdown();
+               
+               if(rpc_port_deregister_proc_info() == RPC_PORT_ERROR_NONE)
+               {
+                       PRINT("Remove AUL Proxy Success\n");
+               }
+               else
+               {
+                       PRINT("Remove AUL Proxy Fail(RPC_PORT_ERROR_IO_ERROR)");
+               }
+       }
+       
+       if(res)
+               mmi_shutdown();
+}
+
+TEST_F(MMIFWIpcTest, MMIFWIpcGetVariableBeforeInit)
+{
+       int res = mmi_init();
+       const char *app_id = "org.tizen.mmi-system-ux-test";
+
+       EXPECT_FALSE(mmi_ipc_is_connected());
+
+       rpc_port_proxy_mmifw_h rpc_res = mmi_ipc_get_rpc_h();
+       EXPECT_EQ(rpc_res, nullptr);
+
+       mmi_state state_res = mmi_ipc_get_state();
+       EXPECT_EQ(state_res, MMI_STATE_NONE);
+
+       int uid_res = mmi_ipc_get_uid();
+       EXPECT_NE(uid_res, -1);
+
+       EXPECT_NE(mmi_ipc_get_appid(), app_id);
+       
+       if(res)
+               mmi_shutdown();
+}
+
+TEST_F(MMIFWIpcTest, MMIFWIpcGetVariableAfterInit)
+{
+       int timer = 0;
+       int res = mmi_init();
+       const char *app_id = "org.tizen.mmi-system-ux-test";
+       mmi_handle h = mmi_instance_create(app_id);
+
+       EXPECT_NE(h, nullptr);
+
+       while (timer != 100000)
+       {
+               ecore_main_loop_iterate();
+               timer++;
+       }
+
+       EXPECT_TRUE(mmi_ipc_is_connected());
+
+       if(h)
+       {
+               rpc_port_proxy_mmifw_h rpc_res = mmi_ipc_get_rpc_h();
+               EXPECT_NE(rpc_res, nullptr);
+               EXPECT_EQ(rpc_res, h->rpc_h);
+
+               mmi_state state_res = mmi_ipc_get_state();
+               EXPECT_EQ(state_res, h->state);
+
+               int uid_res = mmi_ipc_get_uid();
+               EXPECT_NE(uid_res, -1);
+               EXPECT_EQ(uid_res, h->uid);
+
+               EXPECT_EQ(mmi_ipc_get_appid(), app_id);
+               EXPECT_EQ(mmi_ipc_get_appid(), h->app_id);
+               EXPECT_EQ(mmi_ipc_get_stub_appid(), h->stub_appid);
+       }
+
+       if(h)
+       {
+               mmi_instance_destroy(h);
+
+               if(rpc_port_deregister_proc_info() == RPC_PORT_ERROR_NONE)
+               {
+                       PRINT("Remove AUL Proxy Success\n");
+               }
+               else{
+                       PRINT("Remove AUL Proxy Fail(RPC_PORT_ERROR_IO_ERROR)");
+               }
+       }
+
+       if(res)
+               mmi_shutdown();
+}
+