Merge lp:~unity-team/unity/favorite-store-update into lp:unity

Proposed by Neil J. Patel on 2010-11-24
Status: Merged
Approved by: Neil J. Patel on 2010-11-24
Approved revision: 627
Merge reported by: Neil J. Patel
Merged at revision: not available
Proposed branch: lp:~unity-team/unity/favorite-store-update
Merge into: lp:unity
Diff against target: 666 lines (+424/-40)
7 files modified
CMakeLists.txt (+2/-2)
src/FavoriteStore.h (+9/-3)
src/FavoriteStoreGSettings.cpp (+139/-27)
src/FavoriteStoreGSettings.h (+2/-2)
tests/CMakeLists.txt (+6/-0)
tests/data/update-manager.desktop (+10/-0)
tests/unit/TestFavoriteStoreGSettings.cpp (+256/-6)
To merge this branch: bzr merge lp:~unity-team/unity/favorite-store-update
Reviewer Review Type Date Requested Status
Jason Smith (community) 2010-11-24 Needs Fixing on 2010-11-24
Review via email: mp+41783@code.launchpad.net

Description of the Change

- Makes the FavoritesStore GSettings implementation aware of /path/to/desktop/files as well as normal desktop ids
- Converts paths to desktop ids unless they fall out of the standard XDG_DATA_DIRS
- Fixes AddFavorite
- Fixes RemoveFavorite
- Adds MoveFavorite
- Adds tests for the above

The main thing missing here is all the signalling if someone else changes dconf outside of Unity, but this should cover at least what Unity needs to do right now.

To post a comment you must log in.
Jason Smith (jassmith) wrote :

CMakeLists.txt has merge cruft left in it

review: Needs Fixing

Apart from the conflict mentioned by Jason this looks good to me. So
approved modulo that :-)

627. By Neil J. Patel on 2010-11-24

[merge] trunk

Neil J. Patel (njpatel) wrote :

Thanks guys, fixed, merged and pushed :)

Didier Roche (didrocks) wrote :

"fixed, merged" -> maybe
"pushed" -> definitively not. I'm sooooooooo disappointed :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2010-11-24 15:25:33 +0000
3+++ CMakeLists.txt 2010-11-24 21:47:12 +0000
4@@ -1,4 +1,4 @@
5-project (unity)
6+ project (unity)
7 cmake_minimum_required(VERSION 2.8)
8
9 subdirs (libunity services tests)
10@@ -74,7 +74,7 @@
11 #
12 # src (Compiz Plugin)
13 #
14-set (UNITY_PLUGIN_DEPS "nux-0.9;libbamf;dbus-glib-1;dee-1.0;gio-2.0;gio-unix-2.0;dbusmenu-glib;x11;libstartup-notification-1.0")
15+set (UNITY_PLUGIN_DEPS "nux-0.9;libbamf;dbus-glib-1;dee-1.0;gio-2.0;gio-unix-2.0;dbusmenu-glib;x11;libstartup-notification-1.0;gthread-2.0")
16
17 find_package (Compiz REQUIRED)
18 include (CompizPlugin)
19
20=== modified file 'src/FavoriteStore.h'
21--- src/FavoriteStore.h 2010-11-03 11:44:21 +0000
22+++ src/FavoriteStore.h 2010-11-24 21:47:12 +0000
23@@ -46,12 +46,18 @@
24 // DO NOT RELY ON THE CHAR *, STRDUP THEM
25 virtual GSList * GetFavorites () = 0;
26
27- // These will emit the relevant signals, so bare that in mind
28- virtual void AddFavorite (const char *desktop_path, guint32 position) = 0;
29+ // These will NOT emit the relevant signals, so bare that in mind
30+ // i.e. don't hope that you can add stuff and hook the view up to
31+ // favorite_added events to update the view. The signals only emit if
32+ // there has been a change on the GSettings object from an external
33+ // source
34+ virtual void AddFavorite (const char *desktop_path, gint position) = 0;
35 virtual void RemoveFavorite (const char *desktop_path) = 0;
36- virtual void MoveFavorite (const char *desktop_path, guint32 position) = 0;
37+ virtual void MoveFavorite (const char *desktop_path, gint position) = 0;
38
39 // Signals
40+ // Therse only emit if something has changed the GSettings object externally
41+
42 //desktop_path, position
43 sigc::signal<void, const char *, guint32> favorite_added;
44
45
46=== modified file 'src/FavoriteStoreGSettings.cpp'
47--- src/FavoriteStoreGSettings.cpp 2010-11-04 12:48:48 +0000
48+++ src/FavoriteStoreGSettings.cpp 2010-11-24 21:47:12 +0000
49@@ -20,9 +20,11 @@
50
51 #include "FavoriteStoreGSettings.h"
52
53+#define SETTINGS_NAME "com.canonical.Unity.Launcher"
54+
55 FavoriteStoreGSettings::FavoriteStoreGSettings ()
56 {
57- m_settings = g_settings_new ("com.canonical.Unity.Launcher");
58+ m_settings = g_settings_new (SETTINGS_NAME);
59 m_favorites = NULL;
60
61 Refresh ();
62@@ -30,7 +32,7 @@
63
64 FavoriteStoreGSettings::FavoriteStoreGSettings (GSettingsBackend *backend)
65 {
66- m_settings = g_settings_new_with_backend ("com.canonical.Unity.Launcher", backend);
67+ m_settings = g_settings_new_with_backend (SETTINGS_NAME, backend);
68 m_favorites = NULL;
69
70 Refresh ();
71@@ -52,27 +54,46 @@
72
73 g_slist_foreach (m_favorites, (GFunc)g_free, NULL);
74 g_slist_free (m_favorites);
75+ m_favorites = NULL;
76
77 favs = g_settings_get_strv (m_settings, "favorites");
78
79 while (favs[i] != NULL)
80 {
81- GDesktopAppInfo *info;
82-
83- info = g_desktop_app_info_new (favs[i]);
84-
85- if (info == NULL || g_desktop_app_info_get_filename (info) == NULL)
86- {
87- g_warning ("Unable to load GDesktopAppInfo for '%s'", favs[i]);
88-
89- i++;
90- continue;
91- }
92-
93- m_favorites = g_slist_append (m_favorites, g_strdup (g_desktop_app_info_get_filename (info)));
94+ /*
95+ * We will be storing either full /path/to/desktop/files or foo.desktop id's
96+ */
97+ if (favs[i][0] == '/')
98+ {
99+ if (g_file_test (favs[i], G_FILE_TEST_EXISTS))
100+ {
101+ m_favorites = g_slist_append (m_favorites, g_strdup (favs[i]));
102+ }
103+ else
104+ {
105+ g_warning ("Unable to load desktop file: %s", favs[i]);
106+ }
107+ }
108+ else
109+ {
110+ GDesktopAppInfo *info;
111+
112+ info = g_desktop_app_info_new (favs[i]);
113+
114+ if (info == NULL || g_desktop_app_info_get_filename (info) == NULL)
115+ {
116+ g_warning ("Unable to load GDesktopAppInfo for '%s'", favs[i]);
117+
118+ i++;
119+ continue;
120+ }
121+
122+ m_favorites = g_slist_append (m_favorites, g_strdup (g_desktop_app_info_get_filename (info)));
123+
124+ g_object_unref (info);
125+ }
126+
127 i++;
128-
129- g_object_unref (info);
130 }
131
132 g_strfreev (favs);
133@@ -84,16 +105,42 @@
134 return m_favorites;
135 }
136
137+static gchar *
138+get_basename_or_path (const gchar *desktop_path)
139+{
140+ const gchar * const * dirs;
141+ const gchar * dir;
142+ gint i = 0;
143+
144+ dirs = g_get_system_data_dirs ();
145+
146+ /* We check to see if the desktop file belongs to one of the system data
147+ * directories. If so, then we store it's desktop id, otherwise we store
148+ * it's full path. We're clever like that.
149+ */
150+ while ((dir = dirs[i]))
151+ {
152+ if (g_str_has_prefix (desktop_path, dir))
153+ {
154+ return g_path_get_basename (desktop_path);
155+ }
156+ i++;
157+ }
158+
159+ return g_strdup (desktop_path);
160+}
161+
162 void
163 FavoriteStoreGSettings::AddFavorite (const char *desktop_path,
164- guint32 position)
165+ gint position)
166 {
167 int n_total_favs;
168 GSList *f;
169- guint32 i = 0;
170+ gint i = 0;
171
172 g_return_if_fail (desktop_path);
173-
174+ g_return_if_fail (position < (gint)g_slist_length (m_favorites));
175+
176 n_total_favs = g_slist_length (m_favorites) + 1;
177
178 char *favs[n_total_favs + 1];
179@@ -103,17 +150,23 @@
180 {
181 if (i == position)
182 {
183- favs[i] = g_path_get_basename (desktop_path);
184+ favs[i] = get_basename_or_path (desktop_path);
185 i++;
186 }
187
188- favs[i] = g_path_get_basename ((char *)f->data);
189+ favs[i] = get_basename_or_path ((char *)f->data);
190
191 i++;
192 }
193
194+ /* Add it to the end of the list */
195+ if (position == -1)
196+ {
197+ favs[i] = get_basename_or_path (desktop_path);
198+ }
199+
200 if (!g_settings_set_strv (m_settings, "favorites", favs))
201- g_warning ("Unable to add a new favorite");
202+ g_warning ("Unable to add a new favorite '%s' at position '%u'", desktop_path, position);
203
204 i = 0;
205 while (favs[i] != NULL)
206@@ -132,8 +185,10 @@
207 int n_total_favs;
208 GSList *f;
209 int i = 0;
210+ bool found = false;
211
212 g_return_if_fail (desktop_path);
213+ g_return_if_fail (desktop_path[0] == '/');
214
215 n_total_favs = g_slist_length (m_favorites) - 1;
216
217@@ -142,15 +197,25 @@
218
219 for (f = m_favorites; f; f = f->next)
220 {
221- if (g_strcmp0 ((char *)f->data, desktop_path))
222+ if (g_strcmp0 ((char *)f->data, desktop_path) != 0)
223 {
224- favs[i] = g_path_get_basename ((char *)f->data);
225+ favs[i] = get_basename_or_path ((char *)f->data);
226 i++;
227 }
228+ else
229+ {
230+ found = true;
231+ }
232+ }
233+
234+ if (!found)
235+ {
236+ g_warning ("Unable to remove favorite '%s': Does not exist in favorites",
237+ desktop_path);
238 }
239
240 if (!g_settings_set_strv (m_settings, "favorites", favs))
241- g_warning ("Unable to add a new favorite");
242+ g_warning ("Unable to remove favorite '%s'", desktop_path);
243
244 i = 0;
245 while (favs[i] != NULL)
246@@ -165,6 +230,53 @@
247
248 void
249 FavoriteStoreGSettings::MoveFavorite (const char *desktop_path,
250- guint32 position)
251+ gint position)
252 {
253+ int n_total_favs;
254+ GSList *f;
255+ gint i = 0;
256+
257+ g_return_if_fail (desktop_path);
258+ g_return_if_fail (position < (gint)g_slist_length (m_favorites));
259+
260+ n_total_favs = g_slist_length (m_favorites);
261+
262+ char *favs[n_total_favs + 1];
263+ favs[n_total_favs] = NULL;
264+
265+ for (f = m_favorites; f; f = f->next)
266+ {
267+ if (i == position)
268+ {
269+ favs[i] = get_basename_or_path (desktop_path);
270+ i++;
271+ }
272+
273+ if (g_strcmp0 (desktop_path, (char *)f->data) != 0)
274+ {
275+ favs[i] = get_basename_or_path ((char *)f->data);
276+ i++;
277+ }
278+ }
279+
280+ /* Add it to the end of the list */
281+ if (position == -1)
282+ {
283+ favs[i] = get_basename_or_path (desktop_path);
284+ i++;
285+ }
286+ favs[i] = NULL;
287+
288+ if (!g_settings_set_strv (m_settings, "favorites", favs))
289+ g_warning ("Unable to add a new favorite '%s' at position '%u'", desktop_path, position);
290+
291+ i = 0;
292+ while (favs[i] != NULL)
293+ {
294+ g_free (favs[i]);
295+ favs[i] = NULL;
296+ i++;
297+ }
298+
299+ Refresh ();
300 }
301
302=== modified file 'src/FavoriteStoreGSettings.h'
303--- src/FavoriteStoreGSettings.h 2010-11-04 12:48:48 +0000
304+++ src/FavoriteStoreGSettings.h 2010-11-24 21:47:12 +0000
305@@ -36,9 +36,9 @@
306
307 //Methods
308 virtual GSList * GetFavorites ();
309- virtual void AddFavorite (const char *desktop_path, guint32 position);
310+ virtual void AddFavorite (const char *desktop_path, gint position);
311 virtual void RemoveFavorite (const char *desktop_path);
312- virtual void MoveFavorite (const char *desktop_path, guint32 position);
313+ virtual void MoveFavorite (const char *desktop_path, gint position);
314
315 private:
316 void Refresh ();
317
318=== modified file 'tests/CMakeLists.txt'
319--- tests/CMakeLists.txt 2010-11-18 16:25:14 +0000
320+++ tests/CMakeLists.txt 2010-11-24 21:47:12 +0000
321@@ -1,4 +1,10 @@
322 #
323+# Data
324+#
325+configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/update-manager.desktop
326+ ${CMAKE_BINARY_DIR}/tests/data/update-manager.desktop)
327+
328+#
329 # Unit tests
330 #
331 find_package (PkgConfig)
332
333=== added directory 'tests/data'
334=== added file 'tests/data/update-manager.desktop'
335--- tests/data/update-manager.desktop 1970-01-01 00:00:00 +0000
336+++ tests/data/update-manager.desktop 2010-11-24 21:47:12 +0000
337@@ -0,0 +1,10 @@
338+[Desktop Entry]
339+Name=Update Manager
340+GenericName=Software Updates
341+Comment=Show and install available updates
342+Exec=/usr/bin/update-manager
343+Icon=update-manager
344+Terminal=false
345+Type=Application
346+Categories=System;Settings;
347+X-Ubuntu-Gettext-Domain=update-manager
348
349=== modified file 'tests/unit/TestFavoriteStoreGSettings.cpp'
350--- tests/unit/TestFavoriteStoreGSettings.cpp 2010-11-05 14:43:07 +0000
351+++ tests/unit/TestFavoriteStoreGSettings.cpp 2010-11-24 21:47:12 +0000
352@@ -28,23 +28,51 @@
353 #include "FavoriteStore.h"
354 #include "FavoriteStoreGSettings.h"
355
356+#define CUSTOM_DESKTOP BUILDDIR"/tests/data/update-manager.desktop"
357+
358 #define BASE_STORE_FILE BUILDDIR"/settings/test-favorite-store-gsettings.store"
359 #define BASE_STORE_CONTENTS "[desktop/unity/launcher]\n" \
360- "favorites=['evolution.desktop', 'firefox.desktop']"
361+ "favorites=['evolution.desktop', 'firefox.desktop', '%s']"
362
363-static const char *base_store_favs[] = { "evolution.desktop", "firefox.desktop", NULL };
364-static int n_base_store_favs = 2;
365+static const char *base_store_favs[] = { "evolution.desktop",
366+ "firefox.desktop",
367+ CUSTOM_DESKTOP,
368+ NULL };
369+static int n_base_store_favs = G_N_ELEMENTS (base_store_favs) - 1; /* NULL */
370
371 static void TestAllocation (void);
372 static void TestGetFavorites (void);
373
374+static void TestAddFavorite (void);
375+static void TestAddFavoritePosition (void);
376+static void TestAddFavoriteLast (void);
377+static void TestAddFavoriteOutOfRange (void);
378+
379+static void TestRemoveFavorite (void);
380+static void TestRemoveFavoriteBad (void);
381+
382+static void TestMoveFavorite (void);
383+static void TestMoveFavoriteBad (void);
384+
385 void
386 TestFavoriteStoreGSettingsCreateSuite ()
387 {
388 #define _DOMAIN "/Unit/FavoriteStoreGSettings"
389
390 g_test_add_func (_DOMAIN"/Allocation", TestAllocation);
391+
392 g_test_add_func (_DOMAIN"/GetFavorites", TestGetFavorites);
393+
394+ g_test_add_func (_DOMAIN"/AddFavorite", TestAddFavorite);
395+ g_test_add_func (_DOMAIN"/AddFavoritePosition", TestAddFavoritePosition);
396+ g_test_add_func (_DOMAIN"/AddFavoriteLast", TestAddFavoriteLast);
397+ g_test_add_func (_DOMAIN"/AddFavoriteOutOfRange", TestAddFavoriteOutOfRange);
398+
399+ g_test_add_func (_DOMAIN"/RemoveFavorite", TestRemoveFavorite);
400+ g_test_add_func (_DOMAIN"/RemoveFavoriteBad", TestRemoveFavoriteBad);
401+
402+ g_test_add_func (_DOMAIN"/MoveFavorite", TestMoveFavorite);
403+ g_test_add_func (_DOMAIN"/MoveFavoriteBad", TestMoveFavoriteBad);
404 }
405
406 static GSettingsBackend *
407@@ -52,23 +80,34 @@
408 {
409 GSettingsBackend *b;
410 GError *error = NULL;
411+ gchar *contents = NULL;
412+
413+ contents = g_strdup_printf (BASE_STORE_CONTENTS, CUSTOM_DESKTOP);
414
415 g_file_set_contents (BASE_STORE_FILE,
416- BASE_STORE_CONTENTS,
417+ contents,
418 -1,
419 &error);
420 g_assert (error == NULL);
421
422 b = g_keyfile_settings_backend_new (BASE_STORE_FILE, "/", "root");
423
424+ g_free (contents);
425 return b;
426 }
427
428 static void
429 TestAllocation ()
430 {
431- FavoriteStoreGSettings *settings = new FavoriteStoreGSettings ();
432+ GSettingsBackend *backend;
433+ FavoriteStoreGSettings *settings;
434+
435+ backend = CreateDefaultKeyFileBackend ();
436+ g_assert (G_IS_SETTINGS_BACKEND (backend));
437+
438+ settings = new FavoriteStoreGSettings (backend);
439 g_assert (settings != NULL);
440+ g_object_unref (backend);
441
442 settings->UnReference ();
443 }
444@@ -97,10 +136,221 @@
445 gchar *basename;
446
447 basename = g_path_get_basename ((char*)f->data);
448- g_assert_cmpstr (basename, ==, base_store_favs[i]);
449+ if (g_strcmp0 (basename, "update-manager.desktop") == 0)
450+ g_assert_cmpstr (CUSTOM_DESKTOP, ==, base_store_favs[i]);
451+ else
452+ g_assert_cmpstr (basename, ==, base_store_favs[i]);
453
454 g_free (basename);
455 }
456
457 settings->UnReference ();
458 }
459+
460+static void
461+TestAddFavorite ()
462+{
463+#define OTHER_DESKTOP "/usr/share/applications/nautilus.desktop"
464+ GSettingsBackend *backend;
465+ FavoriteStoreGSettings *settings;
466+ GSList *favs;
467+
468+ backend = CreateDefaultKeyFileBackend ();
469+ g_assert (G_IS_SETTINGS_BACKEND (backend));
470+
471+ settings = new FavoriteStoreGSettings (backend);
472+ g_assert (settings != NULL);
473+ g_object_unref (backend);
474+
475+ settings->AddFavorite (OTHER_DESKTOP, 0);
476+
477+ favs = settings->GetFavorites ();
478+ g_assert_cmpstr ((const gchar *)g_slist_nth_data (favs, 0), ==, OTHER_DESKTOP);
479+
480+ settings->UnReference ();
481+}
482+
483+static void
484+TestAddFavoritePosition ()
485+{
486+#define OTHER_DESKTOP "/usr/share/applications/nautilus.desktop"
487+ GSettingsBackend *backend;
488+ FavoriteStoreGSettings *settings;
489+ GSList *favs;
490+
491+ backend = CreateDefaultKeyFileBackend ();
492+ g_assert (G_IS_SETTINGS_BACKEND (backend));
493+
494+ settings = new FavoriteStoreGSettings (backend);
495+ g_assert (settings != NULL);
496+ g_object_unref (backend);
497+
498+ settings->AddFavorite (OTHER_DESKTOP, 2);
499+
500+ favs = settings->GetFavorites ();
501+ g_assert_cmpstr ((const gchar *)g_slist_nth_data (favs, 2), ==, OTHER_DESKTOP);
502+
503+ settings->UnReference ();
504+}
505+
506+static void
507+TestAddFavoriteLast ()
508+{
509+#define OTHER_DESKTOP "/usr/share/applications/nautilus.desktop"
510+ GSettingsBackend *backend;
511+ FavoriteStoreGSettings *settings;
512+ GSList *favs;
513+
514+ backend = CreateDefaultKeyFileBackend ();
515+ g_assert (G_IS_SETTINGS_BACKEND (backend));
516+
517+ settings = new FavoriteStoreGSettings (backend);
518+ g_assert (settings != NULL);
519+ g_object_unref (backend);
520+
521+ settings->AddFavorite (OTHER_DESKTOP, -1);
522+
523+ favs = settings->GetFavorites ();
524+ g_assert_cmpstr ((const gchar *)g_slist_nth_data (favs, n_base_store_favs), ==, OTHER_DESKTOP);
525+
526+ settings->UnReference ();
527+}
528+
529+static void
530+TestAddFavoriteOutOfRange ()
531+{
532+#define OTHER_DESKTOP "/usr/share/applications/nautilus.desktop"
533+ GSettingsBackend *backend;
534+ FavoriteStoreGSettings *settings;
535+
536+ backend = CreateDefaultKeyFileBackend ();
537+ g_assert (G_IS_SETTINGS_BACKEND (backend));
538+
539+ settings = new FavoriteStoreGSettings (backend);
540+ g_assert (settings != NULL);
541+ g_object_unref (backend);
542+
543+ if (g_test_trap_fork (0, (GTestTrapFlags)(G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR)))
544+ {
545+ settings->AddFavorite (OTHER_DESKTOP, n_base_store_favs + 1);
546+ }
547+ g_test_trap_assert_stderr ("*g_slist_length*");
548+
549+ settings->UnReference ();
550+}
551+
552+
553+static void
554+TestRemoveFavorite ()
555+{
556+ GSettingsBackend *backend;
557+ FavoriteStoreGSettings *settings;
558+ GSList *favs;
559+
560+ backend = CreateDefaultKeyFileBackend ();
561+ g_assert (G_IS_SETTINGS_BACKEND (backend));
562+
563+ settings = new FavoriteStoreGSettings (backend);
564+ g_assert (settings != NULL);
565+ g_object_unref (backend);
566+
567+ favs = settings->GetFavorites ();
568+
569+ settings->RemoveFavorite ((const gchar *)g_slist_nth_data (favs, 0));
570+ favs = settings->GetFavorites ();
571+ g_assert_cmpint (g_slist_length (favs), ==, n_base_store_favs - 1);
572+ g_assert (g_str_has_suffix ((const gchar *)g_slist_nth_data (favs, 0), base_store_favs[1]));
573+
574+ settings->RemoveFavorite ((const char *)g_slist_nth_data (favs, 1));
575+ favs = settings->GetFavorites ();
576+ g_assert_cmpint (g_slist_length (favs), ==, n_base_store_favs - 2);
577+ g_assert (g_str_has_suffix ((const gchar *)g_slist_nth_data (favs, 0), base_store_favs[1]));
578+
579+ settings->UnReference ();
580+}
581+
582+static void
583+TestRemoveFavoriteBad ()
584+{
585+ GSettingsBackend *backend;
586+ FavoriteStoreGSettings *settings;
587+
588+ backend = CreateDefaultKeyFileBackend ();
589+ g_assert (G_IS_SETTINGS_BACKEND (backend));
590+
591+ settings = new FavoriteStoreGSettings (backend);
592+ g_assert (settings != NULL);
593+ g_object_unref (backend);
594+
595+ if (g_test_trap_fork (0, (GTestTrapFlags)(G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR)))
596+ {
597+ settings->RemoveFavorite (NULL);
598+ }
599+ g_test_trap_assert_stderr ("*");
600+
601+ if (g_test_trap_fork (0, (GTestTrapFlags)(G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR)))
602+ {
603+ settings->RemoveFavorite ("foo.desktop");
604+ }
605+ g_test_trap_assert_stderr ("*[0]*");
606+
607+ if (g_test_trap_fork (0, (GTestTrapFlags)(G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR)))
608+ {
609+ settings->RemoveFavorite ("/this/desktop/doesnt/exist/hopefully.desktop");
610+ }
611+ g_test_trap_assert_stderr ("*Unable to remove favorite*");
612+
613+ settings->UnReference ();
614+}
615+
616+static void
617+TestMoveFavorite ()
618+{
619+ GSettingsBackend *backend;
620+ FavoriteStoreGSettings *settings;
621+ GSList *favs;
622+
623+ backend = CreateDefaultKeyFileBackend ();
624+ g_assert (G_IS_SETTINGS_BACKEND (backend));
625+
626+ settings = new FavoriteStoreGSettings (backend);
627+ g_assert (settings != NULL);
628+ g_object_unref (backend);
629+
630+ settings->MoveFavorite (base_store_favs[2], 0);
631+
632+ favs = settings->GetFavorites ();
633+ g_assert_cmpstr ((const gchar *)favs->data, ==, base_store_favs[2]);
634+ g_assert (g_str_has_suffix ((const gchar *)g_slist_nth_data (favs, 1), base_store_favs[0]));
635+ g_assert (g_str_has_suffix ((const gchar *)g_slist_nth_data (favs, 2), base_store_favs[1]));
636+
637+ settings->UnReference ();
638+}
639+
640+static void
641+TestMoveFavoriteBad ()
642+{
643+ GSettingsBackend *backend;
644+ FavoriteStoreGSettings *settings;
645+
646+ backend = CreateDefaultKeyFileBackend ();
647+ g_assert (G_IS_SETTINGS_BACKEND (backend));
648+
649+ settings = new FavoriteStoreGSettings (backend);
650+ g_assert (settings != NULL);
651+ g_object_unref (backend);
652+
653+ if (g_test_trap_fork (0, (GTestTrapFlags)(G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR)))
654+ {
655+ settings->MoveFavorite (NULL, 0);
656+ }
657+ g_test_trap_assert_stderr ("*desktop_path*");
658+
659+ if (g_test_trap_fork (0, (GTestTrapFlags)(G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR)))
660+ {
661+ settings->MoveFavorite (CUSTOM_DESKTOP, 100);
662+ }
663+ g_test_trap_assert_stderr ("*g_slist_length*");
664+
665+ settings->UnReference ();
666+}