~vibhavp/ubuntu/raring/libnotify/add-autopkgtest

« back to all changes in this revision

Viewing changes to tests/test-multi-actions.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2010-06-29 07:27:38 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20100629072738-prk3l3rnruq2lx1x
Tags: 0.5.0-1
* New upstream release:
  + debian/rules,
    debian/compat,
    debian/control.in,
    debian/source/format,
    debian/patches/*:
    - Update to debhelper compat level 7.
    - Update to source format 3.0 (quilt).
    - Update to Standards-Version 3.8.4.
  + debian/control:
    - Update build dependencies.
  + debian/rules:
    - Update shlibs version to 0.5.0 because of new API.
  + debian/patches/01_hurd-path-max.patch:
    - Dropped, fixed upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
 
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
 
2
 *
2
3
 * @file tests/test-multi-actions.c Unit test: multiple actions
3
4
 *
4
5
 * @Copyright(C) 2004 Mike Hearn <mike@navi.cx>
35
36
static GMainLoop *loop;
36
37
 
37
38
static void
38
 
help_callback(NotifyNotification *n, const char *action)
39
 
{
40
 
        g_assert(action != NULL);
41
 
        g_assert(strcmp(action, "help") == 0);
42
 
 
43
 
        printf("You clicked Help\n");
44
 
 
45
 
        notify_notification_close(n, NULL);
46
 
 
47
 
        g_main_loop_quit(loop);
48
 
}
49
 
 
50
 
static void
51
 
ignore_callback(NotifyNotification *n, const char *action)
52
 
{
53
 
        g_assert(action != NULL);
54
 
        g_assert(strcmp(action, "ignore") == 0);
55
 
 
56
 
        printf("You clicked Ignore\n");
57
 
 
58
 
        notify_notification_close(n, NULL);
59
 
 
60
 
        g_main_loop_quit(loop);
61
 
}
62
 
 
63
 
static void
64
 
empty_callback(NotifyNotification *n, const char *action)
65
 
{
66
 
        g_assert(action != NULL);
67
 
        g_assert(strcmp(action, "empty") == 0);
68
 
 
69
 
        printf("You clicked Empty Trash\n");
70
 
 
71
 
        notify_notification_close(n, NULL);
72
 
 
73
 
        g_main_loop_quit(loop);
 
39
help_callback (NotifyNotification *n,
 
40
               const char         *action)
 
41
{
 
42
        g_assert (action != NULL);
 
43
        g_assert (strcmp (action, "help") == 0);
 
44
 
 
45
        printf ("You clicked Help\n");
 
46
 
 
47
        notify_notification_close (n, NULL);
 
48
 
 
49
        g_main_loop_quit (loop);
 
50
}
 
51
 
 
52
static void
 
53
ignore_callback (NotifyNotification *n,
 
54
                 const char         *action)
 
55
{
 
56
        g_assert (action != NULL);
 
57
        g_assert (strcmp (action, "ignore") == 0);
 
58
 
 
59
        printf ("You clicked Ignore\n");
 
60
 
 
61
        notify_notification_close (n, NULL);
 
62
 
 
63
        g_main_loop_quit (loop);
 
64
}
 
65
 
 
66
static void
 
67
empty_callback (NotifyNotification *n,
 
68
                const char         *action)
 
69
{
 
70
        g_assert (action != NULL);
 
71
        g_assert (strcmp (action, "empty") == 0);
 
72
 
 
73
        printf ("You clicked Empty Trash\n");
 
74
 
 
75
        notify_notification_close (n, NULL);
 
76
 
 
77
        g_main_loop_quit (loop);
74
78
}
75
79
 
76
80
 
77
81
int
78
 
main(int argc, char **argv)
 
82
main (int argc, char **argv)
79
83
{
80
 
        NotifyNotification *n;
81
 
        DBusConnection *conn;
82
 
 
83
 
        if (!notify_init("Multi Action Test"))
84
 
                exit(1);
85
 
 
86
 
        conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
87
 
        loop = g_main_loop_new(NULL, FALSE);
88
 
 
89
 
        dbus_connection_setup_with_g_main(conn, NULL);
90
 
 
91
 
        n = notify_notification_new("Low disk space",
92
 
                                                                "You can free up some disk space by "
93
 
                                                                "emptying the trash can.",
94
 
                                                                NULL, NULL);
95
 
        notify_notification_set_urgency(n, NOTIFY_URGENCY_CRITICAL);
96
 
        notify_notification_set_timeout(n, NOTIFY_EXPIRES_DEFAULT);
97
 
        notify_notification_add_action(n, "help", "Help",
98
 
                                                                   (NotifyActionCallback)help_callback,
99
 
                                                                   NULL, NULL);
100
 
        notify_notification_add_action(n, "ignore", "Ignore",
101
 
                                                                   (NotifyActionCallback)ignore_callback,
102
 
                                                                   NULL, NULL);
103
 
        notify_notification_add_action(n, "empty", "Empty Trash",
104
 
                                                                   (NotifyActionCallback)empty_callback,
105
 
                                                                   NULL, NULL);
106
 
        notify_notification_set_category(n, "device");
107
 
 
108
 
        if (!notify_notification_show(n, NULL))
109
 
        {
110
 
                fprintf(stderr, "failed to send notification\n");
111
 
                return 1;
112
 
        }
113
 
 
114
 
        g_main_loop_run(loop);
115
 
 
116
 
        return 0;
 
84
        NotifyNotification *n;
 
85
        DBusConnection     *conn;
 
86
 
 
87
        if (!notify_init ("Multi Action Test"))
 
88
                exit (1);
 
89
 
 
90
        conn = dbus_bus_get (DBUS_BUS_SESSION, NULL);
 
91
        loop = g_main_loop_new (NULL, FALSE);
 
92
 
 
93
        dbus_connection_setup_with_g_main (conn, NULL);
 
94
 
 
95
        n = notify_notification_new ("Low disk space",
 
96
                                     "You can free up some disk space by "
 
97
                                     "emptying the trash can.",
 
98
                                     NULL,
 
99
                                     NULL);
 
100
        notify_notification_set_urgency (n, NOTIFY_URGENCY_CRITICAL);
 
101
        notify_notification_set_timeout (n, NOTIFY_EXPIRES_DEFAULT);
 
102
        notify_notification_add_action (n,
 
103
                                        "help",
 
104
                                        "Help",
 
105
                                        (NotifyActionCallback) help_callback,
 
106
                                        NULL,
 
107
                                        NULL);
 
108
        notify_notification_add_action (n,
 
109
                                        "ignore",
 
110
                                        "Ignore",
 
111
                                        (NotifyActionCallback)
 
112
                                        ignore_callback,
 
113
                                        NULL,
 
114
                                        NULL);
 
115
        notify_notification_add_action (n,
 
116
                                        "empty",
 
117
                                        "Empty Trash",
 
118
                                        (NotifyActionCallback) empty_callback,
 
119
                                        NULL,
 
120
                                        NULL);
 
121
        notify_notification_set_category (n, "device");
 
122
 
 
123
        if (!notify_notification_show (n, NULL)) {
 
124
                fprintf (stderr, "failed to send notification\n");
 
125
                return 1;
 
126
        }
 
127
 
 
128
        g_main_loop_run (loop);
 
129
 
 
130
        return 0;
117
131
}