~ubuntu-branches/ubuntu/trusty/fcitx/trusty-proposed

« back to all changes in this revision

Viewing changes to src/lib/fcitx-gclient/test/testgclient.c

  • Committer: Package Import Robot
  • Author(s): Aron Xu
  • Date: 2013-02-10 17:03:56 UTC
  • mfrom: (1.3.18) (33.1.3 experimental)
  • Revision ID: package-import@ubuntu.com-20130210170356-2yuv6xy3ed378kn0
Tags: 1:4.2.7-1
* New upstream release.
* New binary packages:
  - fcitx-libs-gclient: D-Bus client library for Glib
  - fcitx-libs-qt: D-Bus client library for Qt
  - fcitx-module-quickphrase-editor: Quick Phrase editor module

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include <fcitx-gclient/fcitxkbd.h>
 
2
#include <fcitx-gclient/fcitxclient.h>
 
3
#include <fcitx-utils/keysym.h>
 
4
#include <fcitx/fcitx.h>
2
5
 
3
6
static gboolean
4
7
timeout_cb (gpointer data)
19
22
static void
20
23
foreach_cb(gpointer data, gpointer user_data)
21
24
{
 
25
    FCITX_UNUSED(user_data);
22
26
    FcitxLayoutItem* item = data;
23
27
    g_debug("%s %s %s %s", item->layout, item->variant, item->name, item->langcode);
24
28
}
26
30
static void
27
31
test_keyboard (void)
28
32
{
29
 
    run_loop_with_timeout (1000);
30
33
    FcitxKbd* kbd = fcitx_kbd_new(G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, 0, NULL, NULL);
31
34
 
32
35
    GPtrArray* layouts = fcitx_kbd_get_layouts(kbd);
38
41
    g_object_unref(G_OBJECT(kbd));
39
42
}
40
43
 
 
44
static void
 
45
_process_cb(GObject* obj, GAsyncResult* res, gpointer user_data)
 
46
{
 
47
    FCITX_UNUSED(obj);
 
48
    FCITX_UNUSED(res);
 
49
    FCITX_UNUSED(user_data);
 
50
}
 
51
 
 
52
static void
 
53
_connect_cb(FcitxClient* client, void* user_data)
 
54
{
 
55
    FCITX_UNUSED(user_data);
 
56
    GCancellable* cancellable = g_cancellable_new();
 
57
    fcitx_client_process_key_async(client, FcitxKey_a, 0, 0, 0, 0, -1, cancellable, _process_cb, NULL);
 
58
    g_cancellable_cancel(cancellable);
 
59
    g_object_unref(cancellable);
 
60
    fcitx_client_process_key_async(client, FcitxKey_a, 0, 0, 0, 0, -1, NULL, _process_cb, NULL);
 
61
}
 
62
 
 
63
static void
 
64
test_client (void)
 
65
{
 
66
    FcitxClient* client = fcitx_client_new();
 
67
    g_signal_connect(client, "connected", G_CALLBACK(_connect_cb), NULL);
 
68
    run_loop_with_timeout (10000);
 
69
}
 
70
 
41
71
int main(int argc, char* argv[])
42
72
{
 
73
#if !GLIB_CHECK_VERSION(2, 35, 1)
43
74
    g_type_init();
 
75
#endif
44
76
    g_test_init (&argc, &argv, NULL);
45
77
 
46
78
    g_test_add_func ("/fcitx/keyboard", test_keyboard);
 
79
    g_test_add_func ("/fcitx/client", test_client);
47
80
 
48
81
    return g_test_run ();
49
 
}
 
 
b'\\ No newline at end of file'
 
82
}