[glib] tests: add tests for GDesktopAppInfo Implements=



commit 880e8e8cb254e8c0c8a4bb62ebb606404818b52b
Author: Ryan Lortie <desrt desrt ca>
Date:   Fri Nov 15 14:44:33 2013 -0500

    tests: add tests for GDesktopAppInfo Implements=
    
    https://bugzilla.gnome.org/show_bug.cgi?id=712391

 gio/tests/apps.c                                   |    7 ++++
 gio/tests/desktop-app-info.c                       |   39 +++++++++++++++++++-
 .../desktop-files/usr/applications/cheese.desktop  |    1 +
 .../desktop-files/usr/applications/eog.desktop     |    1 +
 .../usr/applications/gnome-contacts.desktop        |    1 +
 .../usr/applications/gnome-music.desktop           |    1 +
 6 files changed, 49 insertions(+), 1 deletions(-)
---
diff --git a/gio/tests/apps.c b/gio/tests/apps.c
index 6597966..6a4b04f 100644
--- a/gio/tests/apps.c
+++ b/gio/tests/apps.c
@@ -51,6 +51,13 @@ main (int argc, char **argv)
         }
       g_free (results);
     }
+  else if (g_str_equal (argv[1], "implementations"))
+    {
+      GList *results;
+
+      results = g_desktop_app_info_get_implementations (argv[2]);
+      print_app_list (results);
+    }
   else if (g_str_equal (argv[1], "show-info"))
     {
       GAppInfo *info;
diff --git a/gio/tests/desktop-app-info.c b/gio/tests/desktop-app-info.c
index fceaabc..69fe587 100644
--- a/gio/tests/desktop-app-info.c
+++ b/gio/tests/desktop-app-info.c
@@ -492,7 +492,7 @@ assert_strings_equivalent (const gchar *expected,
   gint i, j;
 
   expected_words = g_strsplit (expected, " ", 0);
-  result_words = g_strsplit (result, " ", 0);
+  result_words = g_strsplit_set (result, " \n", 0);
 
   for (i = 0; expected_words[i]; i++)
     {
@@ -566,6 +566,20 @@ assert_search (const gchar *search_string,
   g_free (result);
 }
 
+static void
+assert_implementations (const gchar *interface,
+                        const gchar *expected,
+                        gboolean     with_usr,
+                        gboolean     with_home)
+{
+  gchar *result;
+
+  result = run_apps ("implementations", interface, with_usr, with_home, NULL, NULL);
+  g_strchomp (result);
+  assert_strings_equivalent (expected, result);
+  g_free (result);
+}
+
 #define ALL_USR_APPS  "evince-previewer.desktop nautilus-classic.desktop gnome-font-viewer.desktop "         
\
                       "baobab.desktop yelp.desktop eog.desktop cheese.desktop gnome-clocks.desktop "         
\
                       "gnome-contacts.desktop kde4-kate.desktop gcr-prompter.desktop totem.desktop "         
\
@@ -671,6 +685,28 @@ test_search (void)
                             "kde4-konqbrowser.desktop\n", TRUE, TRUE, "en_US.UTF-8", "eo");
 }
 
+static void
+test_implements (void)
+{
+  /* Make sure we can find our search providers... */
+  assert_implementations ("org.gnome.Shell.SearchProvider2",
+                       "gnome-music.desktop gnome-contacts.desktop eog.desktop",
+                       TRUE, FALSE);
+
+  /* And our image acquisition possibilities... */
+  assert_implementations ("org.freedesktop.ImageProvider",
+                       "cheese.desktop",
+                       TRUE, FALSE);
+
+  /* Make sure the user's eog is properly masking the system one */
+  assert_implementations ("org.gnome.Shell.SearchProvider2",
+                       "gnome-music.desktop gnome-contacts.desktop",
+                       TRUE, TRUE);
+
+  /* Make sure we get nothing if we have nothing */
+  assert_implementations ("org.gnome.Shell.SearchProvider2", "", FALSE, FALSE);
+}
+
 int
 main (int   argc,
       char *argv[])
@@ -690,6 +726,7 @@ main (int   argc,
   g_test_add_func ("/desktop-app-info/extra-getters", test_extra_getters);
   g_test_add_func ("/desktop-app-info/actions", test_actions);
   g_test_add_func ("/desktop-app-info/search", test_search);
+  g_test_add_func ("/desktop-app-info/implements", test_implements);
 
   result = g_test_run ();
 
diff --git a/gio/tests/desktop-files/usr/applications/cheese.desktop 
b/gio/tests/desktop-files/usr/applications/cheese.desktop
index 614ddb5..650c500 100644
--- a/gio/tests/desktop-files/usr/applications/cheese.desktop
+++ b/gio/tests/desktop-files/usr/applications/cheese.desktop
@@ -44,3 +44,4 @@ X-GNOME-Bugzilla-Bugzilla=GNOME
 X-GNOME-Bugzilla-Product=cheese
 X-GNOME-Bugzilla-Component=general
 X-GNOME-Bugzilla-Version=3.11.1
+Implements=org.freedesktop.ImageProvider
diff --git a/gio/tests/desktop-files/usr/applications/eog.desktop 
b/gio/tests/desktop-files/usr/applications/eog.desktop
index 9982842..8dc3911 100644
--- a/gio/tests/desktop-files/usr/applications/eog.desktop
+++ b/gio/tests/desktop-files/usr/applications/eog.desktop
@@ -41,3 +41,4 @@ Keywords[en_GB]=Picture;Slideshow;Graphics;
 Keywords[eo]=Bildo;Lumbildprezentado;Grafiko;
 Keywords[pt]=Imagem;Apresentação;Gráficos;
 Keywords[pt_BR]=Fotos;Apresentação de slides;Gráficos;
+Implements=org.gnome.Shell.SearchProvider2
diff --git a/gio/tests/desktop-files/usr/applications/gnome-contacts.desktop 
b/gio/tests/desktop-files/usr/applications/gnome-contacts.desktop
index 13ccb35..388b26f 100644
--- a/gio/tests/desktop-files/usr/applications/gnome-contacts.desktop
+++ b/gio/tests/desktop-files/usr/applications/gnome-contacts.desktop
@@ -23,3 +23,4 @@ Type=Application
 StartupNotify=true
 Categories=GNOME;GTK;Utility;
 OnlyShowIn=GNOME;Unity;
+Implements=org.gnome.Shell.SearchProvider2
diff --git a/gio/tests/desktop-files/usr/applications/gnome-music.desktop 
b/gio/tests/desktop-files/usr/applications/gnome-music.desktop
index 8928b21..e4262cd 100644
--- a/gio/tests/desktop-files/usr/applications/gnome-music.desktop
+++ b/gio/tests/desktop-files/usr/applications/gnome-music.desktop
@@ -20,3 +20,4 @@ Terminal=false
 Type=Application
 Categories=GNOME;GTK;AudioVideo;Player;Audio;
 StartupNotify=true
+Implements=org.gnome.Shell.SearchProvider2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]