|
Packit Service |
1d8f1c |
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
|
|
Packit Service |
1d8f1c |
/* vim:set et sts=4: */
|
|
Packit Service |
1d8f1c |
/* ibus - The Input Bus
|
|
Packit Service |
1d8f1c |
* Copyright (C) 2011 Google, Inc.
|
|
Packit Service |
1d8f1c |
*
|
|
Packit Service |
1d8f1c |
* This library is free software; you can redistribute it and/or
|
|
Packit Service |
1d8f1c |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
1d8f1c |
* License as published by the Free Software Foundation; either
|
|
Packit Service |
1d8f1c |
* version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
1d8f1c |
*
|
|
Packit Service |
1d8f1c |
* This library is distributed in the hope that it will be useful,
|
|
Packit Service |
1d8f1c |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
1d8f1c |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
1d8f1c |
* Lesser General Public License for more details.
|
|
Packit Service |
1d8f1c |
*
|
|
Packit Service |
1d8f1c |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
1d8f1c |
* License along with this library; if not, write to the Free Software
|
|
Packit Service |
1d8f1c |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
|
Packit Service |
1d8f1c |
* USA
|
|
Packit Service |
1d8f1c |
*/
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
#include <string.h>
|
|
Packit Service |
1d8f1c |
#include "ibus.h"
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
static IBusBus *bus = NULL;
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
static void
|
|
Packit Service |
1d8f1c |
create_finish_success (GObject *object,
|
|
Packit Service |
1d8f1c |
GAsyncResult *res,
|
|
Packit Service |
1d8f1c |
gpointer user_data)
|
|
Packit Service |
1d8f1c |
{
|
|
Packit Service |
1d8f1c |
g_assert (object == (GObject *)bus);
|
|
Packit Service |
1d8f1c |
g_assert (user_data == NULL);
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
GError *error = NULL;
|
|
Packit Service |
1d8f1c |
IBusInputContext *context = NULL;
|
|
Packit Service |
1d8f1c |
context = ibus_bus_create_input_context_async_finish (bus, res, &error);
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
g_assert (IBUS_IS_INPUT_CONTEXT (context));
|
|
Packit Service |
1d8f1c |
g_object_unref (context);
|
|
Packit Service |
1d8f1c |
ibus_quit ();
|
|
Packit Service |
1d8f1c |
}
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
static void
|
|
Packit Service |
1d8f1c |
create_finish_failed (GObject *object,
|
|
Packit Service |
1d8f1c |
GAsyncResult *res,
|
|
Packit Service |
1d8f1c |
gpointer user_data)
|
|
Packit Service |
1d8f1c |
{
|
|
Packit Service |
1d8f1c |
g_assert (object == (GObject *)bus);
|
|
Packit Service |
1d8f1c |
g_assert (user_data == NULL);
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
GError *error = NULL;
|
|
Packit Service |
1d8f1c |
IBusInputContext *context = NULL;
|
|
Packit Service |
1d8f1c |
context = ibus_bus_create_input_context_async_finish (bus, res, &error);
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
g_assert (context == NULL);
|
|
Packit Service |
1d8f1c |
g_assert (error != NULL);
|
|
Packit Service |
1d8f1c |
g_debug ("error = %s", error->message);
|
|
Packit Service |
1d8f1c |
g_error_free (error);
|
|
Packit Service |
1d8f1c |
ibus_quit ();
|
|
Packit Service |
1d8f1c |
}
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
static void
|
|
Packit Service |
1d8f1c |
test_success (void)
|
|
Packit Service |
1d8f1c |
{
|
|
Packit Service |
1d8f1c |
ibus_bus_create_input_context_async (bus,
|
|
Packit Service |
1d8f1c |
"test",
|
|
Packit Service |
1d8f1c |
-1,
|
|
Packit Service |
1d8f1c |
NULL,
|
|
Packit Service |
1d8f1c |
create_finish_success,
|
|
Packit Service |
1d8f1c |
NULL);
|
|
Packit Service |
1d8f1c |
ibus_main ();
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
}
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
static void
|
|
Packit Service |
1d8f1c |
test_failed (void)
|
|
Packit Service |
1d8f1c |
{
|
|
Packit Service |
1d8f1c |
ibus_bus_create_input_context_async (bus,
|
|
Packit Service |
1d8f1c |
"test",
|
|
Packit Service |
1d8f1c |
1000,
|
|
Packit Service |
1d8f1c |
NULL,
|
|
Packit Service |
1d8f1c |
create_finish_failed,
|
|
Packit Service |
1d8f1c |
NULL);
|
|
Packit Service |
1d8f1c |
GDBusConnection *connection = ibus_bus_get_connection (bus);
|
|
Packit Service |
1d8f1c |
g_dbus_connection_flush_sync (connection, NULL, NULL);
|
|
Packit Service |
1d8f1c |
g_dbus_connection_close_sync (connection, NULL, NULL);
|
|
Packit Service |
1d8f1c |
ibus_main ();
|
|
Packit Service |
1d8f1c |
}
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
gint
|
|
Packit Service |
1d8f1c |
main (gint argc,
|
|
Packit Service |
1d8f1c |
gchar **argv)
|
|
Packit Service |
1d8f1c |
{
|
|
Packit Service |
1d8f1c |
gint result;
|
|
Packit Service |
1d8f1c |
ibus_init ();
|
|
Packit Service |
1d8f1c |
g_test_init (&argc, &argv, NULL);
|
|
Packit Service |
1d8f1c |
bus = ibus_bus_new ();
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
g_test_add_func ("/ibus/input_context_async_create_success", test_success);
|
|
Packit Service |
1d8f1c |
g_test_add_func ("/ibus/input_context_async_create_failed", test_failed);
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
result = g_test_run ();
|
|
Packit Service |
1d8f1c |
g_object_unref (bus);
|
|
Packit Service |
1d8f1c |
|
|
Packit Service |
1d8f1c |
return result;
|
|
Packit Service |
1d8f1c |
}
|