[grilo] registry: Fix plugin tests running with mocked network
- From: Xavier Claessens <xclaesse src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo] registry: Fix plugin tests running with mocked network
- Date: Thu, 27 Aug 2015 13:14:51 +0000 (UTC)
commit c930f91d77cce2343f6c6483256e941691e3525b
Author: Xavier Claessens <xavier claessens collabora com>
Date: Wed Aug 26 13:16:12 2015 -0400
registry: Fix plugin tests running with mocked network
Unit tests from grilo-plugins sets GRL_NET_MOCKED env variable
to mock network, so we shouldn't hide those plugins if the host
has no internet connectivity. This can happen on build bots for
example.
https://bugzilla.gnome.org/show_bug.cgi?id=754093
src/grl-registry.c | 40 ++++++++++++++++++++++++++--------------
1 files changed, 26 insertions(+), 14 deletions(-)
---
diff --git a/src/grl-registry.c b/src/grl-registry.c
index 8421ac4..c70caaa 100644
--- a/src/grl-registry.c
+++ b/src/grl-registry.c
@@ -211,6 +211,30 @@ grl_registry_class_init (GrlRegistryClass *klass)
#ifdef HAVE_GIO_WITH_NETMON
static void
+get_connectivity (GrlRegistry *registry,
+ GNetworkConnectivity *connectivity,
+ gboolean *network_available)
+{
+ g_assert (connectivity != NULL);
+ g_assert (network_available != NULL);
+
+ if (g_getenv("GRL_NET_MOCKED") != NULL) {
+ GRL_DEBUG ("Mocked network, assuming network is available and connectivity "
+ "level is FULL");
+ *connectivity = G_NETWORK_CONNECTIVITY_FULL;
+ *network_available = TRUE;
+ } else {
+ g_object_get (G_OBJECT (registry->priv->netmon),
+ "connectivity", connectivity,
+ "network-available", network_available,
+ NULL);
+
+ GRL_DEBUG ("Connectivity level is %d, Network is %s",
+ *connectivity, *network_available ? "available" : "unavailable");
+ }
+}
+
+static void
network_changed_cb (GObject *gobject,
GParamSpec *pspec,
GrlRegistry *registry)
@@ -221,14 +245,7 @@ network_changed_cb (GObject *gobject,
GrlSource *current_source;
GRL_DEBUG ("Network availability changed");
-
- g_object_get (G_OBJECT (registry->priv->netmon),
- "connectivity", &connectivity,
- "network-available", &network_available,
- NULL);
-
- GRL_DEBUG ("Connectivity level is %d, Network is %s",
- connectivity, network_available ? "available" : "unavailable");
+ get_connectivity (registry, &connectivity, &network_available);
if (!network_available) {
g_hash_table_iter_init (&iter, registry->priv->sources);
@@ -359,13 +376,8 @@ update_source_visibility (GrlRegistry *registry,
!needs_inet)
return;
- g_object_get (G_OBJECT (registry->priv->netmon),
- "connectivity", &connectivity,
- "network-available", &network_available,
- NULL);
+ get_connectivity (registry, &connectivity, &network_available);
- GRL_DEBUG ("Connectivity level is %d, Network is %s",
- connectivity, network_available ? "available" : "unavailable");
GRL_DEBUG ("Source %s needs %s %s%s",
grl_source_get_id (source),
needs_local ? "local network" : "",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]