summaryrefslogtreecommitdiff
path: root/testsuite/gtk/action.c
blob: d64f876be56a83f4ee0c47b9ee78e842be3f1c63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
/* Copyright (C) 2019 Red Hat, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 */
#include <gtk/gtk.h>

static void
activate (GSimpleAction *action,
          GVariant      *parameter,
          gpointer       user_data)
{
  int *activated = user_data;
  (*activated)++;
}

/* Test that inheriting actions along the widget
 * hierarchy works as expected. Since GtkWidget does
 * not expose the actions, we test this by observing
 * the effect of activating them.
 */
static void
test_inheritance (void)
{
  GtkWidget *window;
  GtkWidget *box;
  GtkWidget *button;
  GSimpleActionGroup *win_actions;
  GSimpleActionGroup *box_actions;
  GActionEntry entries[] = {
    { "action", activate, NULL, NULL, NULL },
  };
  gboolean found;
  int win_activated;
  int box_activated;

  win_activated = 0;
  box_activated = 0;

  /* Our hierarchy looks like this:
   *
   * window    win.action
   *   |
   *  box      box.action
   *   |
   * button
   */
  window = gtk_window_new ();
  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  button = gtk_button_new ();

  gtk_window_set_child (GTK_WINDOW (window), box);
  gtk_box_append (GTK_BOX (box), button);

  win_actions = g_simple_action_group_new ();
  g_action_map_add_action_entries (G_ACTION_MAP (win_actions),
                                   entries, G_N_ELEMENTS (entries),
                                   &win_activated);

  box_actions = g_simple_action_group_new ();
  g_action_map_add_action_entries (G_ACTION_MAP (box_actions),
                                   entries, G_N_ELEMENTS (entries),
                                   &box_activated);

  gtk_widget_insert_action_group (window, "win", G_ACTION_GROUP (win_actions));
  gtk_widget_insert_action_group (box, "box", G_ACTION_GROUP (box_actions));

  g_assert_cmpint (win_activated, ==, 0);
  g_assert_cmpint (box_activated, ==, 0);

  found = gtk_widget_activate_action (button, "win.action", NULL);

  g_assert_true (found);
  g_assert_cmpint (win_activated, ==, 1);
  g_assert_cmpint (box_activated, ==, 0);

  found = gtk_widget_activate_action (box, "win.action", NULL);

  g_assert_true (found);
  g_assert_cmpint (win_activated, ==, 2);
  g_assert_cmpint (box_activated, ==, 0);

  found = gtk_widget_activate_action (button, "box.action", NULL);

  g_assert_true (found);
  g_assert_cmpint (win_activated, ==, 2);
  g_assert_cmpint (box_activated, ==, 1);

  found = gtk_widget_activate_action (window, "box.action", NULL);

  g_assert_false (found);
  g_assert_cmpint (win_activated, ==, 2);
  g_assert_cmpint (box_activated, ==, 1);

  gtk_window_destroy (GTK_WINDOW (window));
  g_object_unref (win_actions);
  g_object_unref (box_actions);
}

/* Test action inheritance with hierarchy changes */
static void
test_inheritance2 (void)
{
  GtkWidget *window;
  GtkWidget *box;
  GtkWidget *box1;
  GtkWidget *box2;
  GtkWidget *button;
  GSimpleActionGroup *win_actions;
  GSimpleActionGroup *box1_actions;
  GSimpleActionGroup *box2_actions;
  GActionEntry entries[] = {
    { "action", activate, NULL, NULL, NULL },
  };
  gboolean found;
  int win_activated;
  int box1_activated;
  int box2_activated;

  win_activated = 0;
  box1_activated = 0;
  box2_activated = 0;

  /* Our hierarchy looks like this:
   *
   * window win.action
   *   |
   *  box--------------------+
   *   |                     |
   *  box1   box1.action    box2   box2.action;
   *   |
   * button
   */
  window = gtk_window_new ();
  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  box1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  button = gtk_button_new ();

  gtk_window_set_child (GTK_WINDOW (window), box);
  gtk_box_append (GTK_BOX (box), box1);
  gtk_box_append (GTK_BOX (box), box2);
  gtk_box_append (GTK_BOX (box1), button);

  win_actions = g_simple_action_group_new ();
  g_action_map_add_action_entries (G_ACTION_MAP (win_actions),
                                   entries, G_N_ELEMENTS (entries),
                                   &win_activated);

  box1_actions = g_simple_action_group_new ();
  g_action_map_add_action_entries (G_ACTION_MAP (box1_actions),
                                   entries, G_N_ELEMENTS (entries),
                                   &box1_activated);

  box2_actions = g_simple_action_group_new ();
  g_action_map_add_action_entries (G_ACTION_MAP (box2_actions),
                                   entries, G_N_ELEMENTS (entries),
                                   &box2_activated);

  gtk_widget_insert_action_group (window, "win", G_ACTION_GROUP (win_actions));
  gtk_widget_insert_action_group (box1, "box1", G_ACTION_GROUP (box1_actions));
  gtk_widget_insert_action_group (box2, "box2", G_ACTION_GROUP (box2_actions));

  g_assert_cmpint (win_activated, ==, 0);
  g_assert_cmpint (box1_activated, ==, 0);
  g_assert_cmpint (box2_activated, ==, 0);

  found = gtk_widget_activate_action (button, "win.action", NULL);

  g_assert_true (found);
  g_assert_cmpint (win_activated, ==, 1);
  g_assert_cmpint (box1_activated, ==, 0);
  g_assert_cmpint (box2_activated, ==, 0);

  found = gtk_widget_activate_action (button, "box1.action", NULL);

  g_assert_true (found);
  g_assert_cmpint (win_activated, ==, 1);
  g_assert_cmpint (box1_activated, ==, 1);
  g_assert_cmpint (box2_activated, ==, 0);

  found = gtk_widget_activate_action (button, "box2.action", NULL);

  g_assert_false (found);
  g_assert_cmpint (win_activated, ==, 1);
  g_assert_cmpint (box1_activated, ==, 1);
  g_assert_cmpint (box2_activated, ==, 0);

  g_object_ref (button);
  gtk_box_remove (GTK_BOX (box1), button);
  gtk_box_append (GTK_BOX (box2), button);
  g_object_unref (button);

  found = gtk_widget_activate_action (button, "win.action", NULL);

  g_assert_true (found);
  g_assert_cmpint (win_activated, ==, 2);
  g_assert_cmpint (box1_activated, ==, 1);
  g_assert_cmpint (box2_activated, ==, 0);

  found = gtk_widget_activate_action (button, "box1.action", NULL);

  g_assert_false (found);
  g_assert_cmpint (win_activated, ==, 2);
  g_assert_cmpint (box1_activated, ==, 1);
  g_assert_cmpint (box2_activated, ==, 0);

  found = gtk_widget_activate_action (button, "box2.action", NULL);

  g_assert_true (found);
  g_assert_cmpint (win_activated, ==, 2);
  g_assert_cmpint (box1_activated, ==, 1);
  g_assert_cmpint (box2_activated, ==, 1);

  gtk_window_destroy (GTK_WINDOW (window));

  g_object_unref (win_actions);
  g_object_unref (box1_actions);
  g_object_unref (box2_actions);
}

/* Similar to test_inheritance2, but using the actionable machinery
 */
static void
test_inheritance3 (void)
{
  GtkWidget *window;
  GtkWidget *box;
  GtkWidget *box1;
  GtkWidget *box2;
  GtkWidget *button;
  GSimpleActionGroup *win_actions;
  GSimpleActionGroup *box1_actions;
  GActionEntry entries[] = {
    { "action", activate, NULL, NULL, NULL },
  };
  int activated;

  /* Our hierarchy looks like this:
   *
   * window win.action
   *   |
   *  box--------------------+
   *   |                     |
   *  box1   box1.action    box2
   *   |
   * button
   */
  window = gtk_window_new ();
  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  box1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  button = gtk_button_new ();

  gtk_window_set_child (GTK_WINDOW (window), box);
  gtk_box_append (GTK_BOX (box), box1);
  gtk_box_append (GTK_BOX (box), box2);
  gtk_box_append (GTK_BOX (box1), button);

  win_actions = g_simple_action_group_new ();
  g_action_map_add_action_entries (G_ACTION_MAP (win_actions),
                                   entries, G_N_ELEMENTS (entries),
                                   &activated);

  box1_actions = g_simple_action_group_new ();
  g_action_map_add_action_entries (G_ACTION_MAP (box1_actions),
                                   entries, G_N_ELEMENTS (entries),
                                   &activated);

  gtk_widget_insert_action_group (window, "win", G_ACTION_GROUP (win_actions));
  gtk_widget_insert_action_group (box1, "box1", G_ACTION_GROUP (box1_actions));

  gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "box1.action");

  g_assert_true (gtk_widget_get_sensitive (button));

  g_object_ref (button);
  gtk_box_remove (GTK_BOX (box1), button);
  gtk_box_append (GTK_BOX (box2), button);
  g_object_unref (button);

  g_assert_false (gtk_widget_get_sensitive (button));

  g_object_ref (button);
  gtk_box_remove (GTK_BOX (box2), button);
  gtk_box_append (GTK_BOX (box1), button);
  g_object_unref (button);

  g_assert_true (gtk_widget_get_sensitive (button));

  g_object_ref (button);
  gtk_box_remove (GTK_BOX (box1), button);
  gtk_box_append (GTK_BOX (box2), button);
  g_object_unref (button);

  g_assert_false (gtk_widget_get_sensitive (button));

  g_object_ref (box2);
  gtk_box_remove (GTK_BOX (box), box2);
  gtk_box_append (GTK_BOX (box1), box2);
  g_object_unref (box2);

  g_assert_true (gtk_widget_get_sensitive (button));

  gtk_widget_insert_action_group (box1, "box1", NULL);

  g_assert_false (gtk_widget_get_sensitive (button));

  gtk_widget_insert_action_group (box1, "box1", G_ACTION_GROUP (box1_actions));

  g_assert_true (gtk_widget_get_sensitive (button));

  gtk_window_destroy (GTK_WINDOW (window));

  g_object_unref (win_actions);
  g_object_unref (box1_actions);
}

static int cut_activated;
static int copy_activated;
static int paste_activated;
static int visibility_changed;

static void
cut_activate (GSimpleAction *action,
              GVariant      *parameter,
              gpointer       user_data)
{
  cut_activated++;
}

static void
copy_activate (GSimpleAction *action,
               GVariant      *parameter,
               gpointer       user_data)
{
  copy_activated++;
}

static void
paste_activate (GSimpleAction *action,
                GVariant      *parameter,
                gpointer       user_data)
{
  paste_activated++;
}

static void
visibility_changed_cb (GObject    *object,
                       GParamSpec *pspec,
                       gpointer    user_data)
{
  visibility_changed++;
}

/* Spot-check that GtkText has the class actions
 * for the context menu. Here we test that the clipboard
 * actions are present, and that toggling visibility
 * via the action works.
 */
static void
test_text (void)
{
  GtkWidget *box;
  GtkWidget *text;
  GSimpleActionGroup *clipboard_actions;
  GActionEntry clipboard_entries[] = {
    { "cut", cut_activate, NULL, NULL, NULL },
    { "copy", copy_activate, NULL, NULL, NULL },
    { "paste", paste_activate, NULL, NULL, NULL },
  };
  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  text = gtk_text_new ();

  gtk_box_append (GTK_BOX (box), text);

  clipboard_actions = g_simple_action_group_new ();
  g_action_map_add_action_entries (G_ACTION_MAP (clipboard_actions),
                                   clipboard_entries,
                                   G_N_ELEMENTS (clipboard_entries),
                                   NULL);

  gtk_widget_insert_action_group (box, "clipboard", G_ACTION_GROUP (clipboard_actions));

  gtk_widget_activate_action (text, "cut.clipboard", NULL);
  gtk_widget_activate_action (text, "copy.clipboard", NULL);
  gtk_widget_activate_action (text, "paste.clipboard", NULL);

  g_assert_cmpint (cut_activated, ==, 0);
  g_assert_cmpint (copy_activated, ==, 0);
  g_assert_cmpint (paste_activated, ==, 0);

  g_signal_connect (text, "notify::visibility",
                    G_CALLBACK (visibility_changed_cb), NULL);

  gtk_widget_activate_action (text, "misc.toggle-visibility", NULL);

  g_assert_cmpint (visibility_changed, ==, 1);

  g_object_unref (g_object_ref_sink (box));
  g_object_unref (clipboard_actions);
}

/* Test that inheritance works for individual actions
 * even if they are in groups with the same prefix.
 * This is a change from the way things work in GTK3.
 */
static void
test_overlap (void)
{
  GtkWidget *window;
  GtkWidget *box;
  GActionEntry win_entries[] = {
    { "win", activate, NULL, NULL, NULL },
  };
  GActionEntry box_entries[] = {
    { "box", activate, NULL, NULL, NULL },
  };
  GSimpleActionGroup *win_actions;
  GSimpleActionGroup *box_actions;
  int win_activated;
  int box_activated;

  window = gtk_window_new ();
  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

  gtk_window_set_child (GTK_WINDOW (window), box);

  win_actions = g_simple_action_group_new ();
  g_action_map_add_action_entries (G_ACTION_MAP (win_actions),
                                   win_entries,
                                   G_N_ELEMENTS (win_entries),
                                   &win_activated);

  box_actions = g_simple_action_group_new ();
  g_action_map_add_action_entries (G_ACTION_MAP (box_actions),
                                   box_entries,
                                   G_N_ELEMENTS (box_entries),
                                   &box_activated);

  gtk_widget_insert_action_group (window, "actions", G_ACTION_GROUP (win_actions));
  gtk_widget_insert_action_group (box, "actions", G_ACTION_GROUP (box_actions));

  win_activated = 0;
  box_activated = 0;

  gtk_widget_activate_action (box, "actions.win", NULL);

  g_assert_cmpint (win_activated, ==, 1);
  g_assert_cmpint (box_activated, ==, 0);

  gtk_widget_activate_action (box, "actions.box", NULL);

  g_assert_cmpint (win_activated, ==, 1);
  g_assert_cmpint (box_activated, ==, 1);

  gtk_window_destroy (GTK_WINDOW (window));
  g_object_unref (win_actions);
  g_object_unref (box_actions);
}

static int toggled;
static int act1;
static int act2;

static void
visibility_toggled (GObject *object,
                    GParamSpec *pspec,
                    gpointer data)
{
  toggled++;
}

static void
activate1 (GSimpleAction *action,
           GVariant      *parameter,
           gpointer       user_data)
{
  act1++;
}

static void
activate2 (GSimpleAction *action,
           GVariant      *parameter,
           gpointer       user_data)
{
  act2++;
}

/* Test that overlap also works as expected between
 * class action and inserted groups. Class actions
 * take precedence over inserted groups in the same
 * muxer, but inheritance works as normal between
 * muxers.
 */
static void
test_overlap2 (void)
{
  GtkWidget *text;
  GtkWidget *child;
  GSimpleActionGroup *group1;
  GSimpleActionGroup *group2;
  GActionEntry entries1[] = {
    { "toggle-visibility", activate1, NULL, NULL, NULL },
  };
  GActionEntry entries2[] = {
    { "toggle-visibility", activate2, NULL, NULL, NULL },
  };

  text = gtk_text_new ();
  g_signal_connect (text, "notify::visibility",
                    G_CALLBACK (visibility_toggled), NULL);

  child = gtk_label_new ("");
  gtk_widget_set_parent (child, text);

  g_assert_cmpint (toggled, ==, 0);
  g_assert_cmpint (act1, ==, 0);
  g_assert_cmpint (act2, ==, 0);

  gtk_widget_activate_action (child, "misc.toggle-visibility", NULL);

  g_assert_cmpint (toggled, ==, 1);
  g_assert_cmpint (act1, ==, 0);
  g_assert_cmpint (act2, ==, 0);

  group1 = g_simple_action_group_new ();
  g_action_map_add_action_entries (G_ACTION_MAP (group1),
                                   entries1,
                                   G_N_ELEMENTS (entries1),
                                   NULL);
  gtk_widget_insert_action_group (text, "misc", G_ACTION_GROUP (group1));
  gtk_widget_activate_action (child, "misc.toggle-visibility", NULL);

  g_assert_cmpint (toggled, ==, 2);
  g_assert_cmpint (act1, ==, 0);
  g_assert_cmpint (act2, ==, 0);

  group2 = g_simple_action_group_new ();
  g_action_map_add_action_entries (G_ACTION_MAP (group2),
                                   entries2,
                                   G_N_ELEMENTS (entries2),
                                   NULL);
  gtk_widget_insert_action_group (child, "misc", G_ACTION_GROUP (group2));

  gtk_widget_activate_action (child, "misc.toggle-visibility", NULL);

  g_assert_cmpint (toggled, ==, 2);
  g_assert_cmpint (act1, ==, 0);
  g_assert_cmpint (act2, ==, 1);

  g_object_unref (group1);
  g_object_unref (group2);

  gtk_widget_unparent (child);
  g_object_unref (g_object_ref_sink (text));
}

/* Test that gtk_widget_class_query_action
 * yields the expected results
 */
static void
test_introspection (void)
{
  GtkWidgetClass *class = g_type_class_ref (GTK_TYPE_TEXT);
  guint i, j;
  guint found;
  GType owner;
  const char *name;
  const GVariantType *params;
  const char *property;
  struct {
    GType owner;
    const char *name;
    const char *params;
    const char *property;
  } expected[] = {
    { GTK_TYPE_TEXT, "misc.toggle-visibility", NULL, "visibility" },
    { GTK_TYPE_TEXT, "misc.insert-emoji", NULL, NULL },
    { GTK_TYPE_TEXT, "selection.select-all", NULL, NULL },
    { GTK_TYPE_TEXT, "selection.delete", NULL, NULL },
    { GTK_TYPE_TEXT, "clipboard.paste", NULL, NULL },
    { GTK_TYPE_TEXT, "clipboard.copy", NULL, NULL },
    { GTK_TYPE_TEXT, "clipboard.cut", NULL, NULL },
    { GTK_TYPE_TEXT, "menu.popup", NULL, NULL },
    { GTK_TYPE_TEXT, "text.redo", NULL, NULL },
    { GTK_TYPE_TEXT, "text.undo", NULL, NULL },
  };

  j = 0;
  found = 0;
  while (gtk_widget_class_query_action (class,
                                        j,
                                        &owner,
                                        &name,
                                        &params,
                                        &property))
    {
      for (i = 0; i < G_N_ELEMENTS (expected); i++)
        {
          if (strcmp (expected[i].name, name) == 0)
            {
              found++;
              g_assert (expected[i].owner == owner);
              g_assert_cmpstr (expected[i].name, ==, name);
              g_assert_cmpstr (expected[i].params, ==, params ? g_variant_type_peek_string (params) : NULL);
              g_assert_cmpstr (expected[i].property, ==, property);
              break;
            }
        }
      if (i == G_N_ELEMENTS (expected))
        g_error ("Unexpected GtkText action: %s", name);
      j++;
    }
  g_assert (found == G_N_ELEMENTS (expected));

  g_type_class_unref (class);
}

/* Test that disabled actions don't get activated */
static void
test_enabled (void)
{
  GtkWidget *text;

  text = gtk_text_new ();
  g_signal_connect (text, "notify::visibility",
                    G_CALLBACK (visibility_toggled), NULL);

  toggled = 0;

  gtk_widget_activate_action (text, "misc.toggle-visibility", NULL);

  g_assert_cmpint (toggled, ==, 1);

  gtk_widget_action_set_enabled (text, "misc.toggle-visibility", FALSE);

  gtk_widget_activate_action (text, "misc.toggle-visibility", NULL);

  g_assert_cmpint (toggled, ==, 1);

  g_object_unref (g_object_ref_sink (text));
}

int
main (int   argc,
      char *argv[])
{
  gtk_test_init (&argc, &argv);

  g_test_add_func ("/action/inheritance", test_inheritance);
  g_test_add_func ("/action/inheritance2", test_inheritance2);
  g_test_add_func ("/action/inheritance3", test_inheritance3);
  g_test_add_func ("/action/text", test_text);
  g_test_add_func ("/action/overlap", test_overlap);
  g_test_add_func ("/action/overlap2", test_overlap2);
  g_test_add_func ("/action/introspection", test_introspection);
  g_test_add_func ("/action/enabled", test_enabled);

  return g_test_run();
}