Updated Portuguese translation
[banshee.git] / build / GSettingsSchemaExtractorTests.cs
blob2e91980ecc7fb30a712769d3fd76b2fe73c40d2c
1 //
2 // GSettingsExtractorTests.cs
3 //
4 // Author:
5 // Andres G. Aragoneses <knocte@gmail.com>
6 //
7 // Copyright 2012 Andres G. Aragoneses
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining a copy
10 // of this software and associated documentation files (the "Software"), to deal
11 // in the Software without restriction, including without limitation the rights
12 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 // copies of the Software, and to permit persons to whom the Software is
14 // furnished to do so, subject to the following conditions:
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 // THE SOFTWARE.
27 #if ENABLE_TESTS
29 using System;
30 using System.Text;
32 using Banshee.Configuration;
34 using NUnit.Framework;
36 namespace GSettingsSchemaExtractor
38 [TestFixture]
39 public class Tests
41 internal class StringType {
42 public static readonly SchemaEntry<string> DefaultExportFormat = new SchemaEntry<string> (
43 "player_window", "default_export_format",
44 "m3u",
45 "Export Format",
46 "The default playlist export format"
50 [Test]
51 public void SchemaWithString ()
53 StringBuilder result = GSettingsSchemaExtractorProgram.Extract (new Type [] { typeof (StringType) });
55 Assert.That (result, Is.Not.Null);
56 Assert.That (result.ToString ().Trim (), Is.EqualTo (@"
57 <schemalist>
58 <schema id=""org.gnome.banshee.player_window"" path=""/apps/banshee/player_window/"" gettext-domain=""banshee"">
59 <key name=""default-export-format"" type=""s"">
60 <default>'m3u'</default>
61 <summary>Export Format</summary>
62 <description>The default playlist export format</description>
63 </key>
64 </schema>
65 </schemalist>"
66 .Trim ()));
70 internal class BooleanType
72 public static readonly SchemaEntry<bool> ShowInitialImportDialog = new SchemaEntry<bool>(
73 "import", "show_initial_import_dialog",
74 true,
75 "Show the Initial Import Dialog",
76 "Show the Initial Import Dialog when the Banshee library is empty"
80 [Test]
81 public void SchemaWithBoolean ()
83 StringBuilder result = GSettingsSchemaExtractorProgram.Extract (new Type [] { typeof (BooleanType) });
85 Assert.That (result, Is.Not.Null);
86 Assert.That (result.ToString ().Trim (), Is.EqualTo (@"
87 <schemalist>
88 <schema id=""org.gnome.banshee.import"" path=""/apps/banshee/import/"" gettext-domain=""banshee"">
89 <key name=""show-initial-import-dialog"" type=""b"">
90 <default>true</default>
91 <summary>Show the Initial Import Dialog</summary>
92 <description>Show the Initial Import Dialog when the Banshee library is empty</description>
93 </key>
94 </schema>
95 </schemalist>"
96 .Trim ()));
99 internal class IntegerType {
100 public static readonly SchemaEntry<int> VolumeSchema = new SchemaEntry<int> (
101 "player_engine", "volume",
103 "Volume",
104 "Volume of playback relative to mixer output"
108 [Test]
109 public void SchemaWithInt ()
111 StringBuilder result = GSettingsSchemaExtractorProgram.Extract (new Type [] { typeof (IntegerType) });
113 Assert.That (result, Is.Not.Null);
114 Assert.That (result.ToString ().Trim (), Is.EqualTo (@"
115 <schemalist>
116 <schema id=""org.gnome.banshee.player_engine"" path=""/apps/banshee/player_engine/"" gettext-domain=""banshee"">
117 <key name=""volume"" type=""i"">
118 <default>80</default>
119 <summary>Volume</summary>
120 <description>Volume of playback relative to mixer output</description>
121 </key>
122 </schema>
123 </schemalist>"
124 .Trim ()));
127 internal class DoubleType {
128 public static readonly SchemaEntry<double> CoverArtSize = new SchemaEntry<double> (
129 "player_window", "cover_art_size",
130 20.5,
131 "Cover art size",
132 "Surface size of cover art in the album grid"
136 [Test]
137 public void SchemaWithDouble ()
139 StringBuilder result = GSettingsSchemaExtractorProgram.Extract (new Type [] { typeof (DoubleType) });
141 Assert.That (result, Is.Not.Null);
142 Assert.That (result.ToString ().Trim (), Is.EqualTo (@"
143 <schemalist>
144 <schema id=""org.gnome.banshee.player_window"" path=""/apps/banshee/player_window/"" gettext-domain=""banshee"">
145 <key name=""cover-art-size"" type=""d"">
146 <default>20.5</default>
147 <summary>Cover art size</summary>
148 <description>Surface size of cover art in the album grid</description>
149 </key>
150 </schema>
151 </schemalist>"
152 .Trim ()));
155 internal class ArrayType {
156 public static readonly SchemaEntry<string[]> CurrentFiltersSchema = new SchemaEntry<string[]> (
157 "sources.fsq", "current_filters",
158 new string[] { "album", "artist" },
159 null,
160 null
164 [Test]
165 public void SchemaWithArray ()
167 StringBuilder result = GSettingsSchemaExtractorProgram.Extract (new Type [] { typeof (ArrayType) });
169 Assert.That (result, Is.Not.Null);
170 Assert.That (result.ToString ().Trim (), Is.EqualTo (@"
171 <schemalist>
172 <schema id=""org.gnome.banshee.sources.fsq"" path=""/apps/banshee/sources/fsq/"" gettext-domain=""banshee"">
173 <key name=""current-filters"" type=""as"">
174 <default>['album','artist']</default>
175 <summary></summary>
176 <description></description>
177 </key>
178 </schema>
179 </schemalist>"
180 .Trim ()));
183 internal class ArrayTypeWithEmptyDefaultValue {
184 public static readonly SchemaEntry<string[]> CurrentFiltersSchema = new SchemaEntry<string[]> (
185 "sources.fsq", "current_filters",
186 new string [0],
187 null,
188 null
192 [Test]
193 public void SchemaWithEmptyArrayAsDefaultValue ()
195 StringBuilder result = GSettingsSchemaExtractorProgram.Extract (new Type [] { typeof (ArrayTypeWithEmptyDefaultValue) });
197 Assert.That (result, Is.Not.Null);
198 Assert.That (result.ToString ().Trim (), Is.EqualTo (@"
199 <schemalist>
200 <schema id=""org.gnome.banshee.sources.fsq"" path=""/apps/banshee/sources/fsq/"" gettext-domain=""banshee"">
201 <key name=""current-filters"" type=""as"">
202 <default>[]</default>
203 <summary></summary>
204 <description></description>
205 </key>
206 </schema>
207 </schemalist>"
208 .Trim ()));
211 [Test]
212 public void SchemaWithMoreThanOneKey ()
214 StringBuilder result = GSettingsSchemaExtractorProgram.Extract (
215 new Type [] { typeof (IntegerType), typeof (DoubleType), typeof (StringType) });
217 Assert.That (result, Is.Not.Null);
218 Assert.That (result.ToString ().Trim (), Is.EqualTo (@"
219 <schemalist>
220 <schema id=""org.gnome.banshee.player_engine"" path=""/apps/banshee/player_engine/"" gettext-domain=""banshee"">
221 <key name=""volume"" type=""i"">
222 <default>80</default>
223 <summary>Volume</summary>
224 <description>Volume of playback relative to mixer output</description>
225 </key>
226 </schema>
227 <schema id=""org.gnome.banshee.player_window"" path=""/apps/banshee/player_window/"" gettext-domain=""banshee"">
228 <key name=""cover-art-size"" type=""d"">
229 <default>20.5</default>
230 <summary>Cover art size</summary>
231 <description>Surface size of cover art in the album grid</description>
232 </key>
233 <key name=""default-export-format"" type=""s"">
234 <default>'m3u'</default>
235 <summary>Export Format</summary>
236 <description>The default playlist export format</description>
237 </key>
238 </schema>
239 </schemalist>"
240 .Trim ()));
243 internal class StringTypeWithNullDefaultValue {
244 public static readonly SchemaEntry<string> LastScrobbleUrlSchema = new SchemaEntry<string> (
245 "plugins.audioscrobbler", "api_url",
246 null,
247 "AudioScrobbler API URL",
248 "URL for the AudioScrobbler API (supports turtle.libre.fm, for instance)"
252 [Test]
253 public void SchemaWithNullDefaultValue ()
255 StringBuilder result = GSettingsSchemaExtractorProgram.Extract (new Type [] { typeof (StringTypeWithNullDefaultValue) });
257 Assert.That (result, Is.Not.Null);
258 Assert.That (result.ToString ().Trim (), Is.EqualTo (@"
259 <schemalist>
260 <schema id=""org.gnome.banshee.plugins.audioscrobbler"" path=""/apps/banshee/plugins/audioscrobbler/"" gettext-domain=""banshee"">
261 <key name=""api-url"" type=""s"">
262 <default>''</default>
263 <summary>AudioScrobbler API URL</summary>
264 <description>URL for the AudioScrobbler API (supports turtle.libre.fm, for instance)</description>
265 </key>
266 </schema>
267 </schemalist>"
268 .Trim ()));
271 internal class TypeWithInternalSchema {
272 internal static readonly SchemaEntry<int> VolumeSchema = new SchemaEntry<int> (
273 "player_engine", "volume",
275 "Volume",
276 "Volume of playback relative to mixer output"
280 [Test]
281 public void SchemaNonPublic ()
283 StringBuilder result = GSettingsSchemaExtractorProgram.Extract (new Type [] { typeof (TypeWithInternalSchema) });
285 Assert.That (result, Is.Not.Null);
286 Assert.That (result.ToString ().Trim (), Is.StringContaining ("<schema id="));
292 #endif