3 static GVolumeMonitor *monitor;
6 do_mount_tests (GDrive *drive, GVolume *volume, GMount *mount)
13 name = g_mount_get_name (mount);
14 g_assert (name != NULL);
17 v = g_mount_get_volume (mount);
18 g_assert (v == volume);
22 d = g_mount_get_drive (mount);
23 g_assert (d == drive);
27 uuid = g_mount_get_uuid (mount);
31 m = g_volume_monitor_get_mount_for_uuid (monitor, uuid);
32 g_assert (m == mount);
39 do_volume_tests (GDrive *drive, GVolume *volume)
46 name = g_volume_get_name (volume);
47 g_assert (name != NULL);
50 d = g_volume_get_drive (volume);
51 g_assert (d == drive);
55 mount = g_volume_get_mount (volume);
58 do_mount_tests (drive, volume, mount);
59 g_object_unref (mount);
62 uuid = g_volume_get_uuid (volume);
66 v = g_volume_monitor_get_volume_for_uuid (monitor, uuid);
67 g_assert (v == volume);
74 do_drive_tests (GDrive *drive)
80 g_assert (G_IS_DRIVE (drive));
81 name = g_drive_get_name (drive);
82 g_assert (name != NULL);
85 has_volumes = g_drive_has_volumes (drive);
86 volumes = g_drive_get_volumes (drive);
87 g_assert (has_volumes == (volumes != NULL));
88 for (l = volumes; l; l = l->next)
90 GVolume *volume = l->data;
91 do_volume_tests (drive, volume);
94 g_list_foreach (volumes, (GFunc)g_object_unref, NULL);
95 g_list_free (volumes);
99 test_connected_drives (void)
104 drives = g_volume_monitor_get_connected_drives (monitor);
106 for (l = drives; l; l = l->next)
108 GDrive *drive = l->data;
109 do_drive_tests (drive);
112 g_list_foreach (drives, (GFunc)g_object_unref, NULL);
113 g_list_free (drives);
121 volumes = g_volume_monitor_get_volumes (monitor);
123 for (l = volumes; l; l = l->next)
125 GVolume *volume = l->data;
128 drive = g_volume_get_drive (volume);
129 do_volume_tests (drive, volume);
131 g_object_unref (drive);
134 g_list_foreach (volumes, (GFunc)g_object_unref, NULL);
135 g_list_free (volumes);
143 mounts = g_volume_monitor_get_mounts (monitor);
145 for (l = mounts; l; l = l->next)
147 GMount *mount = l->data;
151 drive = g_mount_get_drive (mount);
152 volume = g_mount_get_volume (mount);
153 do_mount_tests (drive, volume, mount);
156 g_object_unref (drive);
158 g_object_unref (volume);
161 g_list_foreach (mounts, (GFunc)g_object_unref, NULL);
162 g_list_free (mounts);
165 main (int argc, char *argv[])
169 g_setenv ("GIO_USE_VFS", "local", FALSE);
173 g_test_init (&argc, &argv, NULL);
175 monitor = g_volume_monitor_get ();
177 g_test_add_func ("/volumemonitor/connected_drives", test_connected_drives);
178 g_test_add_func ("/volumemonitor/volumes", test_volumes);
179 g_test_add_func ("/volumemonitor/mounts", test_mounts);
183 g_object_unref (monitor);