Debian Codegraph @

tests/test-default-action.c

raw
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * @file tests/test-default-action.c Unit test: default action
4 *
5 * @Copyright (C) 2004 Mike Hearn <[email protected]>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
21 */
22
23 #include <libnotify/notify.h>
24 #include <stdio.h>
25 #include <unistd.h>
26 #include <stdlib.h>
27 #include <assert.h>
28 #include <string.h>
29
30 static GMainLoop *loop;
31
32 static void
33 callback (NotifyNotification *n,
34 const char *action,
35 void *user_data)
36 {
37 printf ("callback\n");
38 assert (action != NULL);
39 assert (strcmp ("default", action) == 0);
40
41 notify_notification_close (n, NULL);
42
43 g_main_loop_quit (loop);
44 }
45
46 int
47 main ()
48 {
49 NotifyNotification *n;
50
51 if (!notify_init ("Default Action Test"))
52 exit (1);
53
54 loop = g_main_loop_new (NULL, FALSE);
55
56 n = notify_notification_new ("Matt is online", "", NULL);
57 notify_notification_set_timeout (n, NOTIFY_EXPIRES_DEFAULT);
58 notify_notification_add_action (n,
59 "default",
60 "Do Default Action",
61 (NotifyActionCallback) callback,
62 NULL,
63 NULL);
64 notify_notification_set_category (n, "presence.online");
65
66 if (!notify_notification_show (n, NULL)) {
67 fprintf (stderr, "failed to send notification\n");
68 return 1;
69 }
70
71 g_main_loop_run (loop);
72
73 return 0;
74 }