/* 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);
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)
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) {
} 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) {
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);
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;
}