From 9d6f11fceaf8fafb75a9c11cf462ebf45649e151 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 11 Jul 2016 22:54:59 +0900 Subject: [PATCH] [UTC][widget_service][Non-ACR][Fix sample widget crash] Change-Id: Ia6f4a60fb03f76800a3d00e2ba4584e0687589ba Signed-off-by: Hwankyu Jhun --- src/utc/widget_service/utc-widget_service.c | 57 +++++++---------------------- 1 file changed, 14 insertions(+), 43 deletions(-) diff --git a/src/utc/widget_service/utc-widget_service.c b/src/utc/widget_service/utc-widget_service.c index 3fd010b..f38c1c2 100755 --- a/src/utc/widget_service/utc-widget_service.c +++ b/src/utc/widget_service/utc-widget_service.c @@ -822,43 +822,9 @@ int utc_widget_service_trigger_update_p(void) /* Common routines for creating a widget instance - BEGIN */ -static GMainLoop *g_mainloop = NULL; -static guint g_timeout_id = 0; typedef int (*test_case_cb)(Evas_Object *widget); -static gboolean timeout_function(gpointer data) -{ - g_source_remove(g_timeout_id); - g_timeout_id = 0; - g_main_loop_quit(g_mainloop); - return FALSE; -} - -static inline void wait_for_async(void) -{ - if (g_mainloop) { - if (g_timeout_id) { - g_source_remove(g_timeout_id); - g_timeout_id = 0; - } - g_main_loop_quit(g_mainloop); - g_mainloop = NULL; - } - - g_mainloop = g_main_loop_new(NULL, FALSE); - - g_timeout_id = g_timeout_add(2000, timeout_function, NULL); - g_main_loop_run(g_mainloop); - - if (g_timeout_id > 0) { - g_source_remove(g_timeout_id); - g_timeout_id = 0; - } - g_mainloop = NULL; -} - - static int tct_async_ret_callback(test_case_cb cb, struct widget_evas_event_info *info) { assert_neq(info, NULL); @@ -881,12 +847,16 @@ static void _widget_create_cb(void *data, Evas_Object *obj, void *event_info) if (!ret && cb) { cb(obj); } +} - /** - * @TODO - * Quit from the main loop - */ - g_main_loop_quit(g_mainloop); +static int __lifecycle_cb(const char *widget_id, widget_lifecycle_event_e lifecycle_event, + const char *widget_instance_id, void *data) +{ + if (lifecycle_event == WIDGET_LIFE_CYCLE_EVENT_RESUME && + s_info.is_asserted == 0) + elm_exit(); + + return 0; } int add_a_sample_widget(test_case_cb cb) @@ -898,7 +868,7 @@ int add_a_sample_widget(test_case_cb cb) win = elm_win_add(NULL, "sample_widget", ELM_WIN_BASIC); assert_neq(win, NULL); - evas_object_show(win); + evas_object_size_hint_weight_set(win, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); ret = widget_viewer_evas_init(win); if (s_info.appwidget_supported == false) { @@ -907,6 +877,7 @@ int add_a_sample_widget(test_case_cb cb) } else { assert_eq(ret, WIDGET_ERROR_NONE); } + evas_object_show(win); widget = widget_viewer_evas_add_widget(win, "org.tizen.sample_widget", NULL, 0.0f); if (s_info.appwidget_supported == false) { @@ -926,11 +897,13 @@ int add_a_sample_widget(test_case_cb cb) assert_eq(ret, WIDGET_ERROR_NONE); } + widget_service_set_lifecycle_event_cb("org.tizen.sample_widget", __lifecycle_cb, NULL); evas_object_resize(widget, w, h); evas_object_show(widget); - wait_for_async(); + elm_run(); + widget_service_unset_lifecycle_event_cb("org.tizen.sample_widget", NULL); ret = widget_viewer_evas_fini(); if (s_info.appwidget_supported == false) { assert_eq(ret, WIDGET_ERROR_NOT_SUPPORTED); @@ -956,8 +929,6 @@ static int instance_list_cb(const char *widget_id, const char *instance_id, void ret = widget_service_change_period(widget_id, instance_id, 1.0f); s_info.is_asserted = (ret == WIDGET_ERROR_NONE) ? 0 : 1; - g_main_loop_quit(g_mainloop); - return WIDGET_ERROR_NONE; } -- 2.7.4