+ CPPUNIT_ASSERT(m_watcher);
+
+ // Store the initial count; there may already be some watches
+ const int initial = m_watcher->GetWatchedPathsCount();
+
+ m_watcher->Add(dir);
+ CPPUNIT_ASSERT_EQUAL(initial + 1,
+ m_watcher->GetWatchedPathsCount());
+ }
+
+ void RemoveSingleWatch(wxFileName dir)
+ {
+ CPPUNIT_ASSERT(m_watcher);
+
+ const int initial = m_watcher->GetWatchedPathsCount();
+
+ m_watcher->Remove(dir);
+ CPPUNIT_ASSERT_EQUAL(initial - 1,
+ m_watcher->GetWatchedPathsCount());
+ }
+
+ void WatchTree(const wxFileName& dir)
+ {
+ CPPUNIT_ASSERT(m_watcher);
+
+ const size_t
+ treeitems = (subdirs*files) + subdirs + 1; // +1 for the trunk
+
+ // Store the initial count; there may already be some watches
+ const int initial = m_watcher->GetWatchedPathsCount();
+
+ GrowTree(dir);
+
+ m_watcher->AddTree(dir);
+ const int plustree = m_watcher->GetWatchedPathsCount();
+
+ CPPUNIT_ASSERT_EQUAL(initial + treeitems, plustree);
+
+ m_watcher->RemoveTree(dir);
+ CPPUNIT_ASSERT_EQUAL(initial, m_watcher->GetWatchedPathsCount());
+ }
+
+ void RemoveAllWatches()
+ {
+ CPPUNIT_ASSERT(m_watcher);
+
+ m_watcher->RemoveAll();
+ CPPUNIT_ASSERT_EQUAL(0, m_watcher->GetWatchedPathsCount());
+ }
+
+ virtual void GenerateEvent()
+ {
+ // We don't use this function for events. Just run the tests
+
+ wxFileName watchdir = EventGenerator::GetWatchDir();
+ CPPUNIT_ASSERT(watchdir.DirExists());
+
+ wxFileName treedir(watchdir);
+ treedir.AppendDir("treetrunk");
+ CPPUNIT_ASSERT(!treedir.DirExists());
+
+ wxFileName singledir(watchdir);
+ singledir.AppendDir("single");
+ CPPUNIT_ASSERT(!singledir.DirExists());
+ CPPUNIT_ASSERT(singledir.Mkdir());
+
+ WatchDir(singledir);
+ WatchTree(treedir);
+
+ RemoveSingleWatch(singledir);
+ // Add it back again, ready to test RemoveAll()
+ WatchDir(singledir);
+
+ RemoveAllWatches();
+
+ // Clean up
+ RmDir(singledir);
+ RmDir(treedir);
+
+ Exit();