~ubuntu-branches/debian/stretch/alarm-clock-applet/stretch

« back to all changes in this revision

Viewing changes to src/tests/test_list_entry.c

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2009-05-30 23:24:27 UTC
  • Revision ID: james.westby@ubuntu.com-20090530232427-88on1j2ily4ajxdz
Tags: upstream-0.2.6
ImportĀ upstreamĀ versionĀ 0.2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * test_list_entry.c -- Test for AlarmListEntry
 
3
 * 
 
4
 * Copyright (C) 2007-2008 Johannes H. Jensen <joh@pseudoberries.com>
 
5
 * 
 
6
 * This program is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU General Public License
 
8
 * as published by the Free Software Foundation; either version 2
 
9
 * of the License, or (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
19
 * 
 
20
 * Authors:
 
21
 *              Johannes H. Jensen <joh@pseudoberries.com>
 
22
 */
 
23
 
 
24
#include <glib.h>
 
25
 
 
26
#include "list-entry.h"
 
27
 
 
28
static void
 
29
entry_dump (AlarmListEntry *entry)
 
30
{
 
31
        g_print ("ListEntry %p: ");
 
32
        if (entry != NULL)
 
33
                g_print ("name: '%s', data: '%s', icon: '%s'", entry->name, entry->data, entry->icon);
 
34
        g_print ("\n");
 
35
}
 
36
 
 
37
int main (void)
 
38
{
 
39
        AlarmListEntry *entry = NULL;
 
40
        GList *list = NULL, *l;
 
41
        GnomeVFSResult result;
 
42
        gchar *mime;
 
43
        guint i;
 
44
        
 
45
        // Test alarm list entry alloc
 
46
        entry = alarm_list_entry_new ("Name", "Some data", "Icon");
 
47
        entry_dump (entry);
 
48
        alarm_list_entry_free(entry);
 
49
        
 
50
        entry = alarm_list_entry_new ("Name", NULL, NULL);
 
51
        entry_dump (entry);
 
52
        alarm_list_entry_free(entry);
 
53
        
 
54
        // Test alarm list entry from file
 
55
        entry = alarm_list_entry_new_file("file:///usr/share/sounds/question.wav", &result, &mime);
 
56
        entry_dump (entry);
 
57
        g_print ("VFSResult: %s, MIME: %s\n", gnome_vfs_result_to_string(result), mime);
 
58
        alarm_list_entry_free (entry);
 
59
        g_free (mime);
 
60
        
 
61
        // Test alarm list
 
62
        list = alarm_list_entry_list_new ("file:///usr/share/sounds/", NULL);
 
63
        
 
64
        g_print ("\nGot %d entries: \n---\n", g_list_length(list));
 
65
        for (l = list, i = 0; l; l = l->next, i++) {
 
66
                entry = (AlarmListEntry *)l->data;
 
67
                g_print ("#%2d: ", i);
 
68
                entry_dump (entry);
 
69
        }
 
70
        
 
71
        alarm_list_entry_list_free (&list);
 
72
        
 
73
        g_print ("After list_free: %p\n", list);
 
74
        
 
75
        return 0;
 
76
}