Added a test program that displays three notifications and then changes the amount of text in one of them.

This commit is contained in:
Christian Hammond 2006-11-14 07:42:35 +00:00
parent 9362dbd6bd
commit bdf8640cab
4 changed files with 97 additions and 0 deletions

View File

@ -1,3 +1,11 @@
Mon Nov 13 23:42:07 PST 2006 Christian Hammond <chipx86@chipx86.com>
* tests/Makefile.am:
A tests/test-size-changes.c:
* tests/test-default-action.c:
- Added a test program that displays three notifications and then
changes the amount of text in one of them.
Sun Nov 05 12:06:01 PST 2006 Christian Hammond <chipx86@chipx86.com>
* libnotify/notify.c:

View File

@ -8,6 +8,7 @@ noinst_PROGRAMS = \
test-basic \
test-error \
test-markup \
test-size-changes \
test-urgency \
test-xy \
test-xy-actions \
@ -27,6 +28,9 @@ test_replace_widget_LDADD = $(common_ldflags)
test_server_info_SOURCES = test-server-info.c
test_server_info_LDADD = $(common_ldflags)
test_size_changes_SOURCES = test-size-changes.c
test_size_changes_LDADD = $(common_ldflags)
test_default_action_SOURCES = test-default-action.c
test_default_action_LDADD = $(common_ldflags)

View File

@ -37,6 +37,7 @@ static GMainLoop *loop;
static void callback(NotifyNotification *n, const char *action, void *user_data)
{
printf("callback\n");
assert (action != NULL);
assert (strcmp ("default", action) == 0);

84
tests/test-size-changes.c Normal file
View File

@ -0,0 +1,84 @@
/*
* @file tests/test-size-changes.c Unit test: Notification size changes
*
* @Copyright (C) 2006 Christian Hammond <chipx86@chipx86.com>
*
* 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.1 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <libnotify/notify.h>
#include <stdio.h>
#include <unistd.h>
int
main()
{
NotifyNotification *n1, *n2, *n3;
notify_init("Size Changes");
n1 = notify_notification_new("Notification 1", "Notification number 1!",
NULL, NULL);
notify_notification_set_timeout(n1, 7000);
if (!notify_notification_show(n1, NULL))
{
fprintf(stderr, "failed to send notification\n");
return 1;
}
g_object_unref(G_OBJECT(n1));
n2 = notify_notification_new("Notification 2", "Notification number 2!",
NULL, NULL);
notify_notification_set_timeout(n2, 7000);
if (!notify_notification_show(n2, NULL))
{
fprintf(stderr, "failed to send notification\n");
return 1;
}
n3 = notify_notification_new("Notification 3", "Notification number 3!",
NULL, NULL);
notify_notification_set_timeout(n3, 7000);
if (!notify_notification_show(n3, NULL))
{
fprintf(stderr, "failed to send notification\n");
return 1;
}
g_object_unref(G_OBJECT(n3));
sleep(2);
notify_notification_update(n2, "Longer Notification 2",
"This is a much longer notification.\n"
"Two lines.\n"
"Well, okay, three.\n"
"Last one.",
NULL);
if (!notify_notification_show(n2, NULL))
{
fprintf(stderr, "failed to send notification\n");
return 1;
}
return 0;
}