--- /dev/null
+/*
+* 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();
+}
+