Fix introspection tests

* Regressed due to hiding of internal symbols in libsecret.so and
   creation of a separate libsecret-testable.so library
This commit is contained in:
Stef Walter 2012-07-31 14:56:52 +02:00
parent 6becc33e8c
commit 66a7a81216
15 changed files with 28 additions and 17 deletions

View File

@ -86,6 +86,7 @@ libsecret_testable_la_SOURCES =
libsecret_testable_la_LIBADD = $(libsecret_@SECRET_MAJOR@_la_OBJECTS) \ libsecret_testable_la_LIBADD = $(libsecret_@SECRET_MAJOR@_la_OBJECTS) \
$(libsecret_@SECRET_MAJOR@_la_LIBADD) $(libsecret_@SECRET_MAJOR@_la_LIBADD)
libsecret_testable_la_DEPENDENCIES = $(libsecret_@SECRET_MAJOR@_la_OBJECTS) libsecret_testable_la_DEPENDENCIES = $(libsecret_@SECRET_MAJOR@_la_OBJECTS)
libsecret_testable_la_LDFLAGS = -rpath /force/shared
DBUS_XML_DEFINITIONS = \ DBUS_XML_DEFINITIONS = \
$(srcdir)/org.freedesktop.Secrets.xml $(srcdir)/org.freedesktop.Secrets.xml

View File

@ -120,8 +120,6 @@ gboolean _secret_util_set_property_sync (GDBusProxy *proxy
gboolean _secret_util_have_cached_properties (GDBusProxy *proxy); gboolean _secret_util_have_cached_properties (GDBusProxy *proxy);
void _secret_service_set_default_bus_name (const gchar *bus_name);
SecretSession * _secret_service_get_session (SecretService *self); SecretSession * _secret_service_get_session (SecretService *self);
void _secret_service_take_session (SecretService *self, void _secret_service_take_session (SecretService *self,

View File

@ -107,7 +107,6 @@
EGG_SECURE_GLIB_DEFINITIONS (); EGG_SECURE_GLIB_DEFINITIONS ();
GQuark _secret_error_quark = 0; GQuark _secret_error_quark = 0;
static const gchar *default_bus_name = SECRET_SERVICE_BUS_NAME;
enum { enum {
PROP_0, PROP_0,
@ -732,11 +731,16 @@ secret_service_async_initable_iface (GAsyncInitableIface *iface)
iface->init_finish = secret_service_async_initable_init_finish; iface->init_finish = secret_service_async_initable_init_finish;
} }
void static const gchar *
_secret_service_set_default_bus_name (const gchar *bus_name) get_default_bus_name (void)
{ {
g_return_if_fail (bus_name != NULL); const gchar *bus_name;
default_bus_name = bus_name;
bus_name = g_getenv ("SECRET_SERVICE_BUS_NAME");
if (bus_name == NULL)
bus_name = SECRET_SERVICE_BUS_NAME;
return bus_name;
} }
/** /**
@ -772,7 +776,7 @@ secret_service_get (SecretServiceFlags flags,
cancellable, callback, user_data, cancellable, callback, user_data,
"g-flags", G_DBUS_PROXY_FLAGS_NONE, "g-flags", G_DBUS_PROXY_FLAGS_NONE,
"g-interface-info", _secret_gen_service_interface_info (), "g-interface-info", _secret_gen_service_interface_info (),
"g-name", default_bus_name, "g-name", get_default_bus_name (),
"g-bus-type", G_BUS_TYPE_SESSION, "g-bus-type", G_BUS_TYPE_SESSION,
"g-object-path", SECRET_SERVICE_PATH, "g-object-path", SECRET_SERVICE_PATH,
"g-interface-name", SECRET_SERVICE_INTERFACE, "g-interface-name", SECRET_SERVICE_INTERFACE,
@ -870,7 +874,7 @@ secret_service_get_sync (SecretServiceFlags flags,
service = g_initable_new (SECRET_TYPE_SERVICE, cancellable, error, service = g_initable_new (SECRET_TYPE_SERVICE, cancellable, error,
"g-flags", G_DBUS_PROXY_FLAGS_NONE, "g-flags", G_DBUS_PROXY_FLAGS_NONE,
"g-interface-info", _secret_gen_service_interface_info (), "g-interface-info", _secret_gen_service_interface_info (),
"g-name", default_bus_name, "g-name", get_default_bus_name (),
"g-bus-type", G_BUS_TYPE_SESSION, "g-bus-type", G_BUS_TYPE_SESSION,
"g-object-path", SECRET_SERVICE_PATH, "g-object-path", SECRET_SERVICE_PATH,
"g-interface-name", SECRET_SERVICE_INTERFACE, "g-interface-name", SECRET_SERVICE_INTERFACE,
@ -944,7 +948,7 @@ secret_service_new (GType service_gtype,
g_return_if_fail (g_type_is_a (service_gtype, SECRET_TYPE_SERVICE)); g_return_if_fail (g_type_is_a (service_gtype, SECRET_TYPE_SERVICE));
if (service_bus_name == NULL) if (service_bus_name == NULL)
service_bus_name = default_bus_name; service_bus_name = get_default_bus_name ();
g_async_initable_new_async (service_gtype, G_PRIORITY_DEFAULT, g_async_initable_new_async (service_gtype, G_PRIORITY_DEFAULT,
cancellable, callback, user_data, cancellable, callback, user_data,
@ -1027,7 +1031,7 @@ secret_service_new_sync (GType service_gtype,
g_return_val_if_fail (g_type_is_a (service_gtype, SECRET_TYPE_SERVICE), NULL); g_return_val_if_fail (g_type_is_a (service_gtype, SECRET_TYPE_SERVICE), NULL);
if (service_bus_name == NULL) if (service_bus_name == NULL)
service_bus_name = default_bus_name; service_bus_name = get_default_bus_name ();
return g_initable_new (service_gtype, cancellable, error, return g_initable_new (service_gtype, cancellable, error,
"g-flags", G_DBUS_PROXY_FLAGS_NONE, "g-flags", G_DBUS_PROXY_FLAGS_NONE,

View File

@ -25,7 +25,6 @@ libmock_service_la_LDFLAGS = \
-rpath /force/shared -rpath /force/shared
libmock_service_la_LIBADD = \ libmock_service_la_LIBADD = \
$(top_builddir)/libsecret/libsecret-testable.la \
$(LIBGCRYPT_LIBS) $(LIBGCRYPT_LIBS)
LDADD = \ LDADD = \

View File

@ -45,7 +45,7 @@ mock_service_start (const gchar *mock_script,
g_return_val_if_fail (mock_script != NULL, FALSE); g_return_val_if_fail (mock_script != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
_secret_service_set_default_bus_name (MOCK_SERVICE_NAME); g_setenv ("SECRET_SERVICE_BUS_NAME", MOCK_SERVICE_NAME, TRUE);
if (pipe (wait_pipe) < 0) { if (pipe (wait_pipe) < 0) {
g_set_error_literal (error, G_IO_ERROR, g_io_error_from_errno (errno), g_set_error_literal (error, G_IO_ERROR, g_io_error_from_errno (errno),
@ -88,6 +88,5 @@ mock_service_stop (void)
} }
g_spawn_close_pid (pid); g_spawn_close_pid (pid);
secret_service_disconnect ();
pid = 0; pid = 0;
} }

View File

@ -3,7 +3,7 @@
import unittest import unittest
from gi.repository import MockService as Mock from gi.repository import MockService as Mock
from gi.repository import Secret, GLib from gi.repository import Secret, SecretUnstable, GLib
STORE_SCHEMA = Secret.Schema.new("org.mock.Schema", STORE_SCHEMA = Secret.Schema.new("org.mock.Schema",
Secret.SchemaFlags.NONE, Secret.SchemaFlags.NONE,
@ -19,6 +19,7 @@ class TestRemove(unittest.TestCase):
Mock.start("mock-service-normal.py") Mock.start("mock-service-normal.py")
def tearDown(self): def tearDown(self):
SecretUnstable.Service.disconnect()
Mock.stop() Mock.stop()
def testSynchronous(self): def testSynchronous(self):

View File

@ -3,7 +3,7 @@
import unittest import unittest
from gi.repository import MockService as Mock from gi.repository import MockService as Mock
from gi.repository import Secret, GLib from gi.repository import Secret, SecretUnstable, GLib
STORE_SCHEMA = Secret.Schema.new("org.mock.Schema", STORE_SCHEMA = Secret.Schema.new("org.mock.Schema",
Secret.SchemaFlags.NONE, Secret.SchemaFlags.NONE,
@ -19,6 +19,7 @@ class TestLookup(unittest.TestCase):
Mock.start("mock-service-normal.py") Mock.start("mock-service-normal.py")
def tearDown(self): def tearDown(self):
SecretUnstable.Service.disconnect()
Mock.stop() Mock.stop()
def testSynchronous(self): def testSynchronous(self):

View File

@ -89,6 +89,7 @@ static void
teardown_mock (Test *test, teardown_mock (Test *test,
gconstpointer unused) gconstpointer unused)
{ {
secret_service_disconnect ();
mock_service_stop (); mock_service_stop ();
} }

View File

@ -75,6 +75,7 @@ static void
teardown (Test *test, teardown (Test *test,
gconstpointer unused) gconstpointer unused)
{ {
secret_service_disconnect ();
mock_service_stop (); mock_service_stop ();
} }

View File

@ -89,6 +89,7 @@ static void
teardown_mock (Test *test, teardown_mock (Test *test,
gconstpointer unused) gconstpointer unused)
{ {
secret_service_disconnect ();
mock_service_stop (); mock_service_stop ();
} }

View File

@ -47,6 +47,7 @@ static void
teardown_mock (Test *test, teardown_mock (Test *test,
gconstpointer unused) gconstpointer unused)
{ {
secret_service_disconnect ();
mock_service_stop (); mock_service_stop ();
} }

View File

@ -3,7 +3,7 @@
import unittest import unittest
from gi.repository import MockService as Mock from gi.repository import MockService as Mock
from gi.repository import Secret, GLib from gi.repository import Secret, SecretUnstable, GLib
STORE_SCHEMA = Secret.Schema.new("org.mock.Schema", STORE_SCHEMA = Secret.Schema.new("org.mock.Schema",
Secret.SchemaFlags.NONE, Secret.SchemaFlags.NONE,
@ -19,6 +19,7 @@ class TestStore(unittest.TestCase):
Mock.start("mock-service-normal.py") Mock.start("mock-service-normal.py")
def tearDown(self): def tearDown(self):
SecretUnstable.Service.disconnect()
Mock.stop() Mock.stop()
def testSynchronous(self): def testSynchronous(self):

View File

@ -10,6 +10,7 @@ class TestStore(unittest.TestCase):
Mock.start("mock-service-normal.py") Mock.start("mock-service-normal.py")
def tearDown(self): def tearDown(self):
Secret.Service.disconnect()
Mock.stop() Mock.stop()
def testSynchronous(self): def testSynchronous(self):

View File

@ -165,6 +165,7 @@ private static int main (string[] args) {
var res = GLib.Test.run (); var res = GLib.Test.run ();
Secret.Service.disconnect ();
MockService.stop (); MockService.stop ();
schema = null; schema = null;

View File

@ -20,6 +20,7 @@ private static int main (string[] args) {
GLib.Test.add_data_func ("/vala/unstable/read-alias", test_read_alias); GLib.Test.add_data_func ("/vala/unstable/read-alias", test_read_alias);
var res = GLib.Test.run (); var res = GLib.Test.run ();
Secret.Service.disconnect ();
MockService.stop (); MockService.stop ();
return res; return res;
} }