GApplication: add a "resource base path"
[platform/upstream/glib.git] / gio / tests / volumemonitor.c
index 921e848..6b61c30 100644 (file)
@@ -16,11 +16,13 @@ do_mount_tests (GDrive *drive, GVolume *volume, GMount *mount)
 
   v = g_mount_get_volume (mount);
   g_assert (v == volume);
-  g_object_unref (v);
+  if (v != NULL)
+    g_object_unref (v);
 
   d = g_mount_get_drive (mount);
   g_assert (d == drive);
-  g_object_unref (d);
+  if (d != NULL)
+    g_object_unref (d);
 
   uuid = g_mount_get_uuid (mount);
   if (uuid)
@@ -47,7 +49,8 @@ do_volume_tests (GDrive *drive, GVolume *volume)
 
   d = g_volume_get_drive (volume);
   g_assert (d == drive);
-  g_object_unref (d);
+  if (d != NULL)
+    g_object_unref (d);
 
   mount = g_volume_get_mount (volume);
   if (mount != NULL)
@@ -88,8 +91,7 @@ do_drive_tests (GDrive *drive)
       do_volume_tests (drive, volume);
     }
 
-  g_list_foreach (volumes, (GFunc)g_object_unref,  NULL);
-  g_list_free (volumes);
+  g_list_free_full (volumes, g_object_unref);
 }
 
 static void
@@ -106,8 +108,7 @@ test_connected_drives (void)
       do_drive_tests (drive);
     }
 
-  g_list_foreach (drives, (GFunc)g_object_unref,  NULL);
-  g_list_free (drives);
+  g_list_free_full (drives, g_object_unref);
 }
 
 static void
@@ -124,11 +125,11 @@ test_volumes (void)
 
       drive = g_volume_get_drive (volume);
       do_volume_tests (drive, volume);
-      g_object_unref (drive);
+      if (drive != NULL)
+        g_object_unref (drive);
     }
 
-  g_list_foreach (volumes, (GFunc)g_object_unref,  NULL);
-  g_list_free (volumes);
+  g_list_free_full (volumes, g_object_unref);
 }
 
 static void
@@ -147,19 +148,21 @@ test_mounts (void)
       drive = g_mount_get_drive (mount);
       volume = g_mount_get_volume (mount);
       do_mount_tests (drive, volume, mount);
-      g_object_unref (drive);
-      g_object_unref (volume);
+
+      if (drive != NULL)
+        g_object_unref (drive);
+      if (volume != NULL)
+        g_object_unref (volume);
     }
 
-  g_list_foreach (mounts, (GFunc)g_object_unref,  NULL);
-  g_list_free (mounts);
+  g_list_free_full (mounts, g_object_unref);
 }
 int
 main (int argc, char *argv[])
 {
   gboolean ret;
 
-  g_type_init ();
+  g_setenv ("GIO_USE_VFS", "local", FALSE);
 
   g_test_init (&argc, &argv, NULL);