gapplication: enable --help when app has options
[platform/upstream/glib.git] / gio / tests / network-monitor.c
index 9ec441a..08d6008 100644 (file)
@@ -13,9 +13,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "gio.h"
@@ -230,6 +228,8 @@ run_tests (GNetworkMonitor *monitor,
           g_clear_error (&error);
         }
     }
+
+  g_main_loop_unref (data.loop);
 }
 
 static void
@@ -241,7 +241,7 @@ test_default (void)
   m = g_network_monitor_get_default ();
   g_assert (G_IS_NETWORK_MONITOR (m));
 
-  monitor = g_initable_new (G_TYPE_NETWORK_MONITOR_BASE, NULL, &error, NULL);
+  monitor = g_initable_newv (G_TYPE_NETWORK_MONITOR_BASE, 0, NULL, NULL,  &error);
   g_assert_no_error (error);
 
   /* In the default configuration, all addresses are reachable */
@@ -474,6 +474,16 @@ init_test (TestMask *test)
 }
 
 static void
+cleanup_test (TestMask *test)
+{
+  int i;
+
+  g_object_unref (test->mask);
+  for (i = 0; test->addresses[i].string; i++)
+    g_object_unref (test->addresses[i].address);
+}
+
+static void
 watch_network_changed (GNetworkMonitor *monitor,
                        gboolean         available,
                        gpointer         user_data)
@@ -500,7 +510,7 @@ do_watch_network (void)
 int
 main (int argc, char **argv)
 {
-  g_type_init ();
+  int ret;
 
   if (argc == 2 && !strcmp (argv[1], "--watch"))
     {
@@ -523,5 +533,15 @@ main (int argc, char **argv)
   g_test_add_func ("/network-monitor/add_networks", test_add_networks);
   g_test_add_func ("/network-monitor/remove_networks", test_remove_networks);
 
-  return g_test_run ();
+  ret = g_test_run ();
+
+  cleanup_test (&net127);
+  cleanup_test (&net10);
+  cleanup_test (&net192);
+  cleanup_test (&netlocal6);
+  cleanup_test (&netfe80);
+  g_object_unref (ip4_default);
+  g_object_unref (ip6_default);
+
+  return ret;
 }