~ubuntu-branches/ubuntu/saucy/totem/saucy-proposed

« back to all changes in this revision

Viewing changes to src/test-parser.c

  • Committer: Bazaar Package Importer
  • Author(s): Loic Minier, Sebastien Bacher, Loic Minier
  • Date: 2007-03-08 14:51:55 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070308145155-cnu1r0s1z4ffcxza
Tags: 2.16.5-3
[ Sebastien Bacher ]
* debian/patches/30_dlopen_noremove_dbus_glib.dpatch:
  - fix "crash because NPPVpluginKeepLibraryInMemory is broken in gecko",
    patch from Alexander Sack (GNOME bug #415389)

[ Loic Minier ]
* Urgency medium.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
#include <glib.h>
3
 
#include <libgnomevfs/gnome-vfs.h>
4
 
 
5
 
#include "totem-pl-parser.c"
6
 
 
7
 
static GMainLoop *loop = NULL;
8
 
 
9
 
static void
10
 
header (const char *message)
11
 
{
12
 
        g_print ("\n");
13
 
        g_print ("###################### %s ################\n", message);
14
 
        g_print ("\n");
15
 
}
16
 
 
17
 
static void
18
 
test_relative_real (const char *url, const char *output)
19
 
{
20
 
        char *base, *dos;
21
 
 
22
 
        g_print ("url: %s\n", url);
23
 
        g_print ("output: %s\n", output);
24
 
        base = totem_pl_parser_relative (url, output);
25
 
        if (base) {
26
 
                g_print ("relative path: %s\n", base);
27
 
        } else {
28
 
                g_print ("no relative path\n");
29
 
        }
30
 
        dos = totem_pl_parser_url_to_dos (url, output);
31
 
        g_print ("DOS path: %s\n", dos);
32
 
        g_print ("\n");
33
 
 
34
 
        g_free (base);
35
 
        g_free (dos);
36
 
}
37
 
 
38
 
static void
39
 
test_relative (void)
40
 
{
41
 
        header ("relative");
42
 
 
43
 
        test_relative_real ("/home/hadess/test/test file.avi",
44
 
                        "/home/hadess/foobar.m3u");
45
 
        test_relative_real ("file:///home/hadess/test/test%20file.avi",
46
 
                        "/home/hadess/whatever.m3u");
47
 
        test_relative_real ("smb://server/share/file.mp3",
48
 
                        "/home/hadess/whatever again.m3u");
49
 
        test_relative_real ("smb://server/share/file.mp3",
50
 
                        "smb://server/share/file.m3u");
51
 
        test_relative_real ("/home/hadess/test.avi",
52
 
                        "/home/hadess/test/file.m3u");
53
 
        test_relative_real ("http://foobar.com/test.avi",
54
 
                        "/home/hadess/test/file.m3u");
55
 
}
56
 
 
57
 
static void
58
 
entry_added (TotemPlParser *parser, const char *uri, const char *title,
59
 
                const char *genre, gpointer data)
60
 
{
61
 
        g_print ("added URI '%s' with title '%s'\n", uri,
62
 
                        title ? title : "empty");
63
 
}
64
 
 
65
 
static void
66
 
test_parsing_real (TotemPlParser *pl, const char *url)
67
 
{
68
 
        TotemPlParserResult res;
69
 
 
70
 
        res = totem_pl_parser_parse (pl, url, FALSE);
71
 
        if (res != TOTEM_PL_PARSER_RESULT_SUCCESS) {
72
 
                switch (res) {
73
 
                case TOTEM_PL_PARSER_RESULT_UNHANDLED:
74
 
                        g_print ("url '%s' unhandled\n", url);
75
 
                        break;
76
 
                case TOTEM_PL_PARSER_RESULT_ERROR:
77
 
                        g_print ("error handling url '%s'\n", url);
78
 
                        break;
79
 
                default:
80
 
                        ;;
81
 
                }
82
 
        }
83
 
}
84
 
 
85
 
static gboolean
86
 
push_parser (gpointer data)
87
 
{
88
 
        TotemPlParser *pl = (TotemPlParser *)data;
89
 
        test_parsing_real (pl, "/mnt/cdrom");
90
 
        test_parsing_real (pl, "http://live.hujjat.org:7860/main");
91
 
        g_main_loop_quit (loop);
92
 
        return FALSE;
93
 
}
94
 
 
95
 
static void
96
 
test_parsing (void)
97
 
{
98
 
        TotemPlParser *pl = totem_pl_parser_new ();
99
 
        g_signal_connect (G_OBJECT (pl), "entry", G_CALLBACK (entry_added), NULL);
100
 
 
101
 
        header ("parsing");
102
 
        g_timeout_add (1000, push_parser, pl);
103
 
        loop = g_main_loop_new (NULL, FALSE);
104
 
        g_main_loop_run (loop);
105
 
}
106
 
 
107
 
int main (int argc, char **argv)
108
 
{
109
 
        gnome_vfs_init();
110
 
 
111
 
        test_relative ();
112
 
 
113
 
        test_parsing ();
114
 
 
115
 
        return 0;
116
 
}
117