[folks/wip/nielsdg/fix-folks: 13/13] tests/eds: Don't hardcode E-D-S DBus names



commit 6a9fdff5323cf245cef780fdd77f6cdab30101aa
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Sun May 26 11:37:35 2019 +0200

    tests/eds: Don't hardcode E-D-S DBus names
    
    Instead, we can use pkg-config to query the correct variable. So we need no
    more guessing out of a hardcoded list of known names at build-time.
    
    Fixes https://gitlab.gnome.org/GNOME/folks/issues/110

 folks/build-conf.vapi        |  6 ++++
 meson.build                  | 11 ++++++
 tests/lib/eds/meson.build    |  1 +
 tests/lib/eds/test-case.vala | 84 ++++++++++++++++----------------------------
 4 files changed, 49 insertions(+), 53 deletions(-)
---
diff --git a/folks/build-conf.vapi b/folks/build-conf.vapi
index a97593fc..6567436f 100644
--- a/folks/build-conf.vapi
+++ b/folks/build-conf.vapi
@@ -48,6 +48,12 @@ public class Folks.BuildConf
   [CCode (cname = "HAVE_EDS")]
   public static bool HAVE_EDS;
 
+  [CCode (cname = "EDS_SOURCES_SERVICE_NAME")]
+  public const string EDS_SOURCES_SERVICE_NAME;
+
+  [CCode (cname = "EDS_ADDRESS_BOOK_SERVICE_NAME")]
+  public const string EDS_ADDRESS_BOOK_SERVICE_NAME;
+
   [CCode (cname = "HAVE_OFONO")]
   public static bool HAVE_OFONO;
 
diff --git a/meson.build b/meson.build
index 91800654..d5115e28 100644
--- a/meson.build
+++ b/meson.build
@@ -115,6 +115,13 @@ if eds_backend_enabled
   libebook_contacts_dep = dependency('libebook-contacts-1.2', version: '>=' + min_eds_version)
   libedataserver_dep = dependency('libedataserver-1.2', version: '>=' + min_eds_version)
   libxml_dep = dependency('libxml-2.0')
+
+  eds_dep = dependency('evolution-data-server-1.2', version: '>=' + min_eds_version)
+  eds_sources_service_name = eds_dep.get_pkgconfig_variable('sourcesdbusservicename')
+  eds_address_book_service_name = eds_dep.get_pkgconfig_variable('addressbookdbusservicename')
+
+  message('Building E-D-S with Sources service "@0@" AddressBook service "@1@"'.format(
+    eds_sources_service_name, eds_address_book_service_name))
 endif
 
 if ofono_backend_enabled
@@ -160,6 +167,10 @@ conf.set10('HAVE_EDS', eds_backend_enabled)
 conf.set10('HAVE_OFONO', ofono_backend_enabled)
 conf.set10('HAVE_TELEPATHY', telepathy_backend_enabled)
 conf.set10('HAVE_TRACKER', tracker_backend_enabled)
+if eds_backend_enabled
+  conf.set_quoted('EDS_SOURCES_SERVICE_NAME', eds_sources_service_name)
+  conf.set_quoted('EDS_ADDRESS_BOOK_SERVICE_NAME', eds_address_book_service_name)
+endif
 if tracker_backend_enabled
   conf.set_quoted('TRACKER_SPARQL_MAJOR', tracker_sparql_version)
 endif
diff --git a/tests/lib/eds/meson.build b/tests/lib/eds/meson.build
index b31803d2..a0913bff 100644
--- a/tests/lib/eds/meson.build
+++ b/tests/lib/eds/meson.build
@@ -7,6 +7,7 @@ libeds_test_deps = [
   common_test_lib_deps,
   libebook_dep,
   eds_backendlib_dep,
+  build_conf_dep,
 ]
 
 libeds_test = library('eds-test',
diff --git a/tests/lib/eds/test-case.vala b/tests/lib/eds/test-case.vala
index 6de03d8c..2f41592d 100644
--- a/tests/lib/eds/test-case.vala
+++ b/tests/lib/eds/test-case.vala
@@ -113,65 +113,43 @@ public class EdsTest.TestCase : Folks.TestCase
       var libexec = this._get_eds_libexecdir ();
 
       /* Create service files for the Evolution binaries. */
-      const string sources_services[] =
-        {
-          "org.gnome.evolution.dataserver.Sources5",
-          "org.gnome.evolution.dataserver.Sources4",
-          "org.gnome.evolution.dataserver.Sources3",
-          "org.gnome.evolution.dataserver.Sources2",
-          "org.gnome.evolution.dataserver.Sources1"
-        };
-      const string address_book_services[] =
-        {
-          "org.gnome.evolution.dataserver.AddressBook9",
-          "org.gnome.evolution.dataserver.AddressBook8",
-          "org.gnome.evolution.dataserver.AddressBook7",
-          "org.gnome.evolution.dataserver.AddressBook6",
-          "org.gnome.evolution.dataserver.AddressBook5",
-        };
-
       /* Source registry. */
-      for (uint i = 0; i < sources_services.length; i++)
+      var sources_service_file_name =
+          Path.build_filename (this.transient_dir, "dbus-1", "services",
+              "evolution-source-registry.service");
+      var sources_service_file = ("[D-BUS Service]\n" +
+          "Name=%s\n" +
+          "Exec=%s/evolution-source-registry\n").printf (
+              Folks.BuildConf.EDS_SOURCES_SERVICE_NAME, libexec);
+
+      try
         {
-          var service_file_name =
-              Path.build_filename (this.transient_dir, "dbus-1", "services",
-                  "evolution-source-registry-%u.service".printf (i));
-          var service_file = ("[D-BUS Service]\n" +
-              "Name=%s\n" +
-              "Exec=%s/evolution-source-registry\n").printf (
-                  sources_services[i], libexec);
-
-          try
-            {
-              FileUtils.set_contents (service_file_name, service_file);
-            }
-          catch (FileError e2)
-            {
-              error ("Error creating D-Bus service file ‘%s’: %s",
-                  service_file_name, e2.message);
-            }
+          FileUtils.set_contents (sources_service_file_name,
+                                  sources_service_file);
+        }
+      catch (FileError e2)
+        {
+          error ("Error creating D-Bus service file ‘%s’: %s",
+              sources_service_file_name, e2.message);
         }
 
       /* Address book factory. */
-      for (uint i = 0; i < address_book_services.length; i++)
+      var ab_service_file_name =
+          Path.build_filename (this.transient_dir, "dbus-1", "services",
+              "evolution-addressbook-factory.service");
+      var ab_service_file = ("[D-BUS Service]\n" +
+          "Name=%s\n" +
+          "Exec=%s/evolution-addressbook-factory\n").printf (
+              Folks.BuildConf.EDS_ADDRESS_BOOK_SERVICE_NAME, libexec);
+
+      try
+        {
+          FileUtils.set_contents (ab_service_file_name, ab_service_file);
+        }
+      catch (FileError e3)
         {
-          var service_file_name =
-              Path.build_filename (this.transient_dir, "dbus-1", "services",
-                  "evolution-addressbook-factory-%u.service".printf (i));
-          var service_file = ("[D-BUS Service]\n" +
-              "Name=%s\n" +
-              "Exec=%s/evolution-addressbook-factory\n").printf (
-                  address_book_services[i], libexec);
-
-          try
-            {
-              FileUtils.set_contents (service_file_name, service_file);
-            }
-          catch (FileError e3)
-            {
-              error ("Error creating D-Bus service file ‘%s’: %s",
-                  service_file_name, e3.message);
-            }
+          error ("Error creating D-Bus service file ‘%s’: %s",
+              ab_service_file_name, e3.message);
         }
     }
 


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