[tracker/drop-inotify: 12/24] tracker-monitor-tests: test the directory move with files inside
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/drop-inotify: 12/24] tracker-monitor-tests: test the directory move with files inside
- Date: Thu, 8 Jul 2010 09:15:06 +0000 (UTC)
commit 7f0eeaa762f8d7f9351af2a7434001f8317324ab
Author: Aleksander Morgado <aleksander lanedo com>
Date: Thu Jul 1 18:50:49 2010 +0200
tracker-monitor-tests: test the directory move with files inside
tests/libtracker-miner/tracker-monitor-test.c | 53 ++++++++++++++++++++++--
1 files changed, 48 insertions(+), 5 deletions(-)
---
diff --git a/tests/libtracker-miner/tracker-monitor-test.c b/tests/libtracker-miner/tracker-monitor-test.c
index d56e606..be3074d 100644
--- a/tests/libtracker-miner/tracker-monitor-test.c
+++ b/tests/libtracker-miner/tracker-monitor-test.c
@@ -712,23 +712,37 @@ test_monitor_directory_event_moved_to_monitored (TrackerMonitorTestFixture *fixt
gchar *source_path;
GFile *dest_dir;
gchar *dest_path;
+ GFile *file_in_source_dir;
+ GFile *file_in_dest_dir;
+ gchar *file_in_dest_dir_path;
guint file_events;
/* Create directory to test with, before setting up the environment */
create_directory (fixture->monitored_directory, "foo", &source_dir);
+ source_path = g_file_get_path (source_dir);
g_assert (source_dir != NULL);
+ /* Add some file to the new dir */
+ set_file_contents (source_path, "lalala.txt", "whatever", &file_in_source_dir);
+
/* Set up environment */
tracker_monitor_set_enabled (fixture->monitor, TRUE);
/* Set to monitor the new dir also */
g_assert_cmpint (tracker_monitor_add (fixture->monitor, source_dir), ==, TRUE);
- /* Now, rename the file */
- source_path = g_file_get_path (source_dir);
- dest_path = g_build_path (G_DIR_SEPARATOR_S, fixture->monitored_directory, "renamed", NULL);
- dest_dir = g_file_new_for_path (dest_path);
- g_assert (dest_dir != NULL);
+ /* Get final path of the file */
+ file_in_dest_dir_path = g_build_path (G_DIR_SEPARATOR_S,
+ fixture->monitored_directory,
+ "renamed",
+ "lalala.txt",
+ NULL);
+ file_in_dest_dir = g_file_new_for_path (file_in_dest_dir_path);
+ g_assert (file_in_dest_dir != NULL);
+
+ /* Now, rename the directory */
+ dest_dir = g_file_get_parent (file_in_dest_dir);
+ dest_path = g_file_get_path (dest_dir);
g_assert_cmpint (g_rename (source_path, dest_path), ==, 0);
@@ -738,6 +752,12 @@ test_monitor_directory_event_moved_to_monitored (TrackerMonitorTestFixture *fixt
g_hash_table_insert (fixture->events,
g_object_ref (dest_dir),
GUINT_TO_POINTER (MONITOR_SIGNAL_NONE));
+ g_hash_table_insert (fixture->events,
+ g_object_ref (file_in_dest_dir),
+ GUINT_TO_POINTER (MONITOR_SIGNAL_NONE));
+ g_hash_table_insert (fixture->events,
+ g_object_ref (file_in_source_dir),
+ GUINT_TO_POINTER (MONITOR_SIGNAL_NONE));
/* Wait for events */
events_wait (fixture);
@@ -761,14 +781,37 @@ test_monitor_directory_event_moved_to_monitored (TrackerMonitorTestFixture *fixt
g_assert_cmpuint ((file_events & MONITOR_SIGNAL_ITEM_MOVED_FROM), ==, 0);
g_assert_cmpuint ((file_events & MONITOR_SIGNAL_ITEM_DELETED), ==, 0);
+ /* Get events in the file in source dir */
+ file_events = GPOINTER_TO_UINT (g_hash_table_lookup (fixture->events, file_in_source_dir));
+ /* Fail if we got ANY signal */
+ g_assert_cmpuint ((file_events & MONITOR_SIGNAL_ITEM_CREATED), ==, 0);
+ g_assert_cmpuint ((file_events & MONITOR_SIGNAL_ITEM_UPDATED), ==, 0);
+ g_assert_cmpuint ((file_events & MONITOR_SIGNAL_ITEM_DELETED), ==, 0);
+ g_assert_cmpuint ((file_events & MONITOR_SIGNAL_ITEM_MOVED_FROM), ==, 0);
+ g_assert_cmpuint ((file_events & MONITOR_SIGNAL_ITEM_MOVED_TO), ==, 0);
+
+ /* Get events in the file in dest dir */
+ file_events = GPOINTER_TO_UINT (g_hash_table_lookup (fixture->events, file_in_dest_dir));
+ /* Fail if we got ANY signal */
+ g_assert_cmpuint ((file_events & MONITOR_SIGNAL_ITEM_CREATED), ==, 0);
+ g_assert_cmpuint ((file_events & MONITOR_SIGNAL_ITEM_UPDATED), ==, 0);
+ g_assert_cmpuint ((file_events & MONITOR_SIGNAL_ITEM_DELETED), ==, 0);
+ g_assert_cmpuint ((file_events & MONITOR_SIGNAL_ITEM_MOVED_FROM), ==, 0);
+ g_assert_cmpuint ((file_events & MONITOR_SIGNAL_ITEM_MOVED_TO), ==, 0);
+
+
/* Cleanup environment */
tracker_monitor_set_enabled (fixture->monitor, FALSE);
/* Note that monitor is now in dest_dir */
g_assert_cmpint (tracker_monitor_remove (fixture->monitor, dest_dir), ==, TRUE);
+ g_assert_cmpint (g_file_delete (file_in_dest_dir, NULL, NULL), ==, TRUE);
g_assert_cmpint (g_file_delete (dest_dir, NULL, NULL), ==, TRUE);
g_object_unref (source_dir);
+ g_object_unref (file_in_source_dir);
g_object_unref (dest_dir);
+ g_object_unref (file_in_dest_dir);
g_free (source_path);
+ g_free (file_in_dest_dir_path);
g_free (dest_path);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]