static void test_async_apis (void) { g_debug ("start"); IBusInputContext *context; context = ibus_bus_create_input_context (bus, "test"); call_basic_ipcs (context); call_next_async_function (context); ibus_main (); }
static void test_input_context (void) { GList *engines; gchar *active_engine_name = NULL; IBusInputContext *context; IBusEngineDesc *engine_desc; gchar *current_ic; context = ibus_bus_create_input_context (bus, "test"); call_basic_ipcs (context); engines = ibus_bus_list_active_engines (bus); if (engines != NULL) { active_engine_name = get_last_engine_id (engines); } else { active_engine_name = g_strdup ("dummy"); } g_assert (active_engine_name); g_debug ("Use '%s' for testing.", active_engine_name); ibus_input_context_set_engine (context, active_engine_name); current_ic = ibus_bus_current_input_context (bus); g_assert (!strcmp (current_ic, g_dbus_proxy_get_object_path ((GDBusProxy *)context))); g_test_log_set_fatal_handler (fatal_handler, NULL); engine_desc = ibus_input_context_get_engine (context); if (engine_desc) { /* FIXME race condition between ibus_input_context_set_engine and _get_engine. * ibus_input_context_get_engine is not guaranteed to return non-NULL * (even if we use synchronous set_engine()) because ibus-daemon sets a context * engine in an asynchronous manner. See _context_request_engine_cb in * ibusimpl.c which handles context_signals[REQUEST_ENGINE] signal. */ g_assert (!strcmp (active_engine_name, ibus_engine_desc_get_name(engine_desc))); g_object_unref (engine_desc); engine_desc = NULL; } ibus_input_context_process_key_event (context, 0, 0, 0); /* An engine is set. Try to call basic IPCs again. */ call_basic_ipcs (context); g_free (current_ic); g_object_unref (context); g_free (active_engine_name); g_list_foreach (engines, (GFunc) g_object_unref, NULL); g_list_free (engines); }
int main() { g_type_init (); IBusBus *bus; GList *engines; IBusInputContext *context; IBusEngineDesc *engine_desc; gchar *active_engine_name; bus = ibus_bus_new (); /* Test ibusbus.c */ g_debug ("===== Active engines:"); engines = ibus_bus_list_active_engines (bus); g_assert (engines); active_engine_name = get_last_engine_id (engines); print_engines (engines); g_list_free (engines); g_debug ("===== All engines:"); engines = ibus_bus_list_engines (bus); g_assert (engines); print_engines (engines); g_list_free (engines); g_debug ("Test ibusbus.c: passed."); /* Test ibusinputcontext.c */ context = ibus_bus_create_input_context (bus, "test"); ibus_input_context_set_capabilities (context, 0); ibus_input_context_disable (context); g_assert (ibus_input_context_is_enabled (context) == FALSE); ibus_input_context_enable (context); g_assert (ibus_input_context_is_enabled (context) == TRUE); ibus_input_context_set_engine (context, active_engine_name); engine_desc = ibus_input_context_get_engine (context); g_assert (engine_desc); g_assert (!strcmp (active_engine_name, engine_desc->name)); g_debug ("Test ibusinputcontext.c: passed."); g_free (active_engine_name); g_object_unref (engine_desc); g_object_unref (context); g_object_unref (bus); return 0; }
int main() { g_type_init (); GMainLoop *mainloop; IBusBus *bus; IBusInputContext *context; mainloop = g_main_loop_new (NULL, FALSE); bus = ibus_bus_new (); context = ibus_bus_create_input_context (bus, "test"); ibus_input_context_set_capabilities (context, 0); ibus_input_context_destroy (context); g_object_unref (context); g_object_unref (bus); g_main_loop_run (mainloop); return 0; }
static void bus_test_client_init (BusTestClient *client) { IDEBUG ("%s", __FUNCTION__); gchar *active_engine_name; client->connected = FALSE; client->enabled = FALSE; g_return_if_fail (ibus_bus_is_connected (_bus)); client->connected = TRUE; client->ibuscontext = ibus_bus_create_input_context (_bus, "test-client"); g_return_if_fail (client->ibuscontext != NULL); g_object_ref_sink (client->ibuscontext); g_signal_connect (client->ibuscontext, "disabled", G_CALLBACK (_bus_disabled_cb), client); bus_test_client_clear_modifier (client); client->caps = IBUS_CAP_FOCUS; ibus_input_context_set_capabilities (client->ibuscontext, client->caps); active_engine_name = _get_active_engine_name (); g_return_if_fail (active_engine_name != NULL); IDEBUG ("engine:%s", active_engine_name); ibus_input_context_focus_in (client->ibuscontext); ibus_input_context_set_engine (client->ibuscontext, active_engine_name); g_free (active_engine_name); ibus_input_context_enable (client->ibuscontext); client->enabled = TRUE; }
static int xim_create_ic (XIMS xims, IMChangeICStruct *call_data) { static int base_icid = 1; X11IC *x11ic; call_data->icid = base_icid ++; LOG (1, "XIM_CREATE_IC ic=%d connect_id=%d", call_data->icid, call_data->connect_id); x11ic = g_slice_new0 (X11IC); g_return_val_if_fail (x11ic != NULL, 0); x11ic->icid = call_data->icid; x11ic->connect_id = call_data->connect_id; x11ic->conn = (X11ICONN *)g_hash_table_lookup (_connections, GINT_TO_POINTER ((gint) call_data->connect_id)); if (x11ic->conn == NULL) { g_slice_free (X11IC, x11ic); g_return_val_if_reached (0); } _xim_store_ic_values (x11ic, call_data); x11ic->context = ibus_bus_create_input_context (_bus, "xim"); if (x11ic->context == NULL) { g_slice_free (X11IC, x11ic); g_return_val_if_reached (0); } g_signal_connect (x11ic->context, "commit-text", G_CALLBACK (_context_commit_text_cb), x11ic); g_signal_connect (x11ic->context, "forward-key-event", G_CALLBACK (_context_forward_key_event_cb), x11ic); g_signal_connect (x11ic->context, "update-preedit-text", G_CALLBACK (_context_update_preedit_text_cb), x11ic); g_signal_connect (x11ic->context, "show-preedit-text", G_CALLBACK (_context_show_preedit_text_cb), x11ic); g_signal_connect (x11ic->context, "hide-preedit-text", G_CALLBACK (_context_hide_preedit_text_cb), x11ic); g_signal_connect (x11ic->context, "enabled", G_CALLBACK (_context_enabled_cb), x11ic); g_signal_connect (x11ic->context, "disabled", G_CALLBACK (_context_disabled_cb), x11ic); if (x11ic->input_style & XIMPreeditCallbacks) { ibus_input_context_set_capabilities (x11ic->context, IBUS_CAP_FOCUS | IBUS_CAP_PREEDIT_TEXT); } else { ibus_input_context_set_capabilities (x11ic->context, IBUS_CAP_FOCUS); } g_hash_table_insert (_x11_ic_table, GINT_TO_POINTER (x11ic->icid), (gpointer)x11ic); x11ic->conn->clients = g_list_append (x11ic->conn->clients, (gpointer)x11ic); return 1; }
int main() { g_type_init (); IBusBus *bus; GList *engines; gchar *active_engine_name; bus = ibus_bus_new (); /* Test ibusbus.c */ g_debug ("===== Active engines:"); engines = ibus_bus_list_active_engines (bus); g_assert (engines); active_engine_name = get_last_engine_id (engines); print_engines (engines); g_list_free (engines); g_debug ("===== All engines:"); engines = ibus_bus_list_engines (bus); g_assert (engines); print_engines (engines); g_list_free (engines); g_debug ("===== Global engine:"); if (ibus_bus_get_use_global_engine (bus)) { g_debug ("use_global_engine is true."); if (ibus_bus_is_global_engine_enabled (bus)) { g_debug ("Global engine is enabled."); IBusEngineDesc *global_engine = ibus_bus_get_global_engine (bus); g_assert (global_engine); g_debug ("%s (id:%s, icon:%s)", global_engine->longname, global_engine->name, global_engine->icon); g_object_unref (global_engine); } } g_debug ("===== Use system layout:%s", ibus_bus_get_use_sys_layout (bus) ? "true" : "false"); g_debug ("Test ibusbus.c: passed."); /* Test ibusinputcontext.c */ #if 1 { IBusInputContext *context; IBusEngineDesc *engine_desc; gchar *current_ic; context = ibus_bus_create_input_context (bus, "test"); ibus_input_context_set_capabilities (context, IBUS_CAP_FOCUS); ibus_input_context_disable (context); g_assert (ibus_input_context_is_enabled (context) == FALSE); ibus_input_context_enable (context); g_assert (ibus_input_context_is_enabled (context) == TRUE); ibus_input_context_focus_in (context); ibus_input_context_set_engine (context, active_engine_name); current_ic = ibus_bus_current_input_context (bus); g_assert (!strcmp (current_ic, ibus_proxy_get_path (IBUS_PROXY (context)))); engine_desc = ibus_input_context_get_engine (context); g_assert (engine_desc); g_assert (!strcmp (active_engine_name, engine_desc->name)); g_debug ("Test ibusinputcontext.c: passed."); g_free (active_engine_name); g_free (current_ic); g_object_unref (engine_desc); g_object_unref (context); } #endif g_object_unref (bus); return 0; }
gint main (gint argc, gchar **argv) { g_type_init (); g_test_init (&argc, &argv, NULL); #if 0 g_test_add_func ("/ibus/list-engines", test_list_engines); g_test_add_func ("/ibus/list-active-engines", test_list_active_engines); #endif return g_test_run (); #if 0 IBusBus *bus; GList *engines; gchar *active_engine_name; bus = ibus_bus_new (); if (ibus_bus_get_use_global_engine (bus)) { g_debug ("use_global_engine is true."); if (ibus_bus_is_global_engine_enabled (bus)) { g_debug ("Global engine is enabled."); IBusEngineDesc *global_engine = ibus_bus_get_global_engine (bus); g_assert (global_engine); g_debug ("%s (id:%s, icon:%s)", global_engine->longname, global_engine->name, global_engine->icon); g_object_unref (global_engine); } } g_debug ("===== Use system layout:%s", ibus_bus_get_use_sys_layout (bus) ? "true" : "false"); g_debug ("Test ibusbus.c: passed."); /* Test ibusinputcontext.c */ #if 1 { IBusInputContext *context; IBusEngineDesc *engine_desc; gchar *current_ic; context = ibus_bus_create_input_context (bus, "test"); ibus_input_context_set_capabilities (context, IBUS_CAP_FOCUS); ibus_input_context_disable (context); g_assert (ibus_input_context_is_enabled (context) == FALSE); ibus_input_context_enable (context); g_assert (ibus_input_context_is_enabled (context) == TRUE); ibus_input_context_focus_in (context); ibus_input_context_set_engine (context, active_engine_name); current_ic = ibus_bus_current_input_context (bus); g_assert (!strcmp (current_ic, g_dbus_proxy_get_object_path ((GDBusProxy *)context))); engine_desc = ibus_input_context_get_engine (context); g_assert (engine_desc); g_assert (!strcmp (active_engine_name, engine_desc->name)); g_debug ("Test ibusinputcontext.c: passed."); g_free (active_engine_name); g_free (current_ic); g_object_unref (engine_desc); g_object_unref (context); } #endif g_object_unref (bus); #endif return 0; }