Updated French translation
[profile/ivi/rygel.git] / tests / rygel-album-art-spec-test.vala
1 /*
2  * Copyright (C) 2010 Jens Georg.
3  *
4  * Author: Jens Georg <mail@jensge.org>
5  *
6  * This file is part of Rygel.
7  *
8  * Rygel is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * Rygel is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program; if not, write to the Free Software Foundation,
20  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  */
22
23 public abstract class Rygel.MediaItem : GLib.Object {
24     public string title;
25 }
26
27 public class Rygel.AudioItem : MediaItem {}
28
29 public class Rygel.MusicItem : AudioItem {
30     public string artist;
31     public string album;
32 }
33
34 private class Rygel.AlbumArtSpecTest : GLib.Object {
35     public static int main (string[] args) {
36         var test = new AlbumArtSpecTest ();
37
38         test.run ();
39
40         return 0;
41     }
42
43     public void run() {
44         this.test_full_spec ();
45         //this.test_simple_spec ();
46
47         /* This is just here to avoid a warning about an unused method: */
48         var thumbnail = new Thumbnail();
49         var didl_writer = new GUPnP.DIDLLiteWriter (null);
50         var didl_item = didl_writer.add_item ();
51         thumbnail.add_resource(didl_item, "http");
52     }
53
54     public void test_full_spec () {
55         var store = MediaArtStore.get_default ();
56         var item = new MusicItem ();
57         item.artist = "metallica";
58         item.album = "and justice for all";
59         item.title = "Enter Sandman";
60         var file = store.get_media_art_file ("album", item);
61         assert (file != null);
62         assert (file.get_uri ().has_suffix
63                 ("album-" +
64                  "3c2234a7ce973bc1700e0c743d6a819c-" +
65                  "3d422ba022ae0daa8f5454ba7dfa0f9a.jpeg"));
66
67         file = store.get_media_art_file ("artist", item);
68         assert (file != null);
69         assert (file.get_uri ().has_suffix
70                 ("artist-" +
71                  "3c2234a7ce973bc1700e0c743d6a819c-" +
72                  "3d422ba022ae0daa8f5454ba7dfa0f9a.jpeg"));
73
74         item = new MusicItem ();
75         item.title = "radio ga ga";
76         file = store.get_media_art_file ("radio", item);
77         assert (file != null);
78         assert (file.get_uri ().has_suffix
79                 ("radio-" +
80                  "b924ce08955675c6a30c745d18286d21-" +
81                  "7215ee9c7d9dc229d2921a40e899ec5f.jpeg"));
82
83         item = new MusicItem ();
84         item.artist = "met[xXx]allica";
85         item.album = "and justice f[{]}or all";
86         item.title = "Enter Sandman";
87         file = store.get_media_art_file ("album", item);
88         assert (file != null);
89         assert (file.get_uri ().has_suffix
90                 ("album-" +
91                  "3c2234a7ce973bc1700e0c743d6a819c-" +
92                  "3d422ba022ae0daa8f5454ba7dfa0f9a.jpeg"));
93
94         // check block removal algorithm - normalizes to "metallica" and not
95         // "metca"
96         item = new MusicItem ();
97         item.artist = "met[xX[x]alli]ca";
98         item.album = "and justice for all";
99         item.title = "Enter Sandman";
100         file = store.get_media_art_file ("album", item);
101         assert (file != null);
102         assert (file.get_uri ().has_suffix
103                 ("album-" +
104                  "3c2234a7ce973bc1700e0c743d6a819c-" +
105                  "3d422ba022ae0daa8f5454ba7dfa0f9a.jpeg"));
106
107         /* Fails due to unclear spec
108         item = new MusicItem ();
109         item.artist = "World Soccer";
110         item.title = "Daily Podcast";
111         file = store.get_media_art_file ("podcast", item);
112         assert (file != null);
113         assert (file.get_uri ().has_suffix
114                 ("podcast-" +
115                  "d717b10ec8fb35b11644995deb04b721-" +
116                  "08d299536e562915eb133e2676396d3f.jpeg"));
117                 */
118
119         // test banshee spec
120         item = new MusicItem ();
121         item.artist = "Peter Fox";
122         item.album = "Stadtaffe";
123         item.title = "Schwarz zu Blau";
124         file = store.get_media_art_file ("album", item, true);
125         assert (file != null);
126         debug (file.get_uri());
127         assert (file.get_uri ().has_suffix
128                 ("album-15f9f69ee3d841df6b1e2f56439f11a2.jpg"));
129     }
130 }