From bb82b0832e36130074e2ae93db944823fe8e90de Mon Sep 17 00:00:00 2001
From: Julian Bouzas <julian.bouzas@collabora.com>
Date: Tue, 19 May 2020 10:06:39 -0400
Subject: [PATCH] tests: config-policy: make sure the link is activated before
 stopping

---
 tests/modules/config-policy.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/tests/modules/config-policy.c b/tests/modules/config-policy.c
index adb91b01..0dae4bef 100644
--- a/tests/modules/config-policy.c
+++ b/tests/modules/config-policy.c
@@ -214,12 +214,31 @@ config_policy_teardown (TestFixture *f, gconstpointer user_data)
   wp_base_test_fixture_teardown (&f->base);
 }
 
+static void
+on_state_changed (WpEndpointLink *ep_link, WpEndpointLinkState old_state,
+    WpEndpointLinkState new_state, const gchar *error, TestFixture *f)
+{
+  switch (new_state) {
+  case WP_ENDPOINT_LINK_STATE_ACTIVE:
+    break;
+  case WP_ENDPOINT_LINK_STATE_ERROR:
+    wp_message_object ("link failed: %s", error);
+    g_test_fail ();
+  case WP_ENDPOINT_LINK_STATE_INACTIVE:
+  case WP_ENDPOINT_LINK_STATE_PREPARING:
+  default:
+    return;
+  }
+
+  g_main_loop_quit (f->base.loop);
+}
+
 static void
 on_link_activated (WpPlugin *ctx, WpEndpointLink *ep_link,
     TestFixture *f)
 {
   g_assert_nonnull (ep_link);
-  g_main_loop_quit (f->base.loop);
+  g_signal_connect (ep_link, "state-changed", (GCallback) on_state_changed, f);
 }
 
 static void
-- 
GitLab