--- /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 MMIFWMainTest : public ::testing::Test
+{
+public:
+ void SetUp(void) override
+ {
+ }
+
+ void TearDown(void) override
+ {
+ }
+};
+
+
+TEST_F(MMIFWMainTest, MMIFWMainInit)
+{
+ int res = mmi_init();
+
+ EXPECT_EQ(res, 1);
+
+ if(res)
+ mmi_shutdown();
+}
+
+TEST_F(MMIFWMainTest, MMIFWMainInstanceCreateSuccess)
+{
+ 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++;
+ }
+
+ 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();
+}
+
+TEST_F(MMIFWMainTest, MMIFWMainInstanceCreateAndConnectSuccess)
+{
+ 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){
+ 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();
+}
+
+TEST_F(MMIFWMainTest, MMIFWMainInstanceCreateFail)
+{
+ int timer = 0;
+ int res = mmi_init();
+ const char *app_id = NULL;
+ mmi_handle h = mmi_instance_create(app_id);
+
+ EXPECT_EQ(h, nullptr);
+
+ while (timer != 100000)
+ {
+ ecore_main_loop_iterate();
+ timer++;
+ }
+
+ 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();
+}
+
+static Eina_Bool
+_cb_focus(void *data, int type, void *event)
+{
+ if (!event)
+ return ECORE_CALLBACK_PASS_ON;
+
+ EXPECT_TRUE(true);
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_cb_connection(void *data, int type, void *event)
+{
+ if (!event)
+ return ECORE_CALLBACK_PASS_ON;
+
+ EXPECT_TRUE(true);
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+TEST_F(MMIFWMainTest, MMIFWMainEventAddSingleListener)
+{
+ 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);
+ mmi_event_listener * handler = NULL;
+
+ EXPECT_NE(h, nullptr);
+
+ while (timer != 100000)
+ {
+ ecore_main_loop_iterate();
+ timer++;
+ }
+
+ EXPECT_TRUE(mmi_ipc_is_connected());
+
+ if(h){
+ handler = mmi_event_add_listener(h, MMI_EVENT_CONNECTION, _cb_connection, h);
+ }
+
+ EXPECT_NE(handler, nullptr);
+
+ if(handler)
+ mmi_event_remove_listener(h, handler);
+
+ 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();
+}
+
+TEST_F(MMIFWMainTest, MMIFWMainEventAddSingleListenerFail)
+{
+ 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);
+ mmi_event_listener * handler =NULL;
+
+ EXPECT_NE(h, nullptr);
+
+ while (timer != 100000)
+ {
+ ecore_main_loop_iterate();
+ timer++;
+ }
+
+ EXPECT_TRUE(mmi_ipc_is_connected());
+
+ if(h){
+ handler = mmi_event_add_listener(h, MMI_EVENT_CONNECTION, NULL, NULL);
+ }
+
+ EXPECT_EQ(handler, nullptr);
+
+ if(handler)
+ mmi_event_remove_listener(h, handler);
+
+ 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();
+}
+
+TEST_F(MMIFWMainTest, MMIFWMainEventAddSingleListenerSecondFail)
+{
+ 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);
+ mmi_event_listener * handler =NULL;
+
+ EXPECT_NE(h, nullptr);
+
+ while (timer != 100000)
+ {
+ ecore_main_loop_iterate();
+ timer++;
+ }
+
+ EXPECT_TRUE(mmi_ipc_is_connected());
+
+ if(h){
+ handler = mmi_event_add_listener(h, 100, _cb_connection, NULL);
+ }
+
+ EXPECT_EQ(handler, nullptr);
+
+ if(handler)
+ mmi_event_remove_listener(h, handler);
+
+ 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();
+}
+
+TEST_F(MMIFWMainTest, MMIFWMainRequestSendGetFocus)
+{
+ 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){
+ mmi_result mmi_res = mmi_request_send_get_focus(h);
+ EXPECT_EQ(mmi_res, MMI_RESULT_SUCCESS);
+ }
+
+ 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();
+}
+
+TEST_F(MMIFWMainTest, MMIFWMainRequestSendSetGetState)
+{
+ 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){
+ mmi_result mmi_res = mmi_request_send_get_focus(h);
+ EXPECT_EQ(mmi_res, MMI_RESULT_SUCCESS);
+
+ mmi_state state = MMI_STATE_INITIATION;
+ mmi_res = mmi_request_send_set_state(h, state);
+ EXPECT_EQ(mmi_res, MMI_RESULT_SUCCESS);
+
+ state = mmi_state_get_current_state(h);
+ EXPECT_NE(state, MMI_STATE_NONE);
+ }
+
+ 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();
+}
+
+TEST_F(MMIFWMainTest, MMIFWMainEventRemoveAllListener)
+{
+ 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);
+ mmi_event_listener * handler = NULL;
+ mmi_event_listener * handler2 = NULL;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(handler, nullptr);
+
+ while (timer != 100000)
+ {
+ ecore_main_loop_iterate();
+ timer++;
+ }
+
+ EXPECT_TRUE(mmi_ipc_is_connected());
+
+ if(h){
+ handler = mmi_event_add_listener(h, MMI_EVENT_CONNECTION, _cb_connection, h);
+ handler2 = mmi_event_add_listener(h, MMI_EVENT_FOCUS, _cb_focus, h);
+ }
+
+ EXPECT_NE(handler, nullptr);
+ EXPECT_NE(handler2, nullptr);
+
+ if(handler) {
+ mmi_event_remove_all_listeners(h);
+ }
+
+ 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();
+}
\ No newline at end of file