]> git.sesse.net Git - vlc/blob - test/libvlc/meta.c
c969a01b9726b0099947b19a7918dc413265eb57
[vlc] / test / libvlc / meta.c
1 /*
2  * meta.c - libvlc smoke test
3  *
4  * $Id$
5  */
6
7 /**********************************************************************
8  *  Copyright (C) 2007 RĂ©mi Denis-Courmont.                           *
9  *  Copyright (C) 2008 Pierre d'Herbemont.                            *
10  *  This program is free software; you can redistribute and/or modify *
11  *  it under the terms of the GNU General Public License as published *
12  *  by the Free Software Foundation; version 2 of the license, or (at *
13  *  your option) any later version.                                   *
14  *                                                                    *
15  *  This program is distributed in the hope that it will be useful,   *
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of    *
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.              *
18  *  See the GNU General Public License for more details.              *
19  *                                                                    *
20  *  You should have received a copy of the GNU General Public License *
21  *  along with this program; if not, you can get it from:             *
22  *  http://www.gnu.org/copyleft/gpl.html                              *
23  **********************************************************************/
24
25 #include <strings.h>
26
27 #include "test.h"
28
29 static void test_meta (const char ** argv, int argc)
30 {
31     libvlc_instance_t *vlc;
32     libvlc_media_t *media;
33     char * artist;
34
35     log ("Testing meta\n");
36
37     libvlc_exception_init (&ex);
38     vlc = libvlc_new (argc, argv, &ex);
39     catch ();
40
41     media = libvlc_media_new (vlc, "samples/meta.sample", &ex);
42     catch ();
43
44     /* Tell that we are interested in this precise meta data
45      * This is needed to trigger meta data reading
46      * (the first calls return NULL) */
47     artist = libvlc_media_get_meta (media, libvlc_meta_Artist);
48
49     free (artist);
50
51     /* Wait for the meta */
52     while (!libvlc_media_is_preparsed (media))
53     {
54         usleep (10000);
55     }
56
57     artist = libvlc_media_get_meta (media, libvlc_meta_Artist);
58
59     const char *expected_artist = "mike";
60
61     assert (artist);
62     log ("+ got '%s' as Artist, expecting %s\n", artist, expected_artist);
63
64     int string_compare = strcmp (artist, expected_artist);
65     assert (!string_compare);
66
67     free (artist);
68     libvlc_media_release (media);
69     libvlc_release (vlc);
70 }
71
72
73 int main (void)
74 {
75     test_init();
76
77     test_meta (test_defaults_args, test_defaults_nargs);
78
79     return 0;
80 }